Package com.almende.util.AnnotationUtil

Examples of com.almende.util.AnnotationUtil.AnnotatedClass


    String id = UUID.randomUUID().toString();
    return new JSONRequest(id, method.getName(), params);
  }
 
  public static boolean hasPrivate(Class<?> clazz) {
    AnnotatedClass annotated = AnnotationUtil.get(clazz);
    for (Annotation anno : annotated.getAnnotations()) {
      if (anno.annotationType().equals(Access.class)
          && ((Access) anno).value() == AccessType.PRIVATE) {
        return true;
      }
      if (anno.annotationType().equals(Sender.class)) {
View Full Code Here


      // Event param overrules
      event = pushParams.get("event").textValue();
    }
    if (pushParams.has("onChange")
        && pushParams.get("onChange").booleanValue()) {
      AnnotatedClass ac = null;
      event = "change";
      try {
        CallTuple res = NamespaceUtil.get(myAgent,
            pushParams.get("method").textValue());
       
        ac = AnnotationUtil.get(res.getDestination().getClass());
        for (AnnotatedMethod method : ac
            .getMethods(res.getMethodName())) {
          EventTriggered annotation = method
              .getAnnotation(EventTriggered.class);
          if (annotation != null) {
            // If no Event param, get it from annotation, else
View Full Code Here

    return instance._get(destination, path);
  }
 
  private void populateCache(Object destination, String path, String methods)
      throws IllegalAccessException, InvocationTargetException {
    AnnotatedClass clazz = AnnotationUtil.get(destination.getClass());
    for (AnnotatedMethod method : clazz
        .getAnnotatedMethods(Namespace.class)) {
      Object newDest = method.getActualMethod().invoke(destination,
          (Object[]) null);
      // recurse:
      if (newDest != null) {
View Full Code Here

   */
  @Override
  public boolean hasPrivate() {
    try {
      final Class<?> clazz = this.getClass();
      final AnnotatedClass annotated = AnnotationUtil.get(clazz);
      for (final Annotation anno : annotated.getAnnotations()) {
        if (anno.annotationType().equals(Access.class)
            && ((Access) anno).value() == AccessType.PRIVATE) {
          return true;
        }
        if (anno.annotationType().equals(Sender.class)) {
View Full Code Here

  public static List<String> validate(final Class<?> c,
      final RequestParams requestParams) {
    final List<String> errors = new ArrayList<String>();
    final Set<String> methodNames = new HashSet<String>();
   
    AnnotatedClass ac = null;
    try {
      ac = AnnotationUtil.get(c);
      if (ac != null) {
        for (final AnnotatedMethod method : ac.getMethods()) {
          final boolean available = isAvailable(method, null,
              requestParams, null);
          if (available) {
            // The method name may only occur once
            final String name = method.getName();
View Full Code Here

    final Map<String, Object> methods = new TreeMap<String, Object>();
    try {
      if (c == null) {
        return methods;
      }
      final AnnotatedClass annotatedClass = AnnotationUtil.get(c
          .getClass());
      for (final AnnotatedMethod method : annotatedClass.getMethods()) {
        if (isAvailable(method, null, requestParams, null)) {
          // format as JSON
          final List<Object> descParams = new ArrayList<Object>();
          for (final AnnotatedParam param : method.getParams()) {
            if (getRequestAnnotation(param, requestParams) == null) {
              final String name = getName(param);
              final Map<String, Object> paramData = new HashMap<String, Object>();
              paramData.put("name", name);
              paramData.put("type",
                  typeToString(param.getGenericType()));
              paramData.put("required", isRequired(param));
              descParams.add(paramData);
            }
          }
         
          final Map<String, Object> result = new HashMap<String, Object>();
          result.put("type",
              typeToString(method.getGenericReturnType()));
         
          final Map<String, Object> desc = new HashMap<String, Object>();
          final String methodName = namespace.equals("") ? method
              .getName() : namespace + "." + method.getName();
          desc.put("method", methodName);
          desc.put("params", descParams);
          desc.put("result", result);
          methods.put(methodName, desc);
        }
      }
      for (final AnnotatedMethod method : annotatedClass
          .getAnnotatedMethods(Namespace.class)) {
        final String innerNamespace = method.getAnnotation(
            Namespace.class).value();
        methods.putAll(_describe(
            method.getActualMethod().invoke(c, (Object[]) null),
View Full Code Here

   * @return methodType meta information on the method, or null if not found
   */
  private static AnnotatedMethod getMethod(final Object destination,
      final String method, final RequestParams requestParams,
      final JSONAuthorizor auth) {
    AnnotatedClass annotatedClass;
    try {
      annotatedClass = AnnotationUtil.get(destination.getClass());
     
      final List<AnnotatedMethod> methods = annotatedClass
          .getMethods(method);
      for (final AnnotatedMethod m : methods) {
        if (isAvailable(m, destination, requestParams, auth)) {
          return m;
        }
View Full Code Here

TOP

Related Classes of com.almende.util.AnnotationUtil.AnnotatedClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.