在重新发布到JBoss之前,如何运行方法? [英] How do I run a method before republishing to JBoss?
问题描述
作为一个临时黑客,我可以在点击Eclipse中的重新发布之前点击右键添加一个按钮。
实现 ServletContextListener
挂钩webapp的启动和关闭。
public class Config实现ServletContextListener {
public void contextInitialized(ServletContextEvent event){
//启动时做东西
}
public void contextDestroyed(ServletContextEvent event){
//在关闭期间进行填充。
}
}
要使其正常工作,只需在 web.xml
中注册。
< listener>
< listener-class> com.example.Config< / listener-class>
< / listener>
然而,我不知道在发布期间你的意思是什么。但是您可以查看Servlet API中可用的其他侦听器,也可以查看过滤器。
I'm developing a J2EE web application and I would like to be able to run a method (or function, class, whatever - something) during the "republish" process. It would be nice if I could control when during the republish my function gets called (before, during, after, etc.) but a good first step would be getting something to be called automatically.
As a temporary hack, I was able to add a button to my web app that you click right before you click "republish" in Eclipse.
Implement ServletContextListener
to hook on webapp's startup and shutdown.
public class Config implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
// Do stuff during startup.
}
public void contextDestroyed(ServletContextEvent event) {
// Do stuff during shutdown.
}
}
To get it to work, just register it in web.xml
.
<listener>
<listener-class>com.example.Config</listener-class>
</listener>
I am however only not sure what exactly you mean with during publish. But you could take a look for another listeners available in the Servlet API or maybe a Filter.
这篇关于在重新发布到JBoss之前,如何运行方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!