Package org.opencms.scheduler
Class CmsScheduleManager
java.lang.Object
org.opencms.scheduler.CmsScheduleManager
- All Implemented Interfaces:
org.quartz.Job
Manages the OpenCms scheduled jobs.
Please see the documentation of the class CmsScheduledJobInfo
for a full description of the OpenCms scheduling capabilities.
The OpenCms scheduler implementation internally uses the Quartz scheduler from the OpenSymphony project.
This manager class implements the org.quartz.Job
interface
and wraps all calls to the I_CmsScheduledJob
implementing
classes.
- Since:
- 6.0.0
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Key for the scheduled job description in the job data map. -
Constructor Summary
ConstructorDescriptionDefault constructor for the scheduler manager, used only when a new job is scheduled.CmsScheduleManager
(List<CmsScheduledJobInfo> configuredJobs) Used by the configuration to create a new Scheduler during system startup. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(org.quartz.JobExecutionContext context) Implementation of the Quartz job interface.void
executeDirectly
(String jobId) Given a job ID, this directly executes the corresponding job.protected void
executeJob
(CmsScheduledJobInfo jobInfo) Executes the given job.Returns the currently scheduled job description identified by the given id.getJobs()
Returns the currently scheduled job descriptions in an unmodifiable list.void
initialize
(CmsObject adminCms) Initializes the OpenCms scheduler.void
scheduleJob
(CmsObject cms, CmsScheduledJobInfo jobInfo) Adds a new job to the scheduler.void
shutDown()
Shuts down this instance of the OpenCms scheduler manager.unscheduleJob
(CmsObject cms, String jobId) Removes a currently scheduled job from the scheduler.
-
Field Details
-
SCHEDULER_JOB_INFO
Key for the scheduled job description in the job data map.- See Also:
-
-
Constructor Details
-
CmsScheduleManager
public CmsScheduleManager()Default constructor for the scheduler manager, used only when a new job is scheduled. -
CmsScheduleManager
Used by the configuration to create a new Scheduler during system startup.- Parameters:
configuredJobs
- the jobs from the configuration
-
-
Method Details
-
execute
Implementation of the Quartz job interface.The architecture is that this scheduler manager generates a new (empty) instance of itself for every OpenCms job scheduled with Quartz. When the Quartz job is executed, the configured implementation of
I_CmsScheduledJob
will be called from this method.- Specified by:
execute
in interfaceorg.quartz.Job
- See Also:
-
Job.execute(org.quartz.JobExecutionContext)
-
executeDirectly
Given a job ID, this directly executes the corresponding job.- Parameters:
jobId
- the job id
-
getJob
Returns the currently scheduled job description identified by the given id.- Parameters:
id
- the job id- Returns:
- a job or
null
if not found
-
getJobs
Returns the currently scheduled job descriptions in an unmodifiable list.The objects in the List are of type
.CmsScheduledJobInfo
- Returns:
- the currently scheduled job descriptions in an unmodifiable list
-
initialize
Initializes the OpenCms scheduler.- Parameters:
adminCms
- an OpenCms context object that must have been initialized with "Admin" permissions- Throws:
CmsRoleViolationException
- if the user has insufficient role permissions
-
scheduleJob
public void scheduleJob(CmsObject cms, CmsScheduledJobInfo jobInfo) throws CmsRoleViolationException, CmsSchedulerException Adds a new job to the scheduler.- Parameters:
cms
- an OpenCms context object that must have been initialized with "Admin" permissionsjobInfo
- the job info describing the job to schedule- Throws:
CmsRoleViolationException
- if the user has insufficient role permissionsCmsSchedulerException
- if the job could not be scheduled for any reason
-
shutDown
Shuts down this instance of the OpenCms scheduler manager. -
unscheduleJob
public CmsScheduledJobInfo unscheduleJob(CmsObject cms, String jobId) throws CmsRoleViolationException Removes a currently scheduled job from the scheduler.- Parameters:
cms
- an OpenCms context object that must have been initialized with "Admin" permissionsjobId
- the id of the job to unschedule, obtained withCmsScheduledJobInfo.getId()
- Returns:
- the
of the sucessfully unscheduled job, orCmsScheduledJobInfo
null
if the job could not be unscheduled - Throws:
CmsRoleViolationException
- if the user has insufficient role permissions
-
executeJob
Executes the given job.- Parameters:
jobInfo
- the job info bean
-