Class EnvironmentLoaderListener

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

    public class EnvironmentLoaderListener
    extends EnvironmentLoader
    implements javax.servlet.ServletContextListener
    Bootstrap listener to startup and shutdown the web application's Shiro WebEnvironment at ServletContext startup and shutdown respectively. This class exists only to implement the ServletContextListener interface. All 'real' logic is done in the parent EnvironmentLoader class.

    Usage

    Define the following in web.xml:
     <listener>
         <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
     </listener>
     
    Configuration options, such as the WebEnvironment class to instantiate as well as Shiro configuration resource locations are specified as ServletContext context-params and are documented in the EnvironmentLoader JavaDoc.

    Shiro Filter

    This listener is almost always defined in conjunction with the ShiroFilter to ensure security operations for web requests. Please see the ShiroFilter JavaDoc for more.
    Since:
    1.2
    See Also:
    EnvironmentLoader, ShiroFilter
    • Constructor Detail

      • EnvironmentLoaderListener

        public EnvironmentLoaderListener()
    • Method Detail

      • contextInitialized

        public void contextInitialized​(javax.servlet.ServletContextEvent sce)
        Initializes the Shiro WebEnvironment and binds it to the ServletContext at application startup for future reference.
        Specified by:
        contextInitialized in interface javax.servlet.ServletContextListener
        Parameters:
        sce - the ServletContextEvent triggered upon application startup
      • contextDestroyed

        public void contextDestroyed​(javax.servlet.ServletContextEvent sce)
        Destroys any previously created/bound WebEnvironment instance created by the contextInitialized(javax.servlet.ServletContextEvent) method.
        Specified by:
        contextDestroyed in interface javax.servlet.ServletContextListener
        Parameters:
        sce - the ServletContextEvent triggered upon application shutdown