class OptionalDependency extends java.lang.Object implements Dependency, Dependent
| Modifier and Type | Class and Description |
|---|---|
private static class |
OptionalDependency.DependencyState
One of the states of a dependency from the dependent point of view (i.e., based on notifications made by the
dependency).
|
| Modifier and Type | Field and Description |
|---|---|
private boolean |
demandedByDependent
Indicates if this dependency has been demanded by the dependent
|
private boolean |
dependencyFailed
Indicates if optionalDependency notified a dependency failure.
|
private OptionalDependency.DependencyState |
dependencyState
The
optionalDependency state, based on notifications that optionalDependency made to this
dependent. |
private Dependent |
dependent
The dependent on this optional dependency
|
private boolean |
dependentStartedNotified
Keeps track of whether optionalDependency has been notified of a dependent started.
|
(package private) boolean |
forwardNotifications
Indicates if notification should take place
|
private Dependency |
optionalDependency
The actual dependency.
|
private boolean |
transitiveDependencyUnavailable
Indicates if optional dependency has a transitive dependency unavailable.
|
| Constructor and Description |
|---|
OptionalDependency(Dependency optionalDependency) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDemand()
Notify that a
dependent entered active mode. |
void |
addDependent(Dependent dependent)
Add a dependent to this dependency, establishing the dependency relation between this dependency and its
dependent.
|
void |
dependencyFailed()
Notify this dependent that one of its dependencies (immediate or transitive) failed to start.
|
void |
dependencyFailureCleared()
Notify this dependent that all dependency failures previously
notified are now
cleared. |
void |
dependentStarted()
Notify that a
dependent is starting. |
void |
dependentStopped()
Notify that a
dependent is stopping. |
ServiceControllerImpl<?> |
getController()
Get the controller of this dependent.
|
ServiceControllerImpl<?> |
getDependencyController()
Get the controller for this dependency, or
null if there is none currently. |
ServiceName |
getName()
Get the name of this dependency.
|
java.lang.Object |
getValue()
Get the installed instance value, if any exists.
|
void |
immediateDependencyAvailable(ServiceName dependencyName)
Notify this dependent that one of its immediate dependencies is available, i.e., it is installed and, if not
started, should start shortly. |
void |
immediateDependencyDown()
Notify this dependent that one of its immediate dependencies is leaving the
UP state. |
void |
immediateDependencyUnavailable(ServiceName dependencyName)
Notify this dependent that one of its immediate dependencies is unavailable.
A dependency is unavailable when it is not installed or when it is in NEVER
mode. |
void |
immediateDependencyUp()
Notify this dependent that one of its immediate dependencies entered
UP
state. |
void |
removeDemand()
Notify that a
dependent left active mode. |
void |
removeDependent(Dependent dependent)
Remove a dependent from this dependency, breaking the dependency relation between this dependency and its
dependent.
|
void |
transitiveDependencyAvailable()
Notify this dependent that all
unavailable transitive dependencies are
now available (i.e., they are installed and will perform an attempt to start shortly). |
void |
transitiveDependencyUnavailable()
Notify this dependent that one of its transitive dependencies is unavailable (either uninstalled, or in
NEVER mode). |
private final Dependency optionalDependency
private OptionalDependency.DependencyState dependencyState
optionalDependency state, based on notifications that optionalDependency made to this
dependent.private boolean transitiveDependencyUnavailable
private boolean dependencyFailed
private Dependent dependent
private boolean demandedByDependent
boolean forwardNotifications
private boolean dependentStartedNotified
OptionalDependency(Dependency optionalDependency)
public void addDependent(Dependent dependent)
DependencyaddDependent in interface Dependencydependent - the dependent to addpublic void removeDependent(Dependent dependent)
DependencyremoveDependent in interface Dependencydependent - the dependent to removepublic void addDemand()
Dependencydependent entered active mode.
This method must not be called under a lock.addDemand in interface Dependencypublic void removeDemand()
Dependencydependent left active mode.
This method must not be called under a lock.removeDemand in interface Dependencypublic void dependentStarted()
Dependencydependent is starting.
This method must not be called under a lock.dependentStarted in interface Dependencypublic void dependentStopped()
Dependencydependent is stopping.
This method must not be called under a lock.dependentStopped in interface Dependencypublic java.lang.Object getValue()
throws java.lang.IllegalStateException
DependencygetValue in interface DependencygetValue in interface Value<java.lang.Object>java.lang.IllegalStateException - if an error occurspublic ServiceName getName()
DependencygetName in interface Dependencypublic ServiceControllerImpl<?> getDependencyController()
Dependencynull if there is none currently.getDependencyController in interface Dependencynull for nonepublic void immediateDependencyAvailable(ServiceName dependencyName)
Dependentstarted, should start shortly.
This method must not be called under a lock.
immediateDependencyAvailable in interface DependentdependencyName - the name of the immediate dependency that is now availablepublic void immediateDependencyUnavailable(ServiceName dependencyName)
DependentNEVER
mode.
This method must not be called under a lock.
immediateDependencyUnavailable in interface DependentdependencyName - the name of the immediate dependency that is now unavailablepublic void immediateDependencyUp()
DependentUP
state.
This method must not be called under a lock.
immediateDependencyUp in interface Dependentpublic void immediateDependencyDown()
DependentUP state.
This method must not be called under a lock.
immediateDependencyDown in interface Dependentpublic void dependencyFailed()
DependentSTARTING to START_FAILED.
Dependency failures that occur after the notified failure do not result in new dependencyFailed
notifications, as the dependent will never receive two or more dependencyFailed calls in a row. A dependencyFailed notification is only invoked again to notify of new failures if the previous failures have been
cleared.
This method must not be called under a lock.
dependencyFailed in interface Dependentpublic void dependencyFailureCleared()
Dependentnotified are now
cleared. This method is called only after all affected dependencies left START_FAILED state.
This method must not be called under a lock.
dependencyFailureCleared in interface Dependentpublic void transitiveDependencyAvailable()
Dependentunavailable transitive dependencies are
now available (i.e., they are installed and will perform an attempt to start shortly).
This method must not be called under a lock.
transitiveDependencyAvailable in interface Dependentpublic ServiceControllerImpl<?> getController()
DependentgetController in interface Dependentpublic void transitiveDependencyUnavailable()
DependentNEVER mode).
New transitive dependencies that become unavailable after the notified one do not result in new dependencyUnavailable notifications, as the dependent will never receive two or more dependencyUnavailable calls
in a row. A dependencyUnavailable notification is only invoked again to notify of newly found unavailable
dependencies if all the previously unavailable dependencies have become available.
This method must not be called under a lock.
transitiveDependencyUnavailable in interface Dependent