Added ServletContextListener to intercept start and stop of the service

This commit is contained in:
Luca Frosini 2020-03-17 17:22:03 +01:00
parent 507c65cfa9
commit 35e9883a38
2 changed files with 32 additions and 6 deletions

View File

@ -0,0 +1,23 @@
package org.gcube.informationsystem.resourceregistry;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ResourceRegistryContextListener implements ServletContextListener {
private static Logger logger = LoggerFactory.getLogger(ResourceRegistryContextListener.class);
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
logger.info("Resource Registry is going to be stopped");
}
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
logger.info("Resource Registry is going to be started");
}
}

View File

@ -2,10 +2,13 @@
<!DOCTYPE xml>
<web-app>
<servlet>
<servlet-name>org.gcube.informationsystem.resourceregistry.ResourceInitializer</servlet-name>
</servlet>
<servlet-mapping>
<servlet-name>org.gcube.informationsystem.resourceregistry.ResourceInitializer</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet-name>org.gcube.informationsystem.resourceregistry.ResourceInitializer</servlet-name>
</servlet>
<servlet-mapping>
<servlet-name>org.gcube.informationsystem.resourceregistry.ResourceInitializer</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.gcube.informationsystem.resourceregistry.ResourceRegistryContextListener</listener-class>
</listener>
</web-app>