Ric*_*ell 5 java spring servlets
我希望能够从我的servlet容器中运行的Web应用程序中获取所有Spring应用程序上下文的列表.这样我就可以重新初始化上下文而无需重新启动或重新加载我的容器或webapps.
这可能吗?如果是这样,怎么样?无论如何通过Servlet API获取在servlet容器实例上运行的所有servlet上下文的列表?
[编辑:这并没有真正的帮助,因为每个 web.xml 都必须有相同的侦听器]
您可以让ServletContextAttributeListener侦听标准WebApplicationContext属性的插入,然后通知某个集中监视器吗?
未测试:
public class SpringWACListener implements ServletContextAttributeListener {
public void attributeAdded(ServletContextAttributeEvent scab) {
if (WebApplicationContext.
ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE.
equals(scab.getName()) {
myCentralisedMonitor.notify("added");
}
}
// same for others
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1706 次 |
| 最近记录: |