|
11 | 11 | import java.lang.annotation.Target; |
12 | 12 |
|
13 | 13 | /** |
14 | | - * Marks a class and its methods as a JSON-RPC 2.0 endpoint. * |
| 14 | + * Marks a class or its methods as a JSON-RPC 2.0 endpoint. |
15 | 15 | * |
16 | | - * <p>To expose a method via JSON-RPC, the method <b>must</b> be annotated with {@code @JsonRpc}. If |
17 | | - * a class contains methods annotated with {@code @JsonRpc}, the class itself can optionally be |
18 | | - * annotated to define a common namespace. * |
| 16 | + * <h3>Discovery Rules:</h3> |
19 | 17 | * |
20 | | - * <h3>Routing Rules:</h3> |
| 18 | + * <ul> |
| 19 | + * <li><b>Implicit Mapping:</b> If a class is annotated with {@code @JsonRpc} and <b>no</b> |
| 20 | + * methods are explicitly annotated, <b>all</b> public methods are automatically exposed as |
| 21 | + * JSON-RPC endpoints. |
| 22 | + * <li><b>Explicit Mapping:</b> If at least <b>one</b> method in the class is explicitly annotated |
| 23 | + * with {@code @JsonRpc}, implicit mapping is disabled. <b>Only</b> the annotated methods will |
| 24 | + * be exposed, requiring you to map any other desired endpoints one by one. |
| 25 | + * </ul> |
| 26 | + * |
| 27 | + * <h3>Naming & Routing Rules:</h3> |
21 | 28 | * |
22 | 29 | * <ul> |
23 | 30 | * <li><b>Class Level (Namespace):</b> When applied to a class, the {@link #value()} defines the |
24 | 31 | * namespace for all JSON-RPC methods within that class. If the annotation is present but the |
25 | | - * value is empty, the simple class name (e.g., {@code MovieService}) is used as the |
26 | | - * namespace. If the class is not annotated at all, the methods are registered without a |
27 | | - * namespace. * |
28 | | - * <li><b>Method Level (Method Name):</b> When applied to a method, the method is exposed over |
29 | | - * JSON-RPC. The {@link #value()} defines the exact RPC method name. If the value is empty, |
30 | | - * the actual Java/Kotlin method name is used. |
| 32 | + * value is empty (the default), <b>no namespace</b> is applied. |
| 33 | + * <li><b>Method Level (Method Name):</b> When applied to a method, the {@link #value()} defines |
| 34 | + * the exact RPC method name. If the value is empty, the actual Java/Kotlin method name is |
| 35 | + * used. |
31 | 36 | * </ul> |
32 | 37 | * |
33 | | - * * |
34 | | - * |
35 | 38 | * <p>The final JSON-RPC method string expected by the dispatcher is formatted as {@code |
36 | 39 | * "namespace.methodName"} (or just {@code "methodName"} if no namespace exists). |
37 | 40 | */ |
|
41 | 44 |
|
42 | 45 | /** |
43 | 46 | * The explicit namespace (when used on a class) or the explicit method name (when used on a |
44 | | - * method). * @return The overridden name, or an empty string to use the defaults (Simple Class |
45 | | - * Name or Method Name). |
| 47 | + * method). * @return The overridden name, or an empty string to use the defaults (no namespace |
| 48 | + * for classes, actual method name for methods). |
46 | 49 | */ |
47 | 50 | String value() default ""; |
48 | 51 | } |
0 commit comments