Annotation Type WorkflowInterface


  • @Retention(RUNTIME)
    @Target(TYPE)
    public @interface WorkflowInterface
    WorkflowInterface annotation indicates that an interface is a Workflow interface. Only interfaces annotated with this annotation can be used as parameters to WorkflowClient.newWorkflowStub(Class, WorkflowOptions) and Workflow.newChildWorkflowStub(Class) methods.

    All methods of an interface annotated with WorkflowInterface must have one of the following annotations: @WorkflowMethod, @SignalMethod or @QueryMethod

    An interface annotated with WorkflowInterface can extend other interfaces annotated with WorkflowInterface having that it can have at most one method annotated with @WorkflowMethod including all inherited methods.

    The prefix of workflow, signal and query type names is the name of the declaring interface annotated with WorkflowInterface. If a method is declared in non annotated interface the prefix comes from the first sub-interface that has the WorkflowInterface annotation.

    A workflow implementation object must have exactly one method annotated with @WorkflowMethod inherited from all the interfaces it implements.

    Example:

    
    
      public interface A {
         @SignalMethod
          a();
          aa();
      }
    
     @WorkflowInterface
      public interface B extends A {
         @SignalMethod
          b();
    
         @SignalMethod // must define the type of the inherited method
          aa();
      }
    
     @WorkflowInterface
      public interface C extends B {
        @WorkflowMethod
         c();
      }
    
     @WorkflowInterface
      public interface D extends C {
        @QueryMethod
         String d();
      }
    
      public class CImpl implements C {
          public void a() {}
          public void aa() {}
          public void b() {}
          public void c() {}
          public String d() { return "foo"; }
      }
     
    When CImpl instance is registered with the Worker the following is registered:

    • a signal handler
    • b signal handler
    • aa signal handler
    • c workflow main method
    • d query method
    The client code can call signals through stubs to B, C and D interfaces. A call to crate a stub to A interface will fail as A is not annotated with the WorkflowInterface.