org.quartz.TriggerListener Java Examples

The following examples show how to use org.quartz.TriggerListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
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;
        }
    }
}
 
Example #2
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
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;
        }
    }
}
 
Example #3
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #5
Source File: QuartzScheduler.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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;
        }
    }
}
 
Example #6
Source File: QuartzScheduler.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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;
        }
    }
}
 
Example #7
Source File: QuartzScheduler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: RemoteScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example #9
Source File: ChainedListener.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void triggerFired(Trigger trigger, JobExecutionContext ctx) {
    for (Iterator iter = this.listenerChain.iterator(); iter.hasNext();) {
        TriggerListener listener = (TriggerListener) iter.next();
        listener.triggerFired(trigger, ctx);
    }
}
 
Example #10
Source File: ChainedListener.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void triggerComplete(Trigger trigger, JobExecutionContext ctx,
        int triggerInstructionCode) {
    for (Iterator iter = this.listenerChain.iterator(); iter.hasNext();) {
        TriggerListener listener = (TriggerListener) iter.next();
        listener.triggerComplete(trigger, ctx, triggerInstructionCode);
    }
}
 
Example #11
Source File: RemoteMBeanScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example #12
Source File: RemoteMBeanScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example #13
Source File: RemoteScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example #14
Source File: QuartzScheduler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #15
Source File: BroadcastTriggerListener.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
 
Example #16
Source File: BroadcastTriggerListener.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #17
Source File: BroadcastTriggerListener.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void triggerFired(Trigger trigger, JobExecutionContext context) {

        Iterator<TriggerListener> itr = listeners.iterator();
        while(itr.hasNext()) {
            TriggerListener l = itr.next();
            l.triggerFired(trigger, context);
        }
    }
 
Example #18
Source File: RemoteScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example #19
Source File: RemoteMBeanScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example #20
Source File: RemoteScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example #21
Source File: FilterAndBroadcastTriggerListener.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #22
Source File: FilterAndBroadcastTriggerListener.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
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);
        }
    }
 
Example #23
Source File: FilterAndBroadcastTriggerListener.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
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;
    }
 
Example #24
Source File: FilterAndBroadcastTriggerListener.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
public void triggerMisfired(Trigger trigger) {

        if(!shouldDispatch(trigger)) {
            return;
        }

        Iterator itr = listeners.iterator();
        while(itr.hasNext()) {
            TriggerListener l = (TriggerListener) itr.next();
            l.triggerMisfired(trigger);
        }
    }
 
Example #25
Source File: FilterAndBroadcastTriggerListener.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
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);
        }
    }
 
Example #26
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
    }
}
 
Example #27
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
    }
}
 
Example #28
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #29
Source File: SchedulerManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void setGlobalTriggerListeners (final List<TriggerListener> listeners)
{
    globalTriggerListeners.clear();

    if (globalTriggerListener != null)
    {
        globalTriggerListeners.add(globalTriggerListener);
    }

    if (listeners != null)
    {
        globalTriggerListeners.addAll(listeners);
    }
}
 
Example #30
Source File: SchedulerManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * @deprecated use {@link #getGlobalTriggerListeners()}
 * @param globalTriggerListener The globalTriggerListener to set.
 */
public void setGlobalTriggerListener(TriggerListener globalTriggerListener)
{
  this.globalTriggerListener = globalTriggerListener;

    if (globalTriggerListeners != null)
    {
        globalTriggerListeners.addFirst(globalTriggerListener);
    }
}