org.jboss.ejb.txtimer
Class DatabasePersistencePolicy

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.ejb.txtimer.DatabasePersistencePolicy
All Implemented Interfaces:
java.util.EventListener, MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , NotificationListener (src) , Service (src) , ServiceMBean (src)

public class DatabasePersistencePolicy
extends ServiceMBeanSupport (src)
implements NotificationListener (src)

This service implements a PersistencePolicy that persistes the timer to a database.

Since:
09-Sep-2004

Field Summary
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
DatabasePersistencePolicy()
           
 
Method Summary
 void clearTimers()
          Delete all persisted timers
 void deleteTimer(java.lang.String timerId, TimedObjectId (src)  timedObjectId)
          Removes the timer from persistent storage.
 java.lang.String getDatabasePersistencePlugin()
           
 ObjectName (src) getDataSource()
           
 void handleNotification(Notification (src)  notification, java.lang.Object handback)
          Expects a notification from the server when it is done with startup
 void insertTimer(java.lang.String timerId, TimedObjectId (src)  timedObjectId, java.util.Date firstEvent, long intervalDuration, java.io.Serializable info)
          Creates the timer in persistent storage.
 java.util.List listTimerHandles()
          Return a List of TimerHandle objects.
 void resetAndRestoreTimers()
          Re-read the current persistent timers list, clear the db of timers, and restore the timers.
 void restoreTimers()
          Restore the persistent timers seen during service startup
 void setDatabasePersistencePlugin(java.lang.String dbpPluginClass)
           
 void setDataSource(ObjectName (src)  dataSource)
           
 void startService()
          Initializes this service.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop, stopService
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabasePersistencePolicy

public DatabasePersistencePolicy()
Method Detail

startService

public void startService()
                  throws java.lang.Exception
Initializes this service.

Overrides:
startService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

handleNotification

public void handleNotification(Notification (src)  notification,
                               java.lang.Object handback)
Expects a notification from the server when it is done with startup

Specified by:
handleNotification in interface NotificationListener (src)
Parameters:
notification - the notification object
handback - the handback object given to the broadcaster upon listener registration

insertTimer

public void insertTimer(java.lang.String timerId,
                        TimedObjectId (src)  timedObjectId,
                        java.util.Date firstEvent,
                        long intervalDuration,
                        java.io.Serializable info)
Creates the timer in persistent storage.

Parameters:
timerId - The timer id
timedObjectId - The timed object id
firstEvent - The point in time at which the first txtimer expiration must occur.
intervalDuration - The number of milliseconds that must elapse between txtimer expiration notifications.
info - A serializable handback object.

deleteTimer

public void deleteTimer(java.lang.String timerId,
                        TimedObjectId (src)  timedObjectId)
Removes the timer from persistent storage.

Parameters:
timerId - The timer id

listTimerHandles

public java.util.List listTimerHandles()
Return a List of TimerHandle objects.


restoreTimers

public void restoreTimers()
Restore the persistent timers seen during service startup


clearTimers

public void clearTimers()
Delete all persisted timers


resetAndRestoreTimers

public void resetAndRestoreTimers()
                           throws java.sql.SQLException
Re-read the current persistent timers list, clear the db of timers, and restore the timers.

Throws:
java.sql.SQLException

getDataSource

public ObjectName (src)  getDataSource()

setDataSource

public void setDataSource(ObjectName (src)  dataSource)

getDatabasePersistencePlugin

public java.lang.String getDatabasePersistencePlugin()

setDatabasePersistencePlugin

public void setDatabasePersistencePlugin(java.lang.String dbpPluginClass)