spring-framework / org.springframework.web.context.support / ServletContextScope

ServletContextScope

open class ServletContextScope : Scope, 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 org.springframework.web.context.ContextCleanupListener being registered in web.xml. Note that org.springframework.web.context.ContextLoaderListener includes ContextCleanupListener's functionality.

This scope is registered as default scope with key "application".

Author
Juergen Hoeller

Since
3.0

See Also
org.springframework.web.context.ContextCleanupListener

Constructors

<init>

ServletContextScope(servletContext: ServletContext)

Create a new Scope wrapper for the given ServletContext.

Functions

destroy

open fun destroy(): Unit

Invoke all registered destruction callbacks. To be called on ServletContext shutdown.

get

open fun get(name: String, objectFactory: ObjectFactory<*>): Any

getConversationId

open fun getConversationId(): String

registerDestructionCallback

open fun registerDestructionCallback(name: String, callback: Runnable): Unit

remove

open fun remove(name: String): Any

resolveContextualObject

open fun resolveContextualObject(key: String): Any