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()));
    }
  }
Example #2
0
 @Override
 public void visitInvocable(final Invocable invocable) {
   // TODO: check invocable.
   Class resClass = invocable.getHandler().getHandlerClass();
   if (resClass != null && !checkedClasses.contains(resClass)) {
     checkedClasses.add(resClass);
     final boolean provider = Providers.isProvider(resClass);
     int counter = 0;
     for (Annotation annotation : resClass.getAnnotations()) {
       if (SCOPE_ANNOTATIONS.contains(annotation.annotationType())) {
         counter++;
       }
     }
     if (counter == 0 && provider) {
       Errors.warning(
           resClass,
           LocalizationMessages.RESOURCE_IMPLEMENTS_PROVIDER(
               resClass, Providers.getProviderContracts(resClass)));
     } else if (counter > 1) {
       Errors.fatal(resClass, LocalizationMessages.RESOURCE_MULTIPLE_SCOPE_ANNOTATIONS(resClass));
     }
   }
 }