public void stopBatch() {
    Collection<Timer> timer = timerservice.getTimers();

    for (Timer timer1 : timer) {
      timer1.cancel();
    }
  }
Example #2
0
 @Override
 public void remove(String id) {
   JobExecution jobExecution = find(id);
   Timer timer = findTimer(jobExecution);
   if (timer != null) {
     timer.cancel();
   }
   super.remove(id);
 }
  @Timeout
  public void handleTimeout(Timer timer) throws IOException {

    int gameId = (int) timer.getInfo();
    JsonObject gameSummary = (JsonObject) gameResource.endGame(gameId);

    // call websocket to inform end game

    ws.SendtoSameGameConnectedSessions(gameSummary.toString(), gameId);

    timer.cancel();

    System.out.println(gameId);
  }
Example #4
0
  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();
        }
      }
    }
  }
Example #5
0
  @Override
  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 {
        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));
  }
 @Timeout
 private void timeOut(Timer timer) {
   System.out.println("Timer[" + timer.getInfo() + "] TimerBean: timeout occurred");
   System.out.println("Timer[" + timer.getInfo() + "] Persistent : " + timer.isPersistent());
   if (timer.getInfo() != null && (timer.getInfo() instanceof EventInfo)) {
     if (((EventInfo) timer.getInfo()).isRemovable()) {
       timer.cancel();
       EventInfo eventInfo = em.find(EventInfo.class, ((EventInfo) timer.getInfo()).getId());
       em.remove(eventInfo);
     } else {
       if (((EventInfo) timer.getInfo()).isEnabled()) {}
     }
     try {
       Thread.sleep(5000);
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
   }
   System.out.println("Timer[" + timer.getInfo() + "] wait expired.");
 }
 public void cancelMyTimer() {
   for (Object obj : timerService.getAllTimers()) {
     Timer timer = (Timer) obj;
     timer.cancel();
   }
 }