/** * Creates a proxy to a service on the event bus. * * @param clazz the service class (interface) * @param <T> the type of the service interface * @return a proxy to the service */ public <T> T build(Class<T> clazz) { Objects.requireNonNull(address); String proxyClassName = clazz.getName() + "VertxEBProxy"; Class<?> proxyClass = loadClass(proxyClassName, clazz); Constructor constructor; Object instance; if (token != null) { if (options == null) { options = new DeliveryOptions(); } options.addHeader("auth-token", token); } if (options == null) { constructor = getConstructor(proxyClass, Vertx.class, String.class); instance = createInstance(constructor, vertx, address); } else { constructor = getConstructor(proxyClass, Vertx.class, String.class, DeliveryOptions.class); instance = createInstance(constructor, vertx, address, options); } return (T) instance; }