spring-framework / org.springframework.context.support / SimpleThreadScope / <init>

<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!

Author
Arjen Poutsma

Author
Juergen Hoeller

Since
3.0

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