HttpClient client = reference.get(); System.out.println("Consuming \"" + record2.getName() + "\"");
/** * Gets the object to access the service. It can be a proxy, a client or whatever object. The type depends on the * service type and the server itself. This method returns the Java version and primary facet of the object, use * {@link io.vertx.rxjava.servicediscovery.ServiceReference#getAs} to retrieve the polyglot instance of the object or another facet.. * @return the object to access the service */ public <T> T get() { T ret = (T) delegate.get(); return ret; }
/** * Gets the object to access the service. It can be a proxy, a client or whatever object. The type depends on the * service type and the server itself. This method returns the Java version and primary facet of the object, use * {@link io.vertx.rxjava.servicediscovery.ServiceReference#getAs} to retrieve the polyglot instance of the object or another facet.. * @return the object to access the service */ public <T> T get() { T ret = (T) delegate.get(); return ret; }
public static <T>java.lang.Object get(io.vertx.servicediscovery.ServiceReference j_receiver) { return io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.get()); } public static <X>java.lang.Object getAs(io.vertx.servicediscovery.ServiceReference j_receiver, java.lang.Class<java.lang.Object> x) {
/** * Convenient method that looks for a JDBC datasource source and provides the configured {@link io.vertx.ext.jdbc.JDBCClient}. The * async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */ static void getJDBCClient(ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<JDBCClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<JDBCClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a Redis data source and provides the configured {@link io.vertx.redis.RedisClient}. * The async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, cannot be {@code null} * @param resultHandler The result handler */ static void getRedisClient(ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<RedisClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<RedisClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a HTTP endpoint and provides the configured {@link HttpClient}. The async result * is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */ static void getClient(ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<HttpClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<HttpClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a Mongo datasource source and provides the configured {@link io.vertx.ext.mongo.MongoClient}. The * async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */ static void getMongoClient(ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<MongoClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a Redis data source and provides the configured {@link io.vertx.redis.RedisClient}. * The async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */ static void getRedisClient(ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<RedisClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<RedisClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a Redis data source and provides the configured {@link io.vertx.redis.RedisClient}. * The async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, cannot be {@code null} * @param resultHandler The result handler */ static void getRedisClient(ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<RedisClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<RedisClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a HTTP endpoint and provides the configured {@link HttpClient}. The async result * is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter * @param resultHandler The result handler */ static void getClient(ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<HttpClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<HttpClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a JDBC datasource source and provides the configured {@link io.vertx.ext.jdbc.JDBCClient}. The * async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter (must not be {@code null}) * @param resultHandler The result handler */ static void getJDBCClient(ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<JDBCClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<JDBCClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a Mongo datasource source and provides the configured {@link io.vertx.ext.mongo.MongoClient}. The * async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */ static void getMongoClient(ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<MongoClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a JDBC datasource source and provides the configured {@link io.vertx.ext.jdbc.JDBCClient}. The * async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */ static void getJDBCClient(ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<JDBCClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<JDBCClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a JDBC datasource source and provides the configured {@link io.vertx.ext.jdbc.JDBCClient}. The * async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter (must not be {@code null}) * @param resultHandler The result handler */ static void getJDBCClient(ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<JDBCClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<JDBCClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a HTTP endpoint and provides the configured {@link HttpClient}. The async result * is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */ static void getClient(ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<HttpClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<HttpClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a HTTP endpoint and provides the configured {@link HttpClient}. The async result * is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter * @param resultHandler The result handler */ static void getClient(ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<HttpClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<HttpClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a Redis data source and provides the configured {@link io.vertx.redis.RedisClient}. * The async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */ static void getRedisClient(ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<RedisClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<RedisClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a Mongo datasource source and provides the configured * {@link io.vertx.ext.mongo.MongoClient}. The * async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter * @param resultHandler The result handler */ static void getMongoClient(ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<MongoClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.getReference(ar.result()).get())); } }); }
@Test public void should_Create_Service_Reference_With_Configuration() { ServiceReference reference = graphQLService.get(vertx, discovery, record, config); assertNotNull(reference); assertNull(reference.cached()); Queryable serviceProxy = reference.get(); assertNotNull(serviceProxy); } }