How to get resource method matched to URI before Jersey invokes it?

后端 未结 4 1255
感动是毒
感动是毒 2020-12-08 15:35

I\'m trying to implement a ContainerRequestFilter that does custom validation of a request\'s parameters. I need to look up the resource method that will be matched to the U

4条回答
  •  旧时难觅i
    2020-12-08 16:08

    In resteasy-jaxrs-3.0.5, you can retrieve a ResourceMethodInvoker representing the matched resource method from ContainerRequestContext.getProperty() inside a ContainerRequestFilter:

       import org.jboss.resteasy.core.ResourceMethodInvoker;
    
       public class MyRequestFilter implements ContainerRequestFilter
       {
           public void filter(ContainerRequestContext request) throws IOException
           {
                String propName = "org.jboss.resteasy.core.ResourceMethodInvoker";
                ResourceMethodInvoker invoker = (ResourceMethodInvoker)request.getProperty();
                invoker.getMethod().getParameterTypes()....
           }
       }
    

提交回复
热议问题