Class ServiceBinder


  • public class ServiceBinder
    extends Object
    A binder for Service Proxies which state can be reused during the binder lifecycle.
    Author:
    Paulo Lopes
    • 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 with ServiceException.getDebugInfo()
        Parameters:
        includeDebugInfo - the parameter
        Returns:
        self
      • 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