How to get the target method of this JAX-RS request?

Is there a way to get a java.lang.reflect.Methodmethod (which is annotated using @Path) that will be called for a given HttpServletRequest?

Here is my use case: I am in Java EE Filterand want to know if the method that will be called later will be annotated using other specific annotations.

(I am using RESTEasy 3.0.7)

+4
source share
1 answer

It's easy if you can use a ContainerRequestFilter instead of a regular servlet filter .

@Provider
public class SomeFilter implements ContainerRequestFilter {

    @Context
    private ResourceInfo resourceInfo;

    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {
        Method method = resourceInfo.getResourceMethod();
    }

}
+8
source

Source: https://habr.com/ru/post/1544015/


All Articles