Java Code Examples for io.vertx.serviceproxy.ProxyHelper#createProxy()

The following examples show how to use io.vertx.serviceproxy.ProxyHelper#createProxy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PortfolioVerticleTest.java    From vertx-kubernetes-workshop with Apache License 2.0 5 votes vote down vote up
@Test
public void testServiceAccess() {
  Vertx vertx = Vertx.vertx();
  vertx.deployVerticle(PortfolioVerticle.class.getName());

  PortfolioService proxy = ProxyHelper.createProxy(PortfolioService.class, vertx, PortfolioService.ADDRESS);

  assertThat(proxy).isNotNull();
  AtomicReference<Portfolio> reference = new AtomicReference<>();
  proxy.getPortfolio(ar -> reference.set(ar.result()));

  await().untilAtomic(reference, not(nullValue()));

  vertx.close();
}
 
Example 2
Source File: EventBusServiceImpl.java    From vertx-service-discovery with Apache License 2.0 5 votes vote down vote up
/**
 * Build the service proxy and return it. If already built, it returns the cached one.
 *
 * @return the proxy
 */
@Override
public synchronized T retrieve() {
  Class<T> itf = ClassLoaderUtils.load(serviceInterface, this.getClass().getClassLoader());
  if (itf == null) {
    throw new IllegalStateException("Cannot load class " + serviceInterface);
  } else {
    return ProxyHelper.createProxy(itf, vertx, record().getLocation().getString(Record.ENDPOINT), deliveryOptions);
  }
}
 
Example 3
Source File: ServiceProxyInvocationHandler.java    From weld-vertx with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param vertx
 * @param executor
 * @param serviceInterface
 * @param address
 */
ServiceProxyInvocationHandler(ServiceProxySupport serviceProxySupport, Class<?> serviceInterface, String address) {
    this.executor = serviceProxySupport.getExecutor();
    DeliveryOptions deliveryOptions = serviceProxySupport.getDefaultDeliveryOptions(serviceInterface);
    if (deliveryOptions != null) {
        this.delegate = ProxyHelper.createProxy(serviceInterface, serviceProxySupport.getVertx(), address, deliveryOptions);
    } else {
        this.delegate = ProxyHelper.createProxy(serviceInterface, serviceProxySupport.getVertx(), address);
    }
    this.handlerParamPositionCache = new ConcurrentHashMap<>();
}
 
Example 4
Source File: PortfolioVerticleTest.java    From vertx-microservices-workshop with Apache License 2.0 5 votes vote down vote up
@Test
public void testServiceAccess() {
  Vertx vertx = Vertx.vertx();
  vertx.deployVerticle(PortfolioVerticle.class.getName());

  PortfolioService proxy = ProxyHelper.createProxy(PortfolioService.class, vertx, PortfolioService.ADDRESS);

  assertThat(proxy).isNotNull();
  AtomicReference<Portfolio> reference = new AtomicReference<>();
  proxy.getPortfolio(ar -> reference.set(ar.result()));

  await().untilAtomic(reference, not(nullValue()));

  vertx.close();
}
 
Example 5
Source File: RxElasticSearchAdminService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
static RxElasticSearchAdminService createEventBusProxy(Vertx vertx, String address) {
    return new DefaultRxElasticSearchAdminService(ProxyHelper.createProxy(ElasticSearchAdminService.class, vertx, address));
}
 
Example 6
Source File: Rx2ElasticSearchAdminService.java    From vertx-elasticsearch-service with Apache License 2.0 4 votes vote down vote up
static Rx2ElasticSearchAdminService createEventBusProxy(Vertx vertx, String address) {
    return new DefaultRx2ElasticSearchAdminService(ProxyHelper.createProxy(ElasticSearchAdminService.class, vertx, address));
}
 
Example 7
Source File: KafkaProducerService.java    From vertx-kafka-service with Apache License 2.0 4 votes vote down vote up
static KafkaProducerService createProxy(Vertx vertx, String address) {
    return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address);
}
 
Example 8
Source File: KafkaProducerService.java    From vertx-kafka-service with Apache License 2.0 4 votes vote down vote up
static KafkaProducerService createProxyWithTimeout(Vertx vertx, String address, Long timeout) {
    return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address, new DeliveryOptions().setSendTimeout(timeout));
}
 
Example 9
Source File: JobService.java    From vertx-kue with Apache License 2.0 2 votes vote down vote up
/**
 * Factory method for creating a {@link JobService} service proxy.
 * This is useful for doing RPCs.
 *
 * @param vertx Vertx instance
 * @param address event bus address of RPC
 * @return the new {@link JobService} service proxy
 */
static JobService createProxy(Vertx vertx, String address) {
  return ProxyHelper.createProxy(JobService.class, vertx, address);
}
 
Example 10
Source File: Queryable.java    From vertx-graphql-service-discovery with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a service proxy to the {@link Queryable} implementation
 * at the specified address.
 * <p>
 * The {@link DeliveryOptions} to use on the returned message consumer must be passed as
 * plain json, because it does not provide a toJson() method (see:vhttps://github.com/eclipse/vert.x/issues/1502).
 *
 * @param vertx           the vert.x instance
 * @param address         the address of the service proxy
 * @param deliveryOptions the delivery options to use on the message consumer
 * @return the graphql service proxy
 */
static Queryable createProxy(Vertx vertx, String address, JsonObject deliveryOptions) {
    return ProxyHelper.createProxy(Queryable.class, vertx, address, new DeliveryOptions(deliveryOptions));
}