Spring: how to close a shared context

こ雲淡風輕ζ 提交于 2019-12-11 03:58:35

问题


This question describes a nice way to have a shared Spring ApplicationContext as a parent to the ApplicationContexts several WAR within an EAR. (See also ContextLoader.loadParentContext.) This works fine but for the fact that ApplicationContext.close() is never called on this parent context when the server is shut down. This leads in our case to the server never shutting down, since the parent ApplicationContext contains a ThreadPool and starts ehcache, which also starts a couple of (non daemon) threads.

Has anybody an elegant idea how to close this shared ApplicationContext? You can of course put a ContextListener in one of the WARs and just call close() on the shared ApplicationContext, but ideally it should be automatically shut down only after all WAR ApplicationContext are closed.

来源:https://stackoverflow.com/questions/32912723/spring-how-to-close-a-shared-context

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!