Class JobEntryQuartz
- java.lang.Object
-
- org.apache.turbine.services.schedule.JobEntryQuartz
-
- All Implemented Interfaces:
Comparable<JobEntry>,JobEntry,org.quartz.Job
public class JobEntryQuartz extends Object implements JobEntry, org.quartz.Job
This implements a Turbine scheduled job model for theQuartzScheduler.- Author:
- Thomas Vandahl
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_JOB_GROUP_NAMEthe default Quartz schedule group name for Turbine jobs
-
Constructor Summary
Constructors Constructor Description JobEntryQuartz()Default constructorJobEntryQuartz(org.quartz.Trigger jobTrigger)ConstructorJobEntryQuartz(org.quartz.Trigger jobTrigger, org.quartz.JobDetail jobDetail)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalcRunTime()Calculate how long before the next runtime.intcompareTo(JobEntry o)voidexecute(org.quartz.JobExecutionContext context)org.quartz.JobDetailgetJobDetail()intgetJobId()Get the value of jobId.org.quartz.TriggergetJobTrigger()StringgetNextRunAsString()Get the next runtime for this job as a String.DategetNextRunDate()Gets the next runtime as a datelonggetNextRuntime()Get the next runtime for this job as a long.StringgetTask()Get the value of task.booleanisActive()Check to see if job is currently active/runningbooleanisNew()Return true, if the entry is not yet persistedvoidsetActive(boolean isActive)Sets whether the job is running.voidsetJobId(int v)Set the value of jobId.voidsetJobTrigger(org.quartz.Trigger jobTrigger)voidsetTask(String v)Set the value of task.
-
-
-
Field Detail
-
DEFAULT_JOB_GROUP_NAME
public static final String DEFAULT_JOB_GROUP_NAME
the default Quartz schedule group name for Turbine jobs- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JobEntryQuartz
public JobEntryQuartz()
Default constructor
-
JobEntryQuartz
public JobEntryQuartz(org.quartz.Trigger jobTrigger)
Constructor- Parameters:
jobTrigger- Job time table
-
JobEntryQuartz
public JobEntryQuartz(org.quartz.Trigger jobTrigger, org.quartz.JobDetail jobDetail)
Constructor- Parameters:
jobTrigger- Job time tablejobDetail- job details
-
-
Method Detail
-
isNew
public boolean isNew()
Return true, if the entry is not yet persisted
-
getJobId
public int getJobId()
Get the value of jobId.
-
setJobId
public void setJobId(int v)
Set the value of jobId.
-
getJobTrigger
public org.quartz.Trigger getJobTrigger()
- Returns:
- the jobTrigger
-
setJobTrigger
public void setJobTrigger(org.quartz.Trigger jobTrigger)
- Parameters:
jobTrigger- the jobTrigger to set
-
getJobDetail
public org.quartz.JobDetail getJobDetail()
- Returns:
- the jobDetail
-
compareTo
public int compareTo(JobEntry o)
- Specified by:
compareToin interfaceComparable<JobEntry>- See Also:
Comparable.compareTo(java.lang.Object)
-
setActive
public void setActive(boolean isActive)
Description copied from interface:JobEntrySets whether the job is running.- Specified by:
setActivein interfaceJobEntry- Parameters:
isActive- Whether the job is running.- See Also:
JobEntry.setActive(boolean)
-
isActive
public boolean isActive()
Description copied from interface:JobEntryCheck to see if job is currently active/running- Specified by:
isActivein interfaceJobEntry- Returns:
- true if job is currently being run by the worker thread, otherwise false
- See Also:
JobEntry.isActive()
-
getNextRuntime
public long getNextRuntime()
Description copied from interface:JobEntryGet the next runtime for this job as a long.- Specified by:
getNextRuntimein interfaceJobEntry- Returns:
- The next run time as a long.
- See Also:
JobEntry.getNextRuntime()
-
getNextRunDate
public Date getNextRunDate()
Description copied from interface:JobEntryGets the next runtime as a date- Specified by:
getNextRunDatein interfaceJobEntry- Returns:
- Next run date
- See Also:
JobEntry.getNextRunDate()
-
getNextRunAsString
public String getNextRunAsString()
Description copied from interface:JobEntryGet the next runtime for this job as a String.- Specified by:
getNextRunAsStringin interfaceJobEntry- Returns:
- The next run time as a String.
- See Also:
JobEntry.getNextRunAsString()
-
calcRunTime
public void calcRunTime() throws TurbineException
Description copied from interface:JobEntryCalculate how long before the next runtime.
The runtime determines it's position in the job queue. Here's the logic:
1. Create a date the represents when this job is to run.
2. If this date has expired, them "roll" appropriate date fields forward to the next date.
3. Calculate the diff in time between the current time and the next run time.- Specified by:
calcRunTimein interfaceJobEntry- Throws:
TurbineException- a generic exception.- See Also:
JobEntry.calcRunTime()
-
execute
public void execute(org.quartz.JobExecutionContext context) throws org.quartz.JobExecutionException
- Specified by:
executein interfaceorg.quartz.Job- Throws:
org.quartz.JobExecutionException- See Also:
Job.execute(org.quartz.JobExecutionContext)
-
-