T - service value type if service provides single valuepublic interface ServiceBuilder<T>
Service may require multiple dependencies (named values) to be satisfied before starting.
Every dependency requirement must be specified via requires(ServiceName) method.
Single service can provide multiple values which can be requested by dependent services.
Every named value service provides must be specified via provides(ServiceName...) method.
Once all required and provided dependencies are defined, references to all Consumers
and Suppliers should be passed to service instance so they can be accessed by service
at runtime.
Implementations of this interface are thread safe because they rely on thread confinement. The builder instance can be used only by thread that created it.
| Modifier and Type | Method and Description |
|---|---|
ServiceBuilder<T> |
addAliases(ServiceName... aliases)
Deprecated.
Use
provides(ServiceName...) instead.
This method will be removed in a future release. |
<I> ServiceBuilder<T> |
addDependency(ServiceName dependency,
Class<I> type,
Injector<I> target)
Deprecated.
Use
requires(ServiceName) instead.
This method will be removed in a future release. |
ServiceBuilder<T> |
addListener(LifecycleListener listener)
Adds a service listener to be added to the service.
|
ServiceBuilder<T> |
addMonitor(StabilityMonitor monitor)
Deprecated.
Stability monitors are unreliable - do not use them.
This method will be removed in a future release.
|
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.
|
<V> Supplier<V> requires(ServiceName name)
V - required dependency value typename - required dependency nameConcurrentModificationException - if builder is shared between threads.
Only thread that created the builder can manipulate it.IllegalArgumentException - if value name was before used as parameter either in
ServiceTarget.addService(ServiceName) method when creating this builder instance or
in provides(ServiceName...) method call. Value can be either required or provided but not both.IllegalStateException - if this method have been called after install() method.NullPointerException - if name parameter is null.<V> Consumer<V> provides(ServiceName... names)
name parameter must be provided to this method. If there are more names
in the vararg array then the first one is called provided value name and other are called provided value aliases.V - provided value typenames - provided value name (and its aliases)ConcurrentModificationException - if builder is shared between threads.
Only thread that created the builder can manipulate it.IllegalArgumentException - if value name was before used as parameter in
in requires(ServiceName) method call. Value can be either required or provided but not both.IllegalStateException - if this method have been called after install() method.NullPointerException - if names parameter is null or any value of the vararg
array is null.ServiceBuilder<T> setInitialMode(ServiceController.Mode mode)
mode - initial service modeConcurrentModificationException - if builder is shared between threads.
Only thread that created the builder can manipulate it.IllegalArgumentException - if mode is ServiceController.Mode.REMOVE.IllegalStateException - if this method have been either called twice or it was called after
install() method.NullPointerException - if mode parameter is null.ServiceBuilder<T> setInstance(Service service)
install() method call is issued
without this method being called then NULL service will be
installed into the container.
Once this method have been called then all subsequent
calls of requires(ServiceName), and provides(ServiceName...)
methods will fail because their return values should be provided to service instance.
service - the service instanceConcurrentModificationException - if builder is shared between threads.
Only thread that created the builder can manipulate it.IllegalStateException - if this method have been either called twice or it was called after
install() method.ServiceBuilder<T> addListener(LifecycleListener listener)
listener - the listener to add to the serviceConcurrentModificationException - if builder is shared between threads.
Only thread that created the builder can manipulate it.IllegalStateException - if this method have been called after install() method.NullPointerException - if listener parameter is null.ServiceController<T> install()
ConcurrentModificationException - if builder is shared between threads.
Only thread that created the builder can manipulate it.IllegalStateException - if this method have been called twice.ServiceRegistryException - if installation fails for any reason@Deprecated ServiceBuilder<T> addAliases(ServiceName... aliases)
provides(ServiceName...) instead.
This method will be removed in a future release.aliases - the service names to use as aliasesConcurrentModificationException - if builder is shared between threads.
Only thread that created the builder can manipulate it.IllegalArgumentException - if value name was before used as parameter in
in requires(ServiceName) method call. Value can be either required or provided but not both.IllegalStateException - if this method have been called after install() method.NullPointerException - if aliases parameter is null or any value of the vararg
array is null.@Deprecated <I> ServiceBuilder<T> addDependency(ServiceName dependency, Class<I> type, Injector<I> target)
requires(ServiceName) instead.
This method will be removed in a future release.I - the type of the value of the dependencydependency - the name of the dependencytype - the class of the value of the dependencytarget - the injector into which the dependency should be storedConcurrentModificationException - if builder is shared between threads.
Only thread that created the builder can manipulate it.IllegalStateException - if this method have been called after install() method.NullPointerException - if dependency or type or target
parameter is null.@Deprecated ServiceBuilder<T> addMonitor(StabilityMonitor monitor)
monitor - the monitor to add to the serviceConcurrentModificationException - if builder is shared between threads.
Only thread that created the builder can manipulate it.IllegalStateException - if this method have been called after install() method.NullPointerException - if monitor parameter is null.Copyright © 2021 Red Hat, Inc.