|
32 | 32 | */ |
33 | 33 | public interface WithEventBus extends Verticle { |
34 | 34 | /* PUBLISH */ |
| 35 | + |
35 | 36 | /** |
36 | 37 | * @see io.vertx.core.eventbus.EventBus#publish(String, Object, DeliveryOptions) |
37 | 38 | */ |
@@ -61,6 +62,7 @@ default void publish(String address, JsonMessage message) { |
61 | 62 | } |
62 | 63 |
|
63 | 64 | /* SEND */ |
| 65 | + |
64 | 66 | /** |
65 | 67 | * @see io.vertx.core.eventbus.EventBus#send(String, Object, DeliveryOptions) |
66 | 68 | */ |
@@ -90,69 +92,83 @@ default void send(String address, JsonMessage message) { |
90 | 92 | } |
91 | 93 |
|
92 | 94 | /* REQUEST */ |
| 95 | + |
93 | 96 | /** |
94 | | - * @param responseType the type of the response to map to |
95 | 97 | * @see io.vertx.core.eventbus.EventBus#request(String, Object, DeliveryOptions) |
96 | 98 | */ |
97 | | - default <V extends JsonMessage, T> Future<DecodedMessage<V, T>> request( |
98 | | - String address, Object request, DeliveryOptions options, Class<V> responseType) { |
99 | | - return getVertx().eventBus().<T>request(address, request, options) |
100 | | - .map(raw -> new DecodedMessage<>(JsonMessage.from(raw.body(), responseType), raw)); |
| 99 | + default <T> Future<Message<T>> request(String address, Object request, DeliveryOptions options) { |
| 100 | + return getVertx().eventBus().request(address, request, options); |
101 | 101 | } |
102 | 102 |
|
103 | | - default <V extends JsonMessage, T> Future<DecodedMessage<V, T>> request( |
104 | | - String address, JsonMessage request, DeliveryOptions options, Class<V> responseType) { |
105 | | - return request(address, request.json(), options, responseType); |
| 103 | + /** |
| 104 | + * @see io.vertx.core.eventbus.EventBus#request(String, Object) |
| 105 | + */ |
| 106 | + default <T> Future<Message<T>> request(String address, Object request) { |
| 107 | + return getVertx().eventBus().request(address, request); |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + * @param responseType the type of the response to map to |
| 112 | + * @see io.vertx.core.eventbus.EventBus#request(String, Object, DeliveryOptions) |
| 113 | + */ |
| 114 | + default <V extends JsonMessage, T extends JsonObject> Future<DecodedMessage<V, T>> request( |
| 115 | + String address, Object request, DeliveryOptions options, Class<V> responseType |
| 116 | + ) { |
| 117 | + return this.<T>request(address, request, options) |
| 118 | + .map(raw -> new DecodedMessage<>(raw.body().mapTo(responseType), raw)); |
106 | 119 | } |
107 | 120 |
|
108 | 121 | /** |
109 | 122 | * @param responseType the type of the response to map to |
110 | 123 | * @see io.vertx.core.eventbus.EventBus#request(String, Object) |
111 | 124 | */ |
112 | | - default <V extends JsonMessage, T> Future<DecodedMessage<V, T>> request( |
113 | | - String address, Object request, Class<V> responseType) { |
114 | | - return getVertx().eventBus().<T>request(address, request) |
115 | | - .map(raw -> new DecodedMessage<>(((JsonObject) raw.body()).mapTo(responseType), raw)); |
| 125 | + default <V extends JsonMessage, T extends JsonObject> Future<DecodedMessage<V, T>> request( |
| 126 | + String address, Object request, Class<V> responseType |
| 127 | + ) { |
| 128 | + return this.<T>request(address, request) |
| 129 | + .map(raw -> new DecodedMessage<>(raw.body().mapTo(responseType), raw)); |
116 | 130 | } |
117 | 131 |
|
118 | | - default <V extends JsonMessage, T> Future<DecodedMessage<V, T>> request( |
119 | | - String address, JsonMessage request, Class<V> responseType) { |
| 132 | + /** |
| 133 | + * @param responseType the type of the response to map to |
| 134 | + * @see io.vertx.core.eventbus.EventBus#request(String, Object, DeliveryOptions) |
| 135 | + */ |
| 136 | + default <V extends JsonMessage, T extends JsonObject> Future<DecodedMessage<V, T>> request( |
| 137 | + String address, JsonMessage request, DeliveryOptions options, Class<V> responseType |
| 138 | + ) { |
| 139 | + return request(address, request.json(), options, responseType); |
| 140 | + } |
| 141 | + |
| 142 | + /** |
| 143 | + * @param responseType the type of the response to map to |
| 144 | + * @see io.vertx.core.eventbus.EventBus#request(String, Object) |
| 145 | + */ |
| 146 | + default <V extends JsonMessage, T extends JsonObject> Future<DecodedMessage<V, T>> request( |
| 147 | + String address, JsonMessage request, Class<V> responseType |
| 148 | + ) { |
120 | 149 | return request(address, request.json(), responseType); |
121 | 150 | } |
122 | 151 |
|
123 | 152 | /* REGISTER/CONSUME */ |
| 153 | + |
124 | 154 | /** |
125 | | - * Registers a handler onto an eventbus channel. |
126 | | - * |
127 | | - * @param address the eventbus address name |
128 | | - * @param handler the handler that gets called when a new message arrives at the specified eventbus address |
129 | 155 | * @see io.vertx.core.eventbus.EventBus#consumer(String, Handler) |
130 | 156 | */ |
131 | 157 | default <T> void register(String address, Handler<Message<T>> handler) { |
132 | 158 | getVertx().eventBus().consumer(address, handler); |
133 | 159 | } |
134 | 160 |
|
135 | 161 | /** |
136 | | - * Registers a handler onto an eventbus channel. |
137 | | - * The received messages are mapped to the specified json type before handing over to the handler. |
138 | | - * |
139 | | - * @param address the eventbus address name |
140 | | - * @param handler the handler that gets called when a new message arrives at the specified eventbus address |
141 | | - * @param type the json type to map to |
| 162 | + * @param type the type of received message to map to |
142 | 163 | * @see io.vertx.core.eventbus.EventBus#consumer(String, Handler) |
143 | 164 | */ |
144 | 165 | default <V extends JsonMessage> void register(String address, MessageHandler<V> handler, Class<V> type) { |
145 | 166 | register(address, message -> JsonMessage.on(type, message, handler::handle)); |
146 | 167 | } |
147 | 168 |
|
148 | 169 | /** |
149 | | - * Registers a handler onto an eventbus channel. |
150 | | - * The received messages are mapped to the specified json type before handing over to the handler. |
151 | | - * The handler gets the plain message object received from the eventbus, too. |
152 | | - * |
153 | | - * @param address the eventbus address name |
154 | | - * @param handler the handler that gets called when a new message arrives at the specified eventbus address |
155 | | - * @param type the json type to map to |
| 170 | + * @param type the type of received message to map to |
| 171 | + * @see io.vertx.core.eventbus.EventBus#consumer(String, Handler) |
156 | 172 | */ |
157 | 173 | default <V extends JsonMessage, T> void register(String address, ExtendedMessageHandler<V, T> handler, Class<V> type) { |
158 | 174 | this.<T>register(address, message -> JsonMessage.on(type, message, body -> handler.handle(body, message))); |
|
0 commit comments