Package ch.ralscha.extdirectspring.annotation

Examples of ch.ralscha.extdirectspring.annotation.ExtDirectMethod


        }
        this.forwardPath = "forward:" + path;
      }
    }

    ExtDirectMethod extDirectMethodAnnotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class);
    if (extDirectMethodAnnotation != null) {
      this.type = extDirectMethodAnnotation.value();
    }

    this.parameters = buildParameterList(clazz, method);

    for (ParameterInfo parameter : parameters) {
View Full Code Here


      String beanName = entry.getKey();

      Method[] methods = bean.getClass().getMethods();

      for (Method method : methods) {
        ExtDirectMethod annotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class);
        if (annotation != null && isSameGroup(group, annotation.group())) {
          ExtDirectMethodType type = annotation.value();

          switch (type) {
            case SIMPLE:
              remotingApi.addAction(beanName, method.getName(), numberOfParameters(method));
              break;
            case FORM_LOAD:
            case STORE_READ:
            case STORE_MODIFY:
              remotingApi.addAction(beanName, method.getName(), 1);
              break;
            case FORM_POST:
              if (isValidFormPostMethod(method)) {
                remotingApi.addAction(beanName, method.getName(), 0, true);
              } else {
                LogFactory.getLog(getClass()).warn("Method '" + beanName + "." + method.getName()
                            + "' is annotated as a form post method but is not valid. "
                            + "A form post method must be annotated with @RequestMapping and method=RequestMethod.POST. Method ignored.");
              }
              break;
            case POLL:
              remotingApi.addPollingProvider(beanName, method.getName(), annotation.event());
              break;

          }

        }
View Full Code Here

        }
        this.forwardPath = "forward:" + path;
      }
    }

    ExtDirectMethod extDirectMethodAnnotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class);
    if (extDirectMethodAnnotation != null) {
      this.type = extDirectMethodAnnotation.value();
    }

    this.parameters = buildParameterList(method);

    for (ParameterInfo parameter : parameters) {
View Full Code Here

      String beanName = entry.getKey();

      Method[] methods = bean.getClass().getMethods();

      for (Method method : methods) {
        ExtDirectMethod annotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class);
        if (annotation != null) {
          if (isSameGroup(group, annotation.group())) {
            ExtDirectMethodType type = annotation.value();

            switch (type) {
            case SIMPLE:
              remotingApi.addAction(beanName, method.getName(), numberOfParameters(method));
              break;
            case FORM_LOAD:
            case STORE_READ:
              remotingApi.addAction(beanName, method.getName(), 1);
              break;
            case STORE_MODIFY:
              if (annotation.entryClass() != ExtDirectMethod.class) {
                remotingApi.addAction(beanName, method.getName(), 1);
              } else {
                LoggerFactory.getLogger(getClass()).warn(
                    "Method '{}.{}' is annotated as a store modify method but does "
                        + "not specify a entryClass. Method ignored.", beanName, method.getName());
              }
              break;
            case FORM_POST:
              if (isValidFormPostMethod(method)) {
                remotingApi.addAction(beanName, method.getName(), 0, true);
              } else {
                LoggerFactory
                    .getLogger(getClass())
                    .warn(
                        "Method '{}.{}' is annotated as a form post method but is not valid. "
                            + "A form post method must be annotated with @RequestMapping and method=RequestMethod.POST. Method ignored.",
                        beanName, method.getName());
              }
              break;
            case POLL:
              remotingApi.addPollingProvider(beanName, method.getName(), annotation.event());
              break;

            }

          }
View Full Code Here

      String beanName = entry.getKey();

      Method[] methods = beanClass.getMethods();

      for (Method method : methods) {
        ExtDirectMethod annotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class);
        if (annotation != null && isSameGroup(group, annotation.group())) {
          ExtDirectMethodType type = annotation.value();

          switch (type) {
          case SIMPLE:         
            remotingApi.addAction(beanName, method.getName(), numberOfParameters(method));
            break;
          case SIMPLE_NAMED:
            remotingApi.addAction(beanName, method.getName(), parameterNames(beanClass, method));
            break;
          case FORM_LOAD:
          case STORE_READ:
          case STORE_MODIFY:
          case TREE_LOADER:
          case TREE_LOAD: 
            remotingApi.addAction(beanName, method.getName(), 1);
            break;
          case FORM_POST:
            if (isValidFormPostMethod(beanClass, method)) {
              remotingApi.addAction(beanName, method.getName(), 0, true);
            } else {
              LogFactory
                  .getLog(getClass())
                  .warn("Method '"
                      + beanName
                      + "."
                      + method.getName()
                      + "' is annotated as a form post method but is not valid. "
                      + "A form post method must be annotated with @RequestMapping and method=RequestMethod.POST. Method ignored.");
            }
            break;
          case POLL:
            remotingApi.addPollingProvider(beanName, method.getName(), annotation.event());
            break;

          }

        }
View Full Code Here

      String beanName = entry.getKey();

      Method[] methods = bean.getClass().getMethods();

      for (Method method : methods) {
        ExtDirectMethod annotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class);
        if (annotation != null && isSameGroup(group, annotation.group())) {
          ExtDirectMethodType type = annotation.value();

          switch (type) {
            case SIMPLE:
              remotingApi.addAction(beanName, method.getName(), numberOfParameters(method));
              break;
            case FORM_LOAD:
            case STORE_READ:
            case STORE_MODIFY:
              remotingApi.addAction(beanName, method.getName(), 1);
              break;
            case FORM_POST:
              if (isValidFormPostMethod(method)) {
                remotingApi.addAction(beanName, method.getName(), 0, true);
              } else {
                LogFactory.getLog(getClass()).warn("Method '" + beanName + "." + method.getName()
                            + "' is annotated as a form post method but is not valid. "
                            + "A form post method must be annotated with @RequestMapping and method=RequestMethod.POST. Method ignored.");
              }
              break;
            case POLL:
              remotingApi.addPollingProvider(beanName, method.getName(), annotation.event());
              break;

          }

        }
View Full Code Here

  private PollingProvider pollingProvider;

  public MethodInfo(final Class<?> clazz, final String beanName, final Method method) {

    ExtDirectMethod extDirectMethodAnnotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class);
    this.type = extDirectMethodAnnotation.value();

    if (StringUtils.hasText(extDirectMethodAnnotation.group())) {
      this.group = extDirectMethodAnnotation.group().trim();
    } else {
      this.group = null;
    }

    if (type != ExtDirectMethodType.FORM_POST) {
      this.method = method;
      this.synchronizeOnSession = extDirectMethodAnnotation.synchronizeOnSession();
      this.streamResponse = extDirectMethodAnnotation.streamResponse();

      this.parameters = buildParameterList(method);

      this.collectionType = (extDirectMethodAnnotation.entryClass() == Object.class) ? null
          : extDirectMethodAnnotation.entryClass();

      if (this.collectionType == null) {
        for (ParameterInfo parameter : parameters) {
          if (parameter.getCollectionType() != null) {
            this.collectionType = parameter.getCollectionType();
            break;
          }
        }
      }

    } else {
      RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
      if (methodAnnotation != null) {

        RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

        String path = null;
        if (hasValue(classAnnotation)) {
          path = classAnnotation.value()[0];
        }

        if (hasValue(methodAnnotation)) {
          String methodPath = methodAnnotation.value()[0];
          if (path != null) {
            path = path + methodPath;
          } else {
            path = methodPath;
          }
        }

        if (path != null) {
          if (path.charAt(0) == '/' && path.length() > 1) {
            path = path.substring(1, path.length());
          }
          this.forwardPath = "forward:" + path;
        }
      }

    }

    switch (type) {
    case SIMPLE:
      int paramLength = 0;
      for (ParameterInfo parameter : this.parameters) {
        if (!parameter.isSupportedParameter() && !parameter.isHasRequestHeaderAnnotation()) {
          paramLength++;
        }
      }
      this.action = new Action(method.getName(), paramLength, null);
      break;
    case SIMPLE_NAMED:
      List<String> parameterNames = new ArrayList<String>();
      for (ParameterInfo parameter : this.parameters) {
        if (!parameter.isSupportedParameter() && !parameter.isHasRequestHeaderAnnotation()) {
          parameterNames.add(parameter.getName());
        }
      }
      this.action = new Action(method.getName(), parameterNames);
      break;
    case FORM_LOAD:
    case STORE_READ:
    case STORE_MODIFY:
    case TREE_LOAD:
      this.action = new Action(method.getName(), 1, null);
      break;
    case FORM_POST:
      this.action = new Action(method.getName(), 0, true);
      break;
    case POLL:
      this.pollingProvider = new PollingProvider(beanName, method.getName(), extDirectMethodAnnotation.event());
      break;
    }
  }
View Full Code Here

  private String sseMethod;

  public MethodInfo(Class<?> clazz, ApplicationContext context, String beanName, Method method) {

    ExtDirectMethod extDirectMethodAnnotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class);

    this.type = extDirectMethodAnnotation.value();

    if (extDirectMethodAnnotation.jsonView() != ExtDirectMethod.NoJsonView.class) {
      this.jsonView = extDirectMethodAnnotation.jsonView();
    } else {
      this.jsonView = null;
    }

    if (StringUtils.hasText(extDirectMethodAnnotation.group())) {
      this.group = extDirectMethodAnnotation.group().trim();
    } else {
      this.group = null;
    }

    this.synchronizeOnSession = extDirectMethodAnnotation.synchronizeOnSession();
    this.streamResponse = extDirectMethodAnnotation.streamResponse();

    if (type != ExtDirectMethodType.FORM_POST) {
      this.method = method;
      this.parameters = buildParameterList(clazz, method);

      this.collectionType = (extDirectMethodAnnotation.entryClass() == Object.class) ? null
          : extDirectMethodAnnotation.entryClass();

      if (this.collectionType == null) {
        for (ParameterInfo parameter : parameters) {
          Class<?> collType = parameter.getCollectionType();
          if (collType != null) {
            this.collectionType = collType;
            break;
          }
        }
      }
    } else {
      if (method.getReturnType().equals(Void.TYPE)) {

        RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
        RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);

        String path = null;
        if (hasValue(classAnnotation)) {
          path = classAnnotation.value()[0];
        }

        if (hasValue(methodAnnotation)) {
          String methodPath = methodAnnotation.value()[0];
          if (path != null) {
            path = path + methodPath;
          } else {
            path = methodPath;
          }
        }

        if (path != null) {
          if (path.charAt(0) == '/' && path.length() > 1) {
            path = path.substring(1, path.length());
          }
          this.forwardPath = "forward:" + path;
        }
      } else {
        this.handlerMethod = new HandlerMethod(beanName, context, method).createWithResolvedBean();
      }
    }

    switch (type) {
    case SIMPLE:
      int paramLength = 0;
      for (ParameterInfo parameter : this.parameters) {
        if (!parameter.isSupportedParameter() && !parameter.isHasRequestHeaderAnnotation()) {
          paramLength++;
        }
      }
      this.action = new Action(method.getName(), paramLength, null);
      break;
    case SIMPLE_NAMED:
      List<String> parameterNames = new ArrayList<String>();
      for (ParameterInfo parameter : this.parameters) {
        if (!parameter.isSupportedParameter() && !parameter.isHasRequestHeaderAnnotation()) {
          parameterNames.add(parameter.getName());
        }
      }
      this.action = new Action(method.getName(), parameterNames);
      break;
    case FORM_LOAD:
    case STORE_READ:
    case STORE_MODIFY:
    case TREE_LOAD:
      this.action = new Action(method.getName(), 1, null);
      break;
    case FORM_POST:
      this.action = new Action(method.getName(), 0, true);
      break;
    case FORM_POST_JSON:
      this.action = new Action(method.getName(), 1, null);
      break;
    case POLL:
      this.pollingProvider = new PollingProvider(beanName, method.getName(), extDirectMethodAnnotation.event());
      break;
    case SSE:
      this.sseMethod = method.getName();
      break;
    default:
      throw new IllegalStateException("ExtDirectMethodType: " + type + " does not exists");
    }

    this.action = extractDocumentationAnnotations(extDirectMethodAnnotation.documentation());

  }
View Full Code Here

          return AnnotationUtils.findAnnotation(method, ExtDirectMethod.class) != null;
        }
      });

      for (Method method : methods) {
        ExtDirectMethod directMethodAnnotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class);
        final String beanMethodName = beanName + "." + method.getName();
        if (directMethodAnnotation.value().isValid(beanMethodName, userType, method)) {
          MethodInfoCache.INSTANCE.put(beanName, handlerType, method);

          if (log.isDebugEnabled()) {
            String info = "Register " + beanMethodName + "(" + directMethodAnnotation.value();
            if (StringUtils.hasText(directMethodAnnotation.group())) {
              info += ", " + directMethodAnnotation.group();
            }
            info += ")";
            log.debug(info);
          }
        }
View Full Code Here

TOP

Related Classes of ch.ralscha.extdirectspring.annotation.ExtDirectMethod

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.