public abstract class LifecycleParticipant extends Object
| Constructor and Description |
|---|
LifecycleParticipant() |
| Modifier and Type | Method and Description |
|---|---|
void |
addLifecycleListener(LifecycleListener listener)
Adds the specified life cycle listener to receive announcements when the component starts and stops.
|
protected void |
deliverLifecycleAnnouncement(org.slf4j.Logger logger,
boolean starting)
Send a lifecycle announcement to all registered listeners.
|
protected void |
ensureRunning()
Helper method to throw an
IllegalStateException if we are not currently running. |
Set<LifecycleListener> |
getLifecycleListeners()
Get the set of lifecycle listeners that are currently registered.
|
abstract boolean |
isRunning()
Check whether this component has been started.
|
void |
removeLifecycleListener(LifecycleListener listener)
Removes the specified life cycle listener so that it no longer receives announcements when
the component starts or stops.
|
public void addLifecycleListener(LifecycleListener listener)
Adds the specified life cycle listener to receive announcements when the component starts and stops.
If listener is null or already present in the list
of registered listeners, no exception is thrown and no action is performed.
Lifecycle announcements are delivered to listeners on a separate thread to avoid worries about deadlock in synchronized start and stop methods. The called function should still be fast, or delegate long operations to its own separate thread.
listener - the device announcement listener to addpublic void removeLifecycleListener(LifecycleListener listener)
listener is null or not present
in the list of registered listeners, no exception is thrown and no action is performed.listener - the life cycle listener to removepublic Set<LifecycleListener> getLifecycleListeners()
protected void deliverLifecycleAnnouncement(org.slf4j.Logger logger,
boolean starting)
logger - the logger to use, so the log entry shows as belonging to the proper subclass.starting - will be true if the DeviceFinder is starting, false if it is stopping.public abstract boolean isRunning()
protected void ensureRunning()
IllegalStateException if we are not currently running.IllegalStateException - if the component is not runningCopyright © 2016–2018 Deep Symmetry, LLC. All rights reserved.