0

just like in the topic. I have my resource class :

public class HelloWorldEndpoint implements IRest {

    public String sayHello()
    {
      return "Hello world!";
  }

}

And Interface :

@Path("/helloworld")
public interface IRest {

    @GET
    @Path("/hello")
    String sayHello();
}

Is it possible to match sayHello() from HelloWorldEndpoint using only @Path class annotation? This is very specific example of resource class implementation, but it shows that it is possible to have REST endpoint without any annotation in class.. I've tried with inheritsAnnotation() and isAnnotatedWith() but it's not working that way unfortunatly. My goal is to find all resource classes :)

Macko
  • 21
  • 4

1 Answers1

0

Annotations of interfaces are not inherited in accordance to the Java Langauge specification. They are neither exposed by the reflection API, for example.

In order to discover the annotation, you can manually travers the class hierarchy and look for the annotation in question. This is possible by hasSuperType(isAnnotatedWith(...)). Note that this is a rather expensive matching condition.

Rafael Winterhalter
  • 42,759
  • 13
  • 108
  • 192