Example usage for io.vertx.core.eventbus DeliveryOptions DeliveryOptions

List of usage examples for io.vertx.core.eventbus DeliveryOptions DeliveryOptions

Introduction

In this page you can find the example usage for io.vertx.core.eventbus DeliveryOptions DeliveryOptions.

Prototype

public DeliveryOptions(JsonObject json) 

Source Link

Document

Create a delivery options from JSON

Usage

From source file:cm.study.vertx.database.WikiDatabaseServiceVertxEBProxy.java

License:Apache License

public WikiDatabaseService fetchAllPages(Handler<AsyncResult<JsonArray>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from  ww w  .j  a  v  a2 s . com
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "fetchAllPages");
    _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:com.appdocker.iop.InternetOfPeopleServiceVertxEBProxy.java

License:Apache License

public void hello(String message, Handler<AsyncResult<String>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//  w ww. java 2 s.  c  o m
    }
    JsonObject _json = new JsonObject();
    _json.put("message", message);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "hello");
    _vertx.eventBus().<String>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.appdocker.iop.InternetOfPeopleServiceVertxEBProxy.java

License:Apache License

public void close() {
    if (closed) {
        throw new IllegalStateException("Proxy is closed");
    }/*from  w  w  w .  ja  v  a 2 s  . co m*/
    closed = true;
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "close");
    _vertx.eventBus().send(_address, _json, _deliveryOptions);
}

From source file:com.diabolicallabs.process.manager.service.KnowledgeServiceFactoryVertxEBProxy.java

License:Apache License

public KnowledgeServiceFactory getKnowledgeService(Handler<AsyncResult<KnowledgeService>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }// w w w  . j  a va2s  . c o  m
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getKnowledgeService");
    _vertx.eventBus().<KnowledgeService>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            String addr = res.result().headers().get("proxyaddr");
            handler.handle(
                    Future.succeededFuture(ProxyHelper.createProxy(KnowledgeService.class, _vertx, addr)));
        }
    });
    return this;
}

From source file:com.diabolicallabs.process.manager.service.KnowledgeServiceVertxEBProxy.java

License:Apache License

public KnowledgeService addClassPathResource(String resourceName, Handler<AsyncResult<Void>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }// w ww .j  a v  a 2 s.  c om
    JsonObject _json = new JsonObject();
    _json.put("resourceName", resourceName);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "addClassPathResource");
    _vertx.eventBus().<Void>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            handler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:com.diabolicallabs.process.manager.service.KnowledgeServiceVertxEBProxy.java

License:Apache License

public KnowledgeService addFileResource(String fileName, Handler<AsyncResult<Void>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from  www .  ja v  a2  s.com*/
    JsonObject _json = new JsonObject();
    _json.put("fileName", fileName);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "addFileResource");
    _vertx.eventBus().<Void>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            handler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:com.diabolicallabs.process.manager.service.KnowledgeServiceVertxEBProxy.java

License:Apache License

public KnowledgeService processDefinitions(Handler<AsyncResult<JsonArray>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from w w  w .j a v  a  2  s  .  c  o m*/
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "processDefinitions");
    _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            handler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:com.diabolicallabs.process.manager.service.KnowledgeServiceVertxEBProxy.java

License:Apache License

public KnowledgeService getProcessService(Handler<AsyncResult<ProcessService>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*  w  w w . j a v a  2 s  .  c  om*/
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getProcessService");
    _vertx.eventBus().<ProcessService>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            String addr = res.result().headers().get("proxyaddr");
            handler.handle(Future.succeededFuture(ProxyHelper.createProxy(ProcessService.class, _vertx, addr)));
        }
    });
    return this;
}

From source file:com.diabolicallabs.process.manager.service.KnowledgeServiceVertxEBProxy.java

License:Apache License

public KnowledgeService getRuleService(Handler<AsyncResult<RuleService>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }// w  w  w .j av a  2  s.  co m
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getRuleService");
    _vertx.eventBus().<RuleService>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            String addr = res.result().headers().get("proxyaddr");
            handler.handle(Future.succeededFuture(ProxyHelper.createProxy(RuleService.class, _vertx, addr)));
        }
    });
    return this;
}

From source file:com.diabolicallabs.process.manager.service.KnowledgeServiceVertxEBProxy.java

License:Apache License

public KnowledgeService getTaskService(Handler<AsyncResult<TaskService>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//w w w.j  ava  2  s. c  o m
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getTaskService");
    _vertx.eventBus().<TaskService>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            String addr = res.result().headers().get("proxyaddr");
            handler.handle(Future.succeededFuture(ProxyHelper.createProxy(TaskService.class, _vertx, addr)));
        }
    });
    return this;
}