1 package org.quartz.listeners; 2 3 import java.util.Iterator ; 4 import java.util.LinkedList ; 5 import java.util.List ; 6 7 import org.quartz.SchedulerException; 8 import org.quartz.SchedulerListener; 9 import org.quartz.Trigger; 10 11 24 public class BroadcastSchedulerListener implements SchedulerListener { 25 26 private List listeners; 27 28 public BroadcastSchedulerListener() { 29 listeners = new LinkedList (); 30 } 31 32 37 public BroadcastSchedulerListener(List listeners) { 38 this(); 39 this.listeners.addAll(listeners); 40 } 41 42 43 public void addListener(SchedulerListener listener) { 44 listeners.add(listener); 45 } 46 47 public boolean removeListener(SchedulerListener listener) { 48 return listeners.remove(listener); 49 } 50 51 public List getListeners() { 52 return java.util.Collections.unmodifiableList(listeners); 53 } 54 55 public void jobScheduled(Trigger trigger) { 56 Iterator itr = listeners.iterator(); 57 while(itr.hasNext()) { 58 SchedulerListener l = (SchedulerListener) itr.next(); 59 l.jobScheduled(trigger); 60 } 61 } 62 63 public void jobUnscheduled(String triggerName, String triggerGroup) { 64 Iterator itr = listeners.iterator(); 65 while(itr.hasNext()) { 66 SchedulerListener l = (SchedulerListener) itr.next(); 67 l.jobUnscheduled(triggerName, triggerGroup); 68 } 69 } 70 71 public void triggerFinalized(Trigger trigger) { 72 Iterator itr = listeners.iterator(); 73 while(itr.hasNext()) { 74 SchedulerListener l = (SchedulerListener) itr.next(); 75 l.triggerFinalized(trigger); 76 } 77 } 78 79 public void triggersPaused(String triggerName, String triggerGroup) { 80 Iterator itr = listeners.iterator(); 81 while(itr.hasNext()) { 82 SchedulerListener l = (SchedulerListener) itr.next(); 83 l.triggersPaused(triggerName, triggerGroup); 84 } 85 } 86 87 public void triggersResumed(String triggerName, String triggerGroup) { 88 Iterator itr = listeners.iterator(); 89 while(itr.hasNext()) { 90 SchedulerListener l = (SchedulerListener) itr.next(); 91 l.triggersResumed(triggerName, triggerGroup); 92 } 93 } 94 95 public void jobsPaused(String jobName, String jobGroup) { 96 Iterator itr = listeners.iterator(); 97 while(itr.hasNext()) { 98 SchedulerListener l = (SchedulerListener) itr.next(); 99 l.jobsPaused(jobName, jobGroup); 100 } 101 } 102 103 public void jobsResumed(String jobName, String jobGroup) { 104 Iterator itr = listeners.iterator(); 105 while(itr.hasNext()) { 106 SchedulerListener l = (SchedulerListener) itr.next(); 107 l.jobsResumed(jobName, jobGroup); 108 } 109 } 110 111 public void schedulerError(String msg, SchedulerException cause) { 112 Iterator itr = listeners.iterator(); 113 while(itr.hasNext()) { 114 SchedulerListener l = (SchedulerListener) itr.next(); 115 l.schedulerError(msg, cause); 116 } 117 } 118 119 public void schedulerShutdown() { 120 Iterator itr = listeners.iterator(); 121 while(itr.hasNext()) { 122 SchedulerListener l = (SchedulerListener) itr.next(); 123 l.schedulerShutdown(); 124 } 125 } 126 } 127 | Popular Tags |