Class Task
- All Implemented Interfaces:
Cloneable,Constrained,MetaDataBeanAware,MetaDataMerged,Validated
For a task to be valid, it needs to have a type and either the one-shat planned execution needs to be specified, or the repeating frequency.
- Since:
- 1.0
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method is called at least once and maximum once when any meta-data introspection logic is executed.clone()Create a new task option for this task.booleanSets the frequency at which this task should execute repeatedly.frequencySpecification(String specification) Sets the frequency crontab-like specification at which this task should execute repeatedly.Retrieves the frequency at which this task should execute repeatedly.Retrieves the frequency specification at which this task should execute repeatedly.intgetId()Retrieves the unique ID of this task.longCalculate the next timestamp in milliseconds since epoch at which this task should execute.longgetNextTimestamp(long start) Calculate the next timestamp in milliseconds since epoch at which this task should execute, starting from a provided timestamp.longRetrieve the timestamp at which this task is scheduled for the next execution.Retrieve this task's task manager.getTaskOptionValue(String name) Retrieve the value of a named task option for this task.getType()Retrieves the type of this taskbooleanisBusy()Indicates whether this task is currently being processed by anExecutor.planned(long planned) Sets the planned timestamp at which this task should execute next.Sets the planned timestamp at which this task should execute next.voidsetBusy(boolean busy) Sets whether the task is currently busy being processed by anExecutor.voidsetFrequency(Frequency frequency) Sets the frequency at which this task should execute repeatedly.voidsetFrequencySpecification(String specification) Sets the frequency crontab-like specification at which this task should execute repeatedly.voidsetId(int id) Sets the unique ID of this task.voidsetPlanned(long planned) Sets the planned timestamp at which this task should execute next.voidsetPlanned(Date planned) Sets the planned timestamp at which this task should execute next.voidsetTaskManager(TaskManager taskManager) Sets this task's task manager.voidSets the type of the task, which will be used to execute this task with theExecutorthat handles the same task type.Sets the type of the task, which will be used to execute this task with theExecutorthat handles the same task type.Methods inherited from class rife.validation.MetaData
addConstrainedPropertyRules, addConstraint, addConstraint, addGroup, addRule, addValidationError, countValidationErrors, focusGroup, generateConstrainedPropertyRules, getConstrainedBean, getConstrainedProperties, getConstrainedProperty, getGroup, getGroups, getLoadingErrors, getRules, getValidatedSubjects, getValidationErrors, hasPropertyConstraint, isSubjectValid, limitSubjectErrors, makeErrorValid, makeSubjectValid, provideValidatedBean, replaceValidationErrors, resetGroup, resetValidation, retrieveMetaDataBean, retrieveValidatedBean, setMetaDataBean, unlimitSubjectErrors, validate, validate, validateGroup, validateGroup
-
Constructor Details
-
Task
public Task()Create a new task.- Since:
- 1.0
-
-
Method Details
-
activateMetaData
public void activateMetaData()Description copied from class:MetaDataThis method is called at least once and maximum once when any meta-data introspection logic is executed.You need to implement this method since it will be called after the underlying validation context has been initialized. Incidentally, by doing all your metadata setup here, you don't enforce a performance penalty at each object construction like when you do this in the default constructor.
- Overrides:
activateMetaDatain classMetaData
-
setTaskManager
Sets this task's task manager.This is not intended to be used by the user and will be set by RIFE2 when processing tasks.
- Parameters:
taskManager- the task manager to set- Since:
- 1.0
-
getTaskManager
Retrieve this task's task manager.- Returns:
- this task's task manager; or
nullif no task manager has been assigned to this task - Since:
- 1.0
-
getTaskOptionValue
Retrieve the value of a named task option for this task.This method relies on RIFE2 having set the task manager first, without that, the option value will always be
null.- Parameters:
name- the name of the task option to retrieve- Returns:
- the value for the named option; or
nullif the option wasn't available or couldn't be found - Throws:
SchedulerException- when an error occurs during the retrieval of the task option- Since:
- 1.0
-
getNextTimestamp
Calculate the next timestamp in milliseconds since epoch at which this task should execute.- Returns:
- the next execution timestamp; or
-1if there's no next scheduled time - Throws:
FrequencyException- when an error occurred during the timestamp calculation- Since:
- 1.0
-
getNextTimestamp
Calculate the next timestamp in milliseconds since epoch at which this task should execute, starting from a provided timestamp.- Parameters:
start- the starting timestamp in milliseconds since epoch to look for the next execution timestamp- Returns:
- the next execution timestamp; or
-1if there's no next scheduled time - Throws:
FrequencyException- when an error occurred during the timestamp calculation- Since:
- 1.0
-
setType
Sets the type of the task, which will be used to execute this task with theExecutorthat handles the same task type.- Parameters:
type- this task's type- Since:
- 1.0
-
type
Sets the type of the task, which will be used to execute this task with theExecutorthat handles the same task type.- Parameters:
type- this task's type- Returns:
- this task instance
- Since:
- 1.0
-
getType
Retrieves the type of this task- Returns:
- this task's type; or
nullif no type was set
-
setPlanned
Sets the planned timestamp at which this task should execute next.This can be set manually for one-shot task execution, or when providing a frequency, RIFE2 will automatically set the planned timestamp based on the frequency specification.
- Parameters:
planned- the date instance for one-shot task execution- Since:
- 1.0
-
setPlanned
public void setPlanned(long planned) Sets the planned timestamp at which this task should execute next.This can be set manually for one-shot task execution, or when providing a frequency, RIFE2 will automatically set the planned timestamp based on the frequency specification.
- Parameters:
planned- the timestamp in milliseconds since epoch for one-shot task execution- Since:
- 1.0
-
planned
Sets the planned timestamp at which this task should execute next.This can be set manually for one-shot task execution, or when providing a frequency, RIFE2 will automatically set the planned timestamp based on the frequency specification.
- Parameters:
planned- the date instance for one-shot task execution- Returns:
- this task instance
- Since:
- 1.0
-
planned
Sets the planned timestamp at which this task should execute next.- Parameters:
planned- the timestamp in milliseconds since epoch for one-shot task execution- Returns:
- this task instance
- Since:
- 1.0
-
getPlanned
public long getPlanned()Retrieve the timestamp at which this task is scheduled for the next execution.- Returns:
- the next execution timestamp in milliseconds since epoch
- Since:
- 1.0
-
setFrequency
Sets the frequency at which this task should execute repeatedly.- Parameters:
frequency- this task's frequency- Since:
- 1.0
-
frequency
Sets the frequency at which this task should execute repeatedly.- Parameters:
frequency- this task's frequency- Returns:
- this task instance
- Since:
- 1.0
-
getFrequency
Retrieves the frequency at which this task should execute repeatedly.- Returns:
- this task's frequency; or
nullif the frequency hasn't been set - Since:
- 1.0
-
setFrequencySpecification
Sets the frequency crontab-like specification at which this task should execute repeatedly.- Parameters:
specification- the frequency specification- Throws:
FrequencyException- when an error occurred during the parsing of the frequency specification- Since:
- 1.0
-
frequencySpecification
Sets the frequency crontab-like specification at which this task should execute repeatedly.- Parameters:
specification- the frequency specification- Returns:
- this task instance
- Throws:
FrequencyException- when an error occurred during the parsing of the frequency specification- Since:
- 1.0
-
getFrequencySpecification
Retrieves the frequency specification at which this task should execute repeatedly.- Returns:
- this task's frequency specification; or
nullif the frequency hasn't been set - Since:
- 1.0
-
createTaskOption
Create a new task option for this task.Make sure to first add this task to a task manager or scheduler so that it receives its unique ID. Without this, the task option will not be properly associated with the task.
- Returns:
- the newly created task option.
- Since:
- 1.0
-
setId
public void setId(int id) Sets the unique ID of this task.This is intended to be used internally by RIFE2.
- Parameters:
id- the unique ID of this task.- Since:
- 1.0
-
getId
public int getId()Retrieves the unique ID of this task.- Returns:
- this task's unique ID; or
-1if the ID hasn't been set yet - Since:
- 1.0
-
setBusy
public void setBusy(boolean busy) Sets whether the task is currently busy being processed by anExecutor.This is intended to be used internally by RIFE2.
- Parameters:
busy-trueif the task is busy; orfalseotherwise- Since:
- 1.0
-
isBusy
public boolean isBusy()Indicates whether this task is currently being processed by anExecutor.- Returns:
trueif the task is busy; orfalseotherwise- Since:
- 1.0
-
clone
- Overrides:
clonein classMetaData- Throws:
CloneNotSupportedException
-
equals
-