Class ThreadContexts
java.lang.Object
org.jboss.resteasy.spi.concurrent.ThreadContexts
Represents a collection of
ThreadContext's.
The ThreadContext services are located once, when this collection is created, using the current thread's
context class loader. A new instance of each service is created each time the contexts are requested. Contexts added to this collection are shared.
- Author:
- James R. Perkins
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new collection instance and locates theThreadContextservices.ThreadContexts(ThreadContexts parent) Creates a new collection instance with the sameThreadContextservices as the parent and a copy of the contexts added to the parent. -
Method Summary
Modifier and TypeMethodDescriptionadd(ThreadContext<?> threadContext) Adds the context to the current collection.clear()Deprecated, for removal: This API element is subject to removal in a future version.the contexts may be shared and cannot be clearedReturns a collection of the current thread contexts.
-
Constructor Details
-
ThreadContexts
public ThreadContexts()Creates a new collection instance and locates theThreadContextservices. -
ThreadContexts
Creates a new collection instance with the sameThreadContextservices as the parent and a copy of the contexts added to the parent. The services are not located again.- Parameters:
parent- the thread contexts to copy
-
-
Method Details
-
add
Adds the context to the current collection. The same instance is used for each request for the contexts.- Parameters:
threadContext- the thread context to add- Returns:
- this instance
-
getThreadContexts
Returns a collection of the current thread contexts. This is a snapshot of what is currently in the collection sorted by priority. Contexts located as services are new instances on each invocation. Contexts added to this collection are returned as is.- Returns:
- an immutable collection of the current thread contexts
-
clear
Deprecated, for removal: This API element is subject to removal in a future version.the contexts may be shared and cannot be clearedThis is a no-op. The contexts may be shared and cannot be cleared by one consumer.- Returns:
- this instance
-