org.backsource.qcron
Class CronEditor

java.lang.Object
  extended byjavax.management.NotificationBroadcasterSupport
      extended byorg.jboss.system.ServiceMBeanSupport
          extended byorg.backsource.jmx.ServiceMBeanSupport
              extended byorg.backsource.qcron.CronEditor
All Implemented Interfaces:
org.backsource.qcron.CronEditorMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, org.jboss.system.Service, org.jboss.system.ServiceMBean, org.backsource.jmx.ServiceMBean

public class CronEditor
extends org.backsource.jmx.ServiceMBeanSupport
implements org.backsource.qcron.CronEditorMBean

An editor to handle adding/removal of CronEntrys to CronManager.

The editor has two primary purposes:

The editors normal usage is to use it as a cron spool holder; i.e one sets up a particular CronEditor for a domain and it will manage all CronEntries by giing them to the editor through setCronEntries, wich takes a list of ObjectNames each pointing to a CronEntry. The editor will manage its domain; and ad and remove jobs from quertz depending on the state of the entries list when started. This means that an editor used in this way will remove persisten jobs fron quertz if they are not part a the list any longer; and it will add jobs that has become part of the list but has not yet been added to Quartz.

It is also possible to use the editor to create a single group/job. The name of the group must then be unique.

The editor will allways create a Job/Trigger pair,with the same group/name. The group will be taken from the domain of this MBean if available and the name will be from the rest of the ObjectName. if used programatically the group and name parts must be set manually.

See org.backsource.qcron for an example of how to configure it.

For some more info on the attributes that is used to create an edior with a single entry,see CronEntry

Version:
$Revision: 1.1.1.1 $
Author:
Peter Antman

Field Summary
protected  java.util.List cronEntries
          The list of cronEntries this editor manages; is a list of ObjectNames.
protected  java.lang.String cronExp
           
protected  CronManager cronManager
          The CronManager to use when adding/removing jobs.
protected  javax.management.ObjectName cronManagerName
          The CronManager to use when adding/removing jobs.
protected  CronEntry entry
           
protected  javax.management.ObjectName jobObjectName
           
static javax.management.ObjectName OBJECT_NAME
           
protected  javax.management.ObjectName objectName
           
protected  boolean recover
           
protected  javax.management.MBeanServer server
           
protected  boolean volatility
           
 
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
CronEditor()
           
 
Method Summary
 void edit()
          Edit the current list/or single CronEntry(ies), if list is non null any single config is discarded.
 java.util.List getCronEntries()
           
 CronEntry getCronEntry()
          Get the single cron entry this editor holds, it will get group and name from this edtitrs ObjectName, will be null if it has cronEntries or if jobObjectName is non null.
 CronEntry getCronEntry(javax.management.ObjectName name)
          Get cron entry from ObjectName.
 java.lang.String getCronExp()
           
 javax.management.ObjectName getCronManagerName()
           
 javax.management.ObjectName getJobObjectName()
           
protected  javax.management.ObjectName getObjectName(javax.management.MBeanServer server, javax.management.ObjectName name)
           
 boolean getRequestsRecovery()
           
 boolean getVolatility()
           
 void remove(CronEntry entry)
          Remove the given CronEntry from manager and quertz, if the manager is configured through a jboss-service.xml file this file has the last say when component is restarted.
 void setCronEntries(java.util.List cronEntries)
          Set the list of CronEntries this edior handles.
 void setCronExp(java.lang.String cronExp)
          Set the cron expression to use for the trigger.
 void setCronManagerName(javax.management.ObjectName manager)
          Set the cron manager to use when editing.
 void setJobObjectName(javax.management.ObjectName jobName)
          Set the object name of an MBean which should be called when trigger triggers.
 void setRequestsRecovery(boolean recover)
          Scheduler should try to recover job if it should have triggered while the server was down, default to false.
 void setVolatility(boolean volatility)
          Save job to persistent state if false, default is true, i.e no saving to persisten state!
protected  void startService()
          Start the editor, calls edit.
protected  void stopService()
          Stop the editor, remove al volatile entries from CronManager
 
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

OBJECT_NAME

public static final javax.management.ObjectName OBJECT_NAME

objectName

protected javax.management.ObjectName objectName

server

protected javax.management.MBeanServer server

cronManagerName

protected javax.management.ObjectName cronManagerName
The CronManager to use when adding/removing jobs.


cronManager

protected CronManager cronManager
The CronManager to use when adding/removing jobs.


cronEntries

protected java.util.List cronEntries
The list of cronEntries this editor manages; is a list of ObjectNames.


recover

protected boolean recover

volatility

protected boolean volatility

cronExp

protected java.lang.String cronExp

jobObjectName

protected javax.management.ObjectName jobObjectName

entry

protected CronEntry entry
Constructor Detail

CronEditor

public CronEditor()
Method Detail

getObjectName

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

setCronManagerName

public void setCronManagerName(javax.management.ObjectName manager)
Set the cron manager to use when editing.

Specified by:
setCronManagerName in interface org.backsource.qcron.CronEditorMBean

getCronManagerName

public javax.management.ObjectName getCronManagerName()
Specified by:
getCronManagerName in interface org.backsource.qcron.CronEditorMBean

setCronEntries

public void setCronEntries(java.util.List cronEntries)
Set the list of CronEntries this edior handles.

Specified by:
setCronEntries in interface org.backsource.qcron.CronEditorMBean

getCronEntries

public java.util.List getCronEntries()
Specified by:
getCronEntries in interface org.backsource.qcron.CronEditorMBean

setCronExp

public void setCronExp(java.lang.String cronExp)
Set the cron expression to use for the trigger.

Specified by:
setCronExp in interface org.backsource.qcron.CronEditorMBean
See Also:
CronTrigger

getCronExp

public java.lang.String getCronExp()
Specified by:
getCronExp in interface org.backsource.qcron.CronEditorMBean

setJobObjectName

public void setJobObjectName(javax.management.ObjectName jobName)
Set the object name of an MBean which should be called when trigger triggers.

Specified by:
setJobObjectName in interface org.backsource.qcron.CronEditorMBean

getJobObjectName

public javax.management.ObjectName getJobObjectName()
Specified by:
getJobObjectName in interface org.backsource.qcron.CronEditorMBean

setRequestsRecovery

public void setRequestsRecovery(boolean recover)
Scheduler should try to recover job if it should have triggered while the server was down, default to false.

if set to true: volatile must be false.

Specified by:
setRequestsRecovery in interface org.backsource.qcron.CronEditorMBean

getRequestsRecovery

public boolean getRequestsRecovery()
Specified by:
getRequestsRecovery in interface org.backsource.qcron.CronEditorMBean

setVolatility

public void setVolatility(boolean volatility)
Save job to persistent state if false, default is true, i.e no saving to persisten state!

Specified by:
setVolatility in interface org.backsource.qcron.CronEditorMBean

getVolatility

public boolean getVolatility()
Specified by:
getVolatility in interface org.backsource.qcron.CronEditorMBean

startService

protected void startService()
                     throws java.lang.Exception
Start the editor, calls edit.

Throws:
java.lang.Exception

stopService

protected void stopService()
                    throws java.lang.Exception
Stop the editor, remove al volatile entries from CronManager

Throws:
java.lang.Exception

edit

public void edit()
          throws CronException
Edit the current list/or single CronEntry(ies), if list is non null any single config is discarded.

This method will go through al CronEntry objects available in List. Jobbs will be handled under a group name wich is constructed from the ObjectName of the editor and a name from the CronEntry ObjectName. The algoritm is this:

Specified by:
edit in interface org.backsource.qcron.CronEditorMBean
Throws:
CronException

remove

public void remove(CronEntry entry)
            throws CronException
Remove the given CronEntry from manager and quertz, if the manager is configured through a jboss-service.xml file this file has the last say when component is restarted.

Specified by:
remove in interface org.backsource.qcron.CronEditorMBean
Throws:
CronException

getCronEntry

public CronEntry getCronEntry()
                       throws CronException
Get the single cron entry this editor holds, it will get group and name from this edtitrs ObjectName, will be null if it has cronEntries or if jobObjectName is non null.

Specified by:
getCronEntry in interface org.backsource.qcron.CronEditorMBean
Throws:
CronException

getCronEntry

public CronEntry getCronEntry(javax.management.ObjectName name)
                       throws CronException
Get cron entry from ObjectName.

Specified by:
getCronEntry in interface org.backsource.qcron.CronEditorMBean
Throws:
CronException


Copyright © 2003-2004 Backsource. All Rights Reserved.