예제 #1
0
  protected static void processMethod(
      ResourceClassBuilder resourceClassBuilder, Class<?> root, Method implementation) {
    Method method = findAnnotatedMethod(root, implementation);
    if (method != null) {
      Path path = method.getAnnotation(Path.class);
      Set<String> httpMethods = IsHttpMethod.getHttpMethods(method);

      ResteasyUriBuilder builder = new ResteasyUriBuilder();
      if (root.isAnnotationPresent(Path.class)) {
        builder.path(root);
      }
      if (path != null) {
        builder.path(method);
      }
      String pathExpression = builder.getPath();
      if (pathExpression == null) pathExpression = "";

      ResourceLocatorBuilder resourceLocatorBuilder;

      if (httpMethods == null) {
        resourceLocatorBuilder = resourceClassBuilder.locator(implementation, method);
      } else {
        ResourceMethodBuilder resourceMethodBuilder =
            resourceClassBuilder.method(implementation, method);
        resourceLocatorBuilder = resourceMethodBuilder;

        for (String httpMethod : httpMethods) {
          if (httpMethod.equalsIgnoreCase(HttpMethod.GET)) resourceMethodBuilder.get();
          else if (httpMethod.equalsIgnoreCase(HttpMethod.PUT)) resourceMethodBuilder.put();
          else if (httpMethod.equalsIgnoreCase(HttpMethod.POST)) resourceMethodBuilder.post();
          else if (httpMethod.equalsIgnoreCase(HttpMethod.DELETE)) resourceMethodBuilder.delete();
          else if (httpMethod.equalsIgnoreCase(HttpMethod.OPTIONS)) resourceMethodBuilder.options();
          else if (httpMethod.equalsIgnoreCase(HttpMethod.HEAD)) resourceMethodBuilder.head();
          else resourceMethodBuilder.httpMethod(httpMethod);
        }
        Produces produces = method.getAnnotation(Produces.class);
        if (produces == null)
          produces = resourceClassBuilder.resourceClass.getClazz().getAnnotation(Produces.class);
        if (produces == null) produces = method.getDeclaringClass().getAnnotation(Produces.class);
        if (produces != null) resourceMethodBuilder.produces(produces.value());

        Consumes consumes = method.getAnnotation(Consumes.class);
        if (consumes == null)
          consumes = resourceClassBuilder.resourceClass.getClazz().getAnnotation(Consumes.class);
        if (consumes == null) consumes = method.getDeclaringClass().getAnnotation(Consumes.class);
        if (consumes != null) resourceMethodBuilder.consumes(consumes.value());
      }
      resourceLocatorBuilder.path(pathExpression);
      for (int i = 0; i < resourceLocatorBuilder.locator.params.length; i++) {
        resourceLocatorBuilder.param(i).fromAnnotations();
      }
      resourceLocatorBuilder.buildMethod();
    }
  }
예제 #2
0
 @Override
 public ResourceMethodParameterBuilder fromAnnotations() {
   super.fromAnnotations();
   if (param.paramType == Parameter.ParamType.SUSPEND
       || param.paramType == Parameter.ParamType.SUSPENDED) {
     method.method.asynchronous = true;
   } else if (param.paramType == Parameter.ParamType.UNKNOWN) {
     param.paramType = Parameter.ParamType.MESSAGE_BODY;
   }
   return this;
 }
예제 #3
0
 public ResourceMethodParameterBuilder suspend(long timeout) {
   method.method.asynchronous = true;
   parameter.paramType = Parameter.ParamType.SUSPEND;
   parameter.suspendTimeout = timeout;
   return this;
 }
예제 #4
0
 public ResourceMethodParameterBuilder suspended() {
   method.method.asynchronous = true;
   parameter.paramType = Parameter.ParamType.SUSPENDED;
   return this;
 }