org.apache.ignite.startup.servlet

## Class ServletContextListenerStartup

- java.lang.Object
- - org.apache.ignite.startup.servlet.ServletContextListenerStartup

- All Implemented Interfaces:
    EventListener, javax.servlet.ServletContextListener

      public class ServletContextListenerStartup
      extends Object
      implements javax.servlet.ServletContextListener

  This class defines Ignite startup based on servlet context listener. This startup can be used to start Ignite inside any web container.

  This startup must be defined in `web.xml` file.

       <listener>
           <listener-class>org.apache.ignite.startup.servlet.ServletContextListenerStartup</listener-class>
       </listener>

       <context-param>
           <param-name>IgniteConfigurationFilePath</param-name>
           <param-value>config/default-config.xml</param-value>
       </context-param>

  Servlet context listener based startup may be used in any web container like Tomcat, Jetty and etc. Depending on the way this startup is deployed the Ignite instance can be accessed by either all web applications or by only one. See web container class loading architecture:

  - http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html
  - http://docs.codehaus.org/display/JETTY/Classloading

  ## Tomcat

  There are two ways to start Ignite on Tomcat.
  - Ignite started when web container starts and Ignite instance is accessible only to all web applications.
    1. Add Ignite libraries in Tomcat common loader. Add in file `$TOMCAT_HOME/conf/catalina.properties` for property `common.loader` the following `$IGNITE_HOME/*.jar,$IGNITE_HOME/libs/*.jar` (replace `$IGNITE_HOME` with absolute path).
    2. Configure this startup in `$TOMCAT_HOME/conf/web.xml`

                    <listener>
                        <listener-class>org.apache.ignite.startup.servlet.ServletContextListenerStartup</listener-class>
                    </listener>

                    <context-param>
                        <param-name>IgniteConfigurationFilePath</param-name>
                        <param-value>config/default-config.xml</param-value>
                    </context-param>

  - Ignite started from WAR-file and Ignite instance is accessible only to that web application. Difference with approach described above is that `web.xml` file and all libraries should be added in WAR file without changes in Tomcat configuration files.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `IGNITE_CFG_FILE_PATH_PARAM` Configuration file path parameter name.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServletContextListenerStartup()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `contextDestroyed(javax.servlet.ServletContextEvent evt)`
    `void` | `contextInitialized(javax.servlet.ServletContextEvent evt)`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### IGNITE_CFG_FILE_PATH_PARAM

          public static final String IGNITE_CFG_FILE_PATH_PARAM

      Configuration file path parameter name.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ServletContextListenerStartup

          public ServletContextListenerStartup()

  - ### Method Detail

    - #### contextInitialized

          public void contextInitialized(javax.servlet.ServletContextEvent evt)

      Specified by:
        `contextInitialized` in interface `javax.servlet.ServletContextListener`

    - #### contextDestroyed

          public void contextDestroyed(javax.servlet.ServletContextEvent evt)

      Specified by:
        `contextDestroyed` in interface `javax.servlet.ServletContextListener`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

2020 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.9.1
Release Date | : December 9 2020