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".
ContextCleanupListener| Constructor and Description |
|---|
ServletContextScope(ServletContext servletContext)
Create a new Scope wrapper for the given ServletContext.
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Invoke all registered destruction callbacks.
|
Object |
get(String name,
org.springframework.beans.factory.ObjectFactory<?> objectFactory) |
String |
getConversationId() |
void |
registerDestructionCallback(String name,
Runnable callback) |
Object |
remove(String name) |
Object |
resolveContextualObject(String key) |
public ServletContextScope(ServletContext servletContext)
servletContext - the ServletContext to wrappublic Object get(String name, org.springframework.beans.factory.ObjectFactory<?> objectFactory)
get in interface org.springframework.beans.factory.config.Scopepublic Object remove(String name)
remove in interface org.springframework.beans.factory.config.Scopepublic void registerDestructionCallback(String name, Runnable callback)
registerDestructionCallback in interface org.springframework.beans.factory.config.Scopepublic Object resolveContextualObject(String key)
resolveContextualObject in interface org.springframework.beans.factory.config.Scopepublic String getConversationId()
getConversationId in interface org.springframework.beans.factory.config.Scopepublic void destroy()
destroy in interface org.springframework.beans.factory.DisposableBeanContextCleanupListener