How to run a method before republishing to JBoss?

I am developing a J2EE web application, and I would like to be able to run a method (or function, class, something - something) during the "re-release" process. It would be nice if I could control when during a re-release my function is called (before, during, after, etc.), but a good first step would be to get something that needs to be called automatically.

As a temporary hack, I was able to add a button to my web application, which you click directly before clicking "re-publish" in Eclipse.

0
eclipse java-ee
source share
1 answer

Deploy the ServletContextListener to connect to the start and stop of the webapp.

 public class Config implements ServletContextListener { public void contextInitialized(ServletContextEvent event) { // Do stuff during startup. } public void contextDestroyed(ServletContextEvent event) { // Do stuff during shutdown. } } 

To make it work, just register it in web.xml .

 <listener> <listener-class>com.example.Config</listener-class> </listener> 

However, I am not sure what exactly you mean at the time of publication. But you can take a look at the other listeners available in the Servlet API, or perhaps Filter.

+1
source share

All Articles