Example usage for io.vertx.core Future failedFuture

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

Introduction

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

Prototype

static <T> Future<T> failedFuture(String failureMessage) 

Source Link

Document

Create a failed future with the specified failure message.

Usage

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

License:Apache License

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

License:Apache License

public ProcessInstanceService abort(Handler<AsyncResult<Void>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from w  ww  . j a va2  s  .co m
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "abort");
    _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.ProcessInstanceServiceVertxEBProxy.java

License:Apache License

public ProcessInstanceService start(Handler<AsyncResult<Long>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from  w  w  w . j a  v a2s  .c o  m
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "start");
    _vertx.eventBus().<Long>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.ProcessInstanceServiceVertxEBProxy.java

License:Apache License

public ProcessInstanceService getInstanceId(Handler<AsyncResult<Long>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from 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", "getInstanceId");
    _vertx.eventBus().<Long>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.ProcessInstanceServiceVertxEBProxy.java

License:Apache License

public ProcessInstanceService getName(Handler<AsyncResult<String>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from www  .  ja va 2 s  .  c o  m
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getName");
    _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.ProcessInstanceServiceVertxEBProxy.java

License:Apache License

public ProcessInstanceService getParentInstanceId(Handler<AsyncResult<Long>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }// w  w w  .  j ava 2  s  .c  om
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getParentInstanceId");
    _vertx.eventBus().<Long>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.ProcessInstanceServiceVertxEBProxy.java

License:Apache License

public ProcessInstanceService getState(Handler<AsyncResult<ProcessState>> 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", "getState");
    _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() == null ? null : ProcessState.valueOf(res.result().body())));
        }
    });
    return this;
}

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

License:Apache License

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