Example usage for javax.ejb Timer cancel

List of usage examples for javax.ejb Timer cancel

Introduction

In this page you can find the example usage for javax.ejb Timer cancel.

Prototype

public void cancel()
        throws java.lang.IllegalStateException, javax.ejb.NoSuchObjectLocalException, javax.ejb.EJBException;

Source Link

Document

Cause the timer and all its associated expiration notifications to be cancelled.

Usage

From source file:org.rhq.enterprise.server.system.SystemManagerBean.java

@SuppressWarnings("unchecked")
public void scheduleConfigCacheReloader() {
    // each time the webapp is reloaded, we don't want to create duplicate jobs
    Collection<Timer> timers = timerService.getTimers();
    for (Timer existingTimer : timers) {
        log.debug("Found timer - attempting to cancel: " + existingTimer.toString());
        try {/*from  w w w . java  2  s  .co m*/
            existingTimer.cancel();
        } catch (Exception e) {
            log.warn("Failed in attempting to cancel timer: " + existingTimer.toString());
        }
    }

    // single-action timer that will trigger in 60 seconds
    timerService.createTimer(60000L, TIMER_DATA);
}

From source file:ru.runa.wfe.service.impl.BotInvokerServiceBean.java

@Override
public synchronized void cancelPeriodicBotsInvocation() {
    if (isRunning()) {
        log.info("Canceling periodic bot execution...");
        for (Timer timer : timerService.getTimers()) {
            timer.cancel();
        }//from  ww  w  .j av a  2  s.  co m
    } else {
        log.info("BotRunner is not running. skipping cancel...");
    }
}

From source file:ru.runa.wfe.service.impl.BotInvokerServiceBean.java

@WebMethod(exclude = true)
@Timeout//from w ww .  ja  va2  s .c  om
public void timeOutHandler(Timer timer) {
    try {
        // refresh version and check that bot station exists
        BotStation botStation = Delegates.getBotService().getBotStation((Long) timer.getInfo());
        invokeBotsImpl(botStation, firstInvocation);
        firstInvocation = false;
    } catch (BotStationDoesNotExistException e) {
        log.warn("Cancelling periodic invocation due to: " + e);
        timer.cancel();
    }
}