org.backsource.qcron
Class CronEntry

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

public class CronEntry
extends org.backsource.jmx.ServiceMBeanSupport
implements org.backsource.qcron.CronEntryMBean

A "cron" row consisting of time to run command and command to run.

CronEntry is a wrapper above Quartz JobDetail and Trigger. Its purpose is twofold: to make it somewhat simpler to set up a cron jobb and to agument quartz with ways to call live objects to get the work done. If one likes to use the Quartz way of doing thing one may use the constructor that takes a JobDetail and a Trigger. See org.backsource.qcron for setup examples.

Version:
$Revision: 1.1.1.1 $
Author:
Peter Antman

Field Summary
protected  java.lang.String cronExp
           
protected  java.lang.String group
           
protected  org.quartz.JobDetail jobDetail
           
protected  javax.management.ObjectName jobObjectName
           
protected  java.lang.String name
           
static javax.management.ObjectName OBJECT_NAME
           
protected  javax.management.ObjectName objectName
           
protected  boolean recover
           
protected  javax.management.MBeanServer server
           
protected  org.quartz.CronTrigger trigger
           
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
CronEntry()
           
CronEntry(org.quartz.CronTrigger trigger, org.quartz.JobDetail detail)
          Create a CronEntry by directly using the Quertz way of doing things.
CronEntry(java.lang.String cronExpr, javax.management.ObjectName delegate)
          Creata cron entry wich will be triggered accordning to cron specification in cronExpr and wich will delegate callbacks to the MBean name, which must implement the Job interface (or have an equal method).
 
Method Summary
 boolean equals(java.lang.Object otherO)
          Compare if all fields except the trigger and job is equal.
 java.lang.String getCronExp()
          Get the cron expression to use for the trigger.
 java.lang.String getEntryGroup()
           
 java.lang.String getEntryName()
          Get the name of the entry (trigger/jobdetail).
 org.quartz.JobDetail getJobDetail()
          Get the underlying JobDetail.
 javax.management.ObjectName getJobObjectName()
          Get the object name of an MBean which should be called when trigger triggers.
protected  javax.management.ObjectName getObjectName(javax.management.MBeanServer server, javax.management.ObjectName name)
           
 boolean getRequestsRecovery()
          Should sceduler try to recover; for example if server was down when jib shoudl have triggered.
 org.quartz.CronTrigger getTrigger()
          Get the underlying CronTrigger.
 boolean getVolatility()
          Will the entry be saved to persistent store.
 CronEntry instance()
          Get the instance of this MBean
 void setCronExp(java.lang.String cronExp)
          Set the cron expression to use for the trigger.
 void setEntryGroup(java.lang.String group)
          Set the group name of the entry (trigger/jobdetail).
 void setEntryName(java.lang.String name)
          Set the name of the entry (trigger/jobdetail).
 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 false, saving to persisten state!
protected  void startService()
           
 
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, stopService
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, 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

jobDetail

protected org.quartz.JobDetail jobDetail

trigger

protected org.quartz.CronTrigger trigger

name

protected java.lang.String name

group

protected java.lang.String group

recover

protected boolean recover

volatility

protected boolean volatility

cronExp

protected java.lang.String cronExp

jobObjectName

protected javax.management.ObjectName jobObjectName
Constructor Detail

CronEntry

public CronEntry()

CronEntry

public CronEntry(org.quartz.CronTrigger trigger,
                 org.quartz.JobDetail detail)
Create a CronEntry by directly using the Quertz way of doing things.


CronEntry

public CronEntry(java.lang.String cronExpr,
                 javax.management.ObjectName delegate)
          throws CronException
Creata cron entry wich will be triggered accordning to cron specification in cronExpr and wich will delegate callbacks to the MBean name, which must implement the Job interface (or have an equal method).

The gruop and name of the Trigger/Job will be taken from the delegate ObjectName. if this delegate will be used by more than one CronEntry the creator must set setEntryGroup and setEntryName manually after creation.

This method will create a cron entry that will be run at times the cronExp specifyes and invokes the job found my invoking object name. It will be persisted, non-durable and non recovarable. The underlying trigger and job will have the same group and name.

Method Detail

getObjectName

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

setCronExp

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

Specified by:
setCronExp in interface org.backsource.qcron.CronEntryMBean
Throws:
CronException
See Also:
CronTrigger

getCronExp

public java.lang.String getCronExp()
Get the cron expression to use for the trigger.

Specified by:
getCronExp in interface org.backsource.qcron.CronEntryMBean

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.CronEntryMBean

getJobObjectName

public javax.management.ObjectName getJobObjectName()
Get the object name of an MBean which should be called when trigger triggers.

Specified by:
getJobObjectName in interface org.backsource.qcron.CronEntryMBean

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.CronEntryMBean

getRequestsRecovery

public boolean getRequestsRecovery()
Should sceduler try to recover; for example if server was down when jib shoudl have triggered.

Specified by:
getRequestsRecovery in interface org.backsource.qcron.CronEntryMBean

setVolatility

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

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

getVolatility

public boolean getVolatility()
Will the entry be saved to persistent store.

Specified by:
getVolatility in interface org.backsource.qcron.CronEntryMBean

getEntryGroup

public java.lang.String getEntryGroup()
Specified by:
getEntryGroup in interface org.backsource.qcron.CronEntryMBean

setEntryGroup

public void setEntryGroup(java.lang.String group)
Set the group name of the entry (trigger/jobdetail).

Specified by:
setEntryGroup in interface org.backsource.qcron.CronEntryMBean

getEntryName

public java.lang.String getEntryName()
Get the name of the entry (trigger/jobdetail).

Specified by:
getEntryName in interface org.backsource.qcron.CronEntryMBean

setEntryName

public void setEntryName(java.lang.String name)
Set the name of the entry (trigger/jobdetail).

Specified by:
setEntryName in interface org.backsource.qcron.CronEntryMBean

getJobDetail

public org.quartz.JobDetail getJobDetail()
Get the underlying JobDetail.

Specified by:
getJobDetail in interface org.backsource.qcron.CronEntryMBean

getTrigger

public org.quartz.CronTrigger getTrigger()
Get the underlying CronTrigger.

Specified by:
getTrigger in interface org.backsource.qcron.CronEntryMBean

equals

public boolean equals(java.lang.Object otherO)
Compare if all fields except the trigger and job is equal.

Specified by:
equals in interface org.backsource.qcron.CronEntryMBean

instance

public CronEntry instance()
Get the instance of this MBean

Specified by:
instance in interface org.backsource.qcron.CronEntryMBean

startService

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


Copyright © 2003-2004 Backsource. All Rights Reserved.