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
ConstructorDescriptionServletContextScope
(ServletContext servletContext) Create a new Scope wrapper for the given ServletContext. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Invoke all registered destruction callbacks.void
registerDestructionCallback
(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:
get
in interfaceorg.springframework.beans.factory.config.Scope
-
remove
- Specified by:
remove
in interfaceorg.springframework.beans.factory.config.Scope
-
registerDestructionCallback
- Specified by:
registerDestructionCallback
in interfaceorg.springframework.beans.factory.config.Scope
-
resolveContextualObject
- Specified by:
resolveContextualObject
in interfaceorg.springframework.beans.factory.config.Scope
-
getConversationId
- Specified by:
getConversationId
in interfaceorg.springframework.beans.factory.config.Scope
-
destroy
public void destroy()Invoke all registered destruction callbacks. To be called on ServletContext shutdown.- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- See Also:
-