Class ServletContextScope
java.lang.Object
org.springframework.web.context.support.ServletContextScope
- All Implemented Interfaces:
org.springframework.beans.factory.config.Scope,org.springframework.beans.factory.DisposableBean
public class ServletContextScope
extends Object
implements org.springframework.beans.factory.config.Scope, org.springframework.beans.factory.DisposableBean
Scope wrapper for a ServletContext, i.e. for global web application attributes.
This differs from traditional Spring singletons in that it exposes attributes in the ServletContext. Those attributes will get destroyed whenever the entire application shuts down, which might be earlier or later than the shutdown of the containing Spring ApplicationContext.
The associated destruction mechanism relies on a
ContextCleanupListener being registered in
web.xml. Note that ContextLoaderListener
includes ContextCleanupListener's functionality.
This scope is registered as default scope with key
"application".
- Since:
- 3.0
- Author:
- Juergen Hoeller
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionServletContextScope(ServletContext servletContext) Create a new Scope wrapper for the given ServletContext. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Invoke all registered destruction callbacks.voidregisterDestructionCallback(String name, Runnable callback)
-
Constructor Details
-
ServletContextScope
Create a new Scope wrapper for the given ServletContext.- Parameters:
servletContext- the ServletContext to wrap
-
-
Method Details
-
get
- Specified by:
getin interfaceorg.springframework.beans.factory.config.Scope
-
remove
- Specified by:
removein interfaceorg.springframework.beans.factory.config.Scope
-
registerDestructionCallback
- Specified by:
registerDestructionCallbackin interfaceorg.springframework.beans.factory.config.Scope
-
resolveContextualObject
- Specified by:
resolveContextualObjectin interfaceorg.springframework.beans.factory.config.Scope
-
getConversationId
- Specified by:
getConversationIdin interfaceorg.springframework.beans.factory.config.Scope
-
destroy
public void destroy()Invoke all registered destruction callbacks. To be called on ServletContext shutdown.- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- See Also:
-