public class CmsScheduleManager extends java.lang.Object implements org.quartz.Job
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.
CmsScheduledJobInfo
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SCHEDULER_JOB_INFO
Key for the scheduled job description in the job data map.
|
Constructor and Description |
---|
CmsScheduleManager()
Default constructor for the scheduler manager,
used only when a new job is scheduled.
|
CmsScheduleManager(java.util.List<CmsScheduledJobInfo> configuredJobs)
Used by the configuration to create a new Scheduler during system startup.
|
Modifier and Type | Method and Description |
---|---|
void |
execute(org.quartz.JobExecutionContext context)
Implementation of the Quartz job interface.
|
void |
executeDirectly(java.lang.String jobId)
Given a job ID, this directly executes the corresponding job.
|
protected void |
executeJob(CmsScheduledJobInfo jobInfo)
Executes the given job.
|
CmsScheduledJobInfo |
getJob(java.lang.String id)
Returns the currently scheduled job description identified by the given id.
|
java.util.List<CmsScheduledJobInfo> |
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.
|
CmsScheduledJobInfo |
unscheduleJob(CmsObject cms,
java.lang.String jobId)
Removes a currently scheduled job from the scheduler.
|
public static final java.lang.String SCHEDULER_JOB_INFO
public CmsScheduleManager()
public CmsScheduleManager(java.util.List<CmsScheduledJobInfo> configuredJobs)
configuredJobs
- the jobs from the configurationpublic void execute(org.quartz.JobExecutionContext context)
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.
execute
in interface org.quartz.Job
Job.execute(org.quartz.JobExecutionContext)
public void executeDirectly(java.lang.String jobId)
jobId
- the job idpublic CmsScheduledJobInfo getJob(java.lang.String id)
id
- the job idnull
if not foundpublic java.util.List<CmsScheduledJobInfo> getJobs()
The objects in the List are of type
.CmsScheduledJobInfo
public void initialize(CmsObject adminCms) throws CmsRoleViolationException
adminCms
- an OpenCms context object that must have been initialized with "Admin" permissionsCmsRoleViolationException
- if the user has insufficient role permissionspublic void scheduleJob(CmsObject cms, CmsScheduledJobInfo jobInfo) throws CmsRoleViolationException, CmsSchedulerException
cms
- an OpenCms context object that must have been initialized with "Admin" permissionsjobInfo
- the job info describing the job to scheduleCmsRoleViolationException
- if the user has insufficient role permissionsCmsSchedulerException
- if the job could not be scheduled for any reasonpublic void shutDown()
public CmsScheduledJobInfo unscheduleJob(CmsObject cms, java.lang.String jobId) throws CmsRoleViolationException
cms
- an OpenCms context object that must have been initialized with "Admin" permissionsjobId
- the id of the job to unschedule, obtained with CmsScheduledJobInfo.getId()
CmsScheduledJobInfo
of the sucessfully unscheduled job,
or null
if the job could not be unscheduledCmsRoleViolationException
- if the user has insufficient role permissionsprotected void executeJob(CmsScheduledJobInfo jobInfo)
jobInfo
- the job info bean