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
-
-
Constructor Summary
Constructors Constructor Description DelegatingServiceBuilder(ServiceBuilder<T> delegate)
Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ServiceBuilder<T>
addAliases(ServiceName... aliases)
Deprecated.<I> ServiceBuilder<T>
addDependency(ServiceName dependency, Class<I> type, Injector<I> target)
Deprecated.ServiceBuilder<T>
addListener(LifecycleListener listener)
Adds a service listener to be added to the service.ServiceBuilder<T>
addMonitor(StabilityMonitor monitor)
Deprecated.protected ServiceBuilder<T>
getDelegate()
Get the ServiceBuilder delegate.ServiceController<T>
install()
Installs configured service into the container.<V> Consumer<V>
provides(ServiceName... names)
Specifies value provided by service.<V> Supplier<V>
requires(ServiceName name)
Specifies value name required by service.ServiceBuilder<T>
setInitialMode(ServiceController.Mode mode)
Sets initial service mode.ServiceBuilder<T>
setInstance(Service service)
Sets service instance.
-
-
-
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
-
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
-
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
-
-