spring-framework / org.springframework.context.support / SimpleThreadScope

SimpleThreadScope

open class SimpleThreadScope : Scope

A simple thread-backed Scope implementation.

NOTE: This thread scope is not registered by default in common contexts. Instead, you need to explicitly assign it to a scope key in your setup, either through org.springframework.beans.factory.config.ConfigurableBeanFactory#registerScope or through a org.springframework.beans.factory.config.CustomScopeConfigurer bean.

SimpleThreadScope does not clean up any objects associated with it. As such, it is typically preferable to use org.springframework.web.context.request.RequestScope in web environments.

For an implementation of a thread-based Scope with support for destruction callbacks, refer to the Spring by Example Custom Thread Scope Module.

Thanks to Eugene Kuleshov for submitting the original prototype for a thread scope!

Author
Arjen Poutsma

Author
Juergen Hoeller

Since
3.0

See Also
org.springframework.web.context.request.RequestScope

Constructors

<init>

SimpleThreadScope()

A simple thread-backed Scope implementation.

NOTE: This thread scope is not registered by default in common contexts. Instead, you need to explicitly assign it to a scope key in your setup, either through org.springframework.beans.factory.config.ConfigurableBeanFactory#registerScope or through a org.springframework.beans.factory.config.CustomScopeConfigurer bean.

SimpleThreadScope does not clean up any objects associated with it. As such, it is typically preferable to use org.springframework.web.context.request.RequestScope in web environments.

For an implementation of a thread-based Scope with support for destruction callbacks, refer to the Spring by Example Custom Thread Scope Module.

Thanks to Eugene Kuleshov for submitting the original prototype for a thread scope!

Functions

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