Example usage for io.vertx.core Future succeededFuture

List of usage examples for io.vertx.core Future succeededFuture

Introduction

In this page you can find the example usage for io.vertx.core Future succeededFuture.

Prototype

static <T> Future<T> succeededFuture(T result) 

Source Link

Document

Created a succeeded future with the specified result.

Usage

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

License:Apache License

public ProcessService createWithVariables(String processId, JsonObject variables,
        Handler<AsyncResult<ProcessInstanceService>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }// ww w . j  a va 2 s. c om
    JsonObject _json = new JsonObject();
    _json.put("processId", processId);
    _json.put("variables", variables);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "createWithVariables");
    _vertx.eventBus().<ProcessInstanceService>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(ProcessInstanceService.class, _vertx, addr)));
        }
    });
    return this;
}

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

License:Apache License

public ProcessService signalEvent(String eventName, JsonObject data, Handler<AsyncResult<Void>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*  w  ww  .  j  a  v a 2s .  co m*/
    JsonObject _json = new JsonObject();
    _json.put("eventName", eventName);
    _json.put("data", data);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "signalEvent");
    _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.ProcessServiceVertxEBProxy.java

License:Apache License

public ProcessService signalEventForProcess(String eventName, Long processInstanceId, JsonObject data,
        Handler<AsyncResult<Void>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }// www  .  j a  va  2 s . c o m
    JsonObject _json = new JsonObject();
    _json.put("eventName", eventName);
    _json.put("processInstanceId", processInstanceId);
    _json.put("data", data);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "signalEventForProcess");
    _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.ProcessServiceVertxEBProxy.java

License:Apache License

public ProcessService startProcess(String processId, Handler<AsyncResult<ProcessInstanceService>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//  www. j a va 2 s  . c o  m
    JsonObject _json = new JsonObject();
    _json.put("processId", processId);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "startProcess");
    _vertx.eventBus().<ProcessInstanceService>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(ProcessInstanceService.class, _vertx, addr)));
        }
    });
    return this;
}

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

License:Apache License

public ProcessService startProcessWithVariables(String processId, JsonObject jsonObject,
        Handler<AsyncResult<ProcessInstanceService>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/* w w w .  j  av a 2  s . c om*/
    JsonObject _json = new JsonObject();
    _json.put("processId", processId);
    _json.put("jsonObject", jsonObject);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "startProcessWithVariables");
    _vertx.eventBus().<ProcessInstanceService>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(ProcessInstanceService.class, _vertx, addr)));
        }
    });
    return this;
}

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

License:Apache License

public RuleService delete(String factHandle, Handler<AsyncResult<Void>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/* w  w w  .  java  2s . c  o  m*/
    JsonObject _json = new JsonObject();
    _json.put("factHandle", factHandle);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "delete");
    _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.RuleServiceVertxEBProxy.java

License:Apache License

public RuleService fireAllRules(Handler<AsyncResult<Integer>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from   www  .ja v a 2 s  .  c o  m*/
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "fireAllRules");
    _vertx.eventBus().<Integer>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.RuleServiceVertxEBProxy.java

License:Apache License

public RuleService getQueryResults(String queryName, String resultName,
        Handler<AsyncResult<JsonArray>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*w w w.ja  v  a2  s  . c o m*/
    JsonObject _json = new JsonObject();
    _json.put("queryName", queryName);
    _json.put("resultName", resultName);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getQueryResults");
    _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.RuleServiceVertxEBProxy.java

License:Apache License

public RuleService insert(String packageName, String typeName, JsonObject attributes,
        Handler<AsyncResult<String>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//  w  w  w .ja  va2 s. c  o m
    JsonObject _json = new JsonObject();
    _json.put("packageName", packageName);
    _json.put("typeName", typeName);
    _json.put("attributes", attributes);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "insert");
    _vertx.eventBus().<String>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.RuleServiceVertxEBProxy.java

License:Apache License

public RuleService update(String factHandle, String factType, JsonObject attributes,
        Handler<AsyncResult<Void>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//w ww. ja  v a 2  s.co m
    JsonObject _json = new JsonObject();
    _json.put("factHandle", factHandle);
    _json.put("factType", factType);
    _json.put("attributes", attributes);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "update");
    _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;
}