ApplicationListener beans get obtained on demand, supporting non-singletons as well; ApplicationListeners will be called in the order according to the Ordered contract; generified ApplicationListener interface

This commit is contained in:
Juergen Hoeller
2009-02-09 18:26:30 +00:00
parent 6609386e41
commit 60392d6e74
15 changed files with 338 additions and 220 deletions

View File

@@ -26,7 +26,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.ContextRefreshedEvent;
@@ -94,7 +93,8 @@ import org.springframework.web.util.WebUtils;
* @see #setContextConfigLocation
* @see #setNamespace
*/
public abstract class FrameworkServlet extends HttpServletBean implements ApplicationListener {
public abstract class FrameworkServlet extends HttpServletBean
implements ApplicationListener<ContextRefreshedEvent> {
/**
* Suffix for WebApplicationContext namespaces. If a servlet of this class is
@@ -493,11 +493,9 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
* triggering a refresh of this servlet's context-dependent state.
* @param event the incoming ApplicationContext event
*/
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextRefreshedEvent) {
this.refreshEventReceived = true;
onRefresh(((ContextRefreshedEvent) event).getApplicationContext());
}
public void onApplicationEvent(ContextRefreshedEvent event) {
this.refreshEventReceived = true;
onRefresh(event.getApplicationContext());
}
/**