Skip to content

Commit 1a28a6f

Browse files
committed
Migrate to VerticleBase in module examples
See vert-x3/issues#649 There still are some examples with AbstractVerticle, but they don't need to migrated: either the start method is synchronous or pseudo-synchronous (virtual threads). Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
1 parent 14e9377 commit 1a28a6f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

vertx-core/src/main/asciidoc/index.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,15 @@ will automatically stop any running server when the verticle is un-deployed.
322322

323323
=== What happened to Vert.x 4 Verticle and AbstractVerticle contracts?
324324

325-
The contract defined by `Verticle` and `AbstractVerticle` was not adapted anymore to Vert.x 5 future based model
325+
The contract defined by `Verticle` and `AbstractVerticle` wasn't convenient anymore with Vert.x 5 future based model:
326326

327327
[source,java]
328328
----
329329
{@link examples.CoreExamples#verticleContract}
330330
----
331331

332-
`Verticle` and `AbstractVerticle` are not deprecated in Vert.x 5 and it is fine to use them, however it is not the default
333-
recommended choice anymore.
332+
Nevertheless, `Verticle` and `AbstractVerticle` are not deprecated in Vert.x 5.
333+
It is fine to use them, however it is not the default recommended choice anymore.
334334

335335
=== Verticle Types
336336

vertx-core/src/main/java/examples/NetExamples.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
package examples;
1313

1414
import io.netty.handler.logging.ByteBufFormat;
15-
import io.vertx.core.*;
15+
import io.vertx.core.DeploymentOptions;
16+
import io.vertx.core.Future;
17+
import io.vertx.core.VerticleBase;
18+
import io.vertx.core.Vertx;
1619
import io.vertx.core.buffer.Buffer;
1720
import io.vertx.core.http.ClientAuth;
1821
import io.vertx.core.http.HttpServer;
@@ -172,20 +175,20 @@ public void example10(NetSocket socket) {
172175

173176
public void example11(Vertx vertx) {
174177

175-
class MyVerticle extends AbstractVerticle {
178+
class MyVerticle extends VerticleBase {
176179

177180
NetServer server;
178181

179182
@Override
180-
public void start() throws Exception {
183+
public Future<?> start() {
181184
server = vertx.createNetServer();
182185
server.connectHandler(socket -> {
183186
socket.handler(buffer -> {
184187
// Just echo back the data
185188
socket.write(buffer);
186189
});
187190
});
188-
server.listen(1234, "localhost");
191+
return server.listen(1234, "localhost");
189192
}
190193
}
191194

0 commit comments

Comments
 (0)