Class SchedulerService
A scheduler definition is stored in a document with the type "scheduler". The document can provide concrete information to process the timer event.
The TimerService can be started using the method start(). The Methods findTimerDescription and findAllTimerDescriptions are used to lookup enabled and running service instances.
Each Method expects or generates a TimerDescription Object. This object is an instance of a ItemCollection. To create a new timer the ItemCollection should contain the following attributes:
- type - fixed to value 'scheduler'
- _scheduler_definition - the chron/calendar definition for the Java EE timer service.
- _scheduler_enabled - boolean indicates if the scheduler is enabled/disabled
- _scheduler_class - class name of the scheduler implementation
- _scheduelr_log - optional log information
the following additional attributes are generated by the finder methods and can be used by an application to verfiy the status of a running instance:
- nextTimeout - Next Timeout - pint of time when the service will be scheduled
- timeRemaining - Timeout in milliseconds
- statusmessage - text message
- Version:
- 1.0
- Author:
- rsoika
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.ejb.Timer
createTimerOnCalendar
(ItemCollection configItemCollection) Create a calendar-based timer based on a input schedule expression.protected Scheduler
findSchedulerByName
(String schedulerClassName) This method returns a n injected JobHandler by name or null if no JobHandler with the requested class name is injected.jakarta.ejb.Timer
This method returns a timer for a corresponding id if such a timer object exists.loadConfiguration
(String name) Loads the scheduler configuration entity by name.void
logMessage
(String message, ItemCollection configuration, ItemCollection workitem) Creates a new log entry stored in the item _scheduler_log.void
logWarning
(String message, ItemCollection configuration, ItemCollection workitem) Creates a new log entry stored in the item _scheduler_log.protected void
onTimeout
(jakarta.ejb.Timer timer) This is the method which processes the timeout event depending on the running timer settings.saveConfiguration
(ItemCollection configItemCollection) This method saves the scheduler configuration.start
(ItemCollection configuration) Starts a new Timer for the scheduler defined by the Configuration.void
This method will start all schedulers which are not yet started.stop
(ItemCollection configuration) Cancels a running timer instance.stop
(ItemCollection configuration, jakarta.ejb.Timer timer) void
updateTimerDetails
(ItemCollection configuration) Updates the timer details of a running timer service.
-
Field Details
-
DOCUMENT_TYPE
- See Also:
-
-
Constructor Details
-
SchedulerService
public SchedulerService()
-
-
Method Details
-
loadConfiguration
Loads the scheduler configuration entity by name. The method returns null if no scheduler configuration exits.- Returns:
-
saveConfiguration
This method saves the scheduler configuration. The method ensures that the following properties are set to default.- type
- name
- $writeAccess
- $readAccess
- Returns:
- Throws:
AccessDeniedException
-
start
public ItemCollection start(ItemCollection configuration) throws AccessDeniedException, ParseException Starts a new Timer for the scheduler defined by the Configuration.The Timer can be started based on a Calendar setting stored in the property _scheduler_definition.
The $UniqueID of the configuration entity is the id of the timer to be controlled.
The method throws an exception if the configuration entity contains invalid attributes or values.
After the timer was started the configuration is updated with the latest statusmessage. The item _schedueler_enabled will be set to 'true'.
The method returns the updated configuration. The configuration will not be saved!
- Parameters:
configuration
- - scheduler configuration- Returns:
- updated configuration
- Throws:
AccessDeniedException
ParseException
-
stop
Cancels a running timer instance. After cancel a timer the corresponding timerDescripton (ItemCollection) is no longer valid.The method returns the current configuration. The configuration will not be saved!
-
stop
-
startAllSchedulers
public void startAllSchedulers()This method will start all schedulers which are not yet started. The method is called for example by the SchedulerStartupServlet. -
findTimer
This method returns a timer for a corresponding id if such a timer object exists.- Parameters:
id
-- Returns:
- Timer
- Throws:
Exception
-
updateTimerDetails
Updates the timer details of a running timer service. The method updates the properties netxtTimeout and timeRemaining and store them into the timer configuration.- Parameters:
configuration
- - the current scheduler configuration to be updated.
-
logMessage
Creates a new log entry stored in the item _scheduler_log. The log can be writen optional to the scheduler configuration and a workitem.- Parameters:
message
-configuration
-
-
logWarning
Creates a new log entry stored in the item _scheduler_log. The log can be writen optional to the scheduler configuration and a workitem.- Parameters:
message
-configuration
-
-
findSchedulerByName
This method returns a n injected JobHandler by name or null if no JobHandler with the requested class name is injected.- Parameters:
jobHandlerClassName
-- Returns:
- jobHandler class or null if not found
-
onTimeout
protected void onTimeout(jakarta.ejb.Timer timer) This is the method which processes the timeout event depending on the running timer settings. The method calls the abstract method 'process' which need to be implemented by a subclass.- Parameters:
timer
-- Throws:
Exception
QueryException
-
createTimerOnCalendar
protected jakarta.ejb.Timer createTimerOnCalendar(ItemCollection configItemCollection) throws ParseException Create a calendar-based timer based on a input schedule expression. The expression will be parsed by this method. Example:second=0 minute=0 hour=* dayOfWeek= dayOfMonth= month= year=*
- Parameters:
sConfiguation
-- Returns:
- Throws:
ParseException
-