Skip to content

Commit f95db3a

Browse files
committed
- Fixes HTTP/2 Custom Frames example in vertx-core.
- Fixes Net Echo SSL example in vertx-core. - Fixes HTTP/2 Push example error in vertx-core. - Fixes HTTP/2 Simple example bug in vertx-core. - Fixes HTTP HTTPs example bug in vertx-core. - Addes error handling to the HTTP/2 Custom Frames example in vertx-core. - Addes main function for HTTP/2 Simple example in vertx-core. - Removes useless handling for Safari browser for HTTP/2 Push example in vertx-core. - Removes io.vertx.example.core.net.greeter package which is not described in README. - Updates all dependencies of example of vertx-core. - Removes introduction to Groovy verticles. - Remove useless io.netty:netty-tcnative-boringssl-static .
1 parent c264d64 commit f95db3a

File tree

10 files changed

+35
-164
lines changed

10 files changed

+35
-164
lines changed

core-examples/README.adoc

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -464,26 +464,6 @@ Happily served by [email protected]
464464

465465
The verticle has been migrated.
466466

467-
== Groovy verticles
468-
469-
Vert.x supports several _formats_ to develop verticles in Groovy. This link:src/main/groovy/verticles[directory]
470-
illustrates the different formats:
471-
472-
* link:src/main/groovy/verticles/script.groovy[plain script] - a verticle developed as a plain Groovy script
473-
* link:src/main/groovy/verticles/script-with-hooks.groovy[plain script with hooks] - a verticle developed as a script
474-
with hooks called by vert.x when the verticle is deployed and un-deployed
475-
* link:src/main/groovy/verticles/verticle-extending-abstract-verticle.groovy[class extending AbstractVerticle] - a
476-
verticle developed as a class extending `AbstractVerticle`
477-
* link:src/main/groovy/verticles/verticle-extending-groovy-verticle.groovy[class extending GroovyVerticle] - a
478-
verticle developed as a class extending `GroovyVerticle`
479-
480-
You can run these examples using the `vertx` command line. For example:
481-
482-
[source,shell]
483-
----
484-
vertx run script.groovy
485-
----
486-
487467
== JSON streaming parser
488468

489469
A simple example illustrating how to use the streaming `JsonParser` to parse a giant array of small objects.

core-examples/pom.xml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.vertx</groupId>
88
<artifactId>core-examples</artifactId>
9-
<version>4.3.1</version>
9+
<version>4.3.5</version>
1010

1111
<dependencies>
1212

@@ -18,15 +18,8 @@
1818
<dependency>
1919
<groupId>com.fasterxml.jackson.core</groupId>
2020
<artifactId>jackson-annotations</artifactId>
21-
<version>2.11.3</version>
21+
<version>2.14.0</version>
2222
</dependency>
23-
24-
<dependency>
25-
<groupId>io.netty</groupId>
26-
<artifactId>netty-tcnative-boringssl-static</artifactId>
27-
<version>2.0.34.Final</version>
28-
</dependency>
29-
3023
<dependency>
3124
<groupId>io.vertx</groupId>
3225
<artifactId>vertx-hazelcast</artifactId>

core-examples/src/main/java/io/vertx/example/core/http/https/Client.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import io.vertx.core.http.HttpClient;
55
import io.vertx.core.http.HttpClientOptions;
66
import io.vertx.core.http.HttpMethod;
7+
import io.vertx.core.net.JksOptions;
78
import io.vertx.example.util.Runner;
89

910
/*
1011
* @author <a href="http://tfox.org">Tim Fox</a>
12+
* @author linghengqian
1113
*/
1214
public class Client extends AbstractVerticle {
1315

@@ -21,7 +23,9 @@ public void start() throws Exception {
2123

2224
// Note! in real-life you wouldn't often set trust all to true as it could leave you open to man in the middle attacks.
2325

24-
HttpClientOptions options = new HttpClientOptions().setSsl(true).setTrustAll(true);
26+
HttpClientOptions options = new HttpClientOptions().setSsl(true).setTrustAll(true).setKeyStoreOptions(
27+
new JksOptions().setPath("server-keystore.jks").setPassword("wibble")
28+
);
2529
HttpClient client = vertx.createHttpClient(options);
2630
client.request(HttpMethod.GET, 4443, "localhost", "/")
2731
.compose(req -> req.send()

core-examples/src/main/java/io/vertx/example/core/http2/customframes/Client.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
import io.vertx.core.http.HttpClientOptions;
77
import io.vertx.core.http.HttpMethod;
88
import io.vertx.core.http.HttpVersion;
9+
import io.vertx.core.net.PemKeyCertOptions;
910
import io.vertx.example.util.Runner;
1011

1112
/*
1213
* @author <a href="http://tfox.org">Tim Fox</a>
14+
* @author linghengqian
1315
*/
1416
public class Client extends AbstractVerticle {
1517

@@ -27,7 +29,8 @@ public void start() throws Exception {
2729
setSsl(true).
2830
setUseAlpn(true).
2931
setProtocolVersion(HttpVersion.HTTP_2).
30-
setTrustAll(true);
32+
setTrustAll(true).
33+
setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("server-key.pem").setCertPath("server-cert.pem"));
3134

3235
HttpClient client = vertx.createHttpClient(options);
3336

@@ -49,6 +52,6 @@ public void start() throws Exception {
4952
request.writeCustomFrame(10, 0, Buffer.buffer("ping"));
5053
});
5154
});
52-
});
55+
}).onFailure(Throwable::printStackTrace);
5356
}
5457
}

core-examples/src/main/java/io/vertx/example/core/http2/push/Client.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import io.vertx.core.AbstractVerticle;
44
import io.vertx.core.http.*;
5+
import io.vertx.core.net.PemKeyCertOptions;
56
import io.vertx.example.util.Runner;
67

78
/*
89
* @author <a href="http://tfox.org">Tim Fox</a>
10+
* @author linghengqian
911
*/
1012
public class Client extends AbstractVerticle {
1113

@@ -23,11 +25,12 @@ public void start() throws Exception {
2325
setSsl(true).
2426
setUseAlpn(true).
2527
setProtocolVersion(HttpVersion.HTTP_2).
26-
setTrustAll(true);
28+
setTrustAll(true).
29+
setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("server-key.pem").setCertPath("server-cert.pem"));
2730

2831
HttpClient client = vertx.createHttpClient(options);
2932

30-
client.request(HttpMethod.GET, 8080, "localhost", "/").compose(request -> {
33+
client.request(HttpMethod.GET, 8443, "localhost", "/").compose(request -> {
3134

3235
// Set handler for server side push
3336
request.pushHandler(pushedReq -> {

core-examples/src/main/java/io/vertx/example/core/http2/push/Server.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
/*
1212
* @author <a href="http://tfox.org">Tim Fox</a>
13+
* @author linghengqian
1314
*/
1415
public class Server extends AbstractVerticle {
1516

@@ -37,8 +38,6 @@ public void start() throws Exception {
3738
System.out.println("sending push");
3839
HttpServerResponse pushedResp = ar.result();
3940
pushedResp.sendFile("script.js");
40-
} else {
41-
// Sometimes Safari forbids push : "Server push not allowed to opposite endpoint."
4241
}
4342
});
4443

core-examples/src/main/java/io/vertx/example/core/http2/simple/Client.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@
55
import io.vertx.core.http.HttpClientOptions;
66
import io.vertx.core.http.HttpMethod;
77
import io.vertx.core.http.HttpVersion;
8+
import io.vertx.core.net.PemKeyCertOptions;
9+
import io.vertx.example.util.Runner;
810

911
/*
1012
* @author <a href="http://tfox.org">Tim Fox</a>
13+
* @author linghengqian
1114
*/
1215
public class Client extends AbstractVerticle {
1316

17+
// Convenience method so you can run it in your IDE
18+
public static void main(String[] args) {
19+
Runner.runExample(Client.class);
20+
}
21+
1422
@Override
1523
public void start() throws Exception {
1624

@@ -20,16 +28,16 @@ public void start() throws Exception {
2028
setSsl(true).
2129
setUseAlpn(true).
2230
setProtocolVersion(HttpVersion.HTTP_2).
23-
setTrustAll(true);
24-
31+
setTrustAll(true).
32+
setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("server-key.pem").setCertPath("server-cert.pem"));
2533
HttpClient client = vertx.createHttpClient(options);
26-
client.request(HttpMethod.GET, 8080, "localhost", "/")
34+
client.request(HttpMethod.GET, 8443, "localhost", "/")
2735
.compose(req -> req.send()
2836
.compose(resp -> {
2937
System.out.println("Got response " + resp.statusCode());
3038
return resp.body();
3139
})).onSuccess(body -> {
32-
System.out.println("Got data " + body.toString("ISO-8859-1"));
33-
}).onFailure(Throwable::printStackTrace);
40+
System.out.println("Got data " + body.toString("ISO-8859-1"));
41+
}).onFailure(Throwable::printStackTrace);
3442
}
3543
}

core-examples/src/main/java/io/vertx/example/core/net/echossl/Client.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.vertx.example.core.net.echossl;
22

33
import io.vertx.core.AbstractVerticle;
4+
import io.vertx.core.net.JksOptions;
45
import io.vertx.core.net.NetClientOptions;
56
import io.vertx.core.net.NetSocket;
67
import io.vertx.example.util.Runner;
@@ -18,7 +19,9 @@ public static void main(String[] args) {
1819
@Override
1920
public void start() throws Exception {
2021

21-
NetClientOptions options = new NetClientOptions().setSsl(true).setTrustAll(true);
22+
NetClientOptions options = new NetClientOptions().setSsl(true).setTrustAll(true)
23+
.setKeyStoreOptions(new JksOptions().setPath("server-keystore.jks")
24+
.setPassword("wibble"));
2225

2326
vertx.createNetClient(options).connect(1234, "localhost", res -> {
2427
if (res.succeeded()) {

core-examples/src/main/java/io/vertx/example/core/net/greeter/Client.java

Lines changed: 0 additions & 66 deletions
This file was deleted.

core-examples/src/main/java/io/vertx/example/core/net/greeter/Server.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)