Hi

At the moment I can think of the following hack:

have the service endpoint bean injected with (jaxws)WebServiceContext or (jaxrs)MessageContext, and also have a simple bean called, say, ContextHolder injected into the service endpoint bean too. Next, have @PostConstruct method in the service endpoint bean which will set the already injected WebServiceContext on the ContextHolder. Next, access ContextHolder from your aspect code...

Not sure if it actually can work but just an idea...

cheers, Sergey



----- Original Message ----- From: "Adrian M" <adrian.ma...@workstreaminc.com>
To: <users@cxf.apache.org>
Sent: Thursday, October 22, 2009 4:27 PM
Subject: Accessing jax-rs (CXF) MessageContext outside service class (in 
aspect) in Spring (2.5)



Hey All,

I'm trying to access the MessageContext (or WebServiceContext) in an aspect
to get access to the HTTPServletRequest for logging purposes. I would like
to inject the context like I did for spring-ws but I have not found a way to
do it. Here is what I used for spring-ws:

<beans:bean id="transportContext"
class="org.springframework.ws.transport.context.TransportContextHolder"
factory-method="getTransportContext" scope="request">
<aop:scoped-proxy/>
</beans:bean>

I can't use the @Resource annotation on WebServiceContext field/method as I
am not in the service (tried anyways with no luck). Instantiating the
WebServiceContext (ie new WebServiceContextImpl()) doesn't work either, but
supposedly should as this just wraps a threadlocal. I've also tried
importing cxf-extension-jaxws.xml and wiring the bean with id
org.apache.cxf.jaxws.context.WebServiceContextImpl with no luck (it's not
null but doesn't hold anything) Any ideas?

thanks

--
View this message in context: http://www.nabble.com/Accessing-jax-rs-%28CXF%29-MessageContext-outside-service-class-%28in-aspect%29-in-Spring-%282.5%29-tp26012049p26012049.html
Sent from the cxf-user mailing list archive at Nabble.com.


Reply via email to