org.quartz.listeners
Class FilterAndBroadcastJobListener

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

public class FilterAndBroadcastJobListener
extends java.lang.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(java.lang.String name)
          Construct an instance with the given name.
FilterAndBroadcastJobListener(java.lang.String name, java.util.List listeners)
          Construct an instance with the given name, and List of listeners.
 
Method Summary
 void addJobGroupPattern(java.lang.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(java.lang.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)
           
 java.util.List getJobGroupPatterns()
           
 java.util.List getJobNamePatterns()
           
 java.util.List getListeners()
           
 java.lang.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(java.lang.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(java.lang.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(java.lang.String name,
                                     java.util.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 java.lang.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(java.lang.String listenerName)

getListeners

public java.util.List getListeners()

addJobNamePattern

public void addJobNamePattern(java.lang.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 java.util.List getJobNamePatterns()

addJobGroupPattern

public void addJobGroupPattern(java.lang.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 java.util.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-2019, Terracotta, Inc.