Feb 17 2009

Accessing Spring application context in MDB’s

Published by Gilles at 9:22 am under J2EE, Java, Spring

spring25.png
Let’s say you have a message driven bean in which you want to inject beans.

Add an interceptor

Annotate your with the @Interceptors and specify SpringBeanAutowiringInterceptor.class as interceptor. This is an 3-compliant interceptor class that injects beans into fields and methods which are annotated with @Autowired. Performs injection after construction as well as after activation of a passivated bean.
The actual BeanFactory to obtain beans from is determined by the getBeanFactory(.lang.Object) template method. The default implementation obtains the ContextSingletonBeanFactoryLocator, initialized from the default resource location classpath*:beanRefContext.xml, and obtains the single ApplicationContext defined there.
(for more info, see doc)

Pages: 1 2 3

Trackback URI | Comments RSS

Leave a Reply