Skip to content

Commit cde07f4

Browse files
authored
Improve javadocs around interceptors (#1180)
1 parent 37eb2c8 commit cde07f4

File tree

5 files changed

+72
-15
lines changed

5 files changed

+72
-15
lines changed

temporal-sdk/src/main/java/io/temporal/common/interceptors/ActivityInboundCallsInterceptor.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
import io.temporal.activity.ActivityExecutionContext;
2323
import io.temporal.common.Experimental;
2424

25+
/**
26+
* Intercepts inbound calls to the activity execution on the worker side.
27+
*
28+
* <p>Prefer extending {@link ActivityInboundCallsInterceptorBase} and overriding only the methods
29+
* you need instead of implementing this interface directly. {@link
30+
* ActivityInboundCallsInterceptorBase} provides correct default implementations to all the methods
31+
* of this interface.
32+
*/
2533
@Experimental
2634
public interface ActivityInboundCallsInterceptor {
2735
final class ActivityInput {

temporal-sdk/src/main/java/io/temporal/common/interceptors/WorkerInterceptor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@
2828
*/
2929
@Experimental
3030
public interface WorkerInterceptor {
31+
/**
32+
* Called when workflow class is instantiated. May create a {@link
33+
* WorkflowInboundCallsInterceptor} instance. The instance must forward all the calls to {@code
34+
* next} {@link WorkflowInboundCallsInterceptor}, but it may change the input parameters.
35+
*
36+
* @param next an existing interceptor instance to be proxied by the interceptor created inside
37+
* this method
38+
* @return an interceptor that passes all the calls to {@code next}
39+
*/
3140
WorkflowInboundCallsInterceptor interceptWorkflow(WorkflowInboundCallsInterceptor next);
3241

3342
ActivityInboundCallsInterceptor interceptActivity(ActivityInboundCallsInterceptor next);

temporal-sdk/src/main/java/io/temporal/common/interceptors/WorkflowClientCallsInterceptor.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,26 @@
2929
import java.util.concurrent.TimeUnit;
3030
import java.util.concurrent.TimeoutException;
3131

32+
/**
33+
* Intercepts calls to the {@link io.temporal.client.WorkflowClient} related to the lifecycle of a
34+
* Workflow.
35+
*
36+
* <p>Prefer extending {@link WorkflowClientCallsInterceptorBase} and overriding only the methods
37+
* you need instead of implementing this interface directly. {@link
38+
* WorkflowClientCallsInterceptorBase} provides correct default implementations to all the methods
39+
* of this interface.
40+
*/
3241
@Experimental
3342
public interface WorkflowClientCallsInterceptor {
3443
/**
35-
* If you implement this method, {@link #signalWithStart} most likely needs * to be implemented
36-
* too.
44+
* If you implement this method, {@link #signalWithStart} most likely needs to be implemented too.
3745
*
3846
* @see #signalWithStart
3947
*/
4048
WorkflowStartOutput start(WorkflowStartInput input);
4149

4250
/**
43-
* If you implement this method, {@link #signalWithStart} most likely needs * to be implemented
44-
* too.
51+
* If you implement this method, {@link #signalWithStart} most likely needs to be implemented too.
4552
*
4653
* @see #signalWithStart
4754
*/
@@ -50,8 +57,7 @@ public interface WorkflowClientCallsInterceptor {
5057
WorkflowSignalWithStartOutput signalWithStart(WorkflowSignalWithStartInput input);
5158

5259
/**
53-
* If you implement this method, {@link #getResultAsync} most likely needs to * be implemented
54-
* too.
60+
* If you implement this method, {@link #getResultAsync} most likely needs to be implemented too.
5561
*
5662
* @see #getResultAsync
5763
*/

temporal-sdk/src/main/java/io/temporal/common/interceptors/WorkflowInboundCallsInterceptor.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,24 @@
2424
import javax.annotation.Nullable;
2525

2626
/**
27-
* Intercepts calls to the workflow execution. Executes under workflow context. So all the
28-
* restrictions on the workflow code should be obeyed.
27+
* Intercepts inbound calls to the workflow execution on the worker side.
28+
*
29+
* <p>An instance should be created in {@link
30+
* WorkerInterceptor#interceptWorkflow(WorkflowInboundCallsInterceptor)}.
31+
*
32+
* <p>The calls to this interceptor are executed under workflow context, all the rules and
33+
* restrictions on the workflow code apply. See {@link io.temporal.workflow}.
34+
*
35+
* <p>Prefer extending {@link WorkflowInboundCallsInterceptorBase} and overriding only the methods
36+
* you need instead of implementing this interface directly. {@link
37+
* WorkflowInboundCallsInterceptorBase} provides correct default implementations to all the methods
38+
* of this interface.
39+
*
40+
* <p>The implementation must forward all the calls to {@code next}, but it may change the input
41+
* parameters.
42+
*
43+
* @see WorkerInterceptor#interceptWorkflow(WorkflowInboundCallsInterceptor) for a definition of
44+
* "next" {@link WorkflowInboundCallsInterceptor}
2945
*/
3046
@Experimental
3147
public interface WorkflowInboundCallsInterceptor {
@@ -115,9 +131,16 @@ public Object getResult() {
115131
}
116132

117133
/**
118-
* Called when workflow class is instantiated.
134+
* Called when workflow class is instantiated. May create a {@link
135+
* WorkflowOutboundCallsInterceptor} instance. The instance must forward all the calls to {@code
136+
* outboundCalls}, but it may change the input parameters.
137+
*
138+
* <p>The instance should be passed into the {next.init(newWorkflowOutboundCallsInterceptor)}.
119139
*
120-
* @param outboundCalls interceptor for calls that workflow makes to the SDK
140+
* @param outboundCalls an existing interceptor instance to be proxied by the interceptor created
141+
* inside this method
142+
* @see WorkerInterceptor#interceptWorkflow for the definition of "next" {@link
143+
* WorkflowInboundCallsInterceptor}
121144
*/
122145
void init(WorkflowOutboundCallsInterceptor outboundCalls);
123146

temporal-sdk/src/main/java/io/temporal/common/interceptors/WorkflowOutboundCallsInterceptor.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,24 @@
3636
import javax.annotation.Nullable;
3737

3838
/**
39-
* Can be used to intercept workflow code calls to the Temporal APIs. An instance should be created
40-
* through {@link WorkerInterceptor#interceptWorkflow(WorkflowInboundCallsInterceptor)}. An
41-
* interceptor instance must forward all the calls to the next interceptor passed to the
42-
* interceptExecuteWorkflow call.
39+
* Can be used to intercept calls from to workflow code into the Temporal APIs.
4340
*
4441
* <p>The calls to the interceptor are executed in the context of a workflow and must follow the
4542
* same rules all the other workflow code follows.
43+
*
44+
* <p>Prefer extending {@link WorkflowOutboundCallsInterceptorBase} and overriding only the methods
45+
* you need instead of implementing this interface directly. {@link
46+
* WorkflowOutboundCallsInterceptorBase} provides correct default implementations to all the methods
47+
* of this interface.
48+
*
49+
* <p>An instance may be created in {@link
50+
* WorkflowInboundCallsInterceptor#init(WorkflowOutboundCallsInterceptor)} and set by passing it
51+
* into {@code init} method of the {@code next} {@link WorkflowInboundCallsInterceptor} The
52+
* implementation must forward all the calls to the outbound interceptor passed as a {@code
53+
* outboundCalls} parameter to the {@code init} call.
54+
*
55+
* @see WorkerInterceptor#interceptWorkflow for the definition of "next" {@link
56+
* WorkflowInboundCallsInterceptor}.
4657
*/
4758
@Experimental
4859
public interface WorkflowOutboundCallsInterceptor {
@@ -489,7 +500,7 @@ <R> R mutableSideEffect(
489500
void upsertSearchAttributes(Map<String, ?> searchAttributes);
490501

491502
/**
492-
* Intercepts creation of the workflow child thread.
503+
* Intercepts creation of a workflow child thread.
493504
*
494505
* <p>Please note, that "workflow child thread" and "child workflow" are different and independent
495506
* concepts.

0 commit comments

Comments
 (0)