Exemple #1
0
 private RequestMethod getRequestMethod(Action annotation) {
   RequestMethod requestMethod = annotation.method();
   if (requestMethod == null) {
     requestMethod = RequestMethod.ANY;
   }
   return requestMethod;
 }
Exemple #2
0
  private void buildAndAddActions(
      Object controller, String controllerName, List<Method> actions, ApiActionHolder holder)
      throws ApiException {

    for (Method method : actions) {
      final Action annotation = method.getAnnotation(Action.class);
      final String actionName = annotation.name();

      final RequestMethod requestMethod = getRequestMethod(annotation);
      final ActionName name = new ActionName(controllerName, actionName);
      final MethodRef methodRef = new MethodRef(controller, method);
      final ApiAction action = new ApiAction(name, methodRef, requestMethod);

      fillParamsMetadata(action, methodRef);
      fillValidatorMetadata(action, method);
      fillSecurityMetadata(action, method);

      holder.add(action);
    }
  }
Exemple #3
0
  private List<Method> extractActions(Object object) throws ApiException {
    List<Method> result = Lists.newArrayList();
    Method[] methods = object.getClass().getMethods();
    for (Method method : methods) {
      Action annotation = method.getAnnotation(Action.class);
      if (annotation != null) {
        final String actionName = annotation.name();
        if (StringUtils.isEmpty(actionName)) {
          throw new ApiException(
              "Action name is not found on "
                  + object.getClass().getName()
                  + "."
                  + method.getName());
        }

        result.add(method);
      }
    }

    return result;
  }