org.quartz.listeners
Class JobChainingJobListener

java.lang.Object
  extended by org.quartz.listeners.JobListenerSupport
      extended by org.quartz.listeners.JobChainingJobListener
All Implemented Interfaces:
JobListener

public class JobChainingJobListener
extends JobListenerSupport

Keeps a collection of mappings of which Job to trigger after the completion of a given job. If this listener is notified of a job completing that has a mapping, then it will then attempt to trigger the follow-up job. This achieves "job chaining", or a "poor man's workflow".

Generally an instance of this listener would be registered as a global job listener, rather than being registered directly to a given job.

If for some reason there is a failure creating the trigger for the follow-up job (which would generally only be caused by a rare serious failure in the system, or the non-existence of the follow-up job), an error messsage is logged, but no other action is taken. If you need more rigorous handling of the error, consider scheduling the triggering of the flow-up job within your job itself.

Author:
James House (jhouse AT revolition DOT net)

Constructor Summary
JobChainingJobListener(String name)
          Construct an instance with the given name.
 
Method Summary
 void addJobChainLink(JobKey firstJob, JobKey secondJob)
          Add a chain mapping - when the Job identified by the first key completes the job identified by the second key will be triggered.
 String getName()
           Get the name of the JobListener.
 void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException)
           Called by the Scheduler after a JobDetail has been executed, and be for the associated Trigger's triggered(xx) method has been called.
 
Methods inherited from class org.quartz.listeners.JobListenerSupport
getLog, jobExecutionVetoed, jobToBeExecuted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobChainingJobListener

public JobChainingJobListener(String name)
Construct an instance with the given name.

Parameters:
name - the name of this instance
Method Detail

getName

public String getName()
Description copied from interface: JobListener

Get the name of the JobListener.


addJobChainLink

public void addJobChainLink(JobKey firstJob,
                            JobKey secondJob)
Add a chain mapping - when the Job identified by the first key completes the job identified by the second key will be triggered.

Parameters:
firstJob - a JobKey with the name and group of the first job
secondJob - a JobKey with the name and group of the follow-up job

jobWasExecuted

public void jobWasExecuted(JobExecutionContext context,
                           JobExecutionException jobException)
Description copied from interface: JobListener

Called by the Scheduler after a JobDetail has been executed, and be for the associated Trigger's triggered(xx) method has been called.

Specified by:
jobWasExecuted in interface JobListener
Overrides:
jobWasExecuted in class JobListenerSupport


Copyright 2001-2015, Terracotta, Inc.