Class SchedulerUtils
java.lang.Object
net.solarnetwork.central.scheduler.SchedulerUtils
Utility methods for working with scheduled jobs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternA pattern to match a digit-only second field number value. -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringextractExecutionScheduleDescription(org.springframework.scheduling.Trigger trigger) Extract an execution schedule description from a trigger.static org.springframework.scheduling.TriggertriggerForExpression(String expression, TimeUnit timeUnit, boolean randomized) Create a trigger from a schedule expression.
-
Field Details
-
CRON_PLAIN_SECOND_FIELD_PATTERN
A pattern to match a digit-only second field number value.
-
-
Method Details
-
triggerForExpression
public static org.springframework.scheduling.Trigger triggerForExpression(String expression, TimeUnit timeUnit, boolean randomized) Create a trigger from a schedule expression.The
expressioncan be either an integer number representing atimeUnitfrequency or else a cron expression. Ifrandomizeis true then if the cron expression seconds value is a constant value it- Parameters:
expression- the schedule expressiontimeUnit- the time unit to use for periodic triggersrandomized- true to randomize the second field of cron triggers- Returns:
- the trigger, or null if the expression cannot be parsed into one
- Since:
- 2.0
-
extractExecutionScheduleDescription
public static final String extractExecutionScheduleDescription(org.springframework.scheduling.Trigger trigger) Extract an execution schedule description from a trigger.- Parameters:
trigger- the trigger- Returns:
- a description of the given trigger
-