Reputation: 24297
Is there a way to obtain the java.lang.reflect.Method
of the method (which is annotated with @Path
) which will be called for a given HttpServletRequest
?
Here is my use case : I'm in a Java EE Filter
and want to know if the method which will be invoked later is annotated with another specific annotations.
(I'm using RESTEasy 3.0.7)
Upvotes: 6
Views: 2672
Reputation: 10961
It's easy if you can use a ContainerRequestFilter instead of a normal Servlet Filter.
@Provider
public class SomeFilter implements ContainerRequestFilter {
@Context
private ResourceInfo resourceInfo;
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
Method method = resourceInfo.getResourceMethod();
}
}
Upvotes: 10