Hi
On 29/01/13 12:16, Esteban Wagner wrote:
Update:

I got it working. In the service I did:

Message m = PhaseInterceptorChain.getCurrentMessage();
m.get(XApp.class);

How do you set it in the filter for the above to work ? Do you use a message or the injected MessageContext ?


1) Is this the correct way of accessing data that has been put through a
JAX-RS filter?


PhaseInterceptorChain.getCurrentMessage() will always return the current message, this approach works well if you need to get something from the message,

2) Why message context approach does not work?

messageContext.put(XApp.class, xApp);
is translated to
message.put(XApp.class.toString()), xApp);

I guess we can add few more methods to MessageContext wrapping Message methods like put(Class, Object), get(Class), setContent(Class, Object)

From debugging the code I ve
seen that the instance of MessageContext in the Filter its different that
the instance of MessageContext that its injected into the Service. Is this
behavior correct. They both shouldnt be the same instance.?

The injected instances represent thread-safe proxies, so they are different instance, but I guess that can be optimized and the same proxy instance is used.

Cheers, Sergey

Many Thanks,





On Tue, Jan 29, 2013 at 11:41 AM, Esteban Wagner
<[email protected]>wrote:

Please note that also I have tried doing this in the request handler:
@Context MessageContext mc;
handleRequest(){

           XApp xApp = new XApp()

mc.put(XApp.class, xApp);


}



On Tue, Jan 29, 2013 at 11:33 AM, Esteban Wagner<[email protected]
wrote:

Hi,

I am using a JAX-RS Filter to process some input and then I want to put
an instance of an object available for the Service.

So in the filter request handler method I am doing:
            XApp xApp = new XApp()

message.put(XApp.class, xApp);


And in the service in the target method i am doing:

@Context MessageContext mc;
XApp xApp = (XApp) mc.getXApp.class);


The message context gets injected into the service but the object I put
into the message its not there...

What can be wrong here?


Many Thanks,









Reply via email to