Package com.almende.util.AnnotationUtil

Examples of com.almende.util.AnnotationUtil.AnnotatedClass


  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

   */
  static public List<String> validate(Class<?> c, RequestParams requestParams) {
    List<String> errors = new ArrayList<String>();
    Set<String> methodNames = new HashSet<String>();

    AnnotatedClass ac = null;
    try {
      ac = AnnotationUtil.get(c);
    } catch (Exception e) {
      e.printStackTrace();
      errors.add("Class as a whole can't be wrapped for annotation, probably because it's not an AgentInterface implementation.");
    }
    if (ac != null) {
      for (AnnotatedMethod method : ac.getMethods()) {
        boolean available = false;
        try {
          available = isAvailable(method, null, requestParams);
        } catch (Exception e) {
          e.printStackTrace();
View Full Code Here

  public static List<Object> describe(Class<?> c,
      RequestParams requestParams, Boolean asString) {
    try {
      Map<String, Object> methods = new TreeMap<String, Object>();

      AnnotatedClass annotatedClass = AnnotationUtil.get(c);
      for (AnnotatedMethod method : annotatedClass.getMethods()) {
        if (isAvailable(method, null, requestParams)) {
          if (asString == null || asString != true) {
            // format as JSON
            List<Object> descParams = new ArrayList<Object>();
            for (AnnotatedParam param : method.getParams()) {
View Full Code Here

   * @param requestParams
   * @return methodType meta information on the method, or null if not found
   */
  static private AnnotatedMethod getMethod(AgentInterface destination,
      String method, RequestParams requestParams) {
    AnnotatedClass annotatedClass;
    try {
      annotatedClass = AnnotationUtil.get(destination.getClass());

      List<AnnotatedMethod> methods = annotatedClass.getMethods(method);
      for (AnnotatedMethod m : methods) {
        if (isAvailable(m, destination, requestParams)) {
          return m;
        }
      }
View Full Code Here

    return new JSONRequest(method.getName(), params);
  }

  public static boolean hasPrivate(Class<?> clazz) throws SecurityException, Exception{
    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)) return true;
    }
    return false;
  }
View Full Code Here

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

  private static Map<String, Object> _describe(Object c,
      RequestParams requestParams, String namespace) {
    Map<String, Object> methods = new TreeMap<String, Object>();
    try {
     
      AnnotatedClass annotatedClass = AnnotationUtil.get(c.getClass());
      for (AnnotatedMethod method : annotatedClass.getMethods()) {
        if (isAvailable(method, null, requestParams, null)) {
          // format as JSON
          List<Object> descParams = new ArrayList<Object>();
          for (AnnotatedParam param : method.getParams()) {
            if (getRequestAnnotation(param, requestParams) == null) {
              String name = getName(param);
              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);
            }
          }
         
          Map<String, Object> result = new HashMap<String, Object>();
          result.put("type",
              typeToString(method.getGenericReturnType()));
         
          Map<String, Object> desc = new HashMap<String, Object>();
          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 (AnnotatedMethod method : annotatedClass
          .getAnnotatedMethods(Namespace.class)) {
        String innerNamespace = method.getAnnotation(Namespace.class)
            .value();
        methods.putAll(_describe(
            method.getActualMethod().invoke(c, (Object[]) null),
View Full Code Here

   * @param requestParams
   * @return methodType meta information on the method, or null if not found
   */
  private static AnnotatedMethod getMethod(Object destination, String method,
      RequestParams requestParams, JSONAuthorizor auth) {
    AnnotatedClass annotatedClass;
    try {
      annotatedClass = AnnotationUtil.get(destination.getClass());
     
      List<AnnotatedMethod> methods = annotatedClass.getMethods(method);
      for (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.