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

making it vertx3 3.1.0 compatible #1

Open
wants to merge 1 commit into
base: master
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
71 changes: 3 additions & 68 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
<mods.directory>target/mods</mods.directory>

<!--Dependency versions-->
<vertx.version>2.1.5</vertx.version>
<vertx.version>3.1.0</vertx.version>
<vertx.testtools.version>2.0.3-final</vertx.testtools.version>
<junit.version>4.11</junit.version>
<assertj.version>3.0.0</assertj.version>
<junit.version>4.12</junit.version>
<assertj.version>3.2.0</assertj.version>

<!--Plugin versions-->
<maven.compiler.plugin.version>3.0</maven.compiler.plugin.version>
Expand All @@ -75,12 +75,6 @@
<version>${vertx.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-platform</artifactId>
<version>${vertx.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-hazelcast</artifactId>
Expand Down Expand Up @@ -120,48 +114,6 @@
<build>
<plugins>

<!-- The vert.x Maven plugin -->
<plugin>
<groupId>io.vertx</groupId>
<artifactId>vertx-maven-plugin</artifactId>
<version>${maven.vertx.plugin.version}</version>
<!--
You can specify extra config to the plugin as required here
<configuration>
<configFile>/path/to/MyVerticle.conf</configFile>
<instances>1</instances>
<classpath>src/main/resources/:src/test/resources/:target/classes/:target/test-classes/</classpath>
</configuration>
-->
<!-- Make sure that the plugin uses the vert.x versions from this pom.xml not from its own pom.xml -->
<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-platform</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-hazelcast</artifactId>
<version>${vertx.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>PullInDeps</id>
<phase>prepare-package</phase>
<goals>
<goal>pullInDeps</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Other plugins required by the build -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -278,23 +230,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/mod.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>assemble</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
Expand Down
6 changes: 0 additions & 6 deletions src/main/README.txt

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/assembly/mod.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
package org.simondean.vertx.async;

import org.vertx.java.core.AsyncResult;
import org.vertx.java.core.AsyncResultHandler;
import io.vertx.core.AsyncResult;
import io.vertx.core.AsyncResultHandler;

public class AsyncResultHandlerWrapper<T, R> implements AsyncResultHandler<R> {
private final AsyncResultHandler<T> handler;

public AsyncResultHandlerWrapper(AsyncResultHandler<T> handler) {
this.handler = handler;
}
private final AsyncResultHandler<T> handler;

public static <T, R> AsyncResultHandler<R> wrap(AsyncResultHandler<T> handler) {
return new AsyncResultHandlerWrapper<>(handler);
}
public AsyncResultHandlerWrapper(AsyncResultHandler<T> handler) {
this.handler = handler;
}

@Override
public void handle(AsyncResult<R> asyncResult) {
if (asyncResult.failed()) {
handler.handle(DefaultAsyncResult.fail(asyncResult.cause()));
return;
public static <T, R> AsyncResultHandler<R> wrap(AsyncResultHandler<T> handler) {
return new AsyncResultHandlerWrapper<>(handler);
}

handler.handle(DefaultAsyncResult.succeed((T) asyncResult.result()));
}
@Override
public void handle(AsyncResult<R> asyncResult) {
if (asyncResult.failed()) {
handler.handle(DefaultAsyncResult.fail(asyncResult.cause()));
return;
}

handler.handle(DefaultAsyncResult.succeed((T) asyncResult.result()));
}
}
75 changes: 38 additions & 37 deletions src/main/java/org/simondean/vertx/async/DefaultAsyncResult.java
Original file line number Diff line number Diff line change
@@ -1,53 +1,54 @@
package org.simondean.vertx.async;

import org.vertx.java.core.AsyncResult;
import io.vertx.core.AsyncResult;

public class DefaultAsyncResult<T> implements AsyncResult<T> {
private Throwable cause;
private T result;

public DefaultAsyncResult(Throwable cause, T result) {
this.cause = cause;
this.result = result;
}
private Throwable cause;
private T result;

public static <T> AsyncResult<T> succeed(T result) {
return new DefaultAsyncResult<>(null, result);
}
public DefaultAsyncResult(Throwable cause, T result) {
this.cause = cause;
this.result = result;
}

public static AsyncResult<Void> succeed() {
return succeed(null);
}
public static <T> AsyncResult<T> succeed(T result) {
return new DefaultAsyncResult<>(null, result);
}

public static <T> AsyncResult<T> fail(Throwable cause) {
if (cause == null) {
throw new IllegalArgumentException("cause argument cannot be null");
public static AsyncResult<Void> succeed() {
return succeed(null);
}

return new DefaultAsyncResult<>(cause, null);
}
public static <T> AsyncResult<T> fail(Throwable cause) {
if (cause == null) {
throw new IllegalArgumentException("cause argument cannot be null");
}

public static <T> AsyncResult<T> fail(AsyncResult<?> result) {
return fail(result.cause());
}
return new DefaultAsyncResult<>(cause, null);
}

@Override
public T result() {
return result;
}
public static <T> AsyncResult<T> fail(AsyncResult<?> result) {
return fail(result.cause());
}

@Override
public Throwable cause() {
return cause;
}
@Override
public T result() {
return result;
}

@Override
public boolean succeeded() {
return cause == null;
}
@Override
public Throwable cause() {
return cause;
}

@Override
public boolean succeeded() {
return cause == null;
}

@Override
public boolean failed() {
return cause != null;
}
@Override
public boolean failed() {
return cause != null;
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/simondean/vertx/async/EachBuilder.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.simondean.vertx.async;

import org.vertx.java.core.AsyncResultHandler;
import org.vertx.java.core.Vertx;
import io.vertx.core.AsyncResultHandler;
import io.vertx.core.Vertx;

public interface EachBuilder {
void run(Vertx vertx, AsyncResultHandler<Void> handler);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/simondean/vertx/async/Forever.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.simondean.vertx.async;

import org.vertx.java.core.AsyncResultHandler;
import org.vertx.java.core.Vertx;
import io.vertx.core.AsyncResultHandler;
import io.vertx.core.Vertx;

public interface Forever {
void run(Vertx vertx, AsyncResultHandler<Void> handler);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.simondean.vertx.async;

import org.vertx.java.core.AsyncResultHandler;
import io.vertx.core.AsyncResultHandler;

import java.util.function.Consumer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.simondean.vertx.async;

import org.vertx.java.core.AsyncResultHandler;
import io.vertx.core.AsyncResultHandler;

import java.util.function.BiConsumer;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/simondean/vertx/async/Retry.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.simondean.vertx.async;

import org.vertx.java.core.AsyncResultHandler;
import io.vertx.core.AsyncResultHandler;

public interface Retry<T> {
void run(AsyncResultHandler<T> handler);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/simondean/vertx/async/RetryBuilder.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.simondean.vertx.async;

import org.vertx.java.core.AsyncResultHandler;
import io.vertx.core.AsyncResultHandler;

import java.util.function.Consumer;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/simondean/vertx/async/Series.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.simondean.vertx.async;

import org.vertx.java.core.AsyncResultHandler;
import io.vertx.core.AsyncResultHandler;

import java.util.List;
import java.util.function.Consumer;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/simondean/vertx/async/Waterfall.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.simondean.vertx.async;

import org.vertx.java.core.AsyncResultHandler;
import io.vertx.core.AsyncResultHandler;

import java.util.function.BiConsumer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.simondean.vertx.async;

import org.vertx.java.core.AsyncResultHandler;
import io.vertx.core.AsyncResultHandler;

import java.util.function.Consumer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.simondean.vertx.async.internal;

import org.simondean.vertx.async.Waterfall;
import org.vertx.java.core.AsyncResultHandler;
import io.vertx.core.AsyncResultHandler;

import java.util.function.BiConsumer;
import java.util.function.Consumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import org.simondean.vertx.async.DefaultAsyncResult;
import org.simondean.vertx.async.EachBuilder;
import org.simondean.vertx.async.ObjectWrapper;
import org.vertx.java.core.AsyncResultHandler;
import org.vertx.java.core.Vertx;
import io.vertx.core.AsyncResultHandler;
import io.vertx.core.Vertx;

import java.util.ArrayList;
import java.util.function.BiConsumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.simondean.vertx.async.Forever;
import org.simondean.vertx.async.ForeverBuilder;
import org.vertx.java.core.AsyncResultHandler;
import io.vertx.core.AsyncResultHandler;

import java.util.function.Consumer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import org.simondean.vertx.async.DefaultAsyncResult;
import org.simondean.vertx.async.Forever;
import org.simondean.vertx.async.FunctionWrapper;
import org.vertx.java.core.AsyncResultHandler;
import org.vertx.java.core.Vertx;
import io.vertx.core.AsyncResultHandler;
import io.vertx.core.Vertx;

import java.util.function.Consumer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.simondean.vertx.async.EachBuilder;
import org.simondean.vertx.async.IterableBuilder;
import org.vertx.java.core.AsyncResultHandler;
import io.vertx.core.AsyncResultHandler;

import java.util.function.BiConsumer;

Expand Down
Loading