tomcat resteasy单身人士 [英] tomcat resteasy singleton

查看:132
本文介绍了tomcat resteasy单身人士的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用reasteasy的战争应用程序来暴露一些服务。
我想在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆