public Object call() { timer.cancel(); return null; } });
@PreDestroy public void shutdown() { if (timer != null) { try { timer.cancel(); } catch (NoSuchObjectLocalException e) { logger.debug("Timer {} is already canceled or expired", timer); } } }
@PreDestroy public void shutdown() { if (timer != null) { try { timer.cancel(); } catch (NoSuchObjectLocalException e) { logger.debug("Timer {} is already canceled or expired", timer); } } }
public void removeAllTimers() { logger.info("Removing ALL existing timers."); int i = 0; for (Iterator it = timerService.getTimers().iterator(); it.hasNext();) { Timer timer = (Timer) it.next(); logger.info("Removing timer " + i + ";"); timer.cancel(); i++; } logger.info("Done!"); }
/** * Stop the timer. */ public void stop() { Timer timer = getTimer(); if (timer != null) { timer.cancel(); LOGGER.log(Level.INFO, "The timer {0} was cancelled.", TIMER_INFO); } else { LOGGER.log(Level.INFO, "The timer {0} is not running.", TIMER_INFO); } }
/** * Cancel all timers. */ @SuppressWarnings("unchecked") private void cancelAllTimers() { Collection<Timer> timers = timerService.getTimers(); for (Iterator<Timer> it = timers.iterator(); it.hasNext();) { Timer timer = it.next(); timer.cancel(); } timers.clear(); }
/** * {@inheritDoc} */ @Override public void disposeScheduleJob(TimerHandle timerHandle) { Job<RUNNABLE> job = getJob(timerHandle); if (job != null) { LOG.info("disposing job " + job); timerHandle.getTimer().cancel(); jobs.remove(job); } else { LOG.warn("timerHandle " + timerHandle + " not available!"); } }
/** * {@inheritDoc} */ @Override public void disposeAllScheduledJobs() { // final Collection<Timer> timers = timerService.getTimers(); for (final Job<RUNNABLE> job : jobs) { job.getTimerHandle().getTimer().cancel(); } jobs.clear(); }
public void scheduleSessionPurgeJob() { // each time the webapp is reloaded, we don't want to create duplicate jobs Collection<Timer> timers = timerService.getTimers(); for (Timer existingTimer : timers) { if (log.isDebugEnabled()) { log.debug("Found timer - attempting to cancel: " + existingTimer.toString()); } try { existingTimer.cancel(); } catch (Exception e) { log.warn("Failed in attempting to cancel timer: " + existingTimer.toString()); } } // timer that will trigger every 60 seconds timerService.createIntervalTimer(60000L, 60000L, new TimerConfig(null, false)); }
/** * {@inheritDoc} */ @Override public void disposeScheduleJob(String name) { Job<RUNNABLE> job = getJob(name); if (job != null) { LOG.info("disposing job " + job); job.getTimerHandle().getTimer().cancel(); jobs.remove(job); } else { LOG.warn("job with name " + name + " not available!"); } }
public void removeHarvestTimer(HarvestingClient harvestingClient) { // Clear dataverse timer, if one exists try { logger.log(Level.INFO,"Removing harvest timer on " + InetAddress.getLocalHost().getCanonicalHostName()); } catch (UnknownHostException ex) { Logger.getLogger(DataverseTimerServiceBean.class.getName()).log(Level.SEVERE, null, ex); } for (Iterator it = timerService.getTimers().iterator(); it.hasNext();) { Timer timer = (Timer) it.next(); if (timer.getInfo() instanceof HarvestTimerInfo) { HarvestTimerInfo info = (HarvestTimerInfo) timer.getInfo(); if (info.getHarvestingClientId().equals(harvestingClient.getId())) { timer.cancel(); } } } }
public void scheduleServerHeartbeat() { /* each time the webapp is reloaded, it would create * duplicate events if we don't cancel the existing ones */ Collection<Timer> timers = timerService.getTimers(); for (Timer existingTimer : timers) { log.debug("Found timer - attempting to cancel: " + existingTimer.toString()); try { existingTimer.cancel(); } catch (Exception e) { log.warn("Failed in attempting to cancel timer: " + existingTimer.toString()); } } // single-action timer that will trigger in 30 seconds timerService.createIntervalTimer(30000L, 30000L, new TimerConfig(null, false)); }
/** * {@inheritDoc} */ public void cancelTimers(String timerInfo) { Collection<Timer> timers = this.timerService.getTimers(); for (Timer timer : timers) { if (timer.getInfo() != null) { if (timer.getInfo().equals(timerInfo)) { timer.cancel(); LOG.debug("cancel timer: " + timerInfo); } } } }
public void cancelTimers() { Collection<Timer> timers = this.timerService.getTimers(); for (Timer timer : timers) { if (timer.getInfo() != null) { if (timer.getInfo().equals(TIMER_ID)) { timer.cancel(); LOG.debug("cancel timer: " + TIMER_ID); } } } }
private void cancelTimers(final ThreadContext threadContext) { final BeanContext beanContext = threadContext.getBeanContext(); final Object primaryKey = threadContext.getPrimaryKey(); // if we have a real timerservice, stop all timers. Otherwise, ignore... if (primaryKey != null) { final EjbTimerService timerService = beanContext.getEjbTimerService(); if (timerService != null && timerService instanceof EjbTimerServiceImpl) { for (final Timer timer : beanContext.getEjbTimerService().getTimers(primaryKey)) { timer.cancel(); } } } }
private void cancelTimers(final ThreadContext threadContext) { final BeanContext beanContext = threadContext.getBeanContext(); final Object primaryKey = threadContext.getPrimaryKey(); // if we have a real timerservice, stop all timers. Otherwise, ignore... if (primaryKey != null) { final EjbTimerService timerService = beanContext.getEjbTimerService(); if (timerService != null && timerService instanceof EjbTimerServiceImpl) { for (final Timer timer : beanContext.getEjbTimerService().getTimers(primaryKey)) { timer.cancel(); } } } }
private void cancelTimers(ThreadContext threadContext) { CoreDeploymentInfo deploymentInfo = threadContext.getDeploymentInfo(); Object primaryKey = threadContext.getPrimaryKey(); // if we have a real timerservice, stop all timers. Otherwise, ignore... if (primaryKey != null) { EjbTimerService timerService = deploymentInfo.getEjbTimerService(); if (timerService != null && timerService instanceof EjbTimerServiceImpl) { for (Timer timer : deploymentInfo.getEjbTimerService().getTimers(primaryKey)) { timer.cancel(); } } } }
private void cancelTimers(final ThreadContext threadContext) { final BeanContext beanContext = threadContext.getBeanContext(); final Object primaryKey = threadContext.getPrimaryKey(); // stop timers if (primaryKey != null && beanContext.getEjbTimerService() != null) { final EjbTimerService timerService = beanContext.getEjbTimerService(); if (timerService != null && timerService instanceof EjbTimerServiceImpl) { for (final Timer timer : beanContext.getEjbTimerService().getTimers(primaryKey)) { timer.cancel(); } } } }
private void cancelTimers(final ThreadContext threadContext) { final BeanContext beanContext = threadContext.getBeanContext(); final Object primaryKey = threadContext.getPrimaryKey(); // stop timers if (primaryKey != null && beanContext.getEjbTimerService() != null) { final EjbTimerService timerService = beanContext.getEjbTimerService(); if (timerService != null && timerService instanceof EjbTimerServiceImpl) { for (final Timer timer : beanContext.getEjbTimerService().getTimers(primaryKey)) { timer.cancel(); } } } }
private void cancelTimers(ThreadContext threadContext) { DeploymentInfo deploymentInfo = threadContext.getDeploymentInfo(); Object primaryKey = threadContext.getPrimaryKey(); // stop timers if (primaryKey != null && deploymentInfo.getEjbTimerService() != null) { EjbTimerService timerService = deploymentInfo.getEjbTimerService(); if (timerService != null && timerService instanceof EjbTimerServiceImpl) { for (Timer timer : deploymentInfo.getEjbTimerService().getTimers(primaryKey)) { timer.cancel(); } } } }