forked from temporalio/sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActivityInterface.java
More file actions
69 lines (67 loc) · 2.26 KB
/
ActivityInterface.java
File metadata and controls
69 lines (67 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package io.temporal.activity;
import io.temporal.workflow.Workflow;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Indicates that an interface is an activity interface. Only interfaces annotated with this
* annotation can be used as parameters to {@link Workflow#newActivityStub(Class)} methods.
*
* <p>Each method of the interface annotated with <code>ActivityInterface</code> including inherited
* from interfaces is a separate activity. By default, the name of an activity type is its method
* name with the first letter capitalized. Use {@link ActivityInterface#namePrefix()} or {{@link
* ActivityMethod#name()}} to make sure that activity type names are distinct.
*
* <p>Example:
*
* <pre><code>
* public interface A {
* a();
* }
*
* {@literal @}ActivityInterface(namePrefix = "B_")
* public interface B extends A {
* b();
* }
*
* {@literal @}ActivityInterface(namePrefix = "C_")
* public interface C extends B {
* c();
* }
*
* public class CImpl implements C {
* public void a() {}
* public void b() {}
* public void c() {}
* }
* </code></pre>
*
* When <code>CImpl</code> instance is registered with the {@link io.temporal.worker.Worker} the
* following activities are registered:
*
* <ul>
* <li>B_a
* <li>B_b
* <li>C_c
* </ul>
*
* The workflow code can call activities through stubs to <code>B
* </code> and <code>C</code> interfaces. A call to crate stub to <code>A</code> interface will fail
* as <code>A</code> is not annotated with ActivityInterface.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ActivityInterface {
/**
* Prefix to prepend to method names to generate activity types. Default is empty string which
* means that method names are used as activity types.
*
* <p>Note that this value is ignored if a name of an activity is specified explicitly through
* {@link ActivityMethod#name()}.
*
* <p>Be careful about names that contain special characters. These names can be used as metric
* tags. And systems like prometheus ignore metrics which have tags with unsupported characters.
*/
String namePrefix() default "";
}