Java 类org.quartz.TriggerListener 实例源码

项目:lams    文件:ListenerManagerImpl.java   
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);
    }
}
项目:lams    文件:ListenerManagerImpl.java   
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);
    }
}
项目:lams    文件:QuartzScheduler.java   
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;
        }
    }
}
项目:lams    文件:QuartzScheduler.java   
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;
        }
    }
}
项目:asura    文件:QuartzScheduler.java   
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;
}
项目:asura    文件:QuartzScheduler.java   
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;
        }
    }
}
项目:asura    文件:QuartzScheduler.java   
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;
        }
    }
}
项目:lams    文件:BroadcastTriggerListener.java   
/**
 * 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>();
}
项目:lams    文件:BroadcastTriggerListener.java   
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;
}
项目:lams    文件:BroadcastTriggerListener.java   
public void triggerFired(Trigger trigger, JobExecutionContext context) {

        Iterator<TriggerListener> itr = listeners.iterator();
        while(itr.hasNext()) {
            TriggerListener l = itr.next();
            l.triggerFired(trigger, context);
        }
    }
项目:lams    文件:BroadcastTriggerListener.java   
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;
    }
项目:lams    文件:BroadcastTriggerListener.java   
public void triggerMisfired(Trigger trigger) {

        Iterator<TriggerListener> itr = listeners.iterator();
        while(itr.hasNext()) {
            TriggerListener l = itr.next();
            l.triggerMisfired(trigger);
        }
    }
项目:lams    文件:BroadcastTriggerListener.java   
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);
        }
    }
项目:lams    文件:QuartzScheduler.java   
/**
 * <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);
    }
}
项目:lams    文件:QuartzScheduler.java   
private List<TriggerListener> buildTriggerListenerList()
    throws SchedulerException {
    List<TriggerListener> allListeners = new LinkedList<TriggerListener>();
    allListeners.addAll(getListenerManager().getTriggerListeners());
    allListeners.addAll(getInternalTriggerListeners());

    return allListeners;
}
项目:lams    文件:QuartzScheduler.java   
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;
}
项目:lams    文件:QuartzScheduler.java   
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;
}
项目:asura    文件:RemoteMBeanScheduler.java   
/**
 * <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);
}
项目:asura    文件:RemoteMBeanScheduler.java   
/**
 * <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);
}
项目:asura    文件:RemoteMBeanScheduler.java   
/**
 * <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);
}
项目:asura    文件:RemoteMBeanScheduler.java   
/**
 * <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);
}
项目:asura    文件:RemoteScheduler.java   
/**
 * <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);
}
项目:asura    文件:RemoteScheduler.java   
/**
 * <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);
}
项目:asura    文件:RemoteScheduler.java   
/**
 * <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);
}
项目:asura    文件:RemoteScheduler.java   
/**
 * <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);
}
项目:asura    文件:FilterAndBroadcastTriggerListener.java   
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;
}
项目:asura    文件:FilterAndBroadcastTriggerListener.java   
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);
        }
    }
项目:asura    文件:FilterAndBroadcastTriggerListener.java   
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;
    }
项目:asura    文件:FilterAndBroadcastTriggerListener.java   
public void triggerMisfired(Trigger trigger) {

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

        Iterator itr = listeners.iterator();
        while(itr.hasNext()) {
            TriggerListener l = (TriggerListener) itr.next();
            l.triggerMisfired(trigger);
        }
    }
项目:asura    文件:FilterAndBroadcastTriggerListener.java   
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);
        }
    }
项目:asura    文件:QuartzScheduler.java   
/**
 * <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);
    }
}
项目:asura    文件:QuartzScheduler.java   
/**
 * <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);
    }
}
项目:asura    文件:QuartzScheduler.java   
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;
}
项目:taboola-cronyx    文件:CronyxAutoConfiguration.java   
@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;
}
项目:citrine-scheduler    文件:SchedulerManager.java   
/**
 * 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);
  }
}
项目:fathom    文件:SchedulerProvider.java   
/**
 * 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);
    }
}
项目:sakai    文件:SchedulerManagerImpl.java   
/**
 * @deprecated use {@link #getGlobalTriggerListeners()}
 * @param globalTriggerListener The globalTriggerListener to set.
 */
public void setGlobalTriggerListener(TriggerListener globalTriggerListener)
{
  this.globalTriggerListener = globalTriggerListener;

    if (globalTriggerListeners != null)
    {
        globalTriggerListeners.addFirst(globalTriggerListener);
    }
}
项目:sakai    文件:SchedulerManagerImpl.java   
public void setGlobalTriggerListeners (final List<TriggerListener> listeners)
{
    globalTriggerListeners.clear();

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

    if (listeners != null)
    {
        globalTriggerListeners.addAll(listeners);
    }
}
项目:sakai    文件:SchedulerManagerImpl.java   
/**
 * @deprecated use {@link #getGlobalTriggerListeners()}
 * @param globalTriggerListener The globalTriggerListener to set.
 */
public void setGlobalTriggerListener(TriggerListener globalTriggerListener)
{
  this.globalTriggerListener = globalTriggerListener;

    if (globalTriggerListeners != null)
    {
        globalTriggerListeners.addFirst(globalTriggerListener);
    }
}
项目:sakai    文件:SchedulerManagerImpl.java   
public void setGlobalTriggerListeners (final List<TriggerListener> listeners)
{
    globalTriggerListeners.clear();

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

    if (listeners != null)
    {
        globalTriggerListeners.addAll(listeners);
    }
}