I needed to initialize a bean at the application startup so I did that in applicationContext.xml
. But now I need to inject that bean into an object which is created at runtime. Example:
Servlet
...
void doPost(...) {
new Handler(request);
}
...
Handler
public class Handler {
ProfileManager pm; // I need to inject this ???
Handler(Request request) {
handleRequest(request);
}
void handleRequest(Request request) {
pm.getProfile(); // example
}
}