On 15/07/15 03:20, Chris Wolf wrote:
For legacy reasons, all of the resource methods in the project I'm
working on have a signature similar to:
@GET
@Path("/book")
public Response getBook(@Context HttpServletRequest request,
@Context HttpServletResponse response);
When I change to local transport (to save runtime setup of Jetty in
unit tests), these parameters are null, which makes sense since the
protocol is not HTTP. I tried implementing a custom Interceptor to
replace Message content with a two element list containing mock
HttpServletRequest and HttpServletResponse , but I couldn't find the
correct phase.
JAXRSInInterceptor runs at the UNMARSHAL phase, so you can register an
interceptor at UMMARSHAL or earlier, and set the mocks as message
properties, example:
message.put("HTTP.REQUEST", request);
message.put("HTTP.RESPONSE", response);
(the mocks are from mockrunner-servlet)
Now I'm thinking it might be easier with a custom invoker, as
mentioned at the bottom of this page:
http://cxf.apache.org/docs/jax-rs-filters.html
I downloaded the source tarball and found the source at:
https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomJAXRSInvoker.java;h=cce0f048d1c9f1b12925725b9def7730a4aa01ff;hb=HEAD
...but now I can't find any other java module that would show how to
configure this custom invoker. Apologies if I missed it online, but
could find nothing.
This documentation shows how to set it up from Spring only:
http://cxf.apache.org/docs/jax-rs-filters.html#JAX-RSFilters-Custominvokers
or do from the code:
myServerfactoryBean.setInvoker(myInvoker)
Cheers, Sergey
Thanks,
Chris
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com