Package org.apache.shiro.web.env
Class EnvironmentLoaderListener
java.lang.Object
org.apache.shiro.web.env.EnvironmentLoader
org.apache.shiro.web.env.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 inweb.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 theShiroFilter to ensure security operations for web requests. Please
see the ShiroFilter JavaDoc for more.- Since:
- 1.2
- See Also:
-
Field Summary
Fields inherited from class org.apache.shiro.web.env.EnvironmentLoader
CONFIG_LOCATIONS_PARAM, ENVIRONMENT_ATTRIBUTE_KEY, ENVIRONMENT_CLASS_PARAM -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontextDestroyed(javax.servlet.ServletContextEvent sce) Destroys any previously created/boundWebEnvironmentinstance created by thecontextInitialized(javax.servlet.ServletContextEvent)method.voidcontextInitialized(javax.servlet.ServletContextEvent sce) Initializes the ShiroWebEnvironmentand binds it to theServletContextat application startup for future reference.Methods inherited from class org.apache.shiro.web.env.EnvironmentLoader
createEnvironment, customizeEnvironment, destroyEnvironment, determineWebEnvironment, determineWebEnvironmentClass, doLoadWebEnvironmentsFromServiceLoader, finalizeEnvironment, getDefaultWebEnvironmentClass, initEnvironment
-
Constructor Details
-
EnvironmentLoaderListener
public EnvironmentLoaderListener()
-
-
Method Details
-
contextInitialized
Initializes the ShiroWebEnvironmentand binds it to theServletContextat application startup for future reference.- Specified by:
contextInitializedin interfacejavax.servlet.ServletContextListener- Parameters:
sce- the ServletContextEvent triggered upon application startup
-
contextDestroyed
Destroys any previously created/boundWebEnvironmentinstance created by thecontextInitialized(javax.servlet.ServletContextEvent)method.- Specified by:
contextDestroyedin interfacejavax.servlet.ServletContextListener- Parameters:
sce- the ServletContextEvent triggered upon application shutdown
-