org.apache.shiro.web.env
Class EnvironmentLoaderListener

java.lang.Object
  extended by org.apache.shiro.web.env.EnvironmentLoader
      extended by org.apache.shiro.web.env.EnvironmentLoaderListener
All Implemented Interfaces:
EventListener, ServletContextListener

public class EnvironmentLoaderListener
extends EnvironmentLoader
implements 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

Field Summary
 
Fields inherited from class org.apache.shiro.web.env.EnvironmentLoader
CONFIG_LOCATIONS_PARAM, ENVIRONMENT_ATTRIBUTE_KEY, ENVIRONMENT_CLASS_PARAM
 
Constructor Summary
EnvironmentLoaderListener()
           
 
Method Summary
 void contextDestroyed(ServletContextEvent sce)
          Destroys any previously created/bound WebEnvironment instance created by the contextInitialized(javax.servlet.ServletContextEvent) method.
 void contextInitialized(ServletContextEvent sce)
          Initializes the Shiro WebEnvironment and binds it to the ServletContext at application startup for future reference.
 
Methods inherited from class org.apache.shiro.web.env.EnvironmentLoader
createEnvironment, customizeEnvironment, destroyEnvironment, determineWebEnvironmentClass, initEnvironment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnvironmentLoaderListener

public EnvironmentLoaderListener()
Method Detail

contextInitialized

public void contextInitialized(ServletContextEvent sce)
Initializes the Shiro WebEnvironment and binds it to the ServletContext at application startup for future reference.

Specified by:
contextInitialized in interface ServletContextListener
Parameters:
sce - the ServletContextEvent triggered upon application startup

contextDestroyed

public void contextDestroyed(ServletContextEvent sce)
Destroys any previously created/bound WebEnvironment instance created by the contextInitialized(javax.servlet.ServletContextEvent) method.

Specified by:
contextDestroyed in interface ServletContextListener
Parameters:
sce - the ServletContextEvent triggered upon application shutdown


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.