Skip to content

Commit

Permalink
Merge pull request #461 from vert-x3/jpms-integration
Browse files Browse the repository at this point in the history
Enable JPMS module
  • Loading branch information
vietj authored Oct 29, 2024
2 parents cdaacad + 632ce49 commit 3506a74
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 396 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
34 changes: 29 additions & 5 deletions jpms-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<protoc.version>4.27.2</protoc.version>
<testcontainers.version>1.20.1</testcontainers.version>
<native.transport></native.transport>
<osx.arch>aarch64</osx.arch>
<osx.arch>aarch_64</osx.arch>
</properties>

<repositories>
Expand Down Expand Up @@ -130,8 +130,6 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<classifier>osx-${osx.arch}</classifier>
<version>4.2.0.Alpha4</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -161,7 +159,7 @@

<profiles>
<profile>
<id>mac</id>
<id>Mac</id>
<activation>
<os>
<family>mac</family>
Expand All @@ -172,14 +170,40 @@
<osx.arch>${os.detected.arch}</osx.arch>
</properties>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<classifier>osx-${osx.arch}</classifier>
<version>4.2.0.Alpha5</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<classifier>osx-${osx.arch}</classifier>
<version>4.2.0.Alpha4</version>
<version>4.2.0.Alpha5</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>Linux</id>
<activation>
<os>
<family>linux</family>
</os>
</activation>
<properties>
<native.transport>epoll</native.transport>
</properties>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-${os.detected.arch}</classifier>
<version>4.2.0.Alpha5</version>
</dependency>
</dependencies>
</profile>

</profiles>

<build>
Expand Down
32 changes: 15 additions & 17 deletions jpms-examples/src/main/java/io/vertx/example/jpms/grpc/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -21,14 +18,9 @@ public static void main(String[] args) {
}

@Override
public void start(Promise<Void> 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<HelloReply> sayHello(HelloRequest request) {
Expand All @@ -40,10 +32,16 @@ public Future<HelloReply> sayHello(HelloRequest request) {
}
};
api.bind_sayHello(grpcServer);
server
.requestHandler(grpcServer)
.listen(8080)
.<Void>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);
}
}
24 changes: 12 additions & 12 deletions jpms-examples/src/main/java/io/vertx/example/jpms/http/Server.java
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -15,15 +13,17 @@ public static void main(String[] args) {
}

@Override
public void start(Promise<Void> 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)
.<Void>mapEmpty()
.onComplete(startFuture);
req.response().end(new JsonObject()
.put("http", req.version())
.put("message", "Hello World")
.toString());
});

return server.listen(8080);
}
}
29 changes: 14 additions & 15 deletions jpms-examples/src/main/java/io/vertx/example/jpms/http2/Server.java
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -17,20 +15,21 @@ public static void main(String[] args) {
}

@Override
public void start(Promise<Void> 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)
.<Void>mapEmpty()
.onComplete(startFuture);
});

return server.listen(8443);
}
}
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -22,16 +19,17 @@ public static void main(String[] args) {
}

@Override
public void start(Promise<Void> 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)
.<Void>mapEmpty()
.onComplete(startFuture);
});

return server.listen(8080);
}
}
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -19,21 +16,24 @@ public static void main(String[] args) {
}

@Override
public void start(Promise<Void> 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)
.<Void>mapEmpty()
.onComplete(startFuture);
});

return server.listen(8443);
}
}
Original file line number Diff line number Diff line change
@@ -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 <a href="mailto:[email protected]">Paulo Lopes</a>
*/
public class Client extends AbstractVerticle {
public class Client extends VerticleBase {

private PgConnectOptions database;
private HttpServer server;
Expand All @@ -30,8 +24,7 @@ public Client(PgConnectOptions database) {
this.database = database;
}

@Override
public void start(Promise<Void> start) {
public Future<?> start() {
client = PgBuilder.pool()
.connectingTo(database)
.using(vertx)
Expand All @@ -56,8 +49,6 @@ public void start(Promise<Void> start) {
});
});

server.listen(8080)
.<Void>mapEmpty()
.onComplete(start);
return server.listen(8080);
}
}
1 change: 1 addition & 0 deletions jpms-examples/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
requires jdk.crypto.ec;

exports io.vertx.example.jpms.sqlclient;
exports io.vertx.example.jpms.native_transport;

}
Loading

0 comments on commit 3506a74

Please sign in to comment.