Hi Ted, i tried your suggestion and i can get the application context without any problem. The beans that i want to retrieve are available via the manual implementation. So far so good :) I guess this is how i should implement it. Still i do not know the reason why the interceptor is not injected with the autowired stuff.
/Marco 2012/6/5 Ted <[email protected]>: > hrmm I can't remember how I checked off hand, but you can always grab the > one from the spring context and check if it's the same memory location as > the this object, or you can print something in the constructor to see who > is calling the constructor like a stack trace. > > You could just look at how your declaring / adding the interceptor too, > that might give you an idea. i.e. by classname or by spring bean reference. > > > > On Tue, Jun 5, 2012 at 3:19 PM, Marco Pas <[email protected]> wrote: > >> How can i check if the code is indeed running in a spring context? >> >> 2012/6/5 Ted <[email protected]>: >> > I ran into the same problem a while ago, I found that the interceptor was >> > not in the spring context. As a result I had to manually retrieve a >> > reference to the context and get the spring beans that way. >> > >> > You might want to double check that the running code is in a spring >> > context, I suspect you might find it's not. Remember, just because >> > component scan initialises a copy of the bean, doesn't mean the running >> > copy of the bean is from the context. >> > >> > On Tue, Jun 5, 2012 at 7:15 AM, Marco Pas <[email protected]> >> wrote: >> > >> >> Hi there, >> >> >> >> i seem to run into a small issue when using @Autowired into a custom >> >> cxf interceptor. >> >> My use case is that i want to log soap messages and send these using >> >> AMQP to another system. This process works for normal services etc. >> >> I checked the Spring DI log and the context is scanned and pickedup, >> >> so what am i missing? >> >> >> >> Is this even possible in CXF interceptors? >> >> >> >> @Component >> >> public class LogInInterceptor extends AbstractSoapInterceptor { >> >> >> >> private @Value("#{rabbitMQProperties['rabbitmq.binding.log.soap']}") >> >> String binding; >> >> >> >> @Autowired >> >> AmqpTemplate amqpTemplate; >> >> >> >> public LogInInterceptor() { >> >> super(Phase.RECEIVE); >> >> } >> >> >> >> @Override >> >> public void handleMessage(SoapMessage soapMessage) throws Fault { >> >> logIt(soapMessage); >> >> } >> >> >> >> private void logIt(SoapMessage message) throws Fault { >> >> // rest of the code omitted...!!! >> >> amqpTemplate.convertAndSend(binding, buffer.toString()); >> >> } >> >> >> >> } >> >> >> > >> > >> > >> > -- >> > Ted. >> > > > > -- > Ted.
