Class CronJobTrigger
- java.lang.Object
-
- org.silverpeas.core.scheduler.trigger.JobTrigger
-
- org.silverpeas.core.scheduler.trigger.CronJobTrigger
-
public final class CronJobTrigger extends JobTrigger
This job trigger fires a job execution at given moments in time, defined with a Unix cron-like definition.The format of the expected cron expression is as following:
MINUTES HOURS DAY_OF_MONTH MONTH DAY_OF_WEEK
withField definition Field Name Allowed Values Allowed Special Characters MINUTES
0-59
, - * /
HOURS
0-23
, - * /
DAY_OF_MONTH
1-31
, - * ? /
MONTH
1-12 or JAN-DEC
, - * /
DAY_OF_WEEK
1-7 or SUN-SAT
, - * ? /
The '*' character is used to specify all values. For example, "*" in the minute field means "every minute".
The '?' character is allowed for the DAY_OF_MONTH or DAY_OF_WEEK fields. It is used to specify 'no specific value'. This is useful when you need to specify something in one of the two fields as currently specifying both the two fields is not supported.
The '-' character is used to specify ranges. For example "10-12" in the hour field means "the hours 10, 11 and 12".
The ',' character is used to specify additional values. For example "MON,WED,FRI" in the DAY_OF_WEEK field means "the days Monday, Wednesday, and Friday".
The '/' character is used to specify increments. For example "0/15" in the minutes field means "the minutes 0, 15, 30, and 45". And "5/15" in the minutes field means "the minutes 5, 20, 35, and 50". Specifying '*' before the '/' is equivalent to specifying 0 is the valu to start with. Essentially, for each field in the expression, there is a set of numbers that can be turned on or off. For seconds and minutes, the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to 31, and for months 1 to 12. The "/" character simply helps you turn on every "nth" value in the given set. Thus "7/6" in the month field only turns on month "7", it does NOT mean every 6th month, please note that subtlety.
Be careful when setting fire times between mid-night and 1:00 AM - "daylight savings" can cause a skip or a repeat depending on whether the time moves back or jumps forward.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CronJobTrigger(String cronExpression)
Creates a new job trigger that will fire a job execution at given moments in time as defined by the specified Unix cron-like expression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(JobTriggerVisitor visitor)
Accepts the specified visitor to visit it.CronExpression
getCronExpression()
Gets the cron expression that drives the triggering policy of this trigger.-
Methods inherited from class org.silverpeas.core.scheduler.trigger.JobTrigger
getStartDate, startAt, triggerAt, triggerAt, triggerEvery
-
-
-
-
Constructor Detail
-
CronJobTrigger
protected CronJobTrigger(String cronExpression) throws ParseException
Creates a new job trigger that will fire a job execution at given moments in time as defined by the specified Unix cron-like expression.- Parameters:
cronExpression
- the Unix-like cron expression.- Throws:
ParseException
- if the cron expression is not valid.
-
-
Method Detail
-
getCronExpression
public CronExpression getCronExpression()
Gets the cron expression that drives the triggering policy of this trigger.- Returns:
- the cron expression as String.
-
accept
public void accept(JobTriggerVisitor visitor)
Description copied from class:JobTrigger
Accepts the specified visitor to visit it. See the Visitor pattern.- Specified by:
accept
in classJobTrigger
- Parameters:
visitor
- the visitor to accept.
-
-