In my Stripes app I define the following class:
MyServletListener implements ServletContextListener, HttpSessionListener, HttpSessionAttributeListener {
private SomeService someService;
private AnotherService anotherService;
// remaining implementation omitted
}
The service layer of this app uses Spring to define and wire together some service beans in an XML file. I would like to inject the beans that implement SomeService
and AnotherService
into MyServletListener
, is this possible?
Something like this should work:
Your listener should be declared after Spring's
ContextLoaderListener
inweb.xml
.Little bit shorter and simpler is to use
SpringBeanAutowiringSupport
class.Than all you have to do is this:
So using example from axtavt: