Package de.intarsys.tools.event
Class LifecycleWatchdog
java.lang.Object
de.intarsys.tools.event.LifecycleWatchdog
- All Implemented Interfaces:
IInstantiable,IStartStop
A tool for intercepting and handling lifecycle related events.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final INotificationListenerA listener for factory lifecycle eventsprotected final INotificationListenerA listener for object lifecycle events -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidarm(INotificationSupport object) protected voiddisarm(INotificationSupport object) getLabel()booleanAnswertrueif this object is startedprotected final voidmyFactoryStarted(Event event) protected final voidmyFactoryStopped(Event event) protected final voidmyObjectActivated(Object object) A previously armed IObject is activated.protected final voidmyObjectCreated(Object object) A new IObject is created and armed for further notification.protected final voidmyObjectDeactivated(Object object) A previously armed IObject is deactivated.protected final voidmyObjectDestroyed(Object object) A previously armed IObject is destroyed.protected final voidmyObjectStarted(Object object) A previously armed IObject is started.protected final voidmyObjectStopped(Object object) A previously armed IObject is stopped.protected final booleanmyObjectStopRequested(Object object) A previously armed IObject is requested to stop.protected voidobjectActivated(Object object) Redefine to get informed when an IObject is activated.protected voidobjectCreated(Object object) Redefine to get informed when an IObject is created.protected voidobjectDeactivated(Object object) Redefine to get informed when an IObject is deactivated.protected voidobjectDestroyed(Object object) Redefine to get informed when an IObject is destroyed.protected voidobjectStarted(Object object) Redefine to get informed when an IObject is started.protected voidobjectStopped(Object object) Redefine to get informed when an IObject is requested to stop.protected booleanobjectStopRequested(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.voidvoidstart()Arm the watchdog itself.voidArm the watchdog itself.voidstop()Disarm the watchdog itself.booleanstopRequested(Set visited) Ask the component if it agrees to end its lifecycle at the very moment.protected booleanAnswertrueif we are interested in theobjectinstance.toString()
-
Field Details
-
listenObjectLifecycle
A listener for object lifecycle events -
listenFactoryLifecycle
A listener for factory lifecycle events
-
-
Constructor Details
-
LifecycleWatchdog
-
-
Method Details
-
arm
-
disarm
-
getLabel
-
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
-
myFactoryStopped
-
myObjectActivated
A previously armed IObject is activated.- Parameters:
event- The activation event instance
-
myObjectCreated
A new IObject is created and armed for further notification.- Parameters:
event- The activation event instance
-
myObjectDeactivated
A previously armed IObject is deactivated.- Parameters:
event- The activation event instance
-
myObjectDestroyed
A previously armed IObject is destroyed.- Parameters:
event- The activation event instance
-
myObjectStarted
A previously armed IObject is started.- Parameters:
event- The activation event instance
-
myObjectStopped
A previously armed IObject is stopped. All notification listeners are removed.- Parameters:
event- The activation event instance
-
myObjectStopRequested
A previously armed IObject is requested to stop.- Parameters:
event- The event instance
-
objectActivated
Redefine to get informed when an IObject is activated.- Parameters:
object- The object that was activated.
-
objectCreated
Redefine to get informed when an IObject is created.- Parameters:
object- The object that was created,
-
objectDeactivated
Redefine to get informed when an IObject is deactivated.- Parameters:
object- the object that was deactivated.
-
objectDestroyed
Redefine to get informed when an IObject is destroyed.- Parameters:
object- The object that was destroyed.
-
objectStarted
Redefine to get informed when an IObject is started.- Parameters:
object- The object that was started.
-
objectStopped
Redefine to get informed when an IObject is requested to stop.- Parameters:
object- The object that was stopped.
-
objectStopRequested
Redefine to get informed when an IObject is stopped.- Parameters:
object- The object that should be stopped.
-
onFactoryLifecycleEvent
A previously armed object is activated.- Parameters:
event- The activation event instance
-
onObjectLifecycleEvent
A previously armed object is activated.- Parameters:
event- The activation event instance
-
setLabel
-
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:
-
startAuto
public void startAuto()Arm the watchdog itself. From now it will listen to the creation of new instances.- See Also:
-
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:
-
stopRequested
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
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
-