Class BroadcastTriggerListener
- java.lang.Object
-
- org.quartz.listeners.BroadcastTriggerListener
-
- All Implemented Interfaces:
TriggerListener
public class BroadcastTriggerListener extends java.lang.Object implements TriggerListener
Holds a List of references to TriggerListener instances and broadcasts all events to them (in order).The broadcasting behavior of this listener to delegate listeners may be more convenient than registering all of the listeners directly with the Scheduler, and provides the flexibility of easily changing which listeners get notified.
- Author:
- James House (jhouse AT revolition DOT net)
- See Also:
addListener(org.quartz.TriggerListener),removeListener(org.quartz.TriggerListener),removeListener(String)
-
-
Constructor Summary
Constructors Constructor Description BroadcastTriggerListener(java.lang.String name)Construct an instance with the given name.BroadcastTriggerListener(java.lang.String name, java.util.List<TriggerListener> listeners)Construct an instance with the given name, and List of listeners.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(TriggerListener listener)java.util.List<TriggerListener>getListeners()java.lang.StringgetName()Get the name of theTriggerListener.booleanremoveListener(java.lang.String listenerName)booleanremoveListener(TriggerListener listener)voidtriggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode)voidtriggerFired(Trigger trigger, JobExecutionContext context)voidtriggerMisfired(Trigger trigger)booleanvetoJobExecution(Trigger trigger, JobExecutionContext context)
-
-
-
Constructor Detail
-
BroadcastTriggerListener
public BroadcastTriggerListener(java.lang.String name)
Construct an instance with the given name. (Remember to add some delegate listeners!)- Parameters:
name- the name of this instance
-
BroadcastTriggerListener
public BroadcastTriggerListener(java.lang.String name, java.util.List<TriggerListener> listeners)Construct an instance with the given name, and List of listeners.- Parameters:
name- the name of this instancelisteners- the initial List of TriggerListeners to broadcast to.
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:TriggerListenerGet the name of the
TriggerListener.- Specified by:
getNamein interfaceTriggerListener
-
addListener
public void addListener(TriggerListener listener)
-
removeListener
public boolean removeListener(TriggerListener listener)
-
removeListener
public boolean removeListener(java.lang.String listenerName)
-
getListeners
public java.util.List<TriggerListener> getListeners()
-
triggerFired
public void triggerFired(Trigger trigger, JobExecutionContext context)
Description copied from interface:TriggerListenerCalled by the
when aSchedulerhas fired, and it's associatedTriggeris about to be executed.JobDetailIt is called before the
vetoJobExecution(..)method of this interface.- Specified by:
triggerFiredin interfaceTriggerListener- Parameters:
trigger- TheTriggerthat has fired.context- TheJobExecutionContextthat will be passed to theJob'sexecute(xx)method.
-
vetoJobExecution
public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context)
Description copied from interface:TriggerListenerCalled by the
when aSchedulerhas fired, and it's associatedTriggeris about to be executed. If the implementation vetoes the execution (via returningJobDetailtrue), the job's execute method will not be called.It is called after the
triggerFired(..)method of this interface.- Specified by:
vetoJobExecutionin interfaceTriggerListener- Parameters:
trigger- TheTriggerthat has fired.context- TheJobExecutionContextthat will be passed to theJob'sexecute(xx)method.
-
triggerMisfired
public void triggerMisfired(Trigger trigger)
Description copied from interface:TriggerListenerCalled by the
when aSchedulerhas misfired.TriggerConsideration should be given to how much time is spent in this method, as it will affect all triggers that are misfiring. If you have lots of triggers misfiring at once, it could be an issue it this method does a lot.
- Specified by:
triggerMisfiredin interfaceTriggerListener- Parameters:
trigger- TheTriggerthat has misfired.
-
triggerComplete
public void triggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode)
Description copied from interface:TriggerListenerCalled by the
when aSchedulerhas fired, it's associatedTriggerhas been executed, and it'sJobDetailtriggered(xx)method has been called.- Specified by:
triggerCompletein interfaceTriggerListener- Parameters:
trigger- TheTriggerthat was fired.context- TheJobExecutionContextthat was passed to theJob'sexecute(xx)method.triggerInstructionCode- the result of the call on theTrigger'striggered(xx)method.
-
-