Interface ServiceBuilder<T>

    • Method Detail

      • addAliases

        ServiceBuilder<T> addAliases​(ServiceName... aliases)
        Add aliases for this service.
        Parameters:
        aliases - the service names to use as aliases
        Returns:
        the builder
      • addDependencies

        ServiceBuilder<T> addDependencies​(ServiceName... dependencies)
        Add multiple, non-injected dependencies.
        Parameters:
        dependencies - the service names to depend on
        Returns:
        this builder
      • addDependencies

        ServiceBuilder<T> addDependencies​(ServiceBuilder.DependencyType dependencyType,
                                          ServiceName... dependencies)
        Add multiple, non-injected dependencies.
        Parameters:
        dependencyType - the dependency type; must not be null
        dependencies - the service names to depend on
        Returns:
        this builder
      • addDependencies

        ServiceBuilder<T> addDependencies​(java.lang.Iterable<ServiceName> dependencies)
        Add multiple, non-injected dependencies.
        Parameters:
        dependencies - the service names to depend on
        Returns:
        this builder
      • addDependencies

        ServiceBuilder<T> addDependencies​(ServiceBuilder.DependencyType dependencyType,
                                          java.lang.Iterable<ServiceName> dependencies)
        Add multiple, non-injected dependencies.
        Parameters:
        dependencyType - the dependency type; must not be null
        dependencies - the service names to depend on
        Returns:
        this builder
      • addDependency

        ServiceBuilder<T> addDependency​(ServiceName dependency)
        Add a dependency. Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency.
        Parameters:
        dependency - the name of the dependency
        Returns:
        an injection builder for optionally injecting the dependency
      • addDependency

        ServiceBuilder<T> addDependency​(ServiceBuilder.DependencyType dependencyType,
                                        ServiceName dependency)
        Add a dependency. Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency.
        Parameters:
        dependencyType - the dependency type; must not be null
        dependency - the name of the dependency
        Returns:
        an injection builder for optionally injecting the dependency
      • addDependency

        ServiceBuilder<T> addDependency​(ServiceName dependency,
                                        Injector<java.lang.Object> target)
        Add a service dependency. Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency.
        Parameters:
        dependency - the name of the dependency
        target - the injector into which the dependency should be stored
        Returns:
        this builder
      • addDependency

        ServiceBuilder<T> addDependency​(ServiceBuilder.DependencyType dependencyType,
                                        ServiceName dependency,
                                        Injector<java.lang.Object> target)
        Add a service dependency. Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency.
        Parameters:
        dependencyType - the dependency type; must not be null
        dependency - the name of the dependency
        target - the injector into which the dependency should be stored
        Returns:
        this builder
      • addDependency

        <I> ServiceBuilder<T> addDependency​(ServiceName dependency,
                                            java.lang.Class<I> type,
                                            Injector<I> target)
        Add a service dependency. The type of the dependency is checked before it is passed into the (type-safe) injector instance. Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency.
        Type Parameters:
        I - the type of the value of the dependency
        Parameters:
        dependency - the name of the dependency
        type - the class of the value of the dependency
        target - the injector into which the dependency should be stored
        Returns:
        this builder
      • addDependency

        <I> ServiceBuilder<T> addDependency​(ServiceBuilder.DependencyType dependencyType,
                                            ServiceName dependency,
                                            java.lang.Class<I> type,
                                            Injector<I> target)
        Add a service dependency. The type of the dependency is checked before it is passed into the (type-safe) injector instance. Calling this method multiple times for the same service name will only add it as a dependency one time; however this may be useful to specify multiple injections for one dependency.
        Type Parameters:
        I - the type of the value of the dependency
        Parameters:
        dependencyType - the dependency type; must not be null
        dependency - the name of the dependency
        type - the class of the value of the dependency
        target - the injector into which the dependency should be stored
        Returns:
        this builder
      • addInjection

        <I> ServiceBuilder<T> addInjection​(Injector<? super I> target,
                                           I value)
        Add an injection. The given value will be injected into the given injector before service start, and uninjected after service stop.
        Type Parameters:
        I - the injection type
        Parameters:
        target - the injection target
        value - the injection value
        Returns:
        this builder
      • addInjectionValue

        <I> ServiceBuilder<T> addInjectionValue​(Injector<? super I> target,
                                                Value<I> value)
        Add an injection value. The given value will be injected into the given injector before service start, and uninjected after service stop.
        Type Parameters:
        I - the injection type
        Parameters:
        target - the injection target
        value - the injection value
        Returns:
        this builder
      • addInjection

        ServiceBuilder<T> addInjection​(Injector<? super T> target)
        Add an injection of this service into another target. The given injector will be given this service after start, and uninjected when this service stops.

        Differently from other injection types, failures to perform an outward injection will not result in a failure to start the service.

        Parameters:
        target - the injector target
        Returns:
        this builder
      • addMonitor

        ServiceBuilder<T> addMonitor​(StabilityMonitor monitor)
        Add a service stability monitor that will be added to this service.
        Parameters:
        monitor - the stability monitor to add to the service
        Returns:
        this builder
      • addMonitors

        ServiceBuilder<T> addMonitors​(StabilityMonitor... monitors)
        Add service stability monitors that will be added to this service.
        Parameters:
        monitors - a list of stability monitors to add to the service
        Returns:
        this builder
      • addListener

        ServiceBuilder<T> addListener​(ServiceListener<? super T> listener)
        Add a service listener that will be added to this service.
        Parameters:
        listener - the listener to add to the service
        Returns:
        this builder
      • addListener

        ServiceBuilder<T> addListener​(ServiceListener<? super T>... listeners)
        Add service listeners that will be added to this service.
        Parameters:
        listeners - a list of listeners to add to the service
        Returns:
        this builder
      • addListener

        ServiceBuilder<T> addListener​(java.util.Collection<? extends ServiceListener<? super T>> listeners)
        Add service listeners that will be added to this service.
        Parameters:
        listeners - a collection of listeners to add to the service
        Returns:
        this builder
      • install

        ServiceController<T> install()
                              throws ServiceRegistryException,
                                     java.lang.IllegalStateException
        Install the defined service into the container. All service listeners defined for this built service will be invoked from the same thread that calls this method.
        Returns:
        the installed service controller
        Throws:
        ServiceRegistryException - if installation fails
        java.lang.IllegalStateException - if installation has been performed previously