You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by cfineman <cf...@gmail.com> on 2010/07/18 22:19:22 UTC

Access to Locale (MessageContext) in ParameterHandler?

Say I wanted to write a ParameterHandler that was locale-sensitive (e.g. for
parsing dates or monetary values). I can access to the request's locale via
an injected MessageContext but there's no obvious (to me!) way for me to get
at the MessageContext from within the ParameterHanlder. I understand from my
travels that the MessageContext is actually stored in a thread-local
variable... can I get access to that value without creating a dependency
that will likely break in future releases.

I could write a spring interceptor to squirrel away the servlet request but
I was hoping to do it entirely via CXF's framework. Any thoughts? 
-- 
View this message in context: http://cxf.547215.n5.nabble.com/Access-to-Locale-MessageContext-in-ParameterHandler-tp1431382p1431382.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Access to Locale (MessageContext) in ParameterHandler?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On Sun, Jul 18, 2010 at 9:19 PM, cfineman <cf...@gmail.com> wrote:

>
> Say I wanted to write a ParameterHandler that was locale-sensitive (e.g.
> for
> parsing dates or monetary values). I can access to the request's locale via
> an injected MessageContext but there's no obvious (to me!) way for me to
> get
> at the MessageContext from within the ParameterHanlder. I understand from
> my
> travels that the MessageContext is actually stored in a thread-local
> variable... can I get access to that value without creating a dependency
> that will likely break in future releases.
>
> I could write a spring interceptor to squirrel away the servlet request but
>

At the moment ParameterHandlers can not be injected with contexts, but there
is another CXF specific way :

Message m = PhaseInterceptorChain.getCurrentMessage();
Map<String, List<String>> headers = (Map) m.get(Message.PROTOCOL_HEADERS);

or even

HttpHeades headers = new HttpHeadersImpl(m);

which is unlikely to break in the future

cheers, Sergey


> I was hoping to do it entirely via CXF's framework. Any thoughts?
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Access-to-Locale-MessageContext-in-ParameterHandler-tp1431382p1431382.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>