users@jersey.java.net

[Jersey] Re: Method Dispatcher

From: Luis Javier de la Garza Trevino <delagarza_at_gmail.com>
Date: Fri, 10 Jun 2011 16:44:50 +0200

So, I implement (and provide) a ContainRequestFilter, so this method:

ContainerRequest filter(ContainerRequest request) {
}

Does the trick... The problem is that the filters have all been
processed before the method gets actually invoked. This is OK, but
still not what I need... Looking at Jersey's code reveals
(AbstractResourceMethodDispatchProvider.java) that methods get invoked
in the following way:

public void _dispatch(Object resource, HttpContext context) throws
IllegalAccessException, InvocationTargetException {
  final Object[] params = getParams(context);
  // this is where the method actually gets invoked
  invoker.invoke(method, resource, params);
}

final Object[] getParams(HttpContext context) {
  // pp is the InjectableValuesProvider
  return pp.getInjectableValues(context);
}

And this is hapenning AFTER the filters get invoked. So, by the time
filters are dispatched, the values have not been injected... Could you
provide me with extra pointers? Perhaps a snippet?

Thanks!


On Fri, Jun 10, 2011 at 4:31 PM, Santiago Pericas-Geertsen
<Santiago.PericasGeertsen_at_oracle.com> wrote:
>
> On Jun 10, 2011, at 9:48 AM, Luis de la Garza wrote:
>
>> Before posting my question I acutally did a small example using
>> ResourceDebuggingFilterFactory. I noticed that the filters get invoked
>> before the parameters of the method get injected (be it a @QueryParam, a
>> @Context, and so on). So at this point, I know which method will get
>> executed and I also know the parameter types, but I do not know which values
>> will be used to invoke the method...
>
>  That's right, but if you use a ContainerRequestFilter you have access the ContainerRequest that has all you need in there, right?
>
> -- Santiago
>
>



-- 
Luis Javier de la Garza Treviņo