Package io.vertx.serviceproxy
Class ServiceBinder
- java.lang.Object
-
- io.vertx.serviceproxy.ServiceBinder
-
public class ServiceBinder extends Object
A binder for Service Proxies which state can be reused during the binder lifecycle.- Author:
- Paulo Lopes
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_CONNECTION_TIMEOUT
-
Constructor Summary
Constructors Constructor Description ServiceBinder(Vertx vertx)Creates a factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ServiceBinderaddInterceptor(ServiceInterceptor interceptor)ServiceBinderaddInterceptor(String action, ServiceInterceptor interceptor)<T> MessageConsumer<JsonObject>register(Class<T> clazz, T service)Registers a service on the event bus.<T> MessageConsumer<JsonObject>registerLocal(Class<T> clazz, T service)Registers a local service on the event bus.ServiceBindersetAddress(String address)Set the address to use on the subsequent proxy creations or service registrations.ServiceBindersetIncludeDebugInfo(boolean includeDebugInfo)When an exception is thrown by the service or the underlying handler, include debugging info in the ServiceException, that you can access withServiceException.getDebugInfo()ServiceBindersetTimeoutSeconds(long timeoutSeconds)Set the default timeout in seconds while waiting for a reply.ServiceBindersetTopLevel(boolean topLevel)Set if the services to create are a top level services.voidunregister(MessageConsumer<JsonObject> consumer)Unregisters a published service.
-
-
-
Field Detail
-
DEFAULT_CONNECTION_TIMEOUT
public static final long DEFAULT_CONNECTION_TIMEOUT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ServiceBinder
public ServiceBinder(Vertx vertx)
Creates a factory.- Parameters:
vertx- a non null instance of vertx.
-
-
Method Detail
-
setAddress
public ServiceBinder setAddress(String address)
Set the address to use on the subsequent proxy creations or service registrations.- Parameters:
address- an eventbus address- Returns:
- self
-
setTopLevel
public ServiceBinder setTopLevel(boolean topLevel)
Set if the services to create are a top level services.- Parameters:
topLevel- true for top level (default: true)- Returns:
- self
-
setTimeoutSeconds
public ServiceBinder setTimeoutSeconds(long timeoutSeconds)
Set the default timeout in seconds while waiting for a reply.- Parameters:
timeoutSeconds- the default timeout (default: 5 minutes)- Returns:
- self
-
setIncludeDebugInfo
public ServiceBinder setIncludeDebugInfo(boolean includeDebugInfo)
When an exception is thrown by the service or the underlying handler, include debugging info in the ServiceException, that you can access withServiceException.getDebugInfo()- Parameters:
includeDebugInfo- the parameter- Returns:
- self
-
addInterceptor
public ServiceBinder addInterceptor(String action, ServiceInterceptor interceptor)
-
addInterceptor
public ServiceBinder addInterceptor(ServiceInterceptor interceptor)
-
register
public <T> MessageConsumer<JsonObject> register(Class<T> clazz, T service)
Registers a service on the event bus.- Type Parameters:
T- the type of the service interface- Parameters:
clazz- the service class (interface)service- the service object- Returns:
- the consumer used to unregister the service
-
registerLocal
public <T> MessageConsumer<JsonObject> registerLocal(Class<T> clazz, T service)
Registers a local service on the event bus. The registration will not be propagated to other nodes in the cluster.- Type Parameters:
T- the type of the service interface- Parameters:
clazz- the service class (interface)service- the service object- Returns:
- the consumer used to unregister the service
-
unregister
public void unregister(MessageConsumer<JsonObject> consumer)
Unregisters a published service.- Parameters:
consumer- the consumer returned byregister(Class, Object).
-
-