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 INotificationListener
A listener for factory lifecycle eventsprotected final INotificationListener
A listener for object lifecycle events -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
arm
(INotificationSupport object) protected void
disarm
(INotificationSupport object) getLabel()
boolean
Answertrue
if this object is startedprotected final void
myFactoryStarted
(Event event) protected final void
myFactoryStopped
(Event event) protected final void
myObjectActivated
(Object object) A previously armed IObject is activated.protected final void
myObjectCreated
(Object object) A new IObject is created and armed for further notification.protected final void
myObjectDeactivated
(Object object) A previously armed IObject is deactivated.protected final void
myObjectDestroyed
(Object object) A previously armed IObject is destroyed.protected final void
myObjectStarted
(Object object) A previously armed IObject is started.protected final void
myObjectStopped
(Object object) A previously armed IObject is stopped.protected final boolean
myObjectStopRequested
(Object object) A previously armed IObject is requested to stop.protected void
objectActivated
(Object object) Redefine to get informed when an IObject is activated.protected void
objectCreated
(Object object) Redefine to get informed when an IObject is created.protected void
objectDeactivated
(Object object) Redefine to get informed when an IObject is deactivated.protected void
objectDestroyed
(Object object) Redefine to get informed when an IObject is destroyed.protected void
objectStarted
(Object object) Redefine to get informed when an IObject is started.protected void
objectStopped
(Object object) Redefine to get informed when an IObject is requested to stop.protected boolean
objectStopRequested
(Object object) Redefine to get informed when an IObject is stopped.protected void
onFactoryLifecycleEvent
(Event event) A previously armed object is activated.protected void
onObjectLifecycleEvent
(Event event) A previously armed object is activated.void
void
start()
Arm the watchdog itself.void
Arm the watchdog itself.void
stop()
Disarm the watchdog itself.boolean
stopRequested
(Set visited) Ask the component if it agrees to end its lifecycle at the very moment.protected boolean
Answertrue
if we are interested in theobject
instance.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:IStartStop
Answertrue
if this object is started- Specified by:
isStarted
in interfaceIStartStop
- Returns:
- Answer
true
if 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:
start
in 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:
stop
in interfaceIStartStop
- See Also:
-
stopRequested
Description copied from interface:IStartStop
Ask 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:
stopRequested
in interfaceIStartStop
- Parameters:
visited
- The optional set of already visited objects in the stop request cycle.
-
supports
Answertrue
if we are interested in theobject
instance. If we are interested the watchdog will register itself for the lifecycle events.- Parameters:
object
- The newly created object.- Returns:
- Answer
true
if we are interested in theobject
instance.
-
toString
-