Skip to content

Commit f0bbf84

Browse files
authored
Doc fix for polymorphic interfaces (#224)
1 parent 1196386 commit f0bbf84

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

temporal-sdk/src/main/java/io/temporal/activity/ActivityInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public interface ActivityInfo {
7171

7272
String getActivityNamespace();
7373

74-
/** Activity execution attempt starting from 0. */
74+
/** Activity execution attempt starting from 1. */
7575
int getAttempt();
7676

7777
/** Is this activity invoked as a local activity? */

temporal-sdk/src/main/java/io/temporal/activity/ActivityInterface.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
* annotation can be used as parameters to {@link Workflow#newActivityStub(Class)} methods.
3131
*
3232
* <p>Each method of the interface annotated with <code>ActivityInterface</code> including inherited
33-
* from interfaces is a separate activity. By default the name of an activity type is "short
34-
* interface name"_"method name".
33+
* from interfaces is a separate activity. By default the name of an activity type is its method
34+
* name with the first letter capitalized. Use {@link ActivityInterface#namePrefix()} or {{@link
35+
* ActivityMethod#name()}} to make sure that activity type names are distinct.
3536
*
3637
* <p>Example:
3738
*
@@ -40,12 +41,12 @@
4041
* a();
4142
* }
4243
*
43-
* {@literal @}ActivityInterface
44+
* {@literal @}ActivityInterface(namePrefix = "B_")
4445
* public interface B extends A {
4546
* b();
4647
* }
4748
*
48-
* {@literal @}ActivityInterface
49+
* {@literal @}ActivityInterface(namePrefix = "C_")
4950
* public interface C extends B {
5051
* c();
5152
* }
@@ -68,8 +69,7 @@
6869
* <li>C_c
6970
* </ul>
7071
*
71-
* Note that method <code>a()</code> is registered as "B_a" because interface <code>A</code> lacks
72-
* ActivityInterface annotation. The workflow code can call activities through stubs to <code>B
72+
* The workflow code can call activities through stubs to <code>B
7373
* </code> and <code>C</code> interfaces. A call to crate stub to <code>A</code> interface will fail
7474
* as <code>A</code> is not annotated with ActivityInterface.
7575
*/
@@ -80,6 +80,9 @@
8080
* Prefix to prepend to method names to generate activity types. Default is empty string which
8181
* means that method names are used as activity types.
8282
*
83+
* <p>Note that this value is ignored if a name of an activity is specified explicitly through
84+
* {@link ActivityMethod#name()}.
85+
*
8386
* <p>Be careful about names that contain special characters. These names can be used as metric
8487
* tags. And systems like prometheus ignore metrics which have tags with unsupported characters.
8588
*/

temporal-sdk/src/main/java/io/temporal/activity/ActivityMethod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
/**
3636
* Name of the activity type. Default is method name. Also consider using {@link
37-
* ActivityInterface#namePrefix()}.
37+
* ActivityInterface#namePrefix()}. Note that the prefix is ignored if the name is specified.
3838
*
3939
* <p>Be careful about names that contain special characters. These names can be used as metric
4040
* tags. And systems like prometheus ignore metrics which have tags with unsupported characters.

temporal-sdk/src/main/java/io/temporal/workflow/WorkflowInterface.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
* annotations: {@literal @}WorkflowMethod, {@literal @}SignalMethod or {@literal @}QueryMethod
3737
*
3838
* <p>An interface annotated with WorkflowInterface can extend other interfaces annotated with
39-
* WorkflowInterface having that it can have at most one method annotated with
39+
* WorkflowInterface having that it can have <b>at most one</b> method annotated with
4040
* {@literal @}WorkflowMethod including all inherited methods.
4141
*
4242
* <p>The prefix of workflow, signal and query type names is the name of the declaring interface
4343
* annotated with WorkflowInterface. If a method is declared in non annotated interface the prefix
4444
* comes from the first sub-interface that has the WorkflowInterface annotation.
4545
*
46-
* <p>A workflow implementation object must have exactly one method annotated with
46+
* <p>A workflow implementation object must have <b>exactly one</b> method annotated with
4747
* {@literal @}WorkflowMethod inherited from all the interfaces it implements.
4848
*
4949
* <p>Example:
@@ -61,7 +61,7 @@
6161
* {@literal @}SignalMethod
6262
* b();
6363
*
64-
* {@literal @}SignalMethod // must to define the type of the inherited method
64+
* {@literal @}SignalMethod // must define the type of the inherited method
6565
* aa();
6666
* }
6767
*
@@ -92,18 +92,16 @@
9292
* <p>
9393
*
9494
* <ul>
95-
* <li>B_a signal handler
96-
* <li>B_b signal handler
97-
* <li>B_aa signal handler
98-
* <li>C_c workflow main method
99-
* <li>D_d query method
95+
* <li>a signal handler
96+
* <li>b signal handler
97+
* <li>aa signal handler
98+
* <li>c workflow main method
99+
* <li>d query method
100100
* </ul>
101101
*
102-
* Note that methods <code>a()</code> and <code>aa()</code> are registered with "B_" prefix because
103-
* interface <code>A</code> lacks the WorkflowInterface annotation. The client code can call signals
104-
* through stubs to <code>B</code>, <code>C</code> and <code>D</code> interfaces. A call to crate a
105-
* stub to <code>A</code> interface will fail as <code>A</code> is not annotated with the
106-
* WorkflowInterface.
102+
* The client code can call signals through stubs to <code>B</code>, <code>C</code> and <code>D
103+
* </code> interfaces. A call to crate a stub to <code>A</code> interface will fail as <code>A
104+
* </code> is not annotated with the WorkflowInterface.
107105
*/
108106
@Retention(RetentionPolicy.RUNTIME)
109107
@Target(ElementType.TYPE)

0 commit comments

Comments
 (0)