org.apache.cocoon.components.cron
Class QuartzJobScheduler

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.components.cron.QuartzJobScheduler
All Implemented Interfaces:
Disposable, Initializable, Startable, Component, Configurable, Contextualizable, LogEnabled, Serviceable, ThreadSafe, JobScheduler
Direct Known Subclasses:
CocoonQuartzJobScheduler

public class QuartzJobScheduler
extends AbstractLogEnabled
implements JobScheduler, Component, ThreadSafe, Serviceable, Configurable, Startable, Disposable, Contextualizable, Initializable

This component can either schedule jobs or directly execute one.

Since:
2.1.1
Version:
CVS $Id: QuartzJobScheduler.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Giacomo Pati

Field Summary
 
Fields inherited from interface org.apache.cocoon.components.cron.JobScheduler
ROLE
 
Constructor Summary
QuartzJobScheduler()
           
 
Method Summary
 void addJob(String name, Object job, String cronSpec, boolean canRunConcurrently)
          Schedule a time based job.
 void addJob(String name, Object job, String cronSpec, boolean canRunConcurrently, Parameters params, Map objects)
          Schedule a job.
 void addJob(String name, String jobrole, String cronSpec, boolean canRunConcurrently)
          Schedule a time based job.
 void addJob(String name, String jobrole, String cronSpec, boolean canRunConcurrently, Parameters params, Map objects)
          Schedule a time based job.
 void addPeriodicJob(String name, Object job, long period, boolean canRunConcurrently, Parameters params, Map objects)
          Schedule a periodic job.
 void addPeriodicJob(String name, String jobrole, long period, boolean canRunConcurrently, Parameters params, Map objects)
          Schedule a period job.
 void configure(Configuration config)
           
 void contextualize(Context context)
           
protected  org.quartz.JobDetail createJobDetail(String name, org.quartz.JobDataMap jobDataMap)
           
protected  org.quartz.Job createJobExecutor()
           
 void dispose()
           
 boolean fireJob(Object job)
          Fire a CronJob once immediately
 boolean fireJob(Object job, Parameters params, Map objects)
          Fire a job once immediately
 boolean fireJob(String jobrole)
          Fire a job once immediately
 boolean fireJob(String jobrole, Parameters params, Map objects)
          Fire a job once immediately
 void fireJobAt(Date date, String name, Object job)
          Fire a job once at a specific date Note that if a job with the same name has already beed added it is overwritten.
 void fireJobAt(Date date, String name, Object job, Parameters params, Map objects)
          Fire a job once at a specific date Note that if a job with the same name has already beed added it is overwritten.
 void fireJobAt(Date date, String name, String jobrole)
          Fire a job once at a specific date Note that if a job with the same name has already beed added it is overwritten.
 void fireJobAt(Date date, String name, String jobrole, Parameters params, Map objects)
          Fire a job once at a specific date Note that if a job with the same name has already beed added it is overwritten.
 String[] getJobNames()
          Get the names of all scheduled jobs.
 JobSchedulerEntry getJobSchedulerEntry(String jobname)
          Get the JobSchedulerEntry for a scheduled job
protected  org.quartz.JobDataMap initDataMap(org.quartz.JobDataMap jobDataMap, String jobName, boolean concurent, Parameters params, Map objects)
           
 void initialize()
           
 void removeJob(String name)
          Remove a scheduled job by name.
 void service(ServiceManager manager)
           
 void start()
           
 void stop()
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuartzJobScheduler

public QuartzJobScheduler()
Method Detail

getJobNames

public String[] getJobNames()
Description copied from interface: JobScheduler
Get the names of all scheduled jobs.

Specified by:
getJobNames in interface JobScheduler
Returns:
state of execution successfullness

getJobSchedulerEntry

public JobSchedulerEntry getJobSchedulerEntry(String jobname)
Description copied from interface: JobScheduler
Get the JobSchedulerEntry for a scheduled job

Specified by:
getJobSchedulerEntry in interface JobScheduler
Returns:
the entry

addJob

public void addJob(String name,
                   Object job,
                   String cronSpec,
                   boolean canRunConcurrently,
                   Parameters params,
                   Map objects)
            throws CascadingException
Description copied from interface: JobScheduler
Schedule a job. Note that if a job with the same name has already beed added it is overwritten.

Specified by:
addJob in interface JobScheduler
Parameters:
name - the name of the job
job - The job object itself. It must implement either CronJob, Runnable or might also be an implementation specific class (i.e. org.quartz.Job)
cronSpec - the time specification using a scheduling expression
canRunConcurrently - whether this job can run even previous scheduled runs are still running
params - Additional Parameters to setup CronJob
objects - A Map with additional object to setup CronJob
Throws:
CascadingException

addJob

public void addJob(String name,
                   String jobrole,
                   String cronSpec,
                   boolean canRunConcurrently,
                   Parameters params,
                   Map objects)
            throws CascadingException
Description copied from interface: JobScheduler
Schedule a time based job. Note that if a job with the same name has already beed added it is overwritten.

Specified by:
addJob in interface JobScheduler
Parameters:
name - the name of the job
jobrole - The Avalon components role name of the job itself
cronSpec - the time specification using a scheduling expression
canRunConcurrently - whether this job can run even previous scheduled runs are still running
params - Additional Parameters to setup CronJob
objects - A Map with additional object to setup CronJob
Throws:
CascadingException

addJob

public void addJob(String name,
                   Object job,
                   String cronSpec,
                   boolean canRunConcurrently)
            throws CascadingException
Description copied from interface: JobScheduler
Schedule a time based job. Note that if a job with the same name has already beed added it is overwritten.

Specified by:
addJob in interface JobScheduler
Parameters:
name - the name of the job
job - The job object itself. It must implement either CronJob, Runnable or might also be an implementation specific class (i.e. org.quartz.Job)
cronSpec - the time specification using a scheduling expression
canRunConcurrently - whether this job can run even previous scheduled runs are still running
Throws:
CascadingException

addJob

public void addJob(String name,
                   String jobrole,
                   String cronSpec,
                   boolean canRunConcurrently)
            throws CascadingException
Description copied from interface: JobScheduler
Schedule a time based job. Note that if a job with the same name has already beed added it is overwritten.

Specified by:
addJob in interface JobScheduler
Parameters:
name - the name of the job
jobrole - The Avalon components role name of the job itself
cronSpec - the time specification using a scheduling expression
canRunConcurrently - whether this job can run even previous scheduled runs are still running
Throws:
CascadingException

addPeriodicJob

public void addPeriodicJob(String name,
                           String jobrole,
                           long period,
                           boolean canRunConcurrently,
                           Parameters params,
                           Map objects)
                    throws CascadingException
Schedule a period job. Note that if a Job already has same name then it is overwritten.

Specified by:
addPeriodicJob in interface JobScheduler
Parameters:
name - the name of the job
jobrole - The Avalon components role name of the job itself
period - Every period seconds this job is started
canRunConcurrently - whether this job can run even previous scheduled runs are still running
params - additional Parameters to be passed to the job
objects - additional objects to be passed to the job
Throws:
CascadingException - in case of failures

addPeriodicJob

public void addPeriodicJob(String name,
                           Object job,
                           long period,
                           boolean canRunConcurrently,
                           Parameters params,
                           Map objects)
                    throws CascadingException
Schedule a periodic job. The job is started the first time when the period has passed. Note that if a job with the same name has already beed added it is overwritten.

Specified by:
addPeriodicJob in interface JobScheduler
Parameters:
name - the name of the job
job - The job object itself. It must implement either CronJob, Runnable or might also be an implementation specific class (i.e. org.quartz.Job)
period - Every period seconds this job is started
canRunConcurrently - whether this job can run even previous scheduled runs are still running
params - Additional Parameters to setup CronJob
objects - A Map with additional object to setup CronJob
Throws:
CascadingException

configure

public void configure(Configuration config)
               throws ConfigurationException
Specified by:
configure in interface Configurable
Throws:
ConfigurationException

dispose

public void dispose()
Specified by:
dispose in interface Disposable

contextualize

public void contextualize(Context context)
                   throws ContextException
Specified by:
contextualize in interface Contextualizable
Throws:
ContextException

initialize

public void initialize()
                throws Exception
Specified by:
initialize in interface Initializable
Throws:
Exception

fireJob

public boolean fireJob(Object job)
Description copied from interface: JobScheduler
Fire a CronJob once immediately

Specified by:
fireJob in interface JobScheduler
Parameters:
job - The job object itself. It must implement either CronJob, Runnable or might also be an implementation specific class (i.e. org.quartz.Job)
Returns:
whether the job has been successfully started

fireJob

public boolean fireJob(String jobrole)
Description copied from interface: JobScheduler
Fire a job once immediately

Specified by:
fireJob in interface JobScheduler
Parameters:
jobrole - The Avalon components role name of the job itself
Returns:
success state adding the job

fireJob

public boolean fireJob(Object job,
                       Parameters params,
                       Map objects)
                throws CascadingException
Description copied from interface: JobScheduler
Fire a job once immediately

Specified by:
fireJob in interface JobScheduler
Parameters:
job - The job object itself. It must implement either CronJob, Runnable or might also be an implementation specific class (i.e. org.quartz.Job)
params - Additional Parameters to setup CronJob
objects - A Map with additional object to setup CronJob
Returns:
whether the job has been successfully started
Throws:
CascadingException

fireJob

public boolean fireJob(String jobrole,
                       Parameters params,
                       Map objects)
                throws CascadingException
Description copied from interface: JobScheduler
Fire a job once immediately

Specified by:
fireJob in interface JobScheduler
Parameters:
jobrole - The Avalon components role name of the job itself
params - Additional Parameters to setup CronJob
objects - A Map with additional object to setup CronJob
Returns:
whether the job has been successfully started
Throws:
CascadingException

fireJobAt

public void fireJobAt(Date date,
                      String name,
                      Object job)
               throws CascadingException
Description copied from interface: JobScheduler
Fire a job once at a specific date Note that if a job with the same name has already beed added it is overwritten.

Specified by:
fireJobAt in interface JobScheduler
Parameters:
date - The date this job should be scheduled
name - the name of the job
job - The job object itself. It must implement either CronJob, Runnable or might also be an implementation specific class (i.e. org.quartz.Job)
Throws:
CascadingException

fireJobAt

public void fireJobAt(Date date,
                      String name,
                      String jobrole)
               throws CascadingException
Description copied from interface: JobScheduler
Fire a job once at a specific date Note that if a job with the same name has already beed added it is overwritten.

Specified by:
fireJobAt in interface JobScheduler
Parameters:
date - The date this job should be scheduled
name - the name of the job
jobrole - The Avalon components role name of the job itself
Throws:
CascadingException

fireJobAt

public void fireJobAt(Date date,
                      String name,
                      Object job,
                      Parameters params,
                      Map objects)
               throws CascadingException
Description copied from interface: JobScheduler
Fire a job once at a specific date Note that if a job with the same name has already beed added it is overwritten.

Specified by:
fireJobAt in interface JobScheduler
Parameters:
date - The date this job should be scheduled
name - the name of the job
job - The job object itself. It must implement either CronJob, Runnable or might also be an implementation specific class (i.e. org.quartz.Job)
params - Additional Parameters to setup CronJob
objects - A Map with additional object to setup CronJob
Throws:
CascadingException

fireJobAt

public void fireJobAt(Date date,
                      String name,
                      String jobrole,
                      Parameters params,
                      Map objects)
               throws CascadingException
Description copied from interface: JobScheduler
Fire a job once at a specific date Note that if a job with the same name has already beed added it is overwritten.

Specified by:
fireJobAt in interface JobScheduler
Parameters:
date - The date this job should be scheduled
name - the name of the job
jobrole - The Avalon components role name of the job itself
params - Additional Parameters to setup CronJob
objects - A Map with additional object to setup CronJob
Throws:
CascadingException

removeJob

public void removeJob(String name)
               throws NoSuchElementException
Description copied from interface: JobScheduler
Remove a scheduled job by name.

Specified by:
removeJob in interface JobScheduler
Parameters:
name - the name of the job
Throws:
NoSuchElementException

service

public void service(ServiceManager manager)
             throws ServiceException
Specified by:
service in interface Serviceable
Throws:
ServiceException

start

public void start()
           throws Exception
Specified by:
start in interface Startable
Throws:
Exception

stop

public void stop()
          throws Exception
Specified by:
stop in interface Startable
Throws:
Exception

initDataMap

protected org.quartz.JobDataMap initDataMap(org.quartz.JobDataMap jobDataMap,
                                            String jobName,
                                            boolean concurent,
                                            Parameters params,
                                            Map objects)

createJobDetail

protected org.quartz.JobDetail createJobDetail(String name,
                                               org.quartz.JobDataMap jobDataMap)

createJobExecutor

protected org.quartz.Job createJobExecutor()


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.