How to make a legacy webapp spring aware at the container level for bean autowire into Servlets?
- by Pete
We have a legacy web application (not Spring based) and are looking for best practices to autowire some newer Spring configured (thread safe) service beans into instance variables in several of the legacy servlets. Rewriting every servlet to Spring MVC is out of scope. For testability, we do not want any Spring specific bean lookup code in the Servlets to look up beans by name or similar.
Note that we are not concerned about web specific bean scopes such as session or request; all services are singleton scope.
Below shows relevant code snippet
MyServlet extends LegacyServletSuperclass
{
private MyThreadSafeServiceBean wantThisToBeAutowiredBySpring;
....
}