diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5cc403f9b..b69133652 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: name: Run tests strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest, macos-latest] jdk: [11] include: - os: ubuntu-latest @@ -31,4 +31,4 @@ jobs: with: java-version: ${{ matrix.jdk }} - name: Run tests - run: mvn -q clean verify -B -s settings.xml + run: mvn clean verify -B -s settings.xml diff --git a/jpms-examples/pom.xml b/jpms-examples/pom.xml index 08dced1a7..5a8468193 100644 --- a/jpms-examples/pom.xml +++ b/jpms-examples/pom.xml @@ -18,7 +18,7 @@ 4.27.2 1.20.1 - aarch64 + aarch_64 @@ -130,8 +130,6 @@ io.netty netty-resolver-dns-native-macos - osx-${osx.arch} - 4.2.0.Alpha4 @@ -161,7 +159,7 @@ - mac + Mac mac @@ -172,14 +170,40 @@ ${os.detected.arch} + + io.netty + netty-resolver-dns-native-macos + osx-${osx.arch} + 4.2.0.Alpha5 + io.netty netty-transport-native-kqueue osx-${osx.arch} - 4.2.0.Alpha4 + 4.2.0.Alpha5 + + + + + Linux + + + linux + + + + epoll + + + + io.netty + netty-transport-native-epoll + linux-${os.detected.arch} + 4.2.0.Alpha5 + diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/grpc/Server.java b/jpms-examples/src/main/java/io/vertx/example/jpms/grpc/Server.java index df7b232a5..535daa81d 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/grpc/Server.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/grpc/Server.java @@ -3,16 +3,13 @@ import io.grpc.examples.helloworld.HelloReply; import io.grpc.examples.helloworld.HelloRequest; import io.grpc.examples.helloworld.VertxGreeterGrpcServer; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Future; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; +import io.vertx.core.*; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.net.JksOptions; import io.vertx.grpc.server.GrpcServer; -public class Server extends AbstractVerticle { +public class Server extends VerticleBase { public static void main(String[] args) { Vertx vertx = Vertx.vertx(); @@ -21,14 +18,9 @@ public static void main(String[] args) { } @Override - public void start(Promise startFuture) { - HttpServer server = vertx.createHttpServer( - new HttpServerOptions() - .setUseAlpn(true) - .setKeyCertOptions(new JksOptions().setPath("server-keystore.jks").setPassword("wibble")) - .setSsl(false) - ); + public Future start() { GrpcServer grpcServer = GrpcServer.server(vertx); + VertxGreeterGrpcServer.GreeterApi api = new VertxGreeterGrpcServer.GreeterApi() { @Override public Future sayHello(HelloRequest request) { @@ -40,10 +32,16 @@ public Future sayHello(HelloRequest request) { } }; api.bind_sayHello(grpcServer); - server - .requestHandler(grpcServer) - .listen(8080) - .mapEmpty() - .onComplete(startFuture); + + HttpServer server = vertx + .createHttpServer( + new HttpServerOptions() + .setUseAlpn(true) + .setKeyCertOptions(new JksOptions().setPath("server-keystore.jks").setPassword("wibble")) + .setSsl(false) + ) + .requestHandler(grpcServer); + + return server.listen(8080); } } diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/http/Server.java b/jpms-examples/src/main/java/io/vertx/example/jpms/http/Server.java index f4c6020e3..b146d9c78 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/http/Server.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/http/Server.java @@ -1,12 +1,10 @@ package io.vertx.example.jpms.http; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; +import io.vertx.core.*; import io.vertx.core.http.HttpServer; import io.vertx.core.json.JsonObject; -public class Server extends AbstractVerticle { +public class Server extends VerticleBase { public static void main(String[] args) { Vertx vertx = Vertx.vertx(); @@ -15,15 +13,17 @@ public static void main(String[] args) { } @Override - public void start(Promise startFuture) { + public Future start() { + HttpServer server = vertx.createHttpServer(); + server.requestHandler(req -> { - req.response().end(new JsonObject() - .put("http", req.version()) - .put("message", "Hello World") - .toString()); - }).listen(8080) - .mapEmpty() - .onComplete(startFuture); + req.response().end(new JsonObject() + .put("http", req.version()) + .put("message", "Hello World") + .toString()); + }); + + return server.listen(8080); } } diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/http2/Server.java b/jpms-examples/src/main/java/io/vertx/example/jpms/http2/Server.java index 8886f9475..910c35c61 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/http2/Server.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/http2/Server.java @@ -1,14 +1,12 @@ package io.vertx.example.jpms.http2; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; +import io.vertx.core.*; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.json.JsonObject; import io.vertx.core.net.JksOptions; -public class Server extends AbstractVerticle { +public class Server extends VerticleBase { public static void main(String[] args) { Vertx vertx = Vertx.vertx(); @@ -17,20 +15,21 @@ public static void main(String[] args) { } @Override - public void start(Promise startFuture) { - HttpServer server = vertx.createHttpServer( - new HttpServerOptions() - .setUseAlpn(true) - .setKeyCertOptions(new JksOptions().setPath("server-keystore.jks").setPassword("wibble")) - .setSsl(true) - ); - server.requestHandler(req -> { + public Future start() { + HttpServerOptions options = new HttpServerOptions() + .setUseAlpn(true) + .setKeyCertOptions(new JksOptions().setPath("server-keystore.jks").setPassword("wibble")) + .setSsl(true); + + HttpServer server = vertx + .createHttpServer(options) + .requestHandler(req -> { req.response().end(new JsonObject() .put("http", req.version()) .put("message", "Hello World") .toString()); - }).listen(8443) - .mapEmpty() - .onComplete(startFuture); + }); + + return server.listen(8443); } } diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/native_transport/Server.java b/jpms-examples/src/main/java/io/vertx/example/jpms/native_transport/Server.java index 9954efaab..4fbef1054 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/native_transport/Server.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/native_transport/Server.java @@ -1,15 +1,12 @@ package io.vertx.example.jpms.native_transport; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; -import io.vertx.core.VertxOptions; +import io.vertx.core.*; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.json.JsonObject; import io.vertx.core.net.JksOptions; -public class Server extends AbstractVerticle { +public class Server extends VerticleBase { public static void main(String[] args) { Vertx vertx = Vertx.vertx(new VertxOptions() @@ -22,16 +19,17 @@ public static void main(String[] args) { } @Override - public void start(Promise startFuture) { - HttpServer server = vertx.createHttpServer(); - server.requestHandler(req -> { + public Future start() { + HttpServer server = vertx + .createHttpServer() + .requestHandler(req -> { req.response().end(new JsonObject() .put("http", req.version()) .put("message", "Hello World") .put("nativeTransport", vertx.isNativeTransportEnabled()) .toString()); - }).listen(8080) - .mapEmpty() - .onComplete(startFuture); + }); + + return server.listen(8080); } } diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/openssl/Server.java b/jpms-examples/src/main/java/io/vertx/example/jpms/openssl/Server.java index 9160eee9a..f347ed683 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/openssl/Server.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/openssl/Server.java @@ -1,16 +1,13 @@ package io.vertx.example.jpms.openssl; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; -import io.vertx.core.VertxOptions; +import io.vertx.core.*; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.json.JsonObject; import io.vertx.core.net.JksOptions; import io.vertx.core.net.OpenSSLEngineOptions; -public class Server extends AbstractVerticle { +public class Server extends VerticleBase { public static void main(String[] args) { Vertx vertx = Vertx.vertx(); @@ -19,21 +16,24 @@ public static void main(String[] args) { } @Override - public void start(Promise startFuture) { - HttpServer server = vertx.createHttpServer(new HttpServerOptions() + public Future start() { + HttpServerOptions options = new HttpServerOptions() .setSslEngineOptions(new OpenSSLEngineOptions()) .setKeyCertOptions(new JksOptions() .setPath("server-keystore.jks") .setPassword("wibble")) - .setSsl(true)); - server.requestHandler(req -> { + .setSsl(true); + + HttpServer server = vertx + .createHttpServer(options) + .requestHandler(req -> { req.response().end(new JsonObject() .put("http", req.version()) .put("message", "Hello World") .put("nativeTransport", vertx.isNativeTransportEnabled()) .toString()); - }).listen(8443) - .mapEmpty() - .onComplete(startFuture); + }); + + return server.listen(8443); } } diff --git a/jpms-examples/src/main/java/io/vertx/example/jpms/sqlclient/Client.java b/jpms-examples/src/main/java/io/vertx/example/jpms/sqlclient/Client.java index 3f5b66232..7a80dca39 100644 --- a/jpms-examples/src/main/java/io/vertx/example/jpms/sqlclient/Client.java +++ b/jpms-examples/src/main/java/io/vertx/example/jpms/sqlclient/Client.java @@ -1,25 +1,19 @@ package io.vertx.example.jpms.sqlclient; -import io.vertx.core.AbstractVerticle; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; +import io.vertx.core.*; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpServer; import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; import io.vertx.pgclient.PgBuilder; import io.vertx.pgclient.PgConnectOptions; import io.vertx.sqlclient.Pool; -import io.vertx.sqlclient.Row; -import java.util.Map; -import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /* * @author Paulo Lopes */ -public class Client extends AbstractVerticle { +public class Client extends VerticleBase { private PgConnectOptions database; private HttpServer server; @@ -30,8 +24,7 @@ public Client(PgConnectOptions database) { this.database = database; } - @Override - public void start(Promise start) { + public Future start() { client = PgBuilder.pool() .connectingTo(database) .using(vertx) @@ -56,8 +49,6 @@ public void start(Promise start) { }); }); - server.listen(8080) - .mapEmpty() - .onComplete(start); + return server.listen(8080); } } diff --git a/jpms-examples/src/main/java/module-info.java b/jpms-examples/src/main/java/module-info.java index 2819f8203..c569b982c 100644 --- a/jpms-examples/src/main/java/module-info.java +++ b/jpms-examples/src/main/java/module-info.java @@ -18,5 +18,6 @@ requires jdk.crypto.ec; exports io.vertx.example.jpms.sqlclient; + exports io.vertx.example.jpms.native_transport; } diff --git a/jpms-examples/src/test/java/io/vertx/example/jpms/tests/NativeTransportTest.java b/jpms-examples/src/test/java/io/vertx/example/jpms/tests/NativeTransportTest.java new file mode 100644 index 000000000..901b10ed8 --- /dev/null +++ b/jpms-examples/src/test/java/io/vertx/example/jpms/tests/NativeTransportTest.java @@ -0,0 +1,51 @@ +package io.vertx.example.jpms.tests; + +import io.vertx.core.Vertx; +import io.vertx.core.VertxOptions; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpClient; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpResponseExpectation; +import io.vertx.core.json.JsonObject; +import io.vertx.example.jpms.native_transport.Server; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class NativeTransportTest { + + private Vertx vertx; + + @BeforeEach + public void before() { + vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true)); + assertTrue(vertx.isNativeTransportEnabled()); + } + + @AfterEach + public void after() { + vertx + .close() + .await(); + } + + @Test + public void testNativeTransport() { + vertx + .deployVerticle(new Server()) + .await(); + HttpClient client = vertx.createHttpClient(); + JsonObject res = client.request(HttpMethod.GET, 8080, "localhost", "/") + .compose(req -> req.send() + .expecting(HttpResponseExpectation.SC_OK) + .compose(resp -> resp + .body() + .map(Buffer::toJsonObject)) + ) + .await(); + assertEquals("Hello World", res.getString("message")); + assertTrue(res.getBoolean("nativeTransport")); + } +} diff --git a/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java b/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java index 2592b021b..c735c4eb9 100644 --- a/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java +++ b/jpms-examples/src/test/java/io/vertx/example/jpms/tests/SqlClientTest.java @@ -11,6 +11,8 @@ import io.vertx.example.jpms.sqlclient.Client; import io.vertx.pgclient.PgConnectOptions; import org.junit.jupiter.api.*; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.OS; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; import org.testcontainers.utility.DockerImageName; @@ -18,6 +20,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; +@EnabledOnOs(value = { OS.LINUX }) public class SqlClientTest { private static GenericContainer container; diff --git a/pom.xml b/pom.xml index 6efa0baa2..449251d87 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ zipkin-examples web-examples web-client-examples - rxjava-2-examples + rxjava-3-examples metrics-examples micrometer-metrics-examples @@ -42,8 +42,7 @@ cassandra-examples web-graphql-examples openapi-examples - - + jpms-examples diff --git a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxEBProxy.java b/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxEBProxy.java deleted file mode 100644 index 6927c2bd6..000000000 --- a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxEBProxy.java +++ /dev/null @@ -1,75 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package io.vertx.example.reactivex.services.serviceproxy; - -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.Vertx; -import io.vertx.core.Future; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.function.Function; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.ProxyUtils; - -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class SomeDatabaseServiceVertxEBProxy implements SomeDatabaseService { - private Vertx _vertx; - private String _address; - private DeliveryOptions _options; - private boolean closed; - - public SomeDatabaseServiceVertxEBProxy(Vertx vertx, String address) { - this(vertx, address, null); - } - - public SomeDatabaseServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) { - this._vertx = vertx; - this._address = address; - this._options = options; - try { - this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) { - } - } - - @Override - public Future getDataById(int id){ - if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); - JsonObject _json = new JsonObject(); - _json.put("id", id); - - DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); - _deliveryOptions.addHeader("action", "getDataById"); - _deliveryOptions.getHeaders().set("action", "getDataById"); - return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { - return msg.body(); - }); - } -} diff --git a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxProxyHandler.java b/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxProxyHandler.java deleted file mode 100644 index 5e6711170..000000000 --- a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/SomeDatabaseServiceVertxProxyHandler.java +++ /dev/null @@ -1,133 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package io.vertx.example.reactivex.services.serviceproxy; - -import io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService; -import io.vertx.core.Vertx; -import io.vertx.core.Handler; -import io.vertx.core.AsyncResult; -import io.vertx.core.eventbus.EventBus; -import io.vertx.core.eventbus.Message; -import io.vertx.core.eventbus.MessageConsumer; -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.eventbus.ReplyException; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.Collection; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.stream.Collectors; -import io.vertx.serviceproxy.ProxyHandler; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.HelperUtils; -import io.vertx.serviceproxy.ServiceBinder; - -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class SomeDatabaseServiceVertxProxyHandler extends ProxyHandler { - - public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes - private final Vertx vertx; - private final SomeDatabaseService service; - private final long timerID; - private long lastAccessed; - private final long timeoutSeconds; - private final boolean includeDebugInfo; - - public SomeDatabaseServiceVertxProxyHandler(Vertx vertx, SomeDatabaseService service){ - this(vertx, service, DEFAULT_CONNECTION_TIMEOUT); - } - - public SomeDatabaseServiceVertxProxyHandler(Vertx vertx, SomeDatabaseService service, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond); - } - - public SomeDatabaseServiceVertxProxyHandler(Vertx vertx, SomeDatabaseService service, boolean topLevel, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond, false); - } - - public SomeDatabaseServiceVertxProxyHandler(Vertx vertx, SomeDatabaseService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) { - this.vertx = vertx; - this.service = service; - this.includeDebugInfo = includeDebugInfo; - this.timeoutSeconds = timeoutSeconds; - try { - this.vertx.eventBus().registerDefaultCodec(ServiceException.class, - new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) {} - if (timeoutSeconds != -1 && !topLevel) { - long period = timeoutSeconds * 1000 / 2; - if (period > 10000) { - period = 10000; - } - this.timerID = vertx.setPeriodic(period, this::checkTimedOut); - } else { - this.timerID = -1; - } - accessed(); - } - - - private void checkTimedOut(long id) { - long now = System.nanoTime(); - if (now - lastAccessed > timeoutSeconds * 1000000000) { - close(); - } - } - - @Override - public void close() { - if (timerID != -1) { - vertx.cancelTimer(timerID); - } - super.close(); - } - - private void accessed() { - this.lastAccessed = System.nanoTime(); - } - - public void handle(Message msg) { - try{ - JsonObject json = msg.body(); - String action = msg.headers().get("action"); - if (action == null) throw new IllegalStateException("action not specified"); - accessed(); - switch (action) { - case "getDataById": { - service.getDataById(json.getValue("id") == null ? null : (json.getLong("id").intValue())).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); - break; - } - default: throw new IllegalStateException("Invalid action: " + action); - } - } catch (Throwable t) { - if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t))); - else msg.reply(new ServiceException(500, t.getMessage())); - throw t; - } - } -} \ No newline at end of file diff --git a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/reactivex/SomeDatabaseService.java b/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/reactivex/SomeDatabaseService.java deleted file mode 100644 index a87794ba7..000000000 --- a/rxjava-2-examples/src/main/generated/io/vertx/example/reactivex/services/serviceproxy/reactivex/SomeDatabaseService.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2014 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version 2.0 - * (the "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -package io.vertx.example.reactivex.services.serviceproxy.reactivex; - -import io.vertx.reactivex.RxHelper; -import io.vertx.reactivex.ObservableHelper; -import io.vertx.reactivex.FlowableHelper; -import io.vertx.reactivex.impl.AsyncResultMaybe; -import io.vertx.reactivex.impl.AsyncResultSingle; -import io.vertx.reactivex.impl.AsyncResultCompletable; -import io.vertx.reactivex.WriteStreamObserver; -import io.vertx.reactivex.WriteStreamSubscriber; -import java.util.Map; -import java.util.Set; -import java.util.List; -import java.util.Iterator; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import io.vertx.core.Handler; -import io.vertx.core.AsyncResult; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import io.vertx.lang.rx.RxGen; -import io.vertx.lang.rx.TypeArg; -import io.vertx.lang.rx.MappingIterator; - - -@RxGen(io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService.class) -public class SomeDatabaseService { - - @Override - public String toString() { - return delegate.toString(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - SomeDatabaseService that = (SomeDatabaseService) o; - return delegate.equals(that.delegate); - } - - @Override - public int hashCode() { - return delegate.hashCode(); - } - - public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new SomeDatabaseService((io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService) obj), - SomeDatabaseService::getDelegate - ); - - private final io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService delegate; - - public SomeDatabaseService(io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService delegate) { - this.delegate = delegate; - } - - public SomeDatabaseService(Object delegate) { - this.delegate = (io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService)delegate; - } - - public io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService getDelegate() { - return delegate; - } - - - public io.vertx.core.Future getDataById(int id) { - io.vertx.core.Future ret = delegate.getDataById(id).map(val -> val); - return ret; - } - - public io.reactivex.Single rxGetDataById(int id) { - return AsyncResultSingle.toSingle($handler -> { - this.getDataById(id).onComplete($handler); - }); - } - - public static SomeDatabaseService newInstance(io.vertx.example.reactivex.services.serviceproxy.SomeDatabaseService arg) { - return arg != null ? new SomeDatabaseService(arg) : null; - } - -}