tomcat resteasy单身人士 [英] tomcat resteasy singleton
问题描述
我想在tomcat7中部署应用程序。
在这个应用程序里面,我想在单例中保存一些信息,我想在应用程序部署中初始化单例。
我该怎么做?
谢谢
我最终设法找出如何做到这一点
首先我创建了一个定制的ServletContextListener,它实现了两个方法:contextInitialized和contextDestroyed。
当contextInitialized被调用时,我会配置我的单例对象。
然后我在web.xml中注册了自定义监听器。
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
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.
这篇关于tomcat resteasy单身人士的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!