Class LifecycleWatchdog

java.lang.Object
de.intarsys.tools.event.LifecycleWatchdog
All Implemented Interfaces:
IInstantiable, IStartStop

public abstract class LifecycleWatchdog extends Object implements IStartStop
A tool for intercepting and handling lifecycle related events.
  • Field Details

    • listenObjectLifecycle

      protected final INotificationListener listenObjectLifecycle
      A listener for object lifecycle events
    • listenFactoryLifecycle

      protected final INotificationListener listenFactoryLifecycle
      A listener for factory lifecycle events
  • Constructor Details

  • Method Details

    • arm

      protected void arm(INotificationSupport object)
    • disarm

      protected void disarm(INotificationSupport object)
    • getLabel

      public String getLabel()
    • getObject

      public INotificationSupport getObject()
    • isStarted

      public boolean isStarted()
      Description copied from interface: IStartStop
      Answer true if this object is started
      Specified by:
      isStarted in interface IStartStop
      Returns:
      Answer true if this object is started.
    • myFactoryStarted

      protected final void myFactoryStarted(Event event)
    • myFactoryStopped

      protected final void myFactoryStopped(Event event)
    • myObjectActivated

      protected final void myObjectActivated(Object object)
      A previously armed IObject is activated.
      Parameters:
      event - The activation event instance
    • myObjectCreated

      protected final void myObjectCreated(Object object)
      A new IObject is created and armed for further notification.
      Parameters:
      event - The activation event instance
    • myObjectDeactivated

      protected final void myObjectDeactivated(Object object)
      A previously armed IObject is deactivated.
      Parameters:
      event - The activation event instance
    • myObjectDestroyed

      protected final void myObjectDestroyed(Object object)
      A previously armed IObject is destroyed.
      Parameters:
      event - The activation event instance
    • myObjectStarted

      protected final void myObjectStarted(Object object)
      A previously armed IObject is started.
      Parameters:
      event - The activation event instance
    • myObjectStopped

      protected final void myObjectStopped(Object object)
      A previously armed IObject is stopped. All notification listeners are removed.
      Parameters:
      event - The activation event instance
    • myObjectStopRequested

      protected final boolean myObjectStopRequested(Object object)
      A previously armed IObject is requested to stop.
      Parameters:
      event - The event instance
    • objectActivated

      protected void objectActivated(Object object)
      Redefine to get informed when an IObject is activated.
      Parameters:
      object - The object that was activated.
    • objectCreated

      protected void objectCreated(Object object)
      Redefine to get informed when an IObject is created.
      Parameters:
      object - The object that was created,
    • objectDeactivated

      protected void objectDeactivated(Object object)
      Redefine to get informed when an IObject is deactivated.
      Parameters:
      object - the object that was deactivated.
    • objectDestroyed

      protected void objectDestroyed(Object object)
      Redefine to get informed when an IObject is destroyed.
      Parameters:
      object - The object that was destroyed.
    • objectStarted

      protected void objectStarted(Object object)
      Redefine to get informed when an IObject is started.
      Parameters:
      object - The object that was started.
    • objectStopped

      protected void objectStopped(Object object)
      Redefine to get informed when an IObject is requested to stop.
      Parameters:
      object - The object that was stopped.
    • objectStopRequested

      protected boolean objectStopRequested(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(String label)
    • start

      public void start()
      Arm the watchdog itself. From now it will listen to the creation of new instances.
      Specified by:
      start in interface IStartStop
      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 interface IStartStop
      See Also:
    • stopRequested

      public boolean stopRequested(Set visited)
      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 interface IStartStop
      Parameters:
      visited - The optional set of already visited objects in the stop request cycle.
    • supports

      protected boolean supports(Object object)
      Answer true if we are interested in the object 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 the object instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object