Class ThreadContexts

java.lang.Object
org.jboss.resteasy.spi.concurrent.ThreadContexts

public class ThreadContexts extends Object
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 Details

    • ThreadContexts

      public ThreadContexts()
      Creates a new collection instance and locates the ThreadContext services.
    • ThreadContexts

      public ThreadContexts(ThreadContexts parent)
      Creates a new collection instance with the same ThreadContext services 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

      public ThreadContexts add(ThreadContext<?> threadContext)
      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

      public Collection<ThreadContext<Object>> 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(forRemoval=true, since="8.0") public ThreadContexts clear()
      Deprecated, for removal: This API element is subject to removal in a future version.
      the contexts may be shared and cannot be cleared
      This is a no-op. The contexts may be shared and cannot be cleared by one consumer.
      Returns:
      this instance