code: private boolean isRESTMethod(Method method) {
  
          // Check whether the required REST annotations are present
          for (Annotation annotation : method.getAnnotations()) {
  
              // A method is a REST method if it is annotated with @HttpMethod
              Class<? extends Annotation> annotationType = annotation.annotationType();
              if (annotationType.isAnnotationPresent(HttpMethod.class))
                  return true;
  
              // A method is a REST method if it is annotated with @Path
              if (Path.class.isAssignableFrom(annotationType))
                  return true;
  
          }
  
          // A method is also REST method if it overrides a REST method within
          // the superclass
          Class<?> superclass = method.getDeclaringClass().getSuperclass();
          if (superclass != null) {
  
              // Recheck against identical method within superclass
              try {
                  return isRESTMethod(superclass.getMethod(method.getName(),
                          method.getParameterTypes()));
              }
  
              // If there is no such method, then this method cannot possibly be
              // a REST method
              catch (NoSuchMethodException e) {
                  return false;
              }
  
          }
  
          // Lacking a superclass, the search stops here - it's not a REST method
          return false;
  
      }
docs: Returns whether the given method is annotated as a REST method. A REST
  method is annotated with an annotation which is annotated with
  <code>@HttpMethod</code> or <code>@Path</code>.
  
  @param method
  The method to test.
  
  @return
  true if the given method is annotated as a REST method, false
  otherwise.