jboss - tomcat deploy listener

孤人 提交于 2019-12-13 02:59:56

问题


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?


回答1:


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.




回答2:


I think that javax.servlet.ServletContextListener could be what you want:

http://download.oracle.com/javaee/5/api/javax/servlet/ServletContextListener.html

I see lifecycle events for context created and destroyed. Perhaps that, combined with servlet init and destroy methods for individual servlets, can help.



来源:https://stackoverflow.com/questions/6610370/jboss-tomcat-deploy-listener

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