Package org.jboss.msc.service
Class DelegatingServiceBuilder<T>
- java.lang.Object
-
- org.jboss.msc.service.DelegatingServiceBuilder<T>
-
- Type Parameters:
T
- the service type
- All Implemented Interfaces:
ServiceBuilder<T>
public class DelegatingServiceBuilder<T> extends Object implements ServiceBuilder<T>
A service builder which delegates to another service builder.- Author:
- David M. Lloyd, Richard Opalka
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.msc.service.ServiceBuilder
ServiceBuilder.DependencyType
-
-
Constructor Summary
Constructors Constructor Description DelegatingServiceBuilder(ServiceBuilder<T> delegate)
Construct a new instance.
-
Method Summary
-
-
-
Constructor Detail
-
DelegatingServiceBuilder
public DelegatingServiceBuilder(ServiceBuilder<T> delegate)
Construct a new instance.- Parameters:
delegate
- the builder to delegate to
-
-
Method Detail
-
getDelegate
protected ServiceBuilder<T> getDelegate()
Get the ServiceBuilder delegate.- Returns:
- ServiceBuilder delegate
-
requires
public <V> Supplier<V> requires(ServiceName name)
Specifies value name required by service. There can be multiple values service may depend on.- Specified by:
requires
in interfaceServiceBuilder<T>
- Type Parameters:
V
- required dependency value type- Parameters:
name
- required dependency name- Returns:
- readonly dependency reference
-
provides
public <V> Consumer<V> provides(ServiceName... names)
Specifies value provided by service. There can be multiple names for the same value. At least onename
parameter must be provided to this method. If there are morenames
in the vararg array then the first one is called provided value name and other are called provided value aliases.- Specified by:
provides
in interfaceServiceBuilder<T>
- Type Parameters:
V
- provided value type- Parameters:
names
- provided value name (and its aliases)- Returns:
- writable dependency reference
-
setInitialMode
public ServiceBuilder<T> setInitialMode(ServiceController.Mode mode)
Sets initial service mode.- Specified by:
setInitialMode
in interfaceServiceBuilder<T>
- Parameters:
mode
- initial service mode- Returns:
- this builder
-
setInstance
public ServiceBuilder<T> setInstance(Service service)
Sets service instance. IfServiceBuilder.install()
method call is issued without this method being called thenNULL
service will be installed into the container.Once this method have been called then all subsequent calls of
ServiceBuilder.requires(ServiceName)
, andServiceBuilder.provides(ServiceName...)
methods will fail because their return values should be provided to service instance.- Specified by:
setInstance
in interfaceServiceBuilder<T>
- Parameters:
service
- the service instance- Returns:
- this configurator
-
addListener
public ServiceBuilder<T> addListener(LifecycleListener listener)
Adds a service listener to be added to the service.- Specified by:
addListener
in interfaceServiceBuilder<T>
- Parameters:
listener
- the listener to add to the service- Returns:
- this builder
-
install
public ServiceController<T> install()
Installs configured service into the container.- Specified by:
install
in interfaceServiceBuilder<T>
- Returns:
- installed service controller
-
addAliases
@Deprecated public ServiceBuilder<T> addAliases(ServiceName... aliases)
Deprecated.Adds aliases for this service.- Specified by:
addAliases
in interfaceServiceBuilder<T>
- Parameters:
aliases
- the service names to use as aliases- Returns:
- the builder
-
addDependencies
@Deprecated public ServiceBuilder<T> addDependencies(ServiceName... dependencies)
Deprecated.Add multiple, non-injected dependencies.- Specified by:
addDependencies
in interfaceServiceBuilder<T>
- Parameters:
dependencies
- the service names to depend on- Returns:
- this builder
-
addDependencies
@Deprecated public ServiceBuilder<T> addDependencies(ServiceBuilder.DependencyType dependencyType, ServiceName... dependencies)
Deprecated.Add multiple, non-injected dependencies.- Specified by:
addDependencies
in interfaceServiceBuilder<T>
- Parameters:
dependencyType
- the dependency type; must not benull
dependencies
- the service names to depend on- Returns:
- this builder
-
addDependencies
@Deprecated public ServiceBuilder<T> addDependencies(Iterable<ServiceName> dependencies)
Deprecated.Add multiple, non-injected dependencies.- Specified by:
addDependencies
in interfaceServiceBuilder<T>
- Parameters:
dependencies
- the service names to depend on- Returns:
- this builder
-
addDependencies
@Deprecated public ServiceBuilder<T> addDependencies(ServiceBuilder.DependencyType dependencyType, Iterable<ServiceName> dependencies)
Deprecated.Add multiple, non-injected dependencies.- Specified by:
addDependencies
in interfaceServiceBuilder<T>
- Parameters:
dependencyType
- the dependency type; must not benull
dependencies
- the service names to depend on- Returns:
- this builder
-
addDependency
@Deprecated public ServiceBuilder<T> addDependency(ServiceName dependency)
Deprecated.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 interfaceServiceBuilder<T>
- Parameters:
dependency
- the name of the dependency- Returns:
- an injection builder for optionally injecting the dependency
-
addDependency
@Deprecated public ServiceBuilder<T> addDependency(ServiceBuilder.DependencyType dependencyType, ServiceName dependency)
Deprecated.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 interfaceServiceBuilder<T>
- Parameters:
dependencyType
- the dependency type; must not benull
dependency
- the name of the dependency- Returns:
- an injection builder for optionally injecting the dependency
-
addDependency
@Deprecated public ServiceBuilder<T> addDependency(ServiceName dependency, Injector<Object> target)
Deprecated.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 interfaceServiceBuilder<T>
- Parameters:
dependency
- the name of the dependencytarget
- the injector into which the dependency should be stored- Returns:
- this builder
-
addDependency
@Deprecated public ServiceBuilder<T> addDependency(ServiceBuilder.DependencyType dependencyType, ServiceName dependency, Injector<Object> target)
Deprecated.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 interfaceServiceBuilder<T>
- Parameters:
dependencyType
- the dependency type; must not benull
dependency
- the name of the dependencytarget
- the injector into which the dependency should be stored- Returns:
- this builder
-
addDependency
@Deprecated public <I> ServiceBuilder<T> addDependency(ServiceName dependency, Class<I> type, Injector<I> target)
Deprecated.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 interfaceServiceBuilder<T>
- Type Parameters:
I
- the type of the value of the dependency- Parameters:
dependency
- the name of the dependencytype
- the class of the value of the dependencytarget
- the injector into which the dependency should be stored- Returns:
- this builder
-
addDependency
@Deprecated public <I> ServiceBuilder<T> addDependency(ServiceBuilder.DependencyType dependencyType, ServiceName dependency, Class<I> type, Injector<I> target)
Deprecated.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 interfaceServiceBuilder<T>
- Type Parameters:
I
- the type of the value of the dependency- Parameters:
dependencyType
- the dependency type; must not benull
dependency
- the name of the dependencytype
- the class of the value of the dependencytarget
- the injector into which the dependency should be stored- Returns:
- this builder
-
addInjection
@Deprecated public <I> ServiceBuilder<T> addInjection(Injector<? super I> target, I value)
Deprecated.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 interfaceServiceBuilder<T>
- Type Parameters:
I
- the injection type- Parameters:
target
- the injection targetvalue
- the injection value- Returns:
- this builder
-
addInjectionValue
@Deprecated public <I> ServiceBuilder<T> addInjectionValue(Injector<? super I> target, Value<I> value)
Deprecated.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 interfaceServiceBuilder<T>
- Type Parameters:
I
- the injection type- Parameters:
target
- the injection targetvalue
- the injection value- Returns:
- this builder
-
addInjection
@Deprecated public ServiceBuilder<T> addInjection(Injector<? super T> target)
Deprecated.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 interfaceServiceBuilder<T>
- Parameters:
target
- the injector target- Returns:
- this builder
-
addMonitor
@Deprecated public ServiceBuilder<T> addMonitor(StabilityMonitor monitor)
Deprecated.Adds a stability monitor to be added to the service.- Specified by:
addMonitor
in interfaceServiceBuilder<T>
- Parameters:
monitor
- the monitor to add to the service- Returns:
- this builder
-
addMonitors
@Deprecated public ServiceBuilder<T> addMonitors(StabilityMonitor... monitors)
Deprecated.Add service stability monitors that will be added to this service.- Specified by:
addMonitors
in interfaceServiceBuilder<T>
- Parameters:
monitors
- a list of stability monitors to add to the service- Returns:
- this builder
-
addListener
@Deprecated public ServiceBuilder<T> addListener(ServiceListener<? super T> listener)
Deprecated.Add a service listener that will be added to this service.- Specified by:
addListener
in interfaceServiceBuilder<T>
- Parameters:
listener
- the listener to add to the service- Returns:
- this builder
-
addListener
@Deprecated public ServiceBuilder<T> addListener(ServiceListener<? super T>... listeners)
Deprecated.Add service listeners that will be added to this service.- Specified by:
addListener
in interfaceServiceBuilder<T>
- Parameters:
listeners
- a list of listeners to add to the service- Returns:
- this builder
-
addListener
@Deprecated public ServiceBuilder<T> addListener(Collection<? extends ServiceListener<? super T>> listeners)
Deprecated.Add service listeners that will be added to this service.- Specified by:
addListener
in interfaceServiceBuilder<T>
- Parameters:
listeners
- a collection of listeners to add to the service- Returns:
- this builder
-
-