Class ServiceBuilderImpl<T>

  • Type Parameters:
    T - the type of service being built
    All Implemented Interfaces:
    ServiceBuilder<T>

    class ServiceBuilderImpl<T>
    extends java.lang.Object
    implements ServiceBuilder<T>
    ServiceBuilder implementation.
    • Method Detail

      • addDependencies

        public ServiceBuilder<T> addDependencies​(java.lang.Iterable<ServiceName> newDependencies)
        Description copied from interface: ServiceBuilder
        Add multiple, non-injected dependencies.
        Specified by:
        addDependencies in interface ServiceBuilder<T>
        Parameters:
        newDependencies - the service names to depend on
        Returns:
        this builder
      • addDependency

        public ServiceBuilder<T> addDependency​(ServiceName dependency)
        Description copied from interface: ServiceBuilder
        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.
        Specified by:
        addDependency in interface ServiceBuilder<T>
        Parameters:
        dependency - the name of the dependency
        Returns:
        an injection builder for optionally injecting the dependency
      • addDependency

        public ServiceBuilder<T> addDependency​(ServiceBuilder.DependencyType dependencyType,
                                               ServiceName dependency)
        Description copied from interface: ServiceBuilder
        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.
        Specified by:
        addDependency in interface ServiceBuilder<T>
        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

        public ServiceBuilder<T> addDependency​(ServiceName dependency,
                                               Injector<java.lang.Object> target)
        Description copied from interface: ServiceBuilder
        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.
        Specified by:
        addDependency in interface ServiceBuilder<T>
        Parameters:
        dependency - the name of the dependency
        target - the injector into which the dependency should be stored
        Returns:
        this builder
      • addDependency

        public ServiceBuilder<T> addDependency​(ServiceBuilder.DependencyType dependencyType,
                                               ServiceName dependency,
                                               Injector<java.lang.Object> target)
        Description copied from interface: ServiceBuilder
        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.
        Specified by:
        addDependency in interface ServiceBuilder<T>
        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

        public <I> ServiceBuilder<T> addDependency​(ServiceName dependency,
                                                   java.lang.Class<I> type,
                                                   Injector<I> target)
        Description copied from interface: ServiceBuilder
        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.
        Specified by:
        addDependency in interface ServiceBuilder<T>
        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

        public <I> ServiceBuilder<T> addDependency​(ServiceBuilder.DependencyType dependencyType,
                                                   ServiceName dependency,
                                                   java.lang.Class<I> type,
                                                   Injector<I> target)
        Description copied from interface: ServiceBuilder
        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.
        Specified by:
        addDependency in interface ServiceBuilder<T>
        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

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

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

        public ServiceBuilder<T> addInjection​(Injector<? super T> target)
        Description copied from interface: ServiceBuilder
        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.

        Specified by:
        addInjection in interface ServiceBuilder<T>
        Parameters:
        target - the injector target
        Returns:
        this builder
      • addMonitors

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

        public ServiceBuilderImpl<T> addListener​(java.util.Collection<? extends ServiceListener<? super T>> serviceListeners)
        Description copied from interface: ServiceBuilder
        Add service listeners that will be added to this service.
        Specified by:
        addListener in interface ServiceBuilder<T>
        Parameters:
        serviceListeners - a collection of listeners to add to the service
        Returns:
        this builder
      • checkAlreadyInstalled

        private void checkAlreadyInstalled()
      • getValueInjections

        java.util.List<ValueInjection<?>> getValueInjections()
      • getOutInjections

        java.util.List<Injector<? super T>> getOutInjections()