- java.lang.Object
-
- org.deepsymmetry.beatlink.LifecycleParticipant
-
- Direct Known Subclasses:
AnalysisTagFinder,ArtFinder,BeatFinder,BeatGridFinder,ConnectionManager,DeviceFinder,MetadataFinder,SignatureFinder,TimeFinder,VirtualCdj,VirtualRekordbox,WaveformFinder
@API(status=STABLE) public abstract class LifecycleParticipant extends Object
Provides the abstract skeleton for all the classes that can be started and stopped in Beat Link, and for which other classes may have a need to know when they start or stop.
-
-
Constructor Summary
Constructors Constructor Description LifecycleParticipant()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddLifecycleListener(LifecycleListener listener)Adds the specified life cycle listener to receive announcements when the component starts and stops.protected voiddeliverLifecycleAnnouncement(org.slf4j.Logger logger, boolean starting)Send a lifecycle announcement to all registered listeners.protected voidensureRunning()Helper method to throw anIllegalStateExceptionif we are not currently running.Set<LifecycleListener>getLifecycleListeners()Get the set of lifecycle listeners that are currently registered.abstract booleanisRunning()Check whether this component has been started.voidremoveLifecycleListener(LifecycleListener listener)Removes the specified life cycle listener so that it no longer receives announcements when the component starts or stops.
-
-
-
Method Detail
-
addLifecycleListener
@API(status=STABLE) public void addLifecycleListener(LifecycleListener listener)
Adds the specified life cycle listener to receive announcements when the component starts and stops. If
listenerisnullor 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.
- Parameters:
listener- the device announcement listener to add
-
removeLifecycleListener
@API(status=STABLE) public void removeLifecycleListener(LifecycleListener listener)
Removes the specified life cycle listener so that it no longer receives announcements when the component starts or stops. Iflistenerisnullor not present in the list of registered listeners, no exception is thrown and no action is performed.- Parameters:
listener- the life cycle listener to remove
-
getLifecycleListeners
@API(status=STABLE) public Set<LifecycleListener> getLifecycleListeners()
Get the set of lifecycle listeners that are currently registered.- Returns:
- the currently registered lifecycle listeners
-
deliverLifecycleAnnouncement
protected void deliverLifecycleAnnouncement(org.slf4j.Logger logger, boolean starting)Send a lifecycle announcement to all registered listeners.- Parameters:
logger- the logger to use, so the log entry shows as belonging to the proper subclass.starting- will betrueif the DeviceFinder is starting,falseif it is stopping.
-
isRunning
@API(status=STABLE) public abstract boolean isRunning()
Check whether this component has been started.- Returns:
- the component has started successfully and is ready to perform any service it offers.
-
ensureRunning
protected void ensureRunning()
Helper method to throw anIllegalStateExceptionif we are not currently running.- Throws:
IllegalStateException- if the component is not running
-
-