Interface ServiceLocator.ServiceProxyBuilder<T>

  • Type Parameters:
    T - the type of the service for which to build a proxy.
    All Known Implementing Classes:
    JeeJoynrServiceLocator.JeeJoynrServiceFutureProxyBuilder, JeeJoynrServiceLocator.JeeJoynrServiceProxyBuilder
    Enclosing interface:
    ServiceLocator

    public static interface ServiceLocator.ServiceProxyBuilder<T>
    Builder allowing you to set the various properties necessary for constructing a service proxy. The proxy returned might not be immediately connected to the provider, in which case any calls will be queued until such a time as the provider has been discovered and connected. If you want to ensure that you don't make any calls to the proxy until arbitration was successful (i.e. the proxy is connected to an actual provider), then prefer using the useFuture() method to obtain a version of the proxy builder which returns a CompletableFuture which isn't completed until the proxy is successfully connected, or which will complete exceptionally if no provider can be found in time.
    • Method Detail

      • withTtl

        ServiceLocator.ServiceProxyBuilder<T> withTtl​(long ttl)
        Set the time to live for messages being sent from the resulting proxy. Subsequent calls to withMessagingQos(MessagingQos) will override any value you set via this method. If you want to set other messaging QoS values, then you should simply set the TTL on a messaging QoS instance and call withMessagingQos(MessagingQos).
        Parameters:
        ttl - the time to live to use when sending messages from the proxy.
        Returns:
        the builder.
      • withMessagingQos

        ServiceLocator.ServiceProxyBuilder<T> withMessagingQos​(MessagingQos messagingQos)
        Set the messaging quality-of-service to use when sending messages from the resulting proxy.
        Parameters:
        messagingQos - the messaging quality-of-service to use.
        Returns:
        the builder.
      • withDiscoveryQos

        ServiceLocator.ServiceProxyBuilder<T> withDiscoveryQos​(DiscoveryQos discoveryQos)
        Set the discovery quality-of-service to use when looking up the service which the proxy will talk to.
        Parameters:
        discoveryQos - the discovery quality-of-service to use.
        Returns:
        the builder.
      • withUseCase

        ServiceLocator.ServiceProxyBuilder<T> withUseCase​(String useCase)
        Set the stateless async use case name use to find the relevant CallbackHandler to use for processing stateless async replies resulting from requests sent from this proxy.
        Parameters:
        useCase - stateless async use case name
        Returns:
        the builder.
      • withGbids

        ServiceLocator.ServiceProxyBuilder<T> withGbids​(String[] gbids)
        Set the GBIDs to use when looking up the service which the proxy will talk to.
        Parameters:
        gbids - an array of GBIDs
        Returns:
        the builder.
      • withCallback

        ServiceLocator.ServiceProxyBuilder<T> withCallback​(ProxyBuilder.ProxyCreatedCallback<T> callback)
        Set the callback to use when creating the proxy. The callback can be used to be informed of when the proxy is successfully attached to the provider or in the case that this fails.
        Parameters:
        callback - the callback to use when building the proxy.
        Returns:
        the builder.
      • useFuture

        ServiceLocator.ServiceProxyBuilder<CompletableFuture<T>> useFuture()
        If you want to have a CompletableFuture returned which will complete when the proxy has been fully created and initialised successfully, then call this method before calling build(). This also allows you to react to any error encountered while attempting to initialise the proxy, such as encountering discovery timeouts if the requested provider isn't available in time. If you want to additionally use a callback make sure to set the callback on the builder before calling this method, as it will not be possible any more after the call to useFuture().
        Returns:
        returns a version of the proxy builder which returns a CompletableFuture for the proxy rather than the proxy itself.
      • build

        T build()
        Create the service proxy using all of the settings previously setup using the 'with*' methods.
        Returns:
        the service proxy. Alternatively a CompletableFuture which will yield the service proxy upon successful completion if you previously called useFuture().