public void addTriggerListener(TriggerListener triggerListener, List<Matcher<TriggerKey>> matchers) { if (triggerListener.getName() == null || triggerListener.getName().length() == 0) { throw new IllegalArgumentException( "TriggerListener name cannot be empty."); } synchronized (globalTriggerListeners) { globalTriggerListeners.put(triggerListener.getName(), triggerListener); LinkedList<Matcher<TriggerKey>> matchersL = new LinkedList<Matcher<TriggerKey>>(); if(matchers != null && matchers.size() > 0) matchersL.addAll(matchers); else matchersL.add(EverythingMatcher.allTriggers()); globalTriggerListenersMatchers.put(triggerListener.getName(), matchersL); } }
public void addTriggerListener(TriggerListener triggerListener, Matcher<TriggerKey> matcher) { if(matcher == null) throw new IllegalArgumentException("Null value not acceptable for matcher."); if (triggerListener.getName() == null || triggerListener.getName().length() == 0) { throw new IllegalArgumentException( "TriggerListener name cannot be empty."); } synchronized (globalTriggerListeners) { globalTriggerListeners.put(triggerListener.getName(), triggerListener); List<Matcher<TriggerKey>> matchers = new LinkedList<Matcher<TriggerKey>>(); matchers.add(matcher); globalTriggerListenersMatchers.put(triggerListener.getName(), matchers); } }
public void notifyTriggerListenersMisfired(Trigger trigger) throws SchedulerException { // build a list of all trigger listeners that are to be notified... List<TriggerListener> triggerListeners = buildTriggerListenerList(); // notify all trigger listeners in the list for(TriggerListener tl: triggerListeners) { try { if(!matchTriggerListener(tl, trigger.getKey())) continue; tl.triggerMisfired(trigger); } catch (Exception e) { SchedulerException se = new SchedulerException( "TriggerListener '" + tl.getName() + "' threw exception: " + e.getMessage(), e); throw se; } } }
public void notifyTriggerListenersComplete(JobExecutionContext jec, CompletedExecutionInstruction instCode) throws SchedulerException { // build a list of all trigger listeners that are to be notified... List<TriggerListener> triggerListeners = buildTriggerListenerList(); // notify all trigger listeners in the list for(TriggerListener tl: triggerListeners) { try { if(!matchTriggerListener(tl, jec.getTrigger().getKey())) continue; tl.triggerComplete(jec.getTrigger(), jec, instCode); } catch (Exception e) { SchedulerException se = new SchedulerException( "TriggerListener '" + tl.getName() + "' threw exception: " + e.getMessage(), e); throw se; } } }
private List buildTriggerListenerList(String[] additionalLstnrs) throws SchedulerException { List triggerListeners = getGlobalTriggerListeners(); for (int i = 0; i < additionalLstnrs.length; i++) { TriggerListener tl = getTriggerListener(additionalLstnrs[i]); if (tl != null) { triggerListeners.add(tl); } else { throw new SchedulerException("TriggerListener '" + additionalLstnrs[i] + "' not found.", SchedulerException.ERR_TRIGGER_LISTENER_NOT_FOUND); } } return triggerListeners; }
public void notifyTriggerListenersMisfired(Trigger trigger) throws SchedulerException { // build a list of all trigger listeners that are to be notified... List triggerListeners = buildTriggerListenerList(trigger .getTriggerListenerNames()); // notify all trigger listeners in the list java.util.Iterator itr = triggerListeners.iterator(); while (itr.hasNext()) { TriggerListener tl = (TriggerListener) itr.next(); try { tl.triggerMisfired(trigger); } catch (Exception e) { SchedulerException se = new SchedulerException( "TriggerListener '" + tl.getName() + "' threw exception: " + e.getMessage(), e); se.setErrorCode(SchedulerException.ERR_TRIGGER_LISTENER); throw se; } } }
public void notifyTriggerListenersComplete(JobExecutionContext jec, int instCode) throws SchedulerException { // build a list of all trigger listeners that are to be notified... List triggerListeners = buildTriggerListenerList(jec.getTrigger() .getTriggerListenerNames()); // notify all trigger listeners in the list java.util.Iterator itr = triggerListeners.iterator(); while (itr.hasNext()) { TriggerListener tl = (TriggerListener) itr.next(); try { tl.triggerComplete(jec.getTrigger(), jec, instCode); } catch (Exception e) { SchedulerException se = new SchedulerException( "TriggerListener '" + tl.getName() + "' threw exception: " + e.getMessage(), e); se.setErrorCode(SchedulerException.ERR_TRIGGER_LISTENER); throw se; } } }
/** * Construct an instance with the given name. * * (Remember to add some delegate listeners!) * * @param name the name of this instance */ public BroadcastTriggerListener(String name) { if(name == null) { throw new IllegalArgumentException("Listener name cannot be null!"); } this.name = name; listeners = new LinkedList<TriggerListener>(); }
public boolean removeListener(String listenerName) { Iterator<TriggerListener> itr = listeners.iterator(); while(itr.hasNext()) { TriggerListener l = itr.next(); if(l.getName().equals(listenerName)) { itr.remove(); return true; } } return false; }
public void triggerFired(Trigger trigger, JobExecutionContext context) { Iterator<TriggerListener> itr = listeners.iterator(); while(itr.hasNext()) { TriggerListener l = itr.next(); l.triggerFired(trigger, context); } }
public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) { Iterator<TriggerListener> itr = listeners.iterator(); while(itr.hasNext()) { TriggerListener l = itr.next(); if(l.vetoJobExecution(trigger, context)) { return true; } } return false; }
public void triggerMisfired(Trigger trigger) { Iterator<TriggerListener> itr = listeners.iterator(); while(itr.hasNext()) { TriggerListener l = itr.next(); l.triggerMisfired(trigger); } }
public void triggerComplete(Trigger trigger, JobExecutionContext context, CompletedExecutionInstruction triggerInstructionCode) { Iterator<TriggerListener> itr = listeners.iterator(); while(itr.hasNext()) { TriggerListener l = itr.next(); l.triggerComplete(trigger, context, triggerInstructionCode); } }
/** * <p> * Add the given <code>{@link org.quartz.TriggerListener}</code> to the * <code>Scheduler</code>'s <i>internal</i> list. * </p> */ public void addInternalTriggerListener(TriggerListener triggerListener) { if (triggerListener.getName() == null || triggerListener.getName().length() == 0) { throw new IllegalArgumentException( "TriggerListener name cannot be empty."); } synchronized (internalTriggerListeners) { internalTriggerListeners.put(triggerListener.getName(), triggerListener); } }
private List<TriggerListener> buildTriggerListenerList() throws SchedulerException { List<TriggerListener> allListeners = new LinkedList<TriggerListener>(); allListeners.addAll(getListenerManager().getTriggerListeners()); allListeners.addAll(getInternalTriggerListeners()); return allListeners; }
private boolean matchTriggerListener(TriggerListener listener, TriggerKey key) { List<Matcher<TriggerKey>> matchers = getListenerManager().getTriggerListenerMatchers(listener.getName()); if(matchers == null) return true; for(Matcher<TriggerKey> matcher: matchers) { if(matcher.isMatch(key)) return true; } return false; }
public boolean notifyTriggerListenersFired(JobExecutionContext jec) throws SchedulerException { boolean vetoedExecution = false; // build a list of all trigger listeners that are to be notified... List<TriggerListener> triggerListeners = buildTriggerListenerList(); // notify all trigger listeners in the list for(TriggerListener tl: triggerListeners) { try { if(!matchTriggerListener(tl, jec.getTrigger().getKey())) continue; tl.triggerFired(jec.getTrigger(), jec); if(tl.vetoJobExecution(jec.getTrigger(), jec)) { vetoedExecution = true; } } catch (Exception e) { SchedulerException se = new SchedulerException( "TriggerListener '" + tl.getName() + "' threw exception: " + e.getMessage(), e); throw se; } } return vetoedExecution; }
/** * <p> * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>. * </p> */ public void addGlobalTriggerListener(TriggerListener triggerListener) throws SchedulerException { throw new SchedulerException( "Operation not supported for remote schedulers.", SchedulerException.ERR_UNSUPPORTED_FUNCTION_IN_THIS_CONFIGURATION); }
/** * <p> * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>. * </p> */ public void addTriggerListener(TriggerListener triggerListener) throws SchedulerException { throw new SchedulerException( "Operation not supported for remote schedulers.", SchedulerException.ERR_UNSUPPORTED_FUNCTION_IN_THIS_CONFIGURATION); }
/** * <p> * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>. * </p> */ public TriggerListener getGlobalTriggerListener(String name) throws SchedulerException { throw new SchedulerException( "Operation not supported for remote schedulers.", SchedulerException.ERR_UNSUPPORTED_FUNCTION_IN_THIS_CONFIGURATION); }
/** * <p> * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>. * </p> */ public TriggerListener getTriggerListener(String name) throws SchedulerException { throw new SchedulerException( "Operation not supported for remote schedulers.", SchedulerException.ERR_UNSUPPORTED_FUNCTION_IN_THIS_CONFIGURATION); }
public boolean removeListener(String listenerName) { Iterator itr = listeners.iterator(); while(itr.hasNext()) { TriggerListener l = (TriggerListener) itr.next(); if(l.getName().equals(listenerName)) { itr.remove(); return true; } } return false; }
public void triggerFired(Trigger trigger, JobExecutionContext context) { if(!shouldDispatch(trigger)) { return; } Iterator itr = listeners.iterator(); while(itr.hasNext()) { TriggerListener l = (TriggerListener) itr.next(); l.triggerFired(trigger, context); } }
public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) { if(!shouldDispatch(trigger)) { return false; } Iterator itr = listeners.iterator(); while(itr.hasNext()) { TriggerListener l = (TriggerListener) itr.next(); if(l.vetoJobExecution(trigger, context)) { return true; } } return false; }
public void triggerMisfired(Trigger trigger) { if(!shouldDispatch(trigger)) { return; } Iterator itr = listeners.iterator(); while(itr.hasNext()) { TriggerListener l = (TriggerListener) itr.next(); l.triggerMisfired(trigger); } }
public void triggerComplete(Trigger trigger, JobExecutionContext context, int triggerInstructionCode) { if(!shouldDispatch(trigger)) { return; } Iterator itr = listeners.iterator(); while(itr.hasNext()) { TriggerListener l = (TriggerListener) itr.next(); l.triggerComplete(trigger, context, triggerInstructionCode); } }
/** * <p> * Add the given <code>{@link org.quartz.TriggerListener}</code> to the * <code>Scheduler</code>'s<i>global</i> list. * </p> * * <p> * Listeners in the 'global' list receive notification of execution events * for ALL <code>{@link org.quartz.Trigger}</code>s. * </p> */ public void addGlobalTriggerListener(TriggerListener triggerListener) { if (triggerListener.getName() == null || triggerListener.getName().length() == 0) { throw new IllegalArgumentException( "TriggerListener name cannot be empty."); } synchronized (globalTriggerListeners) { globalTriggerListeners.put(triggerListener.getName(), triggerListener); } }
/** * <p> * Add the given <code>{@link org.quartz.TriggerListener}</code> to the * <code>Scheduler</code>'s list, of registered <code>TriggerListener</code>s. */ public void addTriggerListener(TriggerListener triggerListener) { if (triggerListener.getName() == null || triggerListener.getName().length() == 0) { throw new IllegalArgumentException( "TriggerListener name cannot be empty."); } synchronized (triggerListeners) { triggerListeners.put(triggerListener.getName(), triggerListener); } }
public boolean notifyTriggerListenersFired(JobExecutionContext jec) throws SchedulerException { // build a list of all trigger listeners that are to be notified... List triggerListeners = buildTriggerListenerList(jec.getTrigger() .getTriggerListenerNames()); boolean vetoedExecution = false; // notify all trigger listeners in the list java.util.Iterator itr = triggerListeners.iterator(); while (itr.hasNext()) { TriggerListener tl = (TriggerListener) itr.next(); try { tl.triggerFired(jec.getTrigger(), jec); if(tl.vetoJobExecution(jec.getTrigger(), jec)) { vetoedExecution = true; } } catch (Exception e) { SchedulerException se = new SchedulerException( "TriggerListener '" + tl.getName() + "' threw exception: " + e.getMessage(), e); se.setErrorCode(SchedulerException.ERR_TRIGGER_LISTENER); throw se; } } return vetoedExecution; }
@Bean(name = "listenerAdapter") public TriggerListener listenerAdapter(@Qualifier("listenerRegistry") Registry<String, Pair<ListenerMatcher, FiringListener>> listenerRegistry, @Qualifier("contextRegistry") Registry<String, CronyxExecutionContext> contextRegistry, @Qualifier("mainScheduler") Scheduler scheduler, @Qualifier("jobExecutionContextToFiringContext") JobExecutionContextToFiringContext jobExecutionContextToFiringContext) throws SchedulerException { TriggerListener adapter = new QuartzTriggerListenerAdapter(listenerRegistry, contextRegistry, jobExecutionContextToFiringContext); scheduler.getListenerManager().addTriggerListener(adapter); return adapter; }
/** * Adds a TriggerListener to the scheduler. * * @param listener Listener to add. */ public void setTriggerListener(TriggerListener listener) { try { scheduler.addGlobalTriggerListener(listener); } catch (SchedulerException e) { throw new ScheduleException("Error adding trigger listener", e); } }
/** * Sets the {@code TriggerListener}s. * * @param triggerListeners The {@code TriggerListener}s * @throws SchedulerException If any error occurs */ @Inject(optional = true) public void addTriggerListeners(Set<TriggerListener> triggerListeners) throws SchedulerException { for (TriggerListener triggerListener : triggerListeners) { scheduler.getListenerManager().addTriggerListener(triggerListener); } }
/** * @deprecated use {@link #getGlobalTriggerListeners()} * @param globalTriggerListener The globalTriggerListener to set. */ public void setGlobalTriggerListener(TriggerListener globalTriggerListener) { this.globalTriggerListener = globalTriggerListener; if (globalTriggerListeners != null) { globalTriggerListeners.addFirst(globalTriggerListener); } }
public void setGlobalTriggerListeners (final List<TriggerListener> listeners) { globalTriggerListeners.clear(); if (globalTriggerListener != null) { globalTriggerListeners.add(globalTriggerListener); } if (listeners != null) { globalTriggerListeners.addAll(listeners); } }