4242 * {
4343 * install(new Jackson3Module());
4444 * install(new JsonRpcJackson3Module());
45- * * install(new JsonRpcModule(new MyServiceRpc_())
45+ * install(new JsonRpcModule(new MyServiceRpc_())
4646 * .invoker(new MyJsonRpcMiddleware()));
4747 * }
4848 * }</pre>
4949 *
50- * @author Edgar Espina
50+ * @author edgar
5151 * @since 4.0.17
5252 */
5353public class JsonRpcModule implements Extension {
@@ -83,12 +83,14 @@ public JsonRpcModule(JsonRpcService service, JsonRpcService... services) {
8383 /**
8484 * Adds a {@link JsonRpcInvoker} middleware to the execution pipeline.
8585 *
86- * <p>Middlewares are composed together to form a {@link JsonRpcChain}. When multiple invokers are
87- * registered, they wrap around each other, meaning the first added invoker will execute first.
86+ * <p>Execution order follows a First-In-First-Out (FIFO) pipeline. When multiple invokers are
87+ * registered, they wrap around each other in the order they were added. <br>
88+ * For example: {@code .invoker(A).invoker(B)} generates the pipeline {@code A -> B}.
8889 *
8990 * <p><strong>Tracing Priority:</strong> If the provided invoker is an instance of {@link
9091 * OtelJsonRcpTracing}, it is automatically promoted to the absolute head of the pipeline. This
91- * guarantees that OpenTelemetry spans encompass all other middlewares and the final execution.
92+ * guarantees that OpenTelemetry spans encompass all other middlewares and the final execution
93+ * regardless of the order it was added.
9294 *
9395 * @param invoker The middleware interceptor to add to the pipeline.
9496 * @return This module instance for fluent configuration chaining.
@@ -99,7 +101,8 @@ public JsonRpcModule invoker(JsonRpcInvoker invoker) {
99101 this .head = otel ;
100102 } else {
101103 if (this .invoker != null ) {
102- this .invoker = invoker .then (this .invoker );
104+ // Appends to the chain to ensure First-In-First-Out (A -> B)
105+ this .invoker = this .invoker .then (invoker );
103106 } else {
104107 this .invoker = invoker ;
105108 }
0 commit comments