org.backsource.qcron
Class CronManagerService

java.lang.Object
  extended byjavax.management.NotificationBroadcasterSupport
      extended byorg.jboss.system.ServiceMBeanSupport
          extended byorg.backsource.jmx.ServiceMBeanSupport
              extended byorg.backsource.qcron.CronManagerService
All Implemented Interfaces:
CronManager, org.backsource.qcron.CronManagerServiceMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, org.quartz.SchedulerFactory, org.jboss.system.Service, org.jboss.system.ServiceMBean, org.backsource.jmx.ServiceMBean

public class CronManagerService
extends org.backsource.jmx.ServiceMBeanSupport
implements org.backsource.qcron.CronManagerServiceMBean, org.quartz.SchedulerFactory

An MBean service of CronManager based on the Quartz scheduler.

This is an MBean wrapper on top of Quartz. It might be seen as a jboss-service configurable Quartz SchedulerFactory. Its is however also a CronManager,which gives a somewhat simpler API to place jobbs to be done int Quartz, and also makes it easier to call object and othet MBeans.

One thing is inportant to know: quartz does not seem to handle volatile jobbs correct when run with a JDBC store. To use volatile jobs one has to use an instance of this service wich ise configured with a org.quartz.simpl.RAMJobStore JobStoreClass.

Through this MBean Quartz is fully configurable throug an jboss-service.xml file; no Quartz property file is needed.There are a lot of options here is one example on an mbean stanza that uses the Hypersonic database as its persistant storage:

  <mbean code="org.backsource.qcron.CronManagerService" name="cron:name=CronManagerService,service=test">
    <attribute name="SchedulerInstanceName">service=test</attribute>
    <attribute name="SchedLoggerClass">org.quartz.impl.Log4jLogger</attribute>
    <attribute name="XaTransacted">false</attribute>
    <attribute name="ThreadPoolClass">org.quartz.simpl.SimpleThreadPool</attribute>
    <attribute name="ThreadPoolThreadCount">3</attribute>
    <attribute name="ThreadPoolPrio">4</attribute>
    <attribute name="JobStoreClass">org.quartz.impl.jdbcjobstore.JobStoreTX</attribute>
    <attribute name="JobStoreDriverDelegateClass">org.quartz.impl.jdbcjobstore.MSSQLDelegate</attribute>
     <attribute name="DataSourceDriver">org.hsqldb.jdbcDriver</attribute>
    <attribute name="DataSourceJndiURL">java:/DefaultDS</attribute>
    <attribute name="StorageCreateSqlFile">hsqldb-sql.xml</attribute>
  </mbean>

Version:
$Revision: 1.1.1.1 $
Author:
Peter Antman

Field Summary
static java.lang.String DATASOURCE_NAME
           
protected  javax.management.ObjectName name
           
static javax.management.ObjectName OBJECT_NAME
           
static java.lang.String PROP_DATASOURCE_DRIVER
           
static java.lang.String PROP_DATASOURCE_JNDI_URL
           
static java.lang.String PROP_DATASOURCE_MAX_CONNECTIONS
           
static java.lang.String PROP_DATASOURCE_PASSWORD
           
static java.lang.String PROP_DATASOURCE_PREFIX
           
static java.lang.String PROP_DATASOURCE_URL
           
static java.lang.String PROP_DATASOURCE_USER
           
static java.lang.String PROP_DATASOURCE_VALIDATION_QUERY
           
protected  java.util.Properties quartzProp
           
protected  javax.management.MBeanServer server
           
protected  java.lang.String storageCreateSqlFile
           
static java.lang.String TABLE_CHECK
           
static java.lang.String TABLE_PREFIX
           
protected  boolean usePropertyFile
           
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, STARTED, STARTING, states, STOPPED, STOPPING
 
Constructor Summary
CronManagerService()
           
 
Method Summary
 void addCronEntry(CronEntry entry)
          Ad cronEntry to the sceduler.
protected  void createTables(java.sql.Connection conn)
          Create the Quartz db tables.
 CronEntry getCronEntry(java.lang.String group, java.lang.String name)
          Get cronEntry by name from the sceduler, null is returned if not found.
 java.util.List getCronEntryNames(java.lang.String group)
          Get all current cronEntries in the scheduler that belongs to group.
protected  javax.management.ObjectName getObjectName(javax.management.MBeanServer server, javax.management.ObjectName name)
           
 java.util.Properties getProperties()
          Get all properties Quartz was inited with.
 org.quartz.Scheduler getScheduler()
          Return a synchronized Quartz scheduler.
 java.lang.String getStorageCreateSqlFile()
           
 boolean getUsePropertyFile()
           
 void removeCronEntry(CronEntry entry)
           
 void removeCronEntry(java.lang.String group, java.lang.String name)
          Remove the cronEntry from the scheduler.
 void setDataSourceDriver(java.lang.String name)
          JDBC driver if using jdbc.
 void setDataSourceJndiURL(java.lang.String name)
          The JNDI url to a DataSource, J2EE fashion, currently the only supported way!
 void setDataSourceMaxCon(java.lang.Integer name)
          Max open connections if not using tDataSourceJndiURL.
 void setDataSourcePassword(java.lang.String name)
          JDBC password if not using tDataSourceJndiURL.
 void setDataSourceURL(java.lang.String name)
          JDBC URL if not using tDataSourceJndiURL.
 void setDataSourceUser(java.lang.String name)
          JDBC user if not using tDataSourceJndiURL.
 void setDataSourceValidationQuery(java.lang.String name)
          ?
 void setJobStoreClass(java.lang.String name)
          Class to use for job store.
 void setJobStoreDriverDelegateClass(java.lang.String name)
          Driver delegate if using jdbc.
 void setPostgresStyleBlob(java.lang.Boolean use)
          Probably not used any more!
 void setSchedLoggerClass(java.lang.String name)
          The logger class to use; the same for all components.
 void setSchedulerInstanceName(java.lang.String name)
          A uniqe name for this Quartz instance.
 void setSqlServerStyleBlob(java.lang.Boolean use)
          Probably not used any more!
 void setStorageCreateSqlFile(java.lang.String storageCreateSqlFile)
          The name of an XML file containg SQL create table instruction to autmaticllat create the db tables; must be for the correct db and be part of the context class loader path.
 void setThreadPoolClass(java.lang.String name)
          Thread pool class to use in Quartz.
 void setThreadPoolPrio(java.lang.Integer name)
          No idea.
 void setThreadPoolThreadCount(java.lang.Integer name)
          Number of Threads.
protected  void setUpJobbStore()
          Set up the jobstorage, currently only if a jndi url was given.
 void setUsePropertyFile(boolean use)
          Use property file instead of the Mbeans attributes.
 void setXaTransacted(java.lang.Boolean bool)
          Set if Quartz should use XA transactio: does currently not work since Quartz expect user transaction to be in jndi: java:comp/UserTransaction.
protected  void startService()
           
protected  void stopService()
           
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getServer, getServiceName, getState, getStateString, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, 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.system.ServiceMBean
getName, getState, getStateString
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Field Detail

DATASOURCE_NAME

public static final java.lang.String DATASOURCE_NAME
See Also:
Constant Field Values

PROP_DATASOURCE_PREFIX

public static final java.lang.String PROP_DATASOURCE_PREFIX
See Also:
Constant Field Values

PROP_DATASOURCE_DRIVER

public static final java.lang.String PROP_DATASOURCE_DRIVER
See Also:
Constant Field Values

PROP_DATASOURCE_URL

public static final java.lang.String PROP_DATASOURCE_URL
See Also:
Constant Field Values

PROP_DATASOURCE_USER

public static final java.lang.String PROP_DATASOURCE_USER
See Also:
Constant Field Values

PROP_DATASOURCE_PASSWORD

public static final java.lang.String PROP_DATASOURCE_PASSWORD
See Also:
Constant Field Values

PROP_DATASOURCE_MAX_CONNECTIONS

public static final java.lang.String PROP_DATASOURCE_MAX_CONNECTIONS
See Also:
Constant Field Values

PROP_DATASOURCE_JNDI_URL

public static final java.lang.String PROP_DATASOURCE_JNDI_URL
See Also:
Constant Field Values

PROP_DATASOURCE_VALIDATION_QUERY

public static final java.lang.String PROP_DATASOURCE_VALIDATION_QUERY
See Also:
Constant Field Values

TABLE_PREFIX

public static final java.lang.String TABLE_PREFIX
See Also:
Constant Field Values

TABLE_CHECK

public static final java.lang.String TABLE_CHECK
See Also:
Constant Field Values

OBJECT_NAME

public static final javax.management.ObjectName OBJECT_NAME

name

protected javax.management.ObjectName name

server

protected javax.management.MBeanServer server

quartzProp

protected java.util.Properties quartzProp

usePropertyFile

protected boolean usePropertyFile

storageCreateSqlFile

protected java.lang.String storageCreateSqlFile
Constructor Detail

CronManagerService

public CronManagerService()
Method Detail

getObjectName

protected javax.management.ObjectName getObjectName(javax.management.MBeanServer server,
                                                    javax.management.ObjectName name)
                                             throws javax.management.MalformedObjectNameException
Throws:
javax.management.MalformedObjectNameException

setSchedulerInstanceName

public void setSchedulerInstanceName(java.lang.String name)
A uniqe name for this Quartz instance.

Specified by:
setSchedulerInstanceName in interface org.backsource.qcron.CronManagerServiceMBean

setSchedLoggerClass

public void setSchedLoggerClass(java.lang.String name)
The logger class to use; the same for all components.

Specified by:
setSchedLoggerClass in interface org.backsource.qcron.CronManagerServiceMBean

setXaTransacted

public void setXaTransacted(java.lang.Boolean bool)
Set if Quartz should use XA transactio: does currently not work since Quartz expect user transaction to be in jndi: java:comp/UserTransaction.

Specified by:
setXaTransacted in interface org.backsource.qcron.CronManagerServiceMBean

setThreadPoolClass

public void setThreadPoolClass(java.lang.String name)
Thread pool class to use in Quartz.

Specified by:
setThreadPoolClass in interface org.backsource.qcron.CronManagerServiceMBean

setThreadPoolThreadCount

public void setThreadPoolThreadCount(java.lang.Integer name)
Number of Threads.

Specified by:
setThreadPoolThreadCount in interface org.backsource.qcron.CronManagerServiceMBean

setThreadPoolPrio

public void setThreadPoolPrio(java.lang.Integer name)
No idea.

Specified by:
setThreadPoolPrio in interface org.backsource.qcron.CronManagerServiceMBean

setJobStoreClass

public void setJobStoreClass(java.lang.String name)
Class to use for job store.

Specified by:
setJobStoreClass in interface org.backsource.qcron.CronManagerServiceMBean

setJobStoreDriverDelegateClass

public void setJobStoreDriverDelegateClass(java.lang.String name)
Driver delegate if using jdbc.

Specified by:
setJobStoreDriverDelegateClass in interface org.backsource.qcron.CronManagerServiceMBean

setDataSourceDriver

public void setDataSourceDriver(java.lang.String name)
JDBC driver if using jdbc.

Specified by:
setDataSourceDriver in interface org.backsource.qcron.CronManagerServiceMBean

setDataSourceURL

public void setDataSourceURL(java.lang.String name)
JDBC URL if not using tDataSourceJndiURL.

Specified by:
setDataSourceURL in interface org.backsource.qcron.CronManagerServiceMBean

setDataSourceUser

public void setDataSourceUser(java.lang.String name)
JDBC user if not using tDataSourceJndiURL.

Specified by:
setDataSourceUser in interface org.backsource.qcron.CronManagerServiceMBean

setDataSourcePassword

public void setDataSourcePassword(java.lang.String name)
JDBC password if not using tDataSourceJndiURL.

Specified by:
setDataSourcePassword in interface org.backsource.qcron.CronManagerServiceMBean

setDataSourceMaxCon

public void setDataSourceMaxCon(java.lang.Integer name)
Max open connections if not using tDataSourceJndiURL.

Specified by:
setDataSourceMaxCon in interface org.backsource.qcron.CronManagerServiceMBean

setDataSourceJndiURL

public void setDataSourceJndiURL(java.lang.String name)
The JNDI url to a DataSource, J2EE fashion, currently the only supported way!

Specified by:
setDataSourceJndiURL in interface org.backsource.qcron.CronManagerServiceMBean

setDataSourceValidationQuery

public void setDataSourceValidationQuery(java.lang.String name)
?

Specified by:
setDataSourceValidationQuery in interface org.backsource.qcron.CronManagerServiceMBean

setSqlServerStyleBlob

public void setSqlServerStyleBlob(java.lang.Boolean use)
Probably not used any more!

Specified by:
setSqlServerStyleBlob in interface org.backsource.qcron.CronManagerServiceMBean

setPostgresStyleBlob

public void setPostgresStyleBlob(java.lang.Boolean use)
Probably not used any more!

Specified by:
setPostgresStyleBlob in interface org.backsource.qcron.CronManagerServiceMBean

getProperties

public java.util.Properties getProperties()
Get all properties Quartz was inited with.

Specified by:
getProperties in interface org.backsource.qcron.CronManagerServiceMBean

setUsePropertyFile

public void setUsePropertyFile(boolean use)
Use property file instead of the Mbeans attributes.

Specified by:
setUsePropertyFile in interface org.backsource.qcron.CronManagerServiceMBean

getUsePropertyFile

public boolean getUsePropertyFile()
Specified by:
getUsePropertyFile in interface org.backsource.qcron.CronManagerServiceMBean

setStorageCreateSqlFile

public void setStorageCreateSqlFile(java.lang.String storageCreateSqlFile)
The name of an XML file containg SQL create table instruction to autmaticllat create the db tables; must be for the correct db and be part of the context class loader path.

Specified by:
setStorageCreateSqlFile in interface org.backsource.qcron.CronManagerServiceMBean

getStorageCreateSqlFile

public java.lang.String getStorageCreateSqlFile()
Specified by:
getStorageCreateSqlFile in interface org.backsource.qcron.CronManagerServiceMBean

startService

protected void startService()
                     throws java.lang.Exception
Throws:
java.lang.Exception

stopService

protected void stopService()
                    throws java.lang.Exception
Throws:
java.lang.Exception

setUpJobbStore

protected void setUpJobbStore()
                       throws java.lang.Exception
Set up the jobstorage, currently only if a jndi url was given.

if the db tables is not found they will be automatically created.

Throws:
java.lang.Exception

createTables

protected void createTables(java.sql.Connection conn)
                     throws java.lang.Exception
Create the Quartz db tables.

Throws:
java.lang.Exception

getScheduler

public org.quartz.Scheduler getScheduler()
                                  throws org.quartz.SchedulerException
Return a synchronized Quartz scheduler.

Specified by:
getScheduler in interface org.backsource.qcron.CronManagerServiceMBean
Throws:
org.quartz.SchedulerException

addCronEntry

public void addCronEntry(CronEntry entry)
                  throws CronException
Description copied from interface: CronManager
Ad cronEntry to the sceduler.

Specified by:
addCronEntry in interface org.backsource.qcron.CronManagerServiceMBean
Throws:
CronException

getCronEntryNames

public java.util.List getCronEntryNames(java.lang.String group)
                                 throws CronException
Description copied from interface: CronManager
Get all current cronEntries in the scheduler that belongs to group.

Specified by:
getCronEntryNames in interface CronManager
Throws:
CronException
See Also:
CronEntry.getEntryGroup()

getCronEntry

public CronEntry getCronEntry(java.lang.String group,
                              java.lang.String name)
                       throws CronException
Description copied from interface: CronManager
Get cronEntry by name from the sceduler, null is returned if not found.

Specified by:
getCronEntry in interface CronManager
Throws:
CronException

removeCronEntry

public void removeCronEntry(CronEntry entry)
                     throws CronException
Specified by:
removeCronEntry in interface org.backsource.qcron.CronManagerServiceMBean
Throws:
CronException

removeCronEntry

public void removeCronEntry(java.lang.String group,
                            java.lang.String name)
                     throws CronException
Description copied from interface: CronManager
Remove the cronEntry from the scheduler.

Specified by:
removeCronEntry in interface org.backsource.qcron.CronManagerServiceMBean
Throws:
CronException


Copyright © 2003-2004 Backsource. All Rights Reserved.