Reputation: 41
I'm using jax-rs with jersey, I implemented a ContainerRequestFilter, and I have annotated ResourceInfo object with @Context annotation. there is a way to have not only the class but also its implemented interfaces directly from ResourceInfo? Or there is another way to get these information?
Upvotes: 4
Views: 755
Reputation: 209112
I'm assuming you mean if you have
@Path("...")
public class Resource implements IOne, ITwo {
you want to get IOne
and ITwo
. For this, just use Class#getInterfaces()
public Class<?>[] getInterfaces()
Determines the interfaces implemented by the class or interface represented by this object.
For anyone for which the above is still unclear, ResourceInfo#getResourceClass
returns the Class
object for the resource class. From the returned Class
object, you can call getInterfaces()
Class<?>[] ifaces = resourceInfo.getResourceClass().getInterfaces();
Upvotes: 1