restricted onApplicationEvent callbacks for local ApplicationContext only (SPR-6964)
This commit is contained in:
parent
a614430899
commit
461c200ce6
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2010 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -93,8 +93,7 @@ import org.springframework.web.util.WebUtils;
|
||||||
* @see #setContextConfigLocation
|
* @see #setContextConfigLocation
|
||||||
* @see #setNamespace
|
* @see #setNamespace
|
||||||
*/
|
*/
|
||||||
public abstract class FrameworkServlet extends HttpServletBean
|
public abstract class FrameworkServlet extends HttpServletBean {
|
||||||
implements ApplicationListener<ContextRefreshedEvent> {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suffix for WebApplicationContext namespaces. If a servlet of this class is
|
* Suffix for WebApplicationContext namespaces. If a servlet of this class is
|
||||||
|
|
@ -437,7 +436,7 @@ public abstract class FrameworkServlet extends HttpServletBean
|
||||||
wac.setServletConfig(getServletConfig());
|
wac.setServletConfig(getServletConfig());
|
||||||
wac.setNamespace(getNamespace());
|
wac.setNamespace(getNamespace());
|
||||||
wac.setConfigLocation(getContextConfigLocation());
|
wac.setConfigLocation(getContextConfigLocation());
|
||||||
wac.addApplicationListener(new SourceFilteringListener(wac, this));
|
wac.addApplicationListener(new SourceFilteringListener(wac, new ContextRefreshListener()));
|
||||||
|
|
||||||
postProcessWebApplicationContext(wac);
|
postProcessWebApplicationContext(wac);
|
||||||
wac.refresh();
|
wac.refresh();
|
||||||
|
|
@ -514,10 +513,8 @@ public abstract class FrameworkServlet extends HttpServletBean
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ApplicationListener endpoint that receives events from this servlet's
|
* Callback that receives refresh events from this servlet's WebApplicationContext.
|
||||||
* WebApplicationContext.
|
* <p>The default implementation calls {@link #onRefresh},
|
||||||
* <p>The default implementation calls {@link #onRefresh} in case of a
|
|
||||||
* {@link org.springframework.context.event.ContextRefreshedEvent},
|
|
||||||
* triggering a refresh of this servlet's context-dependent state.
|
* triggering a refresh of this servlet's context-dependent state.
|
||||||
* @param event the incoming ApplicationContext event
|
* @param event the incoming ApplicationContext event
|
||||||
*/
|
*/
|
||||||
|
|
@ -741,4 +738,16 @@ public abstract class FrameworkServlet extends HttpServletBean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApplicationListener endpoint that receives events from this servlet's WebApplicationContext
|
||||||
|
* only, delegating to <code>onApplicationEvent</code> on the FrameworkServlet instance.
|
||||||
|
*/
|
||||||
|
private class ContextRefreshListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||||
|
|
||||||
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||||
|
FrameworkServlet.this.onApplicationEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue