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
,ServletContextListener
public class EnvironmentLoaderListener extends EnvironmentLoader implements ServletContextListener
Bootstrap listener to startup and shutdown the web application's ShiroWebEnvironment
at ServletContext startup and shutdown respectively. This class exists only to implement theServletContextListener
interface. All 'real' logic is done in the parentEnvironmentLoader
class.Usage
Define the following inweb.xml
:<listener> <listener-class>
Configuration options, such as theorg.apache.shiro.web.env.EnvironmentLoaderListener
</listener-class> </listener>WebEnvironment
class to instantiate as well as Shiro configuration resource locations are specified asServletContext
context-param
s and are documented in theEnvironmentLoader
JavaDoc.Shiro Filter
This listener is almost always defined in conjunction with theShiroFilter
to ensure security operations for web requests. Please see theShiroFilter
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
Constructors Constructor Description EnvironmentLoaderListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
contextDestroyed(ServletContextEvent sce)
Destroys any previously created/boundWebEnvironment
instance created by thecontextInitialized(javax.servlet.ServletContextEvent)
method.void
contextInitialized(ServletContextEvent sce)
Initializes the ShiroWebEnvironment
and binds it to theServletContext
at application startup for future reference.-
Methods inherited from class org.apache.shiro.web.env.EnvironmentLoader
createEnvironment, customizeEnvironment, destroyEnvironment, determineWebEnvironment, determineWebEnvironmentClass, finalizeEnvironment, getDefaultWebEnvironmentClass, initEnvironment
-
-
-
-
Constructor Detail
-
EnvironmentLoaderListener
public EnvironmentLoaderListener()
-
-
Method Detail
-
contextInitialized
public void contextInitialized(ServletContextEvent sce)
Initializes the ShiroWebEnvironment
and binds it to theServletContext
at application startup for future reference.- Specified by:
contextInitialized
in interfaceServletContextListener
- Parameters:
sce
- the ServletContextEvent triggered upon application startup
-
contextDestroyed
public void contextDestroyed(ServletContextEvent sce)
Destroys any previously created/boundWebEnvironment
instance created by thecontextInitialized(javax.servlet.ServletContextEvent)
method.- Specified by:
contextDestroyed
in interfaceServletContextListener
- Parameters:
sce
- the ServletContextEvent triggered upon application shutdown
-
-