Package de.intarsys.tools.event
Class LifecycleWatchdog
- java.lang.Object
-
- de.intarsys.tools.event.LifecycleWatchdog
-
- All Implemented Interfaces:
IInstantiable,IStartStop
public abstract class LifecycleWatchdog extends java.lang.Object implements IStartStop
A tool for intercepting and handling lifecycle related events.
-
-
Field Summary
Fields Modifier and Type Field Description protected INotificationListenerlistenFactoryLifecycleA listener for factory lifecycle eventsprotected INotificationListenerlistenObjectLifecycleA listener for object lifecycle events
-
Constructor Summary
Constructors Constructor Description LifecycleWatchdog(INotificationSupport factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidarm(INotificationSupport object)protected voiddisarm(INotificationSupport object)java.lang.StringgetLabel()INotificationSupportgetObject()booleanisStarted()Answertrueif this object is startedprotected voidmyFactoryStarted(Event event)protected voidmyFactoryStopped(Event event)protected voidmyObjectActivated(java.lang.Object object)A previously armed IObject is activated.protected voidmyObjectCreated(java.lang.Object object)A new IObject is created and armed for further notification.protected voidmyObjectDeactivated(java.lang.Object object)A previously armed IObject is deactivated.protected voidmyObjectDestroyed(java.lang.Object object)A previously armed IObject is destroyed.protected voidmyObjectStarted(java.lang.Object object)A previously armed IObject is started.protected voidmyObjectStopped(java.lang.Object object)A previously armed IObject is stopped.protected booleanmyObjectStopRequested(java.lang.Object object)A previously armed IObject is requested to stop.protected voidobjectActivated(java.lang.Object object)Redefine to get informed when an IObject is activated.protected voidobjectCreated(java.lang.Object object)Redefine to get informed when an IObject is created.protected voidobjectDeactivated(java.lang.Object object)Redefine to get informed when an IObject is deactivated.protected voidobjectDestroyed(java.lang.Object object)Redefine to get informed when an IObject is destroyed.protected voidobjectStarted(java.lang.Object object)Redefine to get informed when an IObject is started.protected voidobjectStopped(java.lang.Object object)Redefine to get informed when an IObject is requested to stop.protected booleanobjectStopRequested(java.lang.Object object)Redefine to get informed when an IObject is stopped.protected voidonFactoryLifecycleEvent(Event event)A previously armed object is activated.protected voidonObjectLifecycleEvent(Event event)A previously armed object is activated.voidsetLabel(java.lang.String label)voidstart()Arm the watchdog itself.voidstartAuto()Arm the watchdog itself.voidstop()Disarm the watchdog itself.booleanstopRequested(java.util.Set visited)Ask the component if it agrees to end its lifecycle at the very moment.protected booleansupports(java.lang.Object object)Answertrueif we are interested in theobjectinstance.java.lang.StringtoString()
-
-
-
Field Detail
-
listenObjectLifecycle
protected final INotificationListener listenObjectLifecycle
A listener for object lifecycle events
-
listenFactoryLifecycle
protected final INotificationListener listenFactoryLifecycle
A listener for factory lifecycle events
-
-
Constructor Detail
-
LifecycleWatchdog
public LifecycleWatchdog(INotificationSupport factory)
-
-
Method Detail
-
arm
protected void arm(INotificationSupport object)
-
disarm
protected void disarm(INotificationSupport object)
-
getLabel
public java.lang.String getLabel()
-
getObject
public INotificationSupport getObject()
-
isStarted
public boolean isStarted()
Description copied from interface:IStartStopAnswertrueif this object is started- Specified by:
isStartedin interfaceIStartStop- Returns:
- Answer
trueif this object is started.
-
myFactoryStarted
protected final void myFactoryStarted(Event event)
-
myFactoryStopped
protected final void myFactoryStopped(Event event)
-
myObjectActivated
protected final void myObjectActivated(java.lang.Object object)
A previously armed IObject is activated.- Parameters:
event- The activation event instance
-
myObjectCreated
protected final void myObjectCreated(java.lang.Object object)
A new IObject is created and armed for further notification.- Parameters:
event- The activation event instance
-
myObjectDeactivated
protected final void myObjectDeactivated(java.lang.Object object)
A previously armed IObject is deactivated.- Parameters:
event- The activation event instance
-
myObjectDestroyed
protected final void myObjectDestroyed(java.lang.Object object)
A previously armed IObject is destroyed.- Parameters:
event- The activation event instance
-
myObjectStarted
protected final void myObjectStarted(java.lang.Object object)
A previously armed IObject is started.- Parameters:
event- The activation event instance
-
myObjectStopped
protected final void myObjectStopped(java.lang.Object object)
A previously armed IObject is stopped. All notification listeners are removed.- Parameters:
event- The activation event instance
-
myObjectStopRequested
protected final boolean myObjectStopRequested(java.lang.Object object)
A previously armed IObject is requested to stop.- Parameters:
event- The event instance
-
objectActivated
protected void objectActivated(java.lang.Object object)
Redefine to get informed when an IObject is activated.- Parameters:
object- The object that was activated.
-
objectCreated
protected void objectCreated(java.lang.Object object)
Redefine to get informed when an IObject is created.- Parameters:
object- The object that was created,
-
objectDeactivated
protected void objectDeactivated(java.lang.Object object)
Redefine to get informed when an IObject is deactivated.- Parameters:
object- the object that was deactivated.
-
objectDestroyed
protected void objectDestroyed(java.lang.Object object)
Redefine to get informed when an IObject is destroyed.- Parameters:
object- The object that was destroyed.
-
objectStarted
protected void objectStarted(java.lang.Object object)
Redefine to get informed when an IObject is started.- Parameters:
object- The object that was started.
-
objectStopped
protected void objectStopped(java.lang.Object object)
Redefine to get informed when an IObject is requested to stop.- Parameters:
object- The object that was stopped.
-
objectStopRequested
protected boolean objectStopRequested(java.lang.Object object)
Redefine to get informed when an IObject is stopped.- Parameters:
object- The object that should be stopped.
-
onFactoryLifecycleEvent
protected void onFactoryLifecycleEvent(Event event)
A previously armed object is activated.- Parameters:
event- The activation event instance
-
onObjectLifecycleEvent
protected void onObjectLifecycleEvent(Event event)
A previously armed object is activated.- Parameters:
event- The activation event instance
-
setLabel
public void setLabel(java.lang.String label)
-
start
public void start()
Arm the watchdog itself. From now it will listen to the creation of new instances.- Specified by:
startin interfaceIStartStop- See Also:
IStartStop.start()
-
startAuto
public void startAuto()
Arm the watchdog itself. From now it will listen to the creation of new instances.- See Also:
IStartStop.start()
-
stop
public void stop()
Disarm the watchdog itself. From now it will not longer listen to the creation of new instances.- Specified by:
stopin interfaceIStartStop- See Also:
IStartStop.stop()
-
stopRequested
public boolean stopRequested(java.util.Set visited)
Description copied from interface:IStartStopAsk the component if it agrees to end its lifecycle at the very moment. The component may deny this request, but it must be prepared anyway to be stopped.- Specified by:
stopRequestedin interfaceIStartStop- Parameters:
visited- The optional set of already visited objects in the stop request cycle.
-
supports
protected boolean supports(java.lang.Object object)
Answertrueif we are interested in theobjectinstance. If we are interested the watchdog will register itself for the lifecycle events.- Parameters:
object- The newly created object.- Returns:
- Answer
trueif we are interested in theobjectinstance.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-