Class InfinispanLauncher

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

    public class InfinispanLauncher
    extends Object
    implements javax.servlet.ServletContextListener
    Configures and launches an Infinispan cache manager at servlet context startup. The cache manager is stopped at servlet context shutdown (if previously launched).

    The location of the Infinispan configuration file in web application (WAR) is specified as follows:

    • By a Java system property infinispan.configurationFile
    • By a servlet context init parameter infinispan.configurationFile.

      The launched Infinispan cache manager will be exported to the servlet context as an org.infinispan.manager.EmbeddedCacheManager, under a key that bears the interface name.

    • Method Detail

      • contextInitialized

        public void contextInitialized​(javax.servlet.ServletContextEvent sce)
        Handler for servlet context startup events; configures and launches an Infinispan cache manager using the configuration file specified in the servlet context parameter infinispan.configurationFile.

        The configuration file location must be relative to the web application directory, e.g. /WEB-INF/infinispan.xml.

        Exceptions are logged at ERROR level using Log4j.

        Specified by:
        contextInitialized in interface javax.servlet.ServletContextListener
        Parameters:
        sce - A servlet context event.
      • contextDestroyed

        public void contextDestroyed​(javax.servlet.ServletContextEvent sce)
        Handler for servlet context shutdown events. Stops the Infinispan cache manager.
        Specified by:
        contextDestroyed in interface javax.servlet.ServletContextListener
        Parameters:
        sce - A servlet context event.