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(jakarta.servlet.ServletContext servletContext) Create a new Scope wrapper for the given ServletContext. -
Method Summary
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.config.Scope
getConversationId, resolveContextualObject
-
Constructor Details
-
ServletContextScope
public ServletContextScope(jakarta.servlet.ServletContext servletContext) Create a new Scope wrapper for the given ServletContext.- Parameters:
servletContext- the ServletContext to wrap
-
-
Method Details
-
get
-
remove
-
registerDestructionCallback
-
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:
-