Class WorkflowThreadMarker

java.lang.Object
io.temporal.internal.WorkflowThreadMarker

public abstract class WorkflowThreadMarker extends Object
Provides an access to information about a thread type the current code executes in to perform different type of access checks inside Temporal library code.

Note: This class is a singleton and is not intended for an extension.

Note: This class shouldn't be accessed in any way by the application code.

  • Field Details

    • isWorkflowThreadThreadLocal

      protected static final ThreadLocal<Boolean> isWorkflowThreadThreadLocal
  • Constructor Details

    • WorkflowThreadMarker

      public WorkflowThreadMarker()
  • Method Details

    • isWorkflowThread

      public static boolean isWorkflowThread()
      Returns:
      true if the current thread is workflow thread
    • enforceNonWorkflowThread

      public static void enforceNonWorkflowThread()
      Throws IllegalStateException if it's called from workflow thread.
      See Also:
    • protectFromWorkflowThread

      public static <T> T protectFromWorkflowThread(T instance, Class<T> iface)
      Create a proxy that checks all methods executions if they are done from a workflow thread and makes them throw an IllegalStateException if they are indeed triggered from workflow code
      Parameters:
      instance - an instance to wrap
      iface - an interface the instance implements and that proxy should implement and intercept
      Returns:
      a proxy that makes sure that it's methods can't be called from workflow thread