org.jboss.varia.scheduler
Class DBScheduleProvider

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.jboss.varia.scheduler.AbstractScheduleProvider
              extended by org.jboss.varia.scheduler.DBScheduleProvider
All Implemented Interfaces:
javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, org.jboss.system.Service, org.jboss.system.ServiceMBean, AbstractScheduleProviderMBean, DBScheduleProviderMBean

public class DBScheduleProvider
extends AbstractScheduleProvider
implements DBScheduleProviderMBean

This Provider get its Scheduler from a Database and then adds all the Schedules to the Schedule Manager. The "SQL Statement" must deliver the following attributes: Index Content Data Type ---------------------------------- 1., Target, String 2., Method_Name, String 3., Method_Signature, String 4., Start_Date, String 5., Period, long 6., Repetitions, int 7., Date_Format, String ATTENTION: The "Target" is Object Name of the target MBean as String, the "Method_Signature" is a list of attributes separated by colons which can contain:

The "Period" is an long value greater than 0. The "Repetitions" can be set to "-1" which means unlimited repetitions. The "Date_Format" can be null or blank to signify locale usage

Version:
$Revision: 1.5.6.1 $
Author:
Andreas Schaefer

Field Summary
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.varia.scheduler.DBScheduleProviderMBean
OBJECT_NAME
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
DBScheduleProvider()
          Default (no-args) Constructor
 
Method Summary
 String getDataSourceName()
           
 javax.management.ObjectName getObjectName(javax.management.MBeanServer pServer, javax.management.ObjectName pName)
           
protected  String[] getSignature(String pMethodSignature)
          Converts a string of method arguments (separated by colons) into an array of string
 String getSQLStatement()
           
protected  Date getStartDate(String pStartDate, String dateFormat)
          Converts the given Data string to a date where not value means 1/1/1970, "NOW" means now (plus a second), an long value means time in milliseconds since 1/1/1970 and a String is a Date string which is intepreted by a Simple Data Formatter.
 void setDataSourceName(String pDataSourceName)
          Sets the JNDI name of the Data Source.
 void setSQLStatement(String pSQLStatement)
          Sets the SQL Statement used to retrieve the data from the Database
 void startProviding()
          Add the Schedule to the Schedule Manager
 void stopProviding()
          Stops the Provider from providing causing the provider to remove the Schedule
 
Methods inherited from class org.jboss.varia.scheduler.AbstractScheduleProvider
addSchedule, getScheduleManagerName, removeSchedule, setScheduleManagerName, startScheduleProviderService, startService, stopScheduleProviderService, stopService
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, createService, destroy, destroyService, getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.varia.scheduler.AbstractScheduleProviderMBean
getScheduleManagerName, setScheduleManagerName
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Constructor Detail

DBScheduleProvider

public DBScheduleProvider()
Default (no-args) Constructor

Method Detail

getDataSourceName

public String getDataSourceName()
Specified by:
getDataSourceName in interface DBScheduleProviderMBean
Returns:
JNDI name of the Data Source used

setDataSourceName

public void setDataSourceName(String pDataSourceName)
Sets the JNDI name of the Data Source. You have to ensure that the DataSource is available when this service is started.

Specified by:
setDataSourceName in interface DBScheduleProviderMBean

getSQLStatement

public String getSQLStatement()
Specified by:
getSQLStatement in interface DBScheduleProviderMBean
Returns:
SQL Statement used to access the DB

setSQLStatement

public void setSQLStatement(String pSQLStatement)
Sets the SQL Statement used to retrieve the data from the Database

Specified by:
setSQLStatement in interface DBScheduleProviderMBean

startProviding

public void startProviding()
                    throws Exception
Add the Schedule to the Schedule Manager

Specified by:
startProviding in interface AbstractScheduleProviderMBean
Specified by:
startProviding in interface DBScheduleProviderMBean
Specified by:
startProviding in class AbstractScheduleProvider
Throws:
Exception

stopProviding

public void stopProviding()
Stops the Provider from providing causing the provider to remove the Schedule

Specified by:
stopProviding in interface AbstractScheduleProviderMBean
Specified by:
stopProviding in interface DBScheduleProviderMBean
Specified by:
stopProviding in class AbstractScheduleProvider

getSignature

protected String[] getSignature(String pMethodSignature)
Converts a string of method arguments (separated by colons) into an array of string


getStartDate

protected Date getStartDate(String pStartDate,
                            String dateFormat)
Converts the given Data string to a date where not value means 1/1/1970, "NOW" means now (plus a second), an long value means time in milliseconds since 1/1/1970 and a String is a Date string which is intepreted by a Simple Data Formatter.

Parameters:
pStartDate - the date
dateFormat - the dateFormat, the locale is is used when null or blank

getObjectName

public javax.management.ObjectName getObjectName(javax.management.MBeanServer pServer,
                                                 javax.management.ObjectName pName)
                                          throws javax.management.MalformedObjectNameException
Overrides:
getObjectName in class org.jboss.system.ServiceMBeanSupport
Throws:
javax.management.MalformedObjectNameException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.