com.silverpeas.scheduler.trigger
Class CronJobTrigger

java.lang.Object
  extended by com.silverpeas.scheduler.trigger.JobTrigger
      extended by com.silverpeas.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 with

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 seconds field means "the seconds 0, 15, 30, and 45". And "5/15" in the seconds field means "the seconds 5, 20, 35, and 50". Specifying '*' before the '/' is equivalent to specifying 0 is the value 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
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
 void accept(JobTriggerVisitor visitor)
          Accepts the specified visitor to visit it.
 String getCronExpression()
          Gets the cron expression that drives the triggering policy of this trigger.
 
Methods inherited from class com.silverpeas.scheduler.trigger.JobTrigger
getStartDate, startAt, triggerAt, triggerEvery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 String 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 class JobTrigger
Parameters:
visitor - the visitor to accept.


Copyright © 2016 Silverpeas. All Rights Reserved.