Ejemplo n.º 1
0
  private void checkForNonPublicMethodIssues() {
    final MethodList allDeclaredMethods = new MethodList(getAllDeclaredMethods(handlerClass));

    // non-public resource methods
    for (AnnotatedMethod m :
        allDeclaredMethods
            .withMetaAnnotation(HttpMethod.class)
            .withoutAnnotation(Path.class)
            .isNotPublic()) {
      Errors.warning(
          handlerClass, LocalizationMessages.NON_PUB_RES_METHOD(m.getMethod().toGenericString()));
    }
    // non-public subres methods
    for (AnnotatedMethod m :
        allDeclaredMethods
            .withMetaAnnotation(HttpMethod.class)
            .withAnnotation(Path.class)
            .isNotPublic()) {
      Errors.warning(
          handlerClass,
          LocalizationMessages.NON_PUB_SUB_RES_METHOD(m.getMethod().toGenericString()));
    }
    // non-public subres locators
    for (AnnotatedMethod m :
        allDeclaredMethods
            .withoutMetaAnnotation(HttpMethod.class)
            .withAnnotation(Path.class)
            .isNotPublic()) {
      Errors.warning(
          handlerClass, LocalizationMessages.NON_PUB_SUB_RES_LOC(m.getMethod().toGenericString()));
    }
  }
Ejemplo n.º 2
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);
    }
  }