How to make a legacy webapp spring aware at the container level for bean autowire into Servlets?
Posted
by Pete
on Stack Overflow
See other posts from Stack Overflow
or by Pete
Published on 2010-03-17T15:06:11Z
Indexed on
2010/04/02
23:13 UTC
Read the original article
Hit count: 301
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;
....
}
© Stack Overflow or respective owner