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 toWorkflowClient.newWorkflowStub(Class, WorkflowOptions)
andWorkflow.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.
A workflow implementation may have a no-arg constructor or a constructor annotated with @WorkflowInit that takes the same set of arguments as the workflow interface method annotated with @WorkflowMethod. Users should avoid blocking operations in the constructor as the constructor must be called before the workflow method is invoked and before any Signal, Update, or Queries handlers are registered.
Example:
Whenpublic 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"; } }
CImpl
instance is registered with theWorker
the following is registered:- a signal handler
- b signal handler
- aa signal handler
- c workflow main method
- d query method
B
,C
andD
interfaces. A call to crate a stub toA
interface will fail asA
is not annotated with the WorkflowInterface.