001package io.ebean.event;
002
003import javax.servlet.ServletContextEvent;
004
005/**
006 * Listens for webserver server starting and stopping events.
007 * <p>
008 * This should be used when the deployment is into a servlet container where the webapp
009 * can be shutdown or redeployed without the JVM stopping.
010 * </p>
011 * <p>
012 * If deployment is into a container where the JVM is completely shutdown (like spring boot,
013 * runnable war or when using a servlet container that only contains the single webapp and
014 * the JVM is shutdown then this isn't required. Instead we can just rely on the JVM shutdown
015 * hook that Ebean registers.
016 * </p>
017 */
018public class ServletContextListener implements javax.servlet.ServletContextListener {
019
020  /**
021   * The servlet container is stopping.
022   */
023  @Override
024  public void contextDestroyed(ServletContextEvent event) {
025    ShutdownManager.shutdown();
026  }
027
028  /**
029   * Do nothing on startup.
030   */
031  @Override
032  public void contextInitialized(ServletContextEvent event) {
033
034  }
035
036}