Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes documentation errors and code errors for vertx-core example #444

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions core-examples/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -464,26 +464,6 @@ Happily served by 97297@Macintosh.local

The verticle has been migrated.

== Groovy verticles

Vert.x supports several _formats_ to develop verticles in Groovy. This link:src/main/groovy/verticles[directory]
illustrates the different formats:

* link:src/main/groovy/verticles/script.groovy[plain script] - a verticle developed as a plain Groovy script
* link:src/main/groovy/verticles/script-with-hooks.groovy[plain script with hooks] - a verticle developed as a script
with hooks called by vert.x when the verticle is deployed and un-deployed
* link:src/main/groovy/verticles/verticle-extending-abstract-verticle.groovy[class extending AbstractVerticle] - a
verticle developed as a class extending `AbstractVerticle`
* link:src/main/groovy/verticles/verticle-extending-groovy-verticle.groovy[class extending GroovyVerticle] - a
verticle developed as a class extending `GroovyVerticle`

You can run these examples using the `vertx` command line. For example:

[source,shell]
----
vertx run script.groovy
----

== JSON streaming parser

A simple example illustrating how to use the streaming `JsonParser` to parse a giant array of small objects.
Expand Down
13 changes: 3 additions & 10 deletions core-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.vertx</groupId>
<artifactId>core-examples</artifactId>
<version>4.3.1</version>
<version>4.3.5</version>

<dependencies>

Expand All @@ -17,16 +17,9 @@
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.11.3</version>
<artifactId>jackson-databind</artifactId>
<version>2.14.0</version>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.34.Final</version>
</dependency>

<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-hazelcast</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.net.JksOptions;
import io.vertx.example.util.Runner;

/*
* @author <a href="http://tfox.org">Tim Fox</a>
* @author linghengqian
*/
public class Client extends AbstractVerticle {

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

// 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.

HttpClientOptions options = new HttpClientOptions().setSsl(true).setTrustAll(true);
HttpClientOptions options = new HttpClientOptions().setSsl(true).setTrustAll(true).setKeyStoreOptions(
new JksOptions().setPath("server-keystore.jks").setPassword("wibble")
);
HttpClient client = vertx.createHttpClient(options);
client.request(HttpMethod.GET, 4443, "localhost", "/")
.compose(req -> req.send()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpVersion;
import io.vertx.core.net.PemKeyCertOptions;
import io.vertx.example.util.Runner;

/*
* @author <a href="http://tfox.org">Tim Fox</a>
* @author linghengqian
*/
public class Client extends AbstractVerticle {

Expand All @@ -27,7 +29,8 @@ public void start() throws Exception {
setSsl(true).
setUseAlpn(true).
setProtocolVersion(HttpVersion.HTTP_2).
setTrustAll(true);
setTrustAll(true).
setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("server-key.pem").setCertPath("server-cert.pem"));

HttpClient client = vertx.createHttpClient(options);

Expand All @@ -49,6 +52,6 @@ public void start() throws Exception {
request.writeCustomFrame(10, 0, Buffer.buffer("ping"));
});
});
});
}).onFailure(Throwable::printStackTrace);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import io.vertx.core.AbstractVerticle;
import io.vertx.core.http.*;
import io.vertx.core.net.PemKeyCertOptions;
import io.vertx.example.util.Runner;

/*
* @author <a href="http://tfox.org">Tim Fox</a>
* @author linghengqian
*/
public class Client extends AbstractVerticle {

Expand All @@ -23,11 +25,12 @@ public void start() throws Exception {
setSsl(true).
setUseAlpn(true).
setProtocolVersion(HttpVersion.HTTP_2).
setTrustAll(true);
setTrustAll(true).
setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("server-key.pem").setCertPath("server-cert.pem"));

HttpClient client = vertx.createHttpClient(options);

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

// Set handler for server side push
request.pushHandler(pushedReq -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

/*
* @author <a href="http://tfox.org">Tim Fox</a>
* @author linghengqian
*/
public class Server extends AbstractVerticle {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpVersion;
import io.vertx.core.net.PemKeyCertOptions;
import io.vertx.example.util.Runner;

/*
* @author <a href="http://tfox.org">Tim Fox</a>
* @author linghengqian
*/
public class Client extends AbstractVerticle {

// Convenience method so you can run it in your IDE
public static void main(String[] args) {
Runner.runExample(Client.class);
}

@Override
public void start() throws Exception {

Expand All @@ -20,16 +28,16 @@ public void start() throws Exception {
setSsl(true).
setUseAlpn(true).
setProtocolVersion(HttpVersion.HTTP_2).
setTrustAll(true);

setTrustAll(true).
setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("server-key.pem").setCertPath("server-cert.pem"));
HttpClient client = vertx.createHttpClient(options);
client.request(HttpMethod.GET, 8080, "localhost", "/")
client.request(HttpMethod.GET, 8443, "localhost", "/")
.compose(req -> req.send()
.compose(resp -> {
System.out.println("Got response " + resp.statusCode());
return resp.body();
})).onSuccess(body -> {
System.out.println("Got data " + body.toString("ISO-8859-1"));
}).onFailure(Throwable::printStackTrace);
System.out.println("Got data " + body.toString("ISO-8859-1"));
}).onFailure(Throwable::printStackTrace);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.vertx.example.core.net.echossl;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.net.JksOptions;
import io.vertx.core.net.NetClientOptions;
import io.vertx.core.net.NetSocket;
import io.vertx.example.util.Runner;
Expand All @@ -18,7 +19,9 @@ public static void main(String[] args) {
@Override
public void start() throws Exception {

NetClientOptions options = new NetClientOptions().setSsl(true).setTrustAll(true);
NetClientOptions options = new NetClientOptions().setSsl(true).setTrustAll(true)
.setKeyStoreOptions(new JksOptions().setPath("server-keystore.jks")
.setPassword("wibble"));

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

This file was deleted.

This file was deleted.