예제 #1
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));
     }
   }
 }
예제 #2
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()));
    }
  }
예제 #3
0
  private void addSubResourceLocators(
      Resource.Builder resourceBuilder,
      MethodList methodList,
      boolean encodedParameters,
      final boolean extended) {

    for (AnnotatedMethod am :
        methodList.withoutMetaAnnotation(HttpMethod.class).withAnnotation(Path.class)) {
      final String path = am.getAnnotation(Path.class).value();
      Resource.Builder builder = resourceBuilder;
      if (path != null && !path.isEmpty() && !path.equals("/")) {
        builder = resourceBuilder.addChildResource(path);
      }

      builder
          .addMethod()
          .encodedParameters(encodedParameters || am.isAnnotationPresent(Encoded.class))
          .handledBy(handlerClass, am.getMethod())
          .handlingMethod(am.getDeclaredMethod())
          .extended(extended || am.isAnnotationPresent(ExtendedResource.class));
    }
  }