Vert.x Hessian service verticle

The approach to calling Hessain service implementation by Vert.x

Лицензия

Лицензия

Группа

Группа

org.jmmo
Идентификатор

Идентификатор

vertx-hessian
Последняя версия

Последняя версия

1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Vert.x Hessian service verticle
The approach to calling Hessain service implementation by Vert.x
Ссылка на сайт

Ссылка на сайт

https://github.com/Megaprog/vertx-hessian
Система контроля версий

Система контроля версий

https://github.com/Megaprog/vertx-hessian

Скачать vertx-hessian

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.jmmo/vertx-hessian/ -->
<dependency>
    <groupId>org.jmmo</groupId>
    <artifactId>vertx-hessian</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.jmmo/vertx-hessian/
implementation 'org.jmmo:vertx-hessian:1.0'
// https://jarcasting.com/artifacts/org.jmmo/vertx-hessian/
implementation ("org.jmmo:vertx-hessian:1.0")
'org.jmmo:vertx-hessian:jar:1.0'
<dependency org="org.jmmo" name="vertx-hessian" rev="1.0">
  <artifact name="vertx-hessian" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.jmmo', module='vertx-hessian', version='1.0')
)
libraryDependencies += "org.jmmo" % "vertx-hessian" % "1.0"
[org.jmmo/vertx-hessian "1.0"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
com.caucho : hessian jar 4.0.38
io.vertx : vertx-core jar 3.1.0

Модули Проекта

Данный проект не имеет модулей.

Asynchronous Hessian

The approach to export Hessian service through Vert.x Verticle

How to get it?

You can use it as a maven dependency:

<dependency>
    <groupId>org.jmmo</groupId>
    <artifactId>vertx-hessian</artifactId>
    <version>1.0</version>
</dependency>

Or download the latest build at: https://github.com/megaprog/vertx-hessian/releases

How to use it?

Create client interface:

public interface HessianServiceInterface {

    Integer synchronousCall();

    Integer asynchronousCall();
}

Create server interface with same method signatures as in client one but asynchronous methods must return CompletableFuture:

public interface HessianServiceInterfaceAsync {

    Integer synchronousCall();

    CompletableFuture<Integer> asynchronousCall();
}

Implement server asynchronous interface:

public class HessianServiceInterfaceAsyncImpl implements HessianServiceInterfaceAsync {
    private static final Logger log = Logger.getLogger(HessianServiceInterfaceAsyncImpl.class.getName());

    @Override
    public Integer synchronousCall() {
        log.info(() -> "Calling from http processing thread");
        return 1;
    }

    @Override
    public CompletableFuture<Integer> asynchronousCall() {
        return CompletableFuture.supplyAsync(() -> {
            log.info(() -> "Calling from ForkJoinPool thread");
            return 2;
        });
    }
}

Server:

public class ExampleHessianVerticleServer extends AbstractHessianVerticleServer {

    @Override
    public Class<?> getApiClass() {
        return HessianServiceInterfaceAsync.class;
    }

    @Override
    protected Object createService() {
        return new HessianServiceInterfaceAsyncImpl();
    }
}

Client:

public class Client {
    protected static final String SERVICE_URL = "http://localhost:8080";

    public static void main(String[] args) {
        final HessianServiceInterface hessianService = hessianService();

        System.out.println("synchronous method calling result is " + hessianService.synchronousCall());
        System.out.println("asynchronous method calling result is " + hessianService.asynchronousCall());
    }

    protected static HessianServiceInterface hessianService() {
        try {
            return (HessianServiceInterface) new HessianProxyFactory().create(HessianServiceInterface.class, SERVICE_URL);
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }
}

See more at client-server example: https://github.com/Megaprog/vertx-hessian/tree/master/example

Версии библиотеки

Версия
1.0