org.quartz.listeners
Class FilterAndBroadcastJobListener

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

public class FilterAndBroadcastJobListener
extends Object
implements JobListener

Holds a List of references to JobListener instances and broadcasts all events to them (in order) - if the event is not excluded via filtering (read on).

The broadcasting behavior of this listener to delegate listeners may be more convenient than registering all of the listeners directly with the Job, and provides the flexibility of easily changing which listeners get notified.

You may also register a number of Regular Expression patterns to match the events against. If one or more patterns are registered, the broadcast will only take place if the event applies to a job who's name/group matches one or more of the patterns.

Author:
James House (jhouse AT revolition DOT net)
See Also:
addListener(org.quartz.JobListener), removeListener(org.quartz.JobListener), removeListener(String), addJobNamePattern(String), addJobGroupPattern(String)

Constructor Summary
FilterAndBroadcastJobListener(String name)
          Construct an instance with the given name.
FilterAndBroadcastJobListener(String name, List listeners)
          Construct an instance with the given name, and List of listeners.
 
Method Summary
 void addJobGroupPattern(String regularExpression)
          If one or more group patterns are specified, only events relating to jobs who's group matches the given regular expression pattern will be dispatched to the delegate listeners.
 void addJobNamePattern(String regularExpression)
          If one or more name patterns are specified, only events relating to jobs who's name matches the given regular expression pattern will be dispatched to the delegate listeners.
 void addListener(JobListener listener)
           
 List getJobGroupPatterns()
           
 List getJobNamePatterns()
           
 List getListeners()
           
 String getName()
           Get the name of the JobListener.
 void jobExecutionVetoed(JobExecutionContext context)
           Called by the Scheduler when a JobDetail was about to be executed (an associated Trigger has occurred), but a TriggerListener vetoed it's execution.
 void jobToBeExecuted(JobExecutionContext context)
           Called by the Scheduler when a JobDetail is about to be executed (an associated Trigger has occurred).
 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.
 boolean removeListener(JobListener listener)
           
 boolean removeListener(String listenerName)
           
protected  boolean shouldDispatch(JobExecutionContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterAndBroadcastJobListener

public FilterAndBroadcastJobListener(String name)
Construct an instance with the given name. (Remember to add some delegate listeners!)

Parameters:
name - the name of this instance

FilterAndBroadcastJobListener

public FilterAndBroadcastJobListener(String name,
                                     List listeners)
Construct an instance with the given name, and List of listeners.

Parameters:
name - the name of this instance
listeners - the initial List of JobListeners to broadcast to.
Method Detail

getName

public String getName()
Description copied from interface: JobListener

Get the name of the JobListener.

Specified by:
getName in interface JobListener

addListener

public void addListener(JobListener listener)

removeListener

public boolean removeListener(JobListener listener)

removeListener

public boolean removeListener(String listenerName)

getListeners

public List getListeners()

addJobNamePattern

public void addJobNamePattern(String regularExpression)
If one or more name patterns are specified, only events relating to jobs who's name matches the given regular expression pattern will be dispatched to the delegate listeners.

Parameters:
regularExpression -

getJobNamePatterns

public List getJobNamePatterns()

addJobGroupPattern

public void addJobGroupPattern(String regularExpression)
If one or more group patterns are specified, only events relating to jobs who's group matches the given regular expression pattern will be dispatched to the delegate listeners.

Parameters:
regularExpression -

getJobGroupPatterns

public List getJobGroupPatterns()

shouldDispatch

protected boolean shouldDispatch(JobExecutionContext context)

jobToBeExecuted

public void jobToBeExecuted(JobExecutionContext context)
Description copied from interface: JobListener

Called by the Scheduler when a JobDetail is about to be executed (an associated Trigger has occurred).

This method will not be invoked if the execution of the Job was vetoed by a TriggerListener.

Specified by:
jobToBeExecuted in interface JobListener
See Also:
JobListener.jobExecutionVetoed(JobExecutionContext)

jobExecutionVetoed

public void jobExecutionVetoed(JobExecutionContext context)
Description copied from interface: JobListener

Called by the Scheduler when a JobDetail was about to be executed (an associated Trigger has occurred), but a TriggerListener vetoed it's execution.

Specified by:
jobExecutionVetoed in interface JobListener
See Also:
JobListener.jobToBeExecuted(JobExecutionContext)

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


Copyright 2001-2011, Terracotta, Inc.