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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This 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.boolean
Sets 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.int
getId()
Retrieves the unique ID of this task.long
Calculate the next timestamp in milliseconds since epoch at which this task should execute.long
getNextTimestamp
(long start) Calculate the next timestamp in milliseconds since epoch at which this task should execute, starting from a provided timestamp.long
Retrieve 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 taskboolean
isBusy()
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.void
setBusy
(boolean busy) Sets whether the task is currently busy being processed by anExecutor
.void
setFrequency
(Frequency frequency) Sets the frequency at which this task should execute repeatedly.void
setFrequencySpecification
(String specification) Sets the frequency crontab-like specification at which this task should execute repeatedly.void
setId
(int id) Sets the unique ID of this task.void
setPlanned
(long planned) Sets the planned timestamp at which this task should execute next.void
setPlanned
(Date planned) Sets the planned timestamp at which this task should execute next.void
setTaskManager
(TaskManager taskManager) Sets this task's task manager.void
Sets the type of the task, which will be used to execute this task with theExecutor
that handles the same task type.Sets the type of the task, which will be used to execute this task with theExecutor
that 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:MetaData
This 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:
activateMetaData
in 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
null
if 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
null
if 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
-1
if 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
-1
if 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 theExecutor
that 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 theExecutor
that 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
null
if 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
null
if 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
null
if 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
-1
if 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
-true
if the task is busy; orfalse
otherwise- Since:
- 1.0
-
isBusy
public boolean isBusy()Indicates whether this task is currently being processed by anExecutor
.- Returns:
true
if the task is busy; orfalse
otherwise- Since:
- 1.0
-
clone
- Overrides:
clone
in classMetaData
- Throws:
CloneNotSupportedException
-
equals
-