|
| 1 | +# Upgrading from version 3 to 4 |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +With the release of Vert.x 5, important API changes were made, sometimes breaking the compability with Vert.x 4.x projects. It was an opportunity to release a new version of the generator. This guide will walk through the changes between the Mutiny Vert.x bindings for Vert.x 4 and Vert.x 5. |
| 6 | + |
| 7 | +## A new Mutiny bindings generator |
| 8 | +In its 3.x version, the Vert.x-mutiny bindings generator was an annotation processor. It was executed on a given module by using the `maven-processor-plugin`. |
| 9 | +As an annotation processor, it can only be run during maven compilation. Generating bindings thus requires compiling or recompiling the sources. |
| 10 | +The new approach still uses annotations to detect which classes and interfaces must be generated, but annotation processing is now part of a full CLI possessing its own `Main` class and its own lifecycle independent from that of the sources. |
| 11 | +This makes it easier to test and faster to run. |
| 12 | + |
| 13 | +## API changes |
| 14 | +Numerous API changes are due to the transition to Vert.x 5. |
| 15 | +The Vert.x 4 to 5 migration guide is available at <https://vertx.io/docs/guides/vertx-5-migration-guide/>. |
| 16 | + |
| 17 | +We provide here a brief summary of the breaking changes, the exhaustive list can be found [in a compatibility report detailing every API change](compatibility-report-3-to-4.html). |
| 18 | + |
| 19 | +### Generics are better specified |
| 20 | +In version 3 of the bindings generator, several generics were left unspecified. We changed this behavior so that every generics used is either correctly specified or uses a wildcard. |
| 21 | +See the [full compatibility report](compatibility-report-3-to-4.html) for more information. |
| 22 | + |
| 23 | +### No more Callbacks |
| 24 | + |
| 25 | +Complete removal of callback methods such as: |
| 26 | + ```java |
| 27 | +void request(RequestOptions request, Handler<AsyncResult<HttpClientRequest>> callback); |
| 28 | + ``` |
| 29 | + |
| 30 | +They have all been replaced with a Future such as: |
| 31 | +```java |
| 32 | +Future<HttpClientRequest> request(RequestOptions request); |
| 33 | +``` |
| 34 | + |
| 35 | +Consequently, the bindings generator only supports the `Future` style and will generate the following: |
| 36 | +```java |
| 37 | +Uni<HttpClientRequest> request(RequestOptions request); |
| 38 | +``` |
| 39 | + |
| 40 | +### Deprecated modules are no more |
| 41 | +| Sunsetting in 4.x | Replacement in 5.x | |
| 42 | +|-----------------------|-----------------------------------------------------------------------------------| |
| 43 | +| Vert.x Sync | Vert.x virtual threads | |
| 44 | +| Service Factories | None | |
| 45 | +| Maven Service Factory | None | |
| 46 | +| HTTP Service Factory | None | |
| 47 | +| Vert.x Web OpenAPI | [Vert.x Web OpenAPI Router](https://vertx.io/docs/vertx-web-openapi-router/java/) | |
| 48 | +| Vert.x CLI | None | |
| 49 | + |
| 50 | + |
| 51 | +### Changes with regards to `@DataObject` and `@VertxGen` |
| 52 | +Numerous classes are now annotated `@DataObject` instead of `@VertxGen`. `@DataObject` annotation existed in Vert.x 4.x and was used mainly for `*Options.java` classes. No wrappers are thus required, the core Vert.x interface is used directly. They will break existing projects as imports are now invalid. |
| 53 | + |
| 54 | +Below are some classes that are not converted to Mutiny shims anymore: |
| 55 | + |
| 56 | +- `io.vertx.core.buffer.Buffer` |
| 57 | +- `io.vertx.core.net.Address` |
| 58 | +- `io.vertx.core.net.SocketAddress` |
| 59 | +- `io.vertx.core.parsetools.JsonEvent` |
| 60 | +- `io.vertx.core.MultiMap` |
| 61 | +- `io.vertx.core.datagram.DatagramPacket` |
| 62 | + |
| 63 | +### SQL clients have been reworked |
| 64 | +In Vert.x 4, `Pool` subtypes were used for every kind of databases: `PgPool, MySQLPool, MSSQLPool`, etc. They have all been removed and replaced with client builder subtypes: |
| 65 | + |
| 66 | +```java |
| 67 | +// 4.x |
| 68 | +PgPool client = PgPool.pool(vertx, connectOptions, poolOptions); |
| 69 | + |
| 70 | +//5.0 |
| 71 | +Pool client = PgBuilder.pool() |
| 72 | + .with(poolOptions) |
| 73 | + .connectingTo(connectOptions) |
| 74 | + .using(vertx) |
| 75 | + .build(); |
| 76 | +``` |
| 77 | + |
| 78 | +For more information, see [Vert.x 5 migration guide](https://vertx.io/docs/guides/vertx-5-migration-guide/#_vert_x_sql_client). |
| 79 | + |
| 80 | +## Dropped or replaced modules |
| 81 | + |
| 82 | +| Module | Replacement | |
| 83 | +| ------------------- | ----------------------------- | |
| 84 | +| service-discovery-* | *dropped* | |
| 85 | +| web-openapi | (openapi, web-openapi-router) | |
| 86 | +| web-auth-shiro | *dropped* | |
| 87 | +| web-auth-webauthn | web-auth-webauthn4j | |
| 88 | +| auth-jdbc | *dropped* | |
| 89 | +| jdbc-client | *dropped* | |
| 90 | +| web-api-contract | *dropped* | |
| 91 | +| web-templ-jade | *dropped* | |
| 92 | +| stomp | *dropped* | |
| 93 | +| shell | *dropped* | |
| 94 | + |
| 95 | + |
| 96 | +## Using the generator with your own asynchronous APIs |
| 97 | +[Learn how to use the bindings generator with your own asynchronous APIs](using-the-generator.md). |
0 commit comments