You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "KARR, DAVID (ATTSI)" <dk...@att.com> on 2010/11/03 16:29:54 UTC

How to write interceptor that can read "context" set before operation invocation?

I have to write some interceptors that have to read from more than just
the outgoing or incoming message.  Before the operation invocation, the
client code needs to put some data into a "context" that the interceptor
can read.  This container needs to be thread-local.  I've looked through
the doc, the examples, and the existing interceptors, and I don't see a
clue for how to do this.

Re: How to write interceptor that can read "context" set before operation invocation?

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday 03 November 2010 11:29:54 am KARR, DAVID (ATTSI) wrote:
> I have to write some interceptors that have to read from more than just
> the outgoing or incoming message.  Before the operation invocation, the
> client code needs to put some data into a "context" that the interceptor
> can read.  This container needs to be thread-local.  I've looked through
> the doc, the examples, and the existing interceptors, and I don't see a
> clue for how to do this.

This is easy.   If you turn on the thread local request context (see the faq 
http://cxf.apache.org/faq.html) then you can put anything in the request 
context via:

((BindingProvider)proxy).getRequestContext().put("foo", myObject);

and any interceptor can just query it via:

message.get("foo");


-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog