Package com.almende.util.AnnotationUtil

Examples of com.almende.util.AnnotationUtil.AnnotatedClass


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


      Map<String, Object> methods = new TreeMap<String, Object>();
      if (asJSON == null) {
        asJSON = false;
      }

      AnnotatedClass annotatedClass = AnnotationUtil.get(c);
      for (AnnotatedMethod method : annotatedClass.getMethods()) {
        if (isAvailable(method, requestParams)) {
          if (asJSON) {
            // 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(Class<?> objectClass, String method,
      RequestParams requestParams) {
    AnnotatedClass annotatedClass = AnnotationUtil.get(objectClass);
    List<AnnotatedMethod> methods = annotatedClass.getMethods(method);
    for (AnnotatedMethod m : methods) {
      if (isAvailable(m, requestParams)) {
        return m;
      }
    }
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

   *             the invocation target exception
   */
  private void populateCache(final Object destination, final String steps,
      final AnnotatedMethod[] methods) throws IllegalAccessException,
      InvocationTargetException {
    final AnnotatedClass clazz = AnnotationUtil.get(destination.getClass());
    for (final AnnotatedMethod method : clazz
        .getAnnotatedMethods(Namespace.class)) {
      final String path = steps + "."
          + method.getAnnotation(Namespace.class).value();
      methods[methods.length - 1] = method;
      CACHE.put(path, Arrays.copyOf(methods, methods.length));
View Full Code Here

    if (newDestination == null) {
      // Oops, namespace getter returned null pointer!
      return result;
    }
    result.setDestination(newDestination);
    final AnnotatedClass newClazz = AnnotationUtil.get(newDestination
        .getClass());
    final List<AnnotatedMethod> methods = newClazz
        .getMethods(reducedMethod);
    if (!methods.isEmpty()) {
      result.setMethod(methods.get(0));
    }
    return result;
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 {
        final CallTuple res = NamespaceUtil.get(myAgent,
            pushParams.get("method").textValue());
       
        ac = AnnotationUtil.get(res.getDestination().getClass());
        for (final AnnotatedMethod method : ac
            .getMethods(res.getMethodName())) {
          final EventTriggered annotation = method
              .getAnnotation(EventTriggered.class);
          if (annotation != null) {
            // If no Event param, get it from annotation, else
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

   *             the invocation target exception
   */
  private void populateCache(final Object destination, final String steps,
      final Method[] methods) throws IllegalAccessException,
      InvocationTargetException {
    final AnnotatedClass clazz = AnnotationUtil.get(destination.getClass());
    for (final AnnotatedMethod method : clazz
        .getAnnotatedMethods(Namespace.class)) {
      final String path = steps + "."
          + method.getAnnotation(Namespace.class).value();
      methods[methods.length - 1] = method.getActualMethod();
      cache.put(path, Arrays.copyOf(methods, methods.length));
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.