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 | Interface and Description |
|---|---|
static class |
ServiceBuilder.DependencyType
Deprecated.
Optional dependencies are unsafe and should not be used.
This enum will be removed in a future release.
|
| 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. |
ServiceBuilder<T> |
addDependencies(Iterable<ServiceName> dependencies)
Deprecated.
Use
requires(ServiceName) instead.
This method will be removed in a future release. |
ServiceBuilder<T> |
addDependencies(ServiceBuilder.DependencyType dependencyType,
Iterable<ServiceName> dependencies)
Deprecated.
Optional dependencies are unsafe and should not be used.
This method will be removed in a future release.
|
ServiceBuilder<T> |
addDependencies(ServiceBuilder.DependencyType dependencyType,
ServiceName... dependencies)
Deprecated.
Optional dependencies are unsafe and should not be used.
This method will be removed in a future release.
|
ServiceBuilder<T> |
addDependencies(ServiceName... dependencies)
Deprecated.
Use
requires(ServiceName) instead.
This method will be removed in a future release. |
ServiceBuilder<T> |
addDependency(ServiceBuilder.DependencyType dependencyType,
ServiceName dependency)
Deprecated.
Optional dependencies are unsafe and should not be used.
This method will be removed in a future release.
|
<I> ServiceBuilder<T> |
addDependency(ServiceBuilder.DependencyType dependencyType,
ServiceName dependency,
Class<I> type,
Injector<I> target)
Deprecated.
Optional dependencies are unsafe and should not be used.
This method will be removed in a future release.
|
ServiceBuilder<T> |
addDependency(ServiceBuilder.DependencyType dependencyType,
ServiceName dependency,
Injector<Object> target)
Deprecated.
Optional dependencies are unsafe and should not be used.
This method will be removed in a future release.
|
ServiceBuilder<T> |
addDependency(ServiceName dependency)
Deprecated.
Use
requires(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> |
addDependency(ServiceName dependency,
Injector<Object> target)
Deprecated.
Use
requires(ServiceName) instead.
This method will be removed in a future release. |
<I> ServiceBuilder<T> |
addInjection(Injector<? super I> target,
I value)
Deprecated.
Use
requires(ServiceName) instead.
This method will be removed in a future release. |
ServiceBuilder<T> |
addInjection(Injector<? super T> target)
Deprecated.
Use
provides(ServiceName...) instead.
This method will be removed in a future release. |
<I> ServiceBuilder<T> |
addInjectionValue(Injector<? super I> target,
Value<I> value)
Deprecated.
Use
requires(ServiceName) instead.
This method will be removed in a future release. |
ServiceBuilder<T> |
addListener(Collection<? extends ServiceListener<? super T>> listeners)
Deprecated.
Use
addListener(LifecycleListener) 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> |
addListener(ServiceListener<? super T>... listeners)
Deprecated.
Use
addListener(LifecycleListener) instead.
This method will be removed in a future release. |
ServiceBuilder<T> |
addListener(ServiceListener<? super T> listener)
Deprecated.
Use
addListener(LifecycleListener) instead.
This method will be removed in a future release. |
ServiceBuilder<T> |
addMonitor(StabilityMonitor monitor)
Deprecated.
Stability monitors are unreliable - do not use them.
This method will be removed in a future release.
|
ServiceBuilder<T> |
addMonitors(StabilityMonitor... monitors)
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 ServiceBuilder<T> addDependencies(ServiceName... dependencies)
requires(ServiceName) instead.
This method will be removed in a future release.dependencies - the service names to depend onConcurrentModificationException - 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 dependencies parameter is null or any value of the vararg
array is null.@Deprecated ServiceBuilder<T> addDependencies(ServiceBuilder.DependencyType dependencyType, ServiceName... dependencies)
dependencyType - the dependency type; must not be nulldependencies - the service names to depend onConcurrentModificationException - 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 dependencyType or dependencies parameter is
null or any value of the vararg array is null.@Deprecated ServiceBuilder<T> addDependencies(Iterable<ServiceName> dependencies)
requires(ServiceName) instead.
This method will be removed in a future release.dependencies - the service names to depend onConcurrentModificationException - 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 dependencies parameter is null or any value of
the iterable is null.@Deprecated ServiceBuilder<T> addDependencies(ServiceBuilder.DependencyType dependencyType, Iterable<ServiceName> dependencies)
dependencyType - the dependency type; must not be nulldependencies - the service names to depend onConcurrentModificationException - 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 dependencyType or dependencies parameter is
null or any value of the iterable is null.@Deprecated ServiceBuilder<T> addDependency(ServiceName dependency)
requires(ServiceName) instead.
This method will be removed in a future release.dependency - the name of the dependencyConcurrentModificationException - 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 parameter is null.@Deprecated ServiceBuilder<T> addDependency(ServiceBuilder.DependencyType dependencyType, ServiceName dependency)
dependencyType - the dependency type; must not be nulldependency - the name of the dependencyConcurrentModificationException - 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 dependencyType or dependency parameter is
null.@Deprecated ServiceBuilder<T> addDependency(ServiceName dependency, Injector<Object> target)
requires(ServiceName) instead.
This method will be removed in a future release.dependency - the name 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 target parameter is null.@Deprecated ServiceBuilder<T> addDependency(ServiceBuilder.DependencyType dependencyType, ServiceName dependency, Injector<Object> target)
dependencyType - the dependency type; must not be nulldependency - the name 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 dependencyType or dependency or target
parameter 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 <I> ServiceBuilder<T> addDependency(ServiceBuilder.DependencyType dependencyType, ServiceName dependency, Class<I> type, Injector<I> target)
I - the type of the value of the dependencydependencyType - the dependency type; must not be nulldependency - 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 dependencyType or dependency or type
or target parameter is null.@Deprecated <I> ServiceBuilder<T> addInjection(Injector<? super I> target, I value)
requires(ServiceName) instead.
This method will be removed in a future release.I - the injection typetarget - the injection targetvalue - the injection valueConcurrentModificationException - 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 target or value parameter is null.@Deprecated <I> ServiceBuilder<T> addInjectionValue(Injector<? super I> target, Value<I> value)
requires(ServiceName) instead.
This method will be removed in a future release.I - the injection typetarget - the injection targetvalue - the injection valueConcurrentModificationException - 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 target or value parameter is null.@Deprecated ServiceBuilder<T> addInjection(Injector<? super T> target)
provides(ServiceName...) instead.
This method will be removed in a future release.Differently from other injection types, failures to perform an outward injection will not result in a failure to start the service.
target - the injector targetConcurrentModificationException - 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 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.@Deprecated ServiceBuilder<T> addMonitors(StabilityMonitor... monitors)
monitors - a list of stability monitors 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 monitors parameter is null or any value of the vararg
array is null.@Deprecated ServiceBuilder<T> addListener(ServiceListener<? super T> listener)
addListener(LifecycleListener) instead.
This method will be removed in a future release.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.@Deprecated ServiceBuilder<T> addListener(ServiceListener<? super T>... listeners)
addListener(LifecycleListener) instead.
This method will be removed in a future release.listeners - a list of listeners 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 listeners parameter is null or any value of the vararg
array is null.@Deprecated ServiceBuilder<T> addListener(Collection<? extends ServiceListener<? super T>> listeners)
addListener(LifecycleListener) instead.
This method will be removed in a future release.listeners - a collection of listeners 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 listeners parameter is null or any value of the
listeners collection is null.Copyright © 2021 Red Hat, Inc.