tomcat resteasy singleton

*爱你&永不变心* 提交于 2019-12-11 05:52:02

问题


I have war app that uses reasteasy to expose some services. I want to deploy the app in tomcat7.

Inside this app I want to hold some information in a singleton and I want to initialize that singleton on app deploy.

How can I do that?

Thanks


回答1:


I managed eventually to figure out how to do this

First I created a custom ServletContextListener which implements two methods: contextInitialized and contextDestroyed. When contextInitialized is called I instanciate my singleton object. Then I register m custom listener in web.xml.



来源:https://stackoverflow.com/questions/9483644/tomcat-resteasy-singleton

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