We have an outdated web application (not Spring), and they are looking for best practices for automatically creating a new Spring beans service in instance variables in several legacy servlets. Overwriting every servlet on Spring MVC is beyond the scope. For verification, we do not need any Spring bean search code in Servlets to search for beans by name or similar.
Note that we are not interested in web-specific areas of a bean, such as a session or request; all services have the same scope.
The corresponding code snippet is shown below.
MyServlet extends LegacyServletSuperclass
{
private MyThreadSafeServiceBean wantThisToBeAutowiredBySpring;
....
}
Peter source
share