Package org.springframework.context.support

# Class SimpleThreadScope

java.lang.Object
org.springframework.context.support.SimpleThreadScope

All Implemented Interfaces:
  `org.springframework.beans.factory.config.Scope`

public class SimpleThreadScope extends Object implements org.springframework.beans.factory.config.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 `ConfigurableBeanFactory.registerScope(java.lang.String, org.springframework.beans.factory.config.Scope)` or through a `CustomScopeConfigurer` bean.

`SimpleThreadScope` does not clean up any objects associated with it. It is therefore typically preferable to use a request-bound scope implementation such as `org.springframework.web.context.request.RequestScope` in web environments, implementing the full lifecycle for scoped attributes (including reliable destruction).

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

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

Since:
  3.0
Author:
  Arjen Poutsma, Juergen Hoeller
See Also:
  - `org.springframework.web.context.request.RequestScope`

## Constructor Summary

Constructors
Constructor
Description
`SimpleThreadScope()`

## Method Summary

Modifier and Type
Method
Description
`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)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SimpleThreadScope

public SimpleThreadScope()

## Method Details

### get

public Object get(String name, org.springframework.beans.factory.ObjectFactory<?> objectFactory)

Specified by:
  `get` in interface `org.springframework.beans.factory.config.Scope`

### remove

@Nullable public Object remove(String name)

Specified by:
  `remove` in interface `org.springframework.beans.factory.config.Scope`

### registerDestructionCallback

public void registerDestructionCallback(String name, Runnable callback)

Specified by:
  `registerDestructionCallback` in interface `org.springframework.beans.factory.config.Scope`

### resolveContextualObject

@Nullable public Object resolveContextualObject(String key)

Specified by:
  `resolveContextualObject` in interface `org.springframework.beans.factory.config.Scope`

### getConversationId

public String getConversationId()

Specified by:
  `getConversationId` in interface `org.springframework.beans.factory.config.Scope`