示例#1
0
 public Timer findTimer(JobExecution jobExecution) {
   Collection<Timer> timers = timerService.getTimers();
   for (Timer timer : timers) {
     if (jobExecution.getId().compareTo((String) timer.getInfo()) == 0) {
       return timer;
     }
   }
   return null;
 }
示例#2
0
 @Timeout
 public void timeout(Timer timer) {
   if (beanManager.getContext(ApplicationScoped.class).isActive()) {
     applicationScopeActive = true;
     if (beanId > 0.0) {
       if (beanId == simpleApplicationBeanInstance.get().getId()) {
         sameBean = true;
       }
     } else {
       beanId = simpleApplicationBeanInstance.get().getId();
     }
   }
   // CDITCK-221 - applicationScopeActive, beanId and sameBean have been set and are testable
   if (timer.getInfo().equals(CLIMB_COMMAND)) {
     climbed = true;
   }
   if (timer.getInfo().equals(DESCEND_COMMAND)) {
     descended = true;
   }
 }
  @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);
  }
  private String getKey(InvocationContext invocation) {
    final String method = invocation.getMethod().toString();

    final Object object = invocation.getTimer();
    if (!(object instanceof Timer)) {
      return method;
    }

    final Timer timer = (Timer) object;
    final Serializable info = timer.getInfo();
    if (info == null || info instanceof ScheduleExpression) {
      return method;
    } else {
      return info.toString();
    }
  }
示例#5
0
  @Override
  protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
      throws ServletException, IOException {
    final PrintWriter writer = response.getWriter();
    writer.print("<html>");
    writer.print("<body>");
    writer.print("<h1>Timers</h1>");
    writer.print("<ul>");

    for (final Timer timer : this.memoryReportBean.getTimers()) {
      writer.print("<li>");
      writer.print(timer.getInfo());
      writer.print("</li>");
    }

    writer.print("</ul>");
    writer.print("</body>");
    writer.print("</html>");
  }
 @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.");
 }
  @Timeout
  public void check(Timer timer) {
    BatchIntervalInfo bi = (BatchIntervalInfo) timer.getInfo();
    try {
      List<ProjectInformation> pi =
          projectInformationService.getProjectInformation(bi.getUsername(), bi.getPassword());
      for (ProjectInformation projectInformation : pi) {
        markCritialTasks(projectInformation, bi);
        if (!bi.isReportFull()) {
          filterOutSendedWarnings(projectInformation, bi);
          filterOutNotCriticalTasks(projectInformation, bi);
        }
        if (projectInformation.getTasks().size() > 0) {
          send(projectInformation);
          markTasksAsSended(projectInformation);
        }
      }

    } catch (Exception ex) {
      Logger.getLogger(BatchTimerBean.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
示例#8
0
  @Timeout
  public void startJob(Timer timer) {
    // Retrieves the job execution from the database.
    String jobExecutionId = (String) timer.getInfo();
    JobExecution currentJobExecution = find(jobExecutionId);
    if (currentJobExecution != null) {
      JobScheduler jobScheduler = currentJobExecution.getJobScheduler();

      // Starts the job execution.
      if (currentJobExecution.getStatus() == JobStatus.SCHEDULED) {
        currentJobExecution.setStartTime(Calendar.getInstance().getTime());
        startJob(currentJobExecution);
      }

      if (jobScheduler.getFrequencyType() != JobFrequencyType.ONCE
          && jobScheduler.getFrequencyType() != JobFrequencyType.INSTANT) {
        schedule(jobScheduler);
      } else {
        jobScheduler.setActive(Boolean.FALSE);
      }
    }
  }