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
Modifier and TypeFieldDescriptionprotected Context
The contextprotected CurrentUserProvider
The provider of current userprotected ServiceManager
The service managerprotected RightManager
The rights managerprotected RunnableExtensionPoint
The extension point forRunnable
sprotected SchedulableExtensionPoint
The extension point forSchedulable
sprotected Scheduler
The Quartz schedulerprotected SourceResolver
The source resolverprotected SQLDatabaseTypeExtensionPoint
The sql database type epprotected SQLDataSourceManager
The manager for SQL datasourcesprotected UserHelper
The user helperprotected UserManager
The user managerstatic final String
Name of the parameter holding the datasource id for Quartzstatic final String
The group name for jobsstatic final String
The key for the runnable cron expressionstatic final String
The key for the runnable deactivatable propertystatic final String
The key for the runnable descriptionstatic final String
The key for the runnable fire process propertystatic final String
The key for the runnable idstatic final String
The key for the runnable labelstatic final String
The key for the runnable modifiable propertystatic final String
The key for the runnable removable propertystatic final String
The key for 'run at startup' jobs indicating if the job has already been executed and is now completedstatic final String
The key to retrieve theUserIdentity
static final String
The key for the runnable volatile propertystatic final String
The key for the id of the schedulable to executestatic final String
The prefix for the parameter values of the runnable job in the job data mapstatic final String
The Avalon Rolestatic final String
The group name for triggers -
Constructor Summary
-
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.void
contextualize
(Context context) void
dispose()
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 informationvoid
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 completed tasksvoid
scheduleJob
(Runnable runnable) Schedules a jobvoid
service
(ServiceManager manager) void
start()
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 forRunnable
s -
_schedulableEP
The extension point forSchedulable
s -
_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:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in 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 task.- Parameters:
id
- The id of the task- Returns:
- A result map
- Throws:
SchedulerException
- if an error occured
-
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:
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:
dispose
in interfaceDisposable
-