View Javadoc

1   package com.atlassian.sal.api.executor;
2   
3   /**
4    * Manager for retrieving and storing a single object which represents all thread local state.
5    * Objects returned by this interface are opaque to callers and are entirely managed by the host application. These
6    * objects can be safely compared using {@link Object#equals(Object)}.
7    */
8   public interface ThreadLocalContextManager<C>
9   {
10      /**
11       * Get the thread local context of the current thread.
12       *
13       * @return The thread local context
14       */
15      C getThreadLocalContext();
16  
17      /**
18       * Set the thread local context on the current thread.
19       *
20       * @param context The context to set
21       * @throws ClassCastException if the given context is not an instance created via {@link #getThreadLocalContext()}.
22       */
23      void setThreadLocalContext(C context);
24  
25      /**
26       * Clear the thread local context on the current thread.
27       */
28      void clearThreadLocalContext();
29  
30  }