|
10 | 10 | */ |
11 | 11 | package io.vertx.oracleclient.impl.commands; |
12 | 12 |
|
| 13 | +import io.vertx.core.AsyncResult; |
13 | 14 | import io.vertx.core.Completable; |
14 | 15 | import io.vertx.core.Future; |
15 | 16 | import io.vertx.core.Promise; |
16 | 17 | import io.vertx.core.internal.ContextInternal; |
17 | 18 | import io.vertx.oracleclient.impl.Helper.SQLBlockingCodeHandler; |
18 | | -import io.vertx.sqlclient.internal.command.CommandBase; |
19 | | -import io.vertx.sqlclient.internal.command.CommandResponse; |
20 | 19 | import oracle.jdbc.OracleConnection; |
21 | 20 |
|
22 | 21 | import java.util.concurrent.Flow; |
|
26 | 25 |
|
27 | 26 | public abstract class OracleCommand<T> { |
28 | 27 |
|
29 | | - public Completable<T> handler; |
30 | 28 | protected final OracleConnection oracleConnection; |
31 | 29 | protected final ContextInternal connectionContext; |
32 | | - private CommandResponse<T> response; |
| 30 | + private Completable<T> handler; |
| 31 | + private AsyncResult<T> result; |
33 | 32 |
|
34 | 33 | protected OracleCommand(OracleConnection oracleConnection, ContextInternal connectionContext) { |
35 | 34 | this.oracleConnection = oracleConnection; |
36 | 35 | this.connectionContext = connectionContext; |
37 | 36 | } |
38 | 37 |
|
39 | | - public final Future<Void> processCommand(CommandBase<T> cmd, Completable<T> handler) { |
| 38 | + public final Future<?> processCommand(Completable<T> handler) { |
| 39 | + this.handler = handler; |
40 | 40 | return execute().andThen(ar -> { |
41 | | - if (ar.succeeded()) { |
42 | | - response = CommandResponse.success(ar.result()); |
43 | | - } else { |
44 | | - response = CommandResponse.failure(ar.cause()); |
45 | | - } |
46 | | - response.cmd = cmd; |
47 | | - response.handler = handler; |
48 | | - }).mapEmpty(); |
| 41 | + this.result = ar; |
| 42 | + }); |
49 | 43 | } |
50 | 44 |
|
51 | 45 | protected abstract Future<T> execute(); |
@@ -90,6 +84,6 @@ public void onComplete() { |
90 | 84 | } |
91 | 85 |
|
92 | 86 | public final void fireResponse() { |
93 | | - response.fire(); |
| 87 | + handler.complete(result.result(), result.cause()); |
94 | 88 | } |
95 | 89 | } |
0 commit comments