问题
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