jboss - tomcat部署监听器
当所有战争都部署完毕后,我需要编写日志行。 我可以使用 Tomcat 部署程序的观察者模式吗?
第一次启动时,jBoss/Tomcat 会发出一行,其中包含启动所花费的确切时间。 不完美...但有效。
但在热部署时,不会发送/写入任何通知/日志:
((项目中大约有 100 个 servlet,按顺序列出所有 servlet 是有风险的,然后猜测一旦最后一个 servlet 初始化,部署就完成了,所以让我们尝试一下跳过此类解决方案)
有任何提示吗?
I got a requirement to write a log line when all wars have been deployed.
Is there an observer pattern for Tomcat's deployer I could hook onto?
On first start jBoss/Tomcat send out a line with exact time spent on startup.
Not perfect... but works.
But on hot deploy no notification/log is sent/written :(
(There are around 100 servlets in the project and it's a risk to list them all in order and then guess that the deployment is finished once the last one initializes, so let's try to skip solutions of that kind)
Any hints?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(2)
我认为 javax.servlet.ServletContextListener
可能是您想要的:
http://download.oracle.com/javaee/5/api/javax/servlet/ServletContextListener.html
我看到上下文创建和销毁的生命周期事件。也许与各个 servlet 的 servlet init 和 destroy 方法相结合会有所帮助。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
你看过 JBoss JMX API 吗?其中有一个 MainDeployer MBean 可以让您管理部署,它有一个方法
listIncompletelyDeployed()
,您可以调用该方法来检查尚未部署的内容。 ListenerServiceMBeanSupport 允许您订阅 JMX 通知。好吧,我不能给你一个确切的解决方案,但是探索 JMX 可能会给你带来你需要的东西。
Did you look at JBoss JMX API? Among others there is a MainDeployer MBean that lets you manage deployments, it has a method
listIncompletelyDeployed()
which you can call to check what's not yet deployed. A ListenerServiceMBeanSupport allows you to subscribe for JMX notifications.Well I cannot give you an exact solution, but poking around the JMX may bring you what you need.