Spring
If needing to react to events right after the Spring container has started or has been refreshed.
v4.2+
@Component
public class MyClass {
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
// do stuff
}
}
v4.2 and below
@Component
public MyClass implements ApplicationListener<ContextRefreshedEvent> {
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
// do stuff
}
}