Esempio n. 1
0
 public List<MethodParameter> getFormParameters() {
   if (resource.isSubResource()) {
     List<MethodParameter> allFormParameters =
         new ArrayList<MethodParameter>(resource.getParentMethod().getFormParameters());
     allFormParameters.addAll(formParameters);
     return allFormParameters;
   }
   return formParameters;
 }
    public ResourceClass buildClass() {
      resourceClass.fields = fields.toArray(new FieldParameter[fields.size()]);
      resourceClass.setters = setters.toArray(new SetterParameter[setters.size()]);
      resourceClass.resourceMethods =
          resourceMethods.toArray(new ResourceMethod[resourceMethods.size()]);
      resourceClass.resourceLocators =
          resourceLocators.toArray(new ResourceLocator[resourceLocators.size()]);

      return resourceClass;
    }
Esempio n. 3
0
 private void setupMIMEs() {
   producesAnnotation =
       Utils.findMethodAnnotation(declaringClass, method, Utils.getProducesClass());
   consumesAnnotation =
       Utils.findMethodAnnotation(declaringClass, method, Utils.getConsumesClass());
   if (producesAnnotation == null) {
     producesAnnotation = resource.getProducesAnnotation();
   }
   if (consumesAnnotation == null) {
     consumesAnnotation = resource.getConsumesAnnotation();
   }
 }
Esempio n. 4
0
 public ResourceMethod(MethodDoc method, MethodDoc declaringMethod, ResourceClass resource) {
   this.resource = resource;
   this.method = method;
   this.declaringClass = resource.getDeclaringClass();
   this.declaringMethod = declaringMethod;
   this.output = new MethodOutput(declaringMethod);
   try {
     formClass = Class.forName("org.jboss.resteasy.annotations.Form");
   } catch (ClassNotFoundException e) {
     // we won't support @Form
   }
   setupPath();
   setupParameters();
   setupMethods();
   setupMIMEs();
   // is this a resource locator?
   if (methods.isEmpty() && !declaringMethod.returnType().isPrimitive()) {
     // Handle Class style resource locator factory methods
     Type t = declaringMethod.returnType();
     if ("java.lang.Class".equals(t.qualifiedTypeName())) {
       ParameterizedType p = t.asParameterizedType();
       if (p != null) {
         t = p.typeArguments()[0];
       }
     }
     resourceLocator = new ResourceClass(t.asClassDoc(), this);
   }
 }
Esempio n. 5
0
 private void setupPath() {
   final AnnotationDesc pathAnnotation =
       Utils.findMethodAnnotation(declaringClass, method, Path.class);
   final String rootPath = resource.getPath();
   if (pathAnnotation != null) {
     String path = (String) Utils.getAnnotationValue(pathAnnotation);
     path = Utils.removeFragmentRegexes(path, regexFragments);
     this.path = Utils.appendURLFragments(rootPath, path);
   } else this.path = rootPath;
 }
Esempio n. 6
0
 public ResourceLocator(ResourceClass resourceClass, Method method, Method annotatedMethod) {
   this.resourceClass = resourceClass;
   this.annotatedMethod = annotatedMethod;
   this.method = method;
   // we initialize generic types based on the method of the resource class rather than the Method
   // that is actually
   // annotated.  This is so we have the appropriate generic type information.
   this.genericReturnType =
       Types.resolveTypeVariables(resourceClass.getClazz(), method.getGenericReturnType());
   this.returnType = Types.getRawType(genericReturnType);
   this.params = new MethodParameter[method.getParameterTypes().length];
   for (int i = 0; i < method.getParameterTypes().length; i++) {
     this.params[i] =
         new MethodParameter(
             this,
             method.getParameterTypes()[i],
             method.getGenericParameterTypes()[i],
             annotatedMethod.getParameterAnnotations()[i]);
   }
 }
Esempio n. 7
0
 public String getPathParamRegex(String name) {
   if (regexFragments.containsKey(name)) return regexFragments.get(name);
   return resource.getPathParamRegex(name);
 }
Esempio n. 8
0
 public AnnotationDesc getConsumesAnnotation() {
   if (consumesAnnotation != null) return consumesAnnotation;
   if (resource.isSubResource()) return resource.getConsumesAnnotation();
   return null;
 }
Esempio n. 9
0
 public AnnotationDesc getProducesAnnotation() {
   if (producesAnnotation != null) return producesAnnotation;
   if (resource.isSubResource()) return resource.getProducesAnnotation();
   return null;
 }