Feb 17 2009
Accessing Spring application context in MDB’s
![]()
Let’s say you have a message driven bean in which you want to inject spring beans.
Add an interceptor
Annotate your MDB with the @Interceptors and specify SpringBeanAutowiringInterceptor.class as interceptor. This is an EJB3-compliant interceptor class that injects Spring 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 Spring beans from is determined by the getBeanFactory(java.lang.Object) template method. The default implementation obtains the Spring ContextSingletonBeanFactoryLocator, initialized from the default resource location classpath*:beanRefContext.xml, and obtains the single ApplicationContext defined there.
(for more info, see doc)

