List of usage examples for io.vertx.core Future succeededFuture
static <T> Future<T> succeededFuture()
From source file:de.braintags.netrelay.controller.persistence.PersistenceController.java
License:Open Source License
/** * @param context/*from w w w . j a va 2 s.com*/ * @param resolvedCaptureCollections * @param handler */ private void handlePersistence(RoutingContext context, List<CaptureMap> resolvedCaptureCollections, Handler<AsyncResult<Void>> handler) { CounterObject<Void> co = new CounterObject<>(resolvedCaptureCollections.size(), handler); for (CaptureMap map : resolvedCaptureCollections) { handle(context, map, result -> { if (result.failed()) { co.setThrowable(result.cause()); } else { if (co.reduce()) { handler.handle(Future.succeededFuture()); } } }); if (co.isError()) { break; } } }
From source file:de.braintags.netrelay.mapping.NetRelayStoreObject.java
License:Open Source License
protected void finishToEntity(T tmpObject, Handler<AsyncResult<Void>> handler) { this.entity = tmpObject; try {/*from w w w .j a v a2 s . co m*/ handler.handle(Future.succeededFuture()); } catch (Exception e) { handler.handle(Future.failedFuture(e)); } }
From source file:de.braintags.netrelay.mapping.NetRelayStoreObject.java
License:Open Source License
/** * Iterate the fields if the mapper and - if a content exists in the current data - * add the new value into the entity//from ww w .ja va 2 s . co m * * @param tmpObject * @param handler */ protected final void iterateFields(T tmpObject, Handler<AsyncResult<Void>> handler) { LOGGER.debug("start iterateFields"); Set<String> fieldNames = getMapper().getFieldNames(); CounterObject<Void> co = new CounterObject<>(fieldNames.size(), handler); for (String fieldName : fieldNames) { IField field = getMapper().getField(fieldName); if (hasProperty(field)) { LOGGER.debug("handling field " + field.getFullName()); field.getPropertyMapper().fromStoreObject(tmpObject, this, field, result -> { if (result.failed()) { co.setThrowable(result.cause()); return; } if (co.reduce()) { LOGGER.debug("field counter finished"); handler.handle(Future.succeededFuture()); } }); } else { if (co.reduce()) { LOGGER.debug("field counter finished"); handler.handle(Future.succeededFuture()); } } } }
From source file:de.braintags.netrelay.mapping.NetRelayStoreObject.java
License:Open Source License
protected void iterateObjectReferences(Object tmpObject, Handler<AsyncResult<Void>> handler) { LOGGER.debug("start iterateObjectReferences"); if (getObjectReferences().isEmpty()) { LOGGER.debug("nothing to do"); handler.handle(Future.succeededFuture()); return;/*w w w .j a v a2 s .c o m*/ } Collection<IObjectReference> refs = getObjectReferences(); CounterObject<Void> co = new CounterObject<>(refs.size(), handler); for (IObjectReference ref : refs) { LOGGER.debug("handling object reference " + ref.getField().getFullName()); ref.getField().getPropertyMapper().fromObjectReference(tmpObject, ref, result -> { if (result.failed()) { co.setThrowable(result.cause()); return; } if (co.reduce()) { LOGGER.debug("object references finished"); handler.handle(Future.succeededFuture()); } }); } }
From source file:de.braintags.netrelay.mapping.NetRelayStoreObject.java
License:Open Source License
/** * Initialize the internal entity into the StoreObject * /*from ww w . java 2 s .c o m*/ * @param handler */ public void initFromEntity(Handler<AsyncResult<Void>> handler) { CounterObject<Void> co = new CounterObject<>(mapper.getFieldNames().size(), handler); for (String fieldName : mapper.getFieldNames()) { IField field = mapper.getField(fieldName); field.getPropertyMapper().intoStoreObject(entity, this, field, result -> { if (result.failed()) { co.setThrowable(result.cause()); } else { if (co.reduce()) handler.handle(Future.succeededFuture()); } }); if (co.isError()) { return; } } }
From source file:de.braintags.netrelay.NetRelay.java
License:Open Source License
/** * Initialize all needed resources of NetRelay * // w ww . j av a 2s. c o m * @param handler */ protected void init(Handler<AsyncResult<Void>> handler) { try { router = Router.router(vertx); mapperFactory = new NetRelayMapperFactory(this); initMailClient(); initController(router); initProcessors(); initHttpServer(router, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { initHttpsServer(router, httpsResult -> { if (httpsResult.failed()) { handler.handle(Future.failedFuture(httpsResult.cause())); } else { handler.handle(Future.succeededFuture()); } }); } }); } catch (Exception e) { handler.handle(Future.failedFuture(e)); } }
From source file:de.braintags.netrelay.NetRelay.java
License:Open Source License
/** * Create an instance of {@link IDataStore} which will be used by the current instance of NetRelay. * The init is performed by using the {@link Settings#getDatastoreSettings()} * /* w w w. j a v a2s . c o m*/ * @handler the handler to be informed * @return the {@link IDataStore} to be used * @throws IllegalAccessException * @throws InstantiationException */ public final void initDataStore(Handler<AsyncResult<Void>> handler) throws InstantiationException, IllegalAccessException { IDataStoreInit dsInit = settings.getDatastoreSettings().getDatastoreInit().newInstance(); dsInit.initDataStore(vertx, settings.getDatastoreSettings(), dsInitResult -> { if (dsInitResult.failed()) { handler.handle(Future.failedFuture(dsInitResult.cause())); } else { datastore = dsInitResult.result(); handler.handle(Future.succeededFuture()); } }); }
From source file:de.braintags.netrelay.NetRelay.java
License:Open Source License
private void initHttpServer(Router router, Handler<AsyncResult<Void>> handler) { HttpServerOptions options = new HttpServerOptions().setPort(settings.getServerPort()); HttpServer server = vertx.createHttpServer(options); server.requestHandler(router::accept).listen(result -> { if (result.failed()) { handler.handle(Future.failedFuture(result.cause())); } else {//from w ww. ja v a2 s. c o m handler.handle(Future.succeededFuture()); } }); }
From source file:de.braintags.netrelay.NetRelay.java
License:Open Source License
private void initHttpsServer(Router router, Handler<AsyncResult<Void>> handler) { if (settings.getSslPort() > 0) { LOGGER.info("launching ssl server listening on port " + settings.getSslPort()); HttpServerOptions options = new HttpServerOptions().setPort(settings.getSslPort()); options.setSsl(true);//from w ww. j a v a 2s . c o m try { handleSslCertificate(options, handler); HttpServer server = vertx.createHttpServer(options); server.requestHandler(router::accept).listen(result -> { if (result.failed()) { handler.handle(Future.failedFuture(result.cause())); } else { handler.handle(Future.succeededFuture()); } }); } catch (Exception e) { handler.handle(Future.failedFuture(e)); } } else { LOGGER.info("no ssl server is launched, cause ssl port is not set: " + settings.getSslPort()); handler.handle(Future.succeededFuture()); } }
From source file:io.apiman.gateway.engine.vertx.polling.fetchers.auth.BasicAuth.java
License:Apache License
@Override public Authenticator authenticate(Vertx vertx, Map<String, String> config, MultiMap headerMap, Handler<AsyncResult<Void>> resultHandler) { headerMap.set("Authorization", Basic.encode(config.get("username"), config.get("password"))); resultHandler.handle(Future.succeededFuture()); return this; }