Пример #1
0
  private void addSubResourceMethods(
      final Resource.Builder resourceBuilder,
      final MethodList methodList,
      final boolean encodedParameters,
      final List<MediaType> defaultConsumedTypes,
      final List<MediaType> defaultProducedTypes,
      final Collection<Class<? extends Annotation>> defaultNameBindings,
      final boolean extended) {

    for (AnnotatedMethod am :
        methodList.withMetaAnnotation(HttpMethod.class).withAnnotation(Path.class)) {
      Resource.Builder childResourceBuilder =
          resourceBuilder.addChildResource(am.getAnnotation(Path.class).value());

      ResourceMethod.Builder methodBuilder =
          childResourceBuilder
              .addMethod(am.getMetaMethodAnnotations(HttpMethod.class).get(0).value())
              .consumes(resolveConsumedTypes(am, defaultConsumedTypes))
              .produces(resolveProducedTypes(am, defaultProducedTypes))
              .encodedParameters(encodedParameters || am.isAnnotationPresent(Encoded.class))
              .nameBindings(defaultNameBindings)
              .nameBindings(am.getAnnotations())
              .handledBy(handlerClass, am.getMethod())
              .handlingMethod(am.getDeclaredMethod())
              .extended(extended || am.isAnnotationPresent(ExtendedResource.class));

      introspectAsyncFeatures(am, methodBuilder);
    }
  }
Пример #2
0
 private void checkResourceClassSetters(final MethodList methodList, final boolean encodedFlag) {
   for (AnnotatedMethod method :
       methodList
           .withoutMetaAnnotation(HttpMethod.class)
           .withoutAnnotation(Path.class)
           .hasNumParams(1)
           .hasReturnType(void.class)
           .nameStartsWith("set")) {
     Parameter p =
         Parameter.create(
             handlerClass,
             method.getMethod().getDeclaringClass(),
             encodedFlag || method.isAnnotationPresent(Encoded.class),
             method.getParameterTypes()[0],
             method.getGenericParameterTypes()[0],
             method.getAnnotations());
     if (null != p) {
       ResourceMethodValidator.validateParameter(
           p,
           method.getMethod(),
           method.getMethod().toGenericString(),
           "1",
           InvocableValidator.isSingleton(handlerClass));
     }
   }
 }