You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Eugeny N Dzhurinsky <bo...@redwerk.com> on 2009/06/14 11:48:04 UTC
Get access to HTTP request parameters from an AOP advice?
Hello!
I would like to develop the RESTful application, which does contain the
session keys within the URL, like below:
http://domain.com/rest/2ac41aab-472f-4731-b767-9b6812332748/products/list
I would like to define the around advice for all the service methods, the code
of the advice will examine the session key
(2ac41aab-472f-4731-b767-9b6812332748) to exist in the current session list.
If there is no such code - or the session was expired - the unauthorized
response code must be sent back to the client.
The question is - how can I get access to this parameter from the around
advice? I checked the user manual and sources, and still have no idea if there
is some ThreadLocal variable, responsible to hold the HTTP request object (may
be WebServiceContextImpl does the trick?)
I am using Spring AOP, if that matters.
Thank you in advance!
--
Eugene N Dzhurinsky
Re: Get access to HTTP request parameters from an AOP advice?
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi
> Message currentMessage = org.apache.cxf.phase.PhaseInterceptorChain.getCurrentMessage();
I think it's safe to use this code. If it were possible for you to use jaxrs filters/invokers or cfx in interceptors sitting between
JAXRSInInterceptor & application code then you'd get the Message being passed explicitly, but in your case using this thread-local
call is probably the only option...
cheers, Sergey
> Hi,
>
> You should be able to get to a current message like this :
>
> Message currentMessage = org.apache.cxf.phase.PhaseInterceptorChain.getCurrentMessage();
> Next you can get to the actual HttpServletRequest like this :currentMessage.get("HTTP.REQUEST"); //
> AbstractHttpDestination.HTTP_REQUESTYou might want to use the CXf JAX-RS URITemplate implementation which will help to extract the
> keys :URITemplate t = new URITemplate("/rest/{key}/products/list");MultivaluedMap<String, String> map = new MetadataMap<String,
> String>();t.match(relativeURI, map);map.get("key");
> cheers, Sergey
Thank you, looks like this is what I really need. Is it a common way, or just
a "hack", which might not work in the next version of CXF?
--
Eugene N Dzhurinsky
Re: Get access to HTTP request parameters from an AOP advice?
Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
On Mon, Jun 15, 2009 at 10:20:07AM +0100, Sergey Beryozkin wrote:
> Hi,
>
> You should be able to get to a current message like this :
>
> Message currentMessage = org.apache.cxf.phase.PhaseInterceptorChain.getCurrentMessage();
> Next you can get to the actual HttpServletRequest like this :currentMessage.get("HTTP.REQUEST"); //
> AbstractHttpDestination.HTTP_REQUESTYou might want to use the CXf JAX-RS URITemplate implementation which will help to extract the
> keys :URITemplate t = new URITemplate("/rest/{key}/products/list");MultivaluedMap<String, String> map = new MetadataMap<String,
> String>();t.match(relativeURI, map);map.get("key");
> cheers, Sergey
Thank you, looks like this is what I really need. Is it a common way, or just
a "hack", which might not work in the next version of CXF?
--
Eugene N Dzhurinsky
Re: Get access to HTTP request parameters from an AOP advice?
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi,
You should be able to get to a current message like this :
Message currentMessage = org.apache.cxf.phase.PhaseInterceptorChain.getCurrentMessage();
Next you can get to the actual HttpServletRequest like this :currentMessage.get("HTTP.REQUEST"); //
AbstractHttpDestination.HTTP_REQUESTYou might want to use the CXf JAX-RS URITemplate implementation which will help to extract the
keys :URITemplate t = new URITemplate("/rest/{key}/products/list");MultivaluedMap<String, String> map = new MetadataMap<String,
String>();t.match(relativeURI, map);map.get("key");
cheers, Sergey
Hello!
I would like to develop the RESTful application, which does contain the
session keys within the URL, like below:
http://domain.com/rest/2ac41aab-472f-4731-b767-9b6812332748/products/list
I would like to define the around advice for all the service methods, the code
of the advice will examine the session key
(2ac41aab-472f-4731-b767-9b6812332748) to exist in the current session list.
If there is no such code - or the session was expired - the unauthorized
response code must be sent back to the client.
The question is - how can I get access to this parameter from the around
advice? I checked the user manual and sources, and still have no idea if there
is some ThreadLocal variable, responsible to hold the HTTP request object (may
be WebServiceContextImpl does the trick?)
I am using Spring AOP, if that matters.
Thank you in advance!
--
Eugene N Dzhurinsky
----- Original Message -----
From: "Eugeny N Dzhurinsky" <bo...@redwerk.com>
To: <us...@cxf.apache.org>
Sent: Sunday, June 14, 2009 10:48 AM
Subject: Get access to HTTP request parameters from an AOP advice?