Class WorkflowThreadMarker


  • public abstract class WorkflowThreadMarker
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.ThreadLocal<java.lang.Boolean> isWorkflowThreadThreadLocal  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void enforceNonWorkflowThread()
      Throws IllegalStateException if it's called from workflow thread.
      static boolean isWorkflowThread()  
      static <T> T protectFromWorkflowThread​(T instance, java.lang.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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • isWorkflowThreadThreadLocal

        protected static final java.lang.ThreadLocal<java.lang.Boolean> isWorkflowThreadThreadLocal
    • Constructor Detail

      • WorkflowThreadMarker

        public WorkflowThreadMarker()
    • Method Detail

      • isWorkflowThread

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

        public static <T> T protectFromWorkflowThread​(T instance,
                                                      java.lang.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