Interface IScheduledTask
- All Superinterfaces:
- AutoCloseable,- Closeable,- Runnable
To configure a task and its schedule, you add properties to a properties file in the following format:
CustomTaskScheduler.TaskName.Class=com.example.ScheduledTask CustomTaskScheduler.TaskName.Expression=* * * * *
Here, TaskName is a name that uniquely identifies an instance of a task, 
 com.example.ScheduledTask is the fully qualified name of the task class, and 
 * * * * * is a cron expression that defines the schedule to run the task on.
 
Note: You can create multiple tasks from the same implementation class, provided that they all have different names.
- Since:
- 12.0
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA set of methods that provide access to other server APIs that you can use from inside aIScheduledTask.
- 
Method SummaryModifier and TypeMethodDescriptiondefault voidclose()Performs teardown or finalization on resources that the task required.default voidonStartup(IScheduledTask.IScheduledTaskObjects scheduledTaskObjects) Performs configuration or initialization that enables the task to run.voidrun()Executes the task.
- 
Method Details- 
runExecutes the task.The server calls this method to perform the custom action, based on the schedule defined by the cron expression in the properties file. If this method encounters a problem, it must throw a CustomTaskFailedExceptionthat tells the server what to do next. Depending on how the exception is constructed, the server might re-run the task immediately, or when it is next scheduled, or never.If this method throws an exception other than CustomTaskFailedException, the custom task is canceled and will not run again until the scheduler is reinitialized through a server restart.- Specified by:
- runin interface- Runnable
- Throws:
- CustomTaskFailedException- If task execution fails.
 
- 
onStartupPerforms configuration or initialization that enables the task to run.The server calls this method during startup, to give the task the opportunity to make itself ready to run. The task can also get access to other server APIs through the scheduledTaskObjectsparameter. Implementing this method is optional; by default it does nothing.- Parameters:
- scheduledTaskObjects- A set of methods that the task can call to retrieve API objects.
 
- 
closedefault void close()Performs teardown or finalization on resources that the task required.The server calls this method during shutdown, to give the task the opportunity to release any resources that it used. Implementing this method is optional; by default it does nothing. - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
 
-