Java Code Examples for org.quartz.TriggerListener

The following examples show how to use org.quartz.TriggerListener. These examples are extracted from open source projects. 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 Project: lams   Source File: ListenerManagerImpl.java    License: 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 2
Source Project: lams   Source File: QuartzScheduler.java    License: 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 3
Source Project: lams   Source File: QuartzScheduler.java    License: 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 4
Source Project: AsuraFramework   Source File: QuartzScheduler.java    License: 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 5
Source Project: AsuraFramework   Source File: QuartzScheduler.java    License: 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 6
Source Project: AsuraFramework   Source File: QuartzScheduler.java    License: 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 7
Source Project: uyuni   Source File: ChainedListener.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void triggerComplete(Trigger trigger, JobExecutionContext ctx,
        CompletedExecutionInstruction cei) {
    for (Iterator iter = this.listenerChain.iterator(); iter.hasNext();) {
        TriggerListener listener = (TriggerListener) iter.next();
        listener.triggerComplete(trigger, ctx, cei);
    }
}
 
Example 8
Source Project: uyuni   Source File: ChainedListener.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
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 9
Source Project: uyuni   Source File: ChainedListener.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void triggerMisfired(Trigger trigger) {
    for (Iterator iter = this.listenerChain.iterator(); iter.hasNext();) {
        TriggerListener listener = (TriggerListener) iter.next();
        listener.triggerMisfired(trigger);
    }
}
 
Example 10
Source Project: uyuni   Source File: ChainedListener.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean vetoJobExecution(Trigger trigger, JobExecutionContext ctx) {
    boolean retval = false;
    for (Iterator iter = this.listenerChain.iterator(); iter.hasNext();) {
        TriggerListener listener = (TriggerListener) iter.next();
        boolean tmp = listener.vetoJobExecution(trigger, ctx);
        if (!retval && tmp) {
            retval = true;
        }
    }
    return retval;
}
 
Example 11
/**
 * 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>();
}
 
Example 12
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 13
public void triggerFired(Trigger trigger, JobExecutionContext context) {

        Iterator<TriggerListener> itr = listeners.iterator();
        while(itr.hasNext()) {
            TriggerListener l = itr.next();
            l.triggerFired(trigger, context);
        }
    }
 
Example 14
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 15
Source Project: spacewalk   Source File: ChainedListener.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean vetoJobExecution(Trigger trigger, JobExecutionContext ctx) {
    boolean retval = false;
    for (Iterator iter = this.listenerChain.iterator(); iter.hasNext();) {
        TriggerListener listener = (TriggerListener) iter.next();
        boolean tmp = listener.vetoJobExecution(trigger, ctx);
        if (!retval && tmp) {
            retval = true;
        }
    }
    return retval;
}
 
Example 16
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);
        }
    }
 
Example 17
Source Project: spacewalk   Source File: ChainedListener.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void triggerMisfired(Trigger trigger) {
    for (Iterator iter = this.listenerChain.iterator(); iter.hasNext();) {
        TriggerListener listener = (TriggerListener) iter.next();
        listener.triggerMisfired(trigger);
    }
}
 
Example 18
Source Project: lams   Source File: QuartzScheduler.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * <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);
    }
}
 
Example 19
Source Project: lams   Source File: QuartzScheduler.java    License: GNU General Public License v2.0 5 votes vote down vote up
private List<TriggerListener> buildTriggerListenerList()
    throws SchedulerException {
    List<TriggerListener> allListeners = new LinkedList<TriggerListener>();
    allListeners.addAll(getListenerManager().getTriggerListeners());
    allListeners.addAll(getInternalTriggerListeners());

    return allListeners;
}
 
Example 20
Source Project: lams   Source File: QuartzScheduler.java    License: 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 21
Source Project: lams   Source File: QuartzScheduler.java    License: 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 22
Source Project: AsuraFramework   Source File: RemoteMBeanScheduler.java    License: 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 23
Source Project: AsuraFramework   Source File: RemoteMBeanScheduler.java    License: 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 24
Source Project: AsuraFramework   Source File: RemoteMBeanScheduler.java    License: 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 25
Source Project: spacewalk   Source File: ChainedListener.java    License: 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 26
Source Project: spacewalk   Source File: ChainedListener.java    License: 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 27
Source Project: AsuraFramework   Source File: RemoteScheduler.java    License: 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 28
Source Project: AsuraFramework   Source File: RemoteScheduler.java    License: 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 29
Source Project: AsuraFramework   Source File: RemoteScheduler.java    License: 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 30
Source Project: AsuraFramework   Source File: RemoteScheduler.java    License: 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);
}