Package org.ametys.plugins.core.schedule
Class Scheduler
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.core.schedule.Scheduler
- All Implemented Interfaces:
LogEnabled,Disposable,Initializable,Component,Contextualizable,Serviceable
public class Scheduler
extends AbstractLogEnabled
implements Component, Initializable, Disposable, Serviceable, Contextualizable
The scheduler component
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ContextThe contextprotected CurrentUserProviderThe provider of current userprotected ServiceManagerThe service managerprotected RightManagerThe rights managerprotected RunnableExtensionPointThe extension point forRunnablesprotected SchedulableExtensionPointThe extension point forSchedulablesprotected SchedulerThe Quartz schedulerprotected SourceResolverThe source resolverprotected SQLDatabaseTypeExtensionPointThe sql database type epprotected SQLDataSourceManagerThe manager for SQL datasourcesprotected UserHelperThe user helperprotected UserManagerThe user managerstatic final StringName of the parameter holding the datasource id for Quartzstatic final StringThe group name for jobsstatic final StringThe key for the runnable cron expressionstatic final StringThe key for the runnable deactivatable propertystatic final StringThe key for the runnable descriptionstatic final StringThe key for the runnable fire process propertystatic final StringThe key for the runnable idstatic final StringThe key for the runnable labelstatic final StringThe key for the runnable modifiable propertystatic final StringThe key for the runnable removable propertystatic final StringThe key for 'run at startup' jobs indicating if the job has already been executed and is now completedstatic final StringThe key to retrieve theUserIdentitystatic final StringThe key for the runnable volatile propertystatic final StringThe key for the id of the schedulable to executestatic final StringThe prefix for the parameter values of the runnable job in the job data mapstatic final StringThe Avalon Rolestatic final StringThe group name for triggers -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(String label, String description, String fireProcess, String cron, String schedulableId, Map<String, Object> params) Adds a new task.add(String label, String description, String fireProcess, String cron, String schedulableId, Map<String, Object> launchUser, Map<String, Object> params) Adds a new task.voidcontextualize(Context context) voiddispose()edit(String id, String label, String description, String fireProcess, String cron, Map<String, Object> launchUser, Map<String, Object> params) Edits the given task.Enables/disables the given task.Gets the configuration for creating/editing a runnable (so returns all the schedulables and their parameters)getJobs()Gets the jobs of the Quartz schedulergetParameters(String schedulableId) Gets the parameters of a given schedulableGets the values of the parameters of the given taskGets all the schedulables (private or not)Get the Quartz schedulerGets all the scheduled tasksgetTasksInformation(List<String> taskIds) Gets tasks informationvoidReturns the enabled state of the task.Returns the enabled state of the task.isModifiable(String id) Returns true if the given task is modifiable.Returns the running state of the task.Removes the given task.Removes the given tasks.Removes the completed tasksvoidscheduleJob(Runnable runnable) Schedules a jobvoidservice(ServiceManager manager) voidstart()Starts the Quartz scheduler.Immediately trigger the given task.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The Avalon Role -
JOB_GROUP
The group name for jobs- See Also:
-
TRIGGER_GROUP
The group name for triggers- See Also:
-
KEY_SCHEDULABLE_ID
The key for the id of the schedulable to execute- See Also:
-
KEY_RUNNABLE_ID
The key for the runnable id- See Also:
-
KEY_RUNNABLE_LABEL
The key for the runnable label- See Also:
-
KEY_RUNNABLE_DESCRIPTION
The key for the runnable description- See Also:
-
KEY_RUNNABLE_FIRE_PROCESS
The key for the runnable fire process property- See Also:
-
KEY_RUNNABLE_STARTUP_COMPLETED
The key for 'run at startup' jobs indicating if the job has already been executed and is now completed- See Also:
-
KEY_RUNNABLE_CRON
The key for the runnable cron expression- See Also:
-
KEY_RUNNABLE_REMOVABLE
The key for the runnable removable property- See Also:
-
KEY_RUNNABLE_MODIFIABLE
The key for the runnable modifiable property- See Also:
-
KEY_RUNNABLE_DEACTIVATABLE
The key for the runnable deactivatable property- See Also:
-
KEY_RUNNABLE_VOLATILE
The key for the runnable volatile property- See Also:
-
KEY_RUNNABLE_USERIDENTITY
The key to retrieve theUserIdentity- See Also:
-
PARAM_VALUES_PREFIX
The prefix for the parameter values of the runnable job in the job data map- See Also:
-
DATASOURCE_CONFIG_NAME
Name of the parameter holding the datasource id for Quartz- See Also:
-
_manager
The service manager -
_context
The context -
_runnableEP
The extension point forRunnables -
_schedulableEP
The extension point forSchedulables -
_scheduler
The Quartz scheduler -
_sqlDataSourceManager
The manager for SQL datasources -
_sourceResolver
The source resolver -
_rightManager
The rights manager -
_currentUserProvider
The provider of current user -
_sqlDatabaseTypeEP
The sql database type ep -
_userManager
The user manager -
_userHelper
The user helper
-
-
Constructor Details
-
Scheduler
public Scheduler()
-
-
Method Details
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
start
Starts the Quartz scheduler. Only call this method once !- Throws:
SchedulerException- if an error occured
-
getScheduler
Get the Quartz scheduler- Returns:
- the scheduler
-
scheduleJob
Schedules a job- Parameters:
runnable- The runnable job to schedule- Throws:
SchedulerException- if the Job or Trigger cannot be added to the Scheduler, or there is an internal Scheduler error.
-
getJobs
Gets the jobs of the Quartz scheduler- Returns:
- the jobs
- Throws:
SchedulerException- if an error occured
-
getTasksInformation
Gets tasks information- Parameters:
taskIds- The ids of the tasks- Returns:
- The tasks information
- Throws:
SchedulerException- if an error occurred
-
getTasksAsJson
Gets all the scheduled tasks- Returns:
- the scheduled tasks
- Throws:
Exception- if an error occured
-
getEditionConfiguration
Gets the configuration for creating/editing a runnable (so returns all the schedulables and their parameters)- Returns:
- A map containing information about what is needed to create/edit a runnable
- Throws:
Exception- If an error occurs.
-
getParameters
Gets the parameters of a given schedulable- Parameters:
schedulableId- The id of the schedulable- Returns:
- A map containing parameters (prefixed) of the given schedulable
- Throws:
Exception- If an error occurs.
-
getParameterValues
Gets the values of the parameters of the given task- Parameters:
id- The id of the task- Returns:
- The values of the parameters
-
isModifiable
Returns true if the given task is modifiable.- Parameters:
id- The id of the task- Returns:
- true if the given task is modifiable.
- Throws:
SchedulerException- if an error occured
-
add
public Map<String,Object> add(String label, String description, String fireProcess, String cron, String schedulableId, Map<String, Object> params) throws SchedulerExceptionAdds a new task.- Parameters:
label- The labeldescription- The descriptionfireProcess- the fire processcron- The cron expressionschedulableId- The id of the schedulable modelparams- The values of the parameters- Returns:
- A result map
- Throws:
SchedulerException- if an error occured
-
add
public Map<String,Object> add(String label, String description, String fireProcess, String cron, String schedulableId, Map<String, Object> launchUser, Map<String, throws SchedulerExceptionObject> params) Adds a new task.- Parameters:
label- The labeldescription- The descriptionfireProcess- the fire processcron- The cron expressionschedulableId- The id of the schedulable modellaunchUser- The user to launch the taskparams- The values of the parameters- Returns:
- A result map
- Throws:
SchedulerException- if an error occured
-
edit
public Map<String,Object> edit(String id, String label, String description, String fireProcess, String cron, Map<String, Object> launchUser, Map<String, throws SchedulerExceptionObject> params) Edits the given task.- Parameters:
id- The id of the tasklabel- The labeldescription- The descriptionfireProcess- the fire processcron- The cron expressionlaunchUser- The user to launch the taskparams- The values of the parameters- Returns:
- A result map
- Throws:
SchedulerException- if an error occured
-
remove
Removes the given tasks.- Parameters:
ids- The ids of the tasks- Returns:
- A result map
- Throws:
SchedulerException- if an error occurred
-
remove
Removes the given task.- Parameters:
id- The id of the task- Returns:
- A result map
- Throws:
SchedulerException- if an error occurred
-
trigger
Immediately trigger the given task.- Parameters:
id- The id of the task- Returns:
- A result map
- Throws:
SchedulerException- if an error occurred
-
enable
Enables/disables the given task.- Parameters:
id- The id of the taskenabled- true to enable the task, false to disable it.- Returns:
- A result map
-
removeCompletedTasks
Removes the completed tasks- Returns:
- The information of deleted tasks
- Throws:
SchedulerException- if an error occured
-
isEnabled
Returns the enabled state of the task.- Parameters:
ids- The ids of the tasks- Returns:
- A result map
-
isEnabled
Returns the enabled state of the task.- Parameters:
id- The id of the task- Returns:
- A result map
-
isRunning
Returns the running state of the task.- Parameters:
id- The id of the task- Returns:
- A result map
-
getSchedulables
Gets all the schedulables (private or not)- Returns:
- the schedulables
-
dispose
- Specified by:
disposein interfaceDisposable
-