Class AbstractJobEntry
java.lang.Object
org.apache.turbine.services.schedule.AbstractJobEntry
- All Implemented Interfaces:
Comparable<JobEntry>,JobEntry
- Direct Known Subclasses:
BaseJobEntryTorque,JobEntryNonPersistent
This class provides the basic implementation of common features for a scheduled job entry.
- Author:
- Thomas Vandahl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumschedule types -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.apache.logging.log4j.LoggerLogging -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorAbstractJobEntry(int sec, int min, int hour, int wd, int day_mo, String task) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalculate how long before the next runtime.
The runtime determines it's position in the job queue.intUsed for ordering Jobentries Note: this comparator imposes orderings that are inconsistent with equals.abstract intGet the value of dayOfMonth.abstract intgetHour()Get the value of hour.abstract intgetJobId()Get the value of jobId.abstract intGet the value of minute.Get the next runtime for this job as a String.Gets the next runtime as a datelongGet the next runtime for this job as a long.abstract intGet the value of second.abstract StringgetTask()Get the value of task.abstract intGet the value of weekDay.booleanisActive()Check to see if job is currently active/runningvoidsetActive(boolean isActive) Sets whether the job is running.abstract voidsetDayOfMonth(int v) Set the value of dayOfMonth.abstract voidsetHour(int v) Set the value of hour.abstract voidsetJobId(int v) Set the value of jobId.abstract voidsetMinute(int v) Set the value of minute.abstract voidsetSecond(int v) Set the value of second.abstract voidSet the value of task.abstract voidsetWeekDay(int v) Set the value of weekDay.
-
Field Details
-
log
Logging
-
-
Constructor Details
-
AbstractJobEntry
public AbstractJobEntry()Default constructor -
AbstractJobEntry
public AbstractJobEntry(int sec, int min, int hour, int wd, int day_mo, String task) throws TurbineException Constructor. Schedule a job to run on a certain point of time.
Example 1: Run the DefaultScheduledJob at 8:00am every 15th of the month -
JobEntry je = new JobEntry(0,0,8,-1,15,"DefaultScheduledJob");
Example 2: Run the DefaultScheduledJob at 8:00am every day -
JobEntry je = new JobEntry(0,0,8,-1,-1,"DefaultScheduledJob");
Example 3: Run the DefaultScheduledJob every 2 hours. -
JobEntry je = new JobEntry(0,120,-1,-1,-1,"DefaultScheduledJob");
Example 4: Run the DefaultScheduledJob every 30 seconds. -
JobEntry je = new JobEntry(30,-1,-1,-1,-1,"DefaultScheduledJob");- Parameters:
sec- Value for entry "seconds".min- Value for entry "minutes".hour- Value for entry "hours".wd- Value for entry "week days".day_mo- Value for entry "month days".task- Task to execute.- Throws:
TurbineException- a generic exception.
-
-
Method Details
-
compareTo
Used for ordering Jobentries Note: this comparator imposes orderings that are inconsistent with equals.- Specified by:
compareToin interfaceComparable<JobEntry>- Parameters:
je- The firstJobEntryobject.- Returns:
- An
intindicating the result of the comparison.
-
setActive
Sets whether the job is running. -
isActive
Check to see if job is currently active/running -
getNextRuntime
Get the next runtime for this job as a long.- Specified by:
getNextRuntimein interfaceJobEntry- Returns:
- The next run time as a long.
-
getNextRunDate
Gets the next runtime as a date- Specified by:
getNextRunDatein interfaceJobEntry- Returns:
- Next run date
-
getNextRunAsString
Get the next runtime for this job as a String.- Specified by:
getNextRunAsStringin interfaceJobEntry- Returns:
- The next run time as a String.
-
calcRunTime
Calculate 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.
-
getJobId
Get the value of jobId. -
setJobId
Set the value of jobId. -
getSecond
Get the value of second.- Returns:
- int
-
setSecond
Set the value of second.- Parameters:
v- new value
-
getMinute
Get the value of minute.- Returns:
- int
-
setMinute
Set the value of minute.- Parameters:
v- new value
-
getHour
Get the value of hour.- Returns:
- int
-
setHour
Set the value of hour.- Parameters:
v- new value
-
getWeekDay
Get the value of weekDay.- Returns:
- int
-
setWeekDay
Set the value of weekDay.- Parameters:
v- new value
-
getDayOfMonth
Get the value of dayOfMonth.- Returns:
- int
-
setDayOfMonth
Set the value of dayOfMonth.- Parameters:
v- new value
-
getTask
Get the value of task. -
setTask
Set the value of task.
-