public class Scheduler extends AbstractLogEnabled implements Component, Initializable, Disposable, Serviceable, Contextualizable
Modifier and Type | Field and Description |
---|---|
private static String |
__QUARTZ_CONFIG_FILE_NAME
The name of the configuration file for Quartz
|
private static String |
__RIGHT_SCHEDULER
The id of the right to execute actions on tasks
|
protected Context |
_context
The context
|
protected CurrentUserProvider |
_currentUserProvider
The provider of current user
|
protected ServiceManager |
_manager
The service manager
|
protected RightManager |
_rightManager
The rights manager
|
protected RunnableExtensionPoint |
_runnableEP
The extension point for
Runnable s |
protected SchedulableExtensionPoint |
_schedulableEP
The extension point for
Schedulable s |
protected Scheduler |
_scheduler
The Quartz scheduler
|
protected SourceResolver |
_sourceResolver
The source resolver
|
protected SQLDatabaseTypeExtensionPoint |
_sqlDatabaseTypeEP
The sql database type ep
|
protected SQLDataSourceManager |
_sqlDataSourceManager
The manager for SQL datasources
|
static String |
DATASOURCE_CONFIG_NAME
Name of the parameter holding the datasource id for Quartz
|
static String |
JOB_GROUP
The group name for jobs
|
static String |
KEY_RUNNABLE_CRON
The key for the runnable cron expression
|
static String |
KEY_RUNNABLE_DEACTIVATABLE
The key for the runnable deactivatable property
|
static String |
KEY_RUNNABLE_DESCRIPTION
The key for the runnable description
|
static String |
KEY_RUNNABLE_FIRE_PROCESS
The key for the runnable fire process property
|
static String |
KEY_RUNNABLE_ID
The key for the runnable id
|
static String |
KEY_RUNNABLE_LABEL
The key for the runnable label
|
static String |
KEY_RUNNABLE_MODIFIABLE
The key for the runnable modifiable property
|
static String |
KEY_RUNNABLE_REMOVABLE
The key for the runnable removable property
|
static String |
KEY_RUNNABLE_STARTUP_COMPLETED
The key for 'run at startup' jobs indicating if the job has already been executed and is now completed
|
static String |
KEY_RUNNABLE_VOLATILE
The key for the runnable volatile property
|
static String |
KEY_SCHEDULABLE_ID
The key for the id of the schedulable to execute
|
static String |
PARAM_VALUES_PREFIX
The prefix for the parameter values of the runnable job in the job data map
|
static String |
ROLE
The Avalon Role
|
static String |
TRIGGER_GROUP
The group name for triggers
|
Constructor and Description |
---|
Scheduler() |
Modifier and Type | Method and Description |
---|---|
private void |
_checkAndCreateTables(String dataSourceId) |
private Map<String,Object> |
_edit(String id,
String label,
String description,
Runnable.FireProcess fireProcess,
String cron,
String schedulableId,
boolean isVolatile,
Map<String,String> params) |
private String |
_generateUniqueId(String label) |
private String |
_getDriverDelegateClass(String dbType) |
private Map<String,Object> |
_getTypedParams(Map<String,String> params,
String schedulableId) |
private Map<String,Object> |
_jobToJson(JobKey jobKey,
List<String> executingJobs) |
private void |
_removeVolatileJobs() |
private JobDataMap |
_runnableToJobDataMap(Runnable runnable) |
private Map<String,Object> |
_schedulableToJson(Schedulable schedulable) |
private void |
_scheduleConfigurableJobs() |
private void |
_triggerRunAtStartupJobs() |
private void |
_triggerToJson(Trigger trigger,
Map<String,Object> result) |
Map<String,Object> |
add(String label,
String description,
String fireProcess,
String cron,
String schedulableId,
Map<String,String> params)
Adds a new task.
|
void |
contextualize(Context context) |
void |
dispose() |
Map<String,Object> |
edit(String id,
String label,
String description,
String fireProcess,
String cron,
Map<String,String> params)
Edits the given task.
|
Map<String,Object> |
enable(String id,
boolean enabled)
Enables/disables the given task.
|
Map<String,Object> |
getEditionConfiguration()
Gets the configuration for creating/editing a runnable (so returns all the schedulables and their parameters)
|
Set<JobKey> |
getJobs()
Gets the jobs of the Quartz scheduler
|
Map<String,Object> |
getParameters(String schedulableId)
Gets the parameters of a given schedulable
|
Map<String,Object> |
getParameterValues(String id)
Gets the values of the parameters of the given task
|
List<Map<String,Object>> |
getSchedulables()
Gets all the schedulables (private or not)
|
Scheduler |
getScheduler()
Get the Quartz scheduler
|
List<Map<String,Object>> |
getTasksAsJson()
Gets all the scheduled tasks
|
List<Map<String,Object>> |
getTasksInformation(List<String> taskIds)
Gets tasks information
|
void |
initialize() |
Map<String,Object> |
isEnabled(String id)
Returns the enabled state of the task.
|
Map<String,Object> |
isModifiable(String id)
Returns true if the given task is modifiable.
|
Map<String,Object> |
remove(String id)
Removes the given task.
|
List<Map<String,Object>> |
removeCompletedTasks()
Removes the completed tasks
|
void |
scheduleJob(Runnable runnable)
Schedules a job
|
void |
service(ServiceManager manager) |
void |
start()
Starts the Quartz scheduler.
|
getLogger, setLogger
public static final String JOB_GROUP
public static final String TRIGGER_GROUP
public static final String KEY_SCHEDULABLE_ID
public static final String KEY_RUNNABLE_ID
public static final String KEY_RUNNABLE_LABEL
public static final String KEY_RUNNABLE_DESCRIPTION
public static final String KEY_RUNNABLE_FIRE_PROCESS
public static final String KEY_RUNNABLE_STARTUP_COMPLETED
public static final String KEY_RUNNABLE_CRON
public static final String KEY_RUNNABLE_REMOVABLE
public static final String KEY_RUNNABLE_MODIFIABLE
public static final String KEY_RUNNABLE_DEACTIVATABLE
public static final String KEY_RUNNABLE_VOLATILE
public static final String PARAM_VALUES_PREFIX
public static final String DATASOURCE_CONFIG_NAME
private static final String __QUARTZ_CONFIG_FILE_NAME
private static final String __RIGHT_SCHEDULER
protected ServiceManager _manager
protected RunnableExtensionPoint _runnableEP
Runnable
sprotected SchedulableExtensionPoint _schedulableEP
Schedulable
sprotected Scheduler _scheduler
protected SQLDataSourceManager _sqlDataSourceManager
protected SourceResolver _sourceResolver
protected RightManager _rightManager
protected CurrentUserProvider _currentUserProvider
protected SQLDatabaseTypeExtensionPoint _sqlDatabaseTypeEP
public Scheduler()
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void initialize() throws Exception
initialize
in interface Initializable
Exception
private void _checkAndCreateTables(String dataSourceId)
private String _getDriverDelegateClass(String dbType)
public void start() throws SchedulerException
SchedulerException
- if an error occuredpublic Scheduler getScheduler()
private void _removeVolatileJobs() throws SchedulerException
SchedulerException
private void _scheduleConfigurableJobs()
private void _triggerRunAtStartupJobs() throws SchedulerException
SchedulerException
public void scheduleJob(Runnable runnable) throws SchedulerException
runnable
- The runnable job to scheduleSchedulerException
- if the Job or Trigger cannot be added to the Scheduler, or there is an internal Scheduler error.private JobDataMap _runnableToJobDataMap(Runnable runnable)
public Set<JobKey> getJobs() throws SchedulerException
SchedulerException
- if an error occuredpublic List<Map<String,Object>> getTasksInformation(List<String> taskIds) throws SchedulerException
taskIds
- The ids of the tasksSchedulerException
- if an error occuredpublic List<Map<String,Object>> getTasksAsJson() throws Exception
Exception
- if an error occuredprivate Map<String,Object> _jobToJson(JobKey jobKey, List<String> executingJobs) throws Exception
Exception
private void _triggerToJson(Trigger trigger, Map<String,Object> result) throws Exception
Exception
private Map<String,Object> _schedulableToJson(Schedulable schedulable) throws Exception
Exception
public Map<String,Object> getEditionConfiguration() throws Exception
Exception
- If an error occurs.public Map<String,Object> getParameters(String schedulableId) throws Exception
schedulableId
- The id of the schedulableException
- If an error occurs.public Map<String,Object> getParameterValues(String id)
id
- The id of the taskpublic Map<String,Object> isModifiable(String id) throws SchedulerException
id
- The id of the taskSchedulerException
- if an error occuredpublic Map<String,Object> add(String label, String description, String fireProcess, String cron, String schedulableId, Map<String,String> params) throws SchedulerException
label
- The labeldescription
- The descriptionfireProcess
- the fire processcron
- The cron expressionschedulableId
- The id of the schedulable modelparams
- The values of the parametersSchedulerException
- if an error occuredprivate String _generateUniqueId(String label) throws SchedulerException
SchedulerException
public Map<String,Object> edit(String id, String label, String description, String fireProcess, String cron, Map<String,String> params) throws SchedulerException
id
- The id of the tasklabel
- The labeldescription
- The descriptionfireProcess
- the fire processcron
- The cron expressionparams
- The values of the parametersSchedulerException
- if an error occuredprivate Map<String,Object> _edit(String id, String label, String description, Runnable.FireProcess fireProcess, String cron, String schedulableId, boolean isVolatile, Map<String,String> params)
private Map<String,Object> _getTypedParams(Map<String,String> params, String schedulableId)
public Map<String,Object> remove(String id)
id
- The id of the taskpublic Map<String,Object> enable(String id, boolean enabled)
id
- The id of the taskenabled
- true to enable the task, false to disable it.public List<Map<String,Object>> removeCompletedTasks() throws SchedulerException
SchedulerException
- if an error occuredpublic Map<String,Object> isEnabled(String id)
id
- The id of the taskpublic List<Map<String,Object>> getSchedulables()
public void dispose()
dispose
in interface Disposable