Class DatabaseTimerPersistence

java.lang.Object
org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence
All Implemented Interfaces:
TimerPersistence, org.jboss.msc.Service

public class DatabaseTimerPersistence extends Object implements TimerPersistence, org.jboss.msc.Service

Database timer persistence store.

Author:
Stuart Douglas, Wolf-Dieter Fink, Joerg Baesner
  • Constructor Details

  • Method Details

    • start

      public void start(org.jboss.msc.service.StartContext context) throws org.jboss.msc.service.StartException
      Specified by:
      start in interface org.jboss.msc.Service
      Throws:
      org.jboss.msc.service.StartException
    • stop

      public void stop(org.jboss.msc.service.StopContext context)
      Specified by:
      stop in interface org.jboss.msc.Service
    • loadTimer

      public TimerImpl loadTimer(String timedObjectId, String timerId, TimerServiceImpl timerService)
      Loads a timer from database by its id and timed object id.
      Parameters:
      timedObjectId - the timed object id for the timer
      timerId - the timer id
      timerService - the active timer service
      Returns:
      the timer loaded from database; null if nothing can be loaded
    • addTimer

      public void addTimer(TimerImpl timerEntity)
      Description copied from interface: TimerPersistence
      Called when a timer is being persisted. In a clustered environment, if an auto timer has already been persisted by another concurrent node, it should not be persisted again, and its state should be set to CANCELED.
      Specified by:
      addTimer in interface TimerPersistence
      Parameters:
      timerEntity - The timer
    • persistTimer

      public void persistTimer(TimerImpl timerEntity)
      Description copied from interface: TimerPersistence
      Called when a timer is being persisted
      Specified by:
      persistTimer in interface TimerPersistence
      Parameters:
      timerEntity - The timer
    • shouldRun

      public boolean shouldRun(TimerImpl timer)
      Description copied from interface: TimerPersistence
      Invoked before running a timer in order to determine if this node should run the timer.
      Specified by:
      shouldRun in interface TimerPersistence
      Parameters:
      timer - The timer
      Returns:
      true if the timer should be run
    • timerUndeployed

      public void timerUndeployed(String timedObjectId)
      Description copied from interface: TimerPersistence
      Signals that a timer is being undeployed, and all cached data relating to this object should be dropped to prevent a class loader leak
      Specified by:
      timerUndeployed in interface TimerPersistence
    • timerDeployed

      public void timerDeployed(String timedObjectId)
      Description copied from interface: TimerPersistence
      Signals that the timer is being deployed and any internal structured required should be added.
      Specified by:
      timerDeployed in interface TimerPersistence
    • loadActiveTimers

      public List<TimerImpl> loadActiveTimers(String timedObjectId, TimerServiceImpl timerService)
      Description copied from interface: TimerPersistence
      Load all active timers for the given object. If the object is an entity bean timers for all beans will be returned.
      Specified by:
      loadActiveTimers in interface TimerPersistence
      Parameters:
      timedObjectId - The timed object id to load timers for
      Returns:
      A list of all active timers
    • registerChangeListener

      public Closeable registerChangeListener(String timedObjectId, TimerPersistence.TimerChangeListener listener)
      Description copied from interface: TimerPersistence
      Registers a listener to listed for new timers that are added to the database.
      Specified by:
      registerChangeListener in interface TimerPersistence
      Parameters:
      timedObjectId - The timed object
      listener - The listener
      Returns:
      A Closable that can be used to unregister the listener
    • refreshTimers

      public void refreshTimers()
    • getPersistedTimerInfo

      public Serializable getPersistedTimerInfo(TimerImpl timer)
      Retrieves the timer info from the timer database.
      Parameters:
      timer - the timer whose info to be retrieved
      Returns:
      the timer info from database; null if SQLException
    • deSerialize

      public Object deSerialize(String data) throws SQLException
      Throws:
      SQLException