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       * Get the thread local context of the current thread.
11       *
12       * @return The thread local context
13       */
14      C getThreadLocalContext();
15  
16      /**
17       * Set the thread local context on the current thread.
18       *
19       * @param context The context to set
20       * @throws ClassCastException if the given context is not an instance created via {@link #getThreadLocalContext()}.
21       */
22      void setThreadLocalContext(C context);
23  
24      /**
25       * Clear the thread local context on the current thread.
26       */
27      void clearThreadLocalContext();
28  
29  }