Java 类javax.ejb.Timer 实例源码

项目:oscm    文件:TimerServiceBean.java   
void createTimerWithPeriod(TimerService timerService, TimerType timerType,
        long timerOffset, Period period) {
    if (isTimerCreated(timerType, timerService)) {
        return;
    }
    TimerConfig config = new TimerConfig();
    config.setInfo(timerType);
    Date startDate = getDateForNextTimerExpiration(period, timerOffset);
    ScheduleExpression schedleExpression = getExpressionForPeriod(period,
            startDate);
    Timer timer = timerService.createCalendarTimer(schedleExpression,
            config);
    Date nextStart = timer.getNextTimeout();
    SimpleDateFormat sdf = new SimpleDateFormat();
    logger.logInfo(Log4jLogger.SYSTEM_LOG,
            LogMessageIdentifier.INFO_TIMER_CREATED,
            String.valueOf(timerType), sdf.format(nextStart));
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:TimerBean.java   
public void programmaticTimeout() {
    logger.info("TimerEJB: programmatic timeout occurred");
    timeoutDone = false;
    long duration = 60;
    Timer timer = timerService.createSingleActionTimer(duration, new TimerConfig());
    timer.getInfo();
    try {
        timer.getSchedule();
    } catch (IllegalStateException e) {
        logger.log(SEVERE, "it is not a scheduler", e);
    }
    TimerHandle timerHandle = timer.getHandle();
    timerHandle.getTimer();
    timer.isCalendarTimer();
    timer.isPersistent();
    timer.getTimeRemaining();
}
项目:oscm-app    文件:APPTimerServiceBean.java   
/**
 * Initialize the timer for polling for the services
 */
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void initTimers_internal() {
    Collection<Timer> timers = timerService.getTimers();
    boolean appTimerExist = false;
    for (Timer timerAPP : timers) {
        if (APP_TIMER_INFO.equals(timerAPP.getInfo())) {
            appTimerExist = true;
        }
    }
    if (!appTimerExist) {
        logger.info("Timer create.");
        try {
            String timerIntervalSetting = configService
                    .getProxyConfigurationSetting(
                            PlatformConfigurationKey.APP_TIMER_INTERVAL);
            long interval = Long.parseLong(timerIntervalSetting);
            timerService.createTimer(0, interval, APP_TIMER_INFO);
        } catch (ConfigurationException e) {
            timerService.createTimer(0, DEFAULT_TIMER_INTERVAL,
                    APP_TIMER_INFO);
            logger.info(
                    "Timer interval not set, switch to default 15 sec.");
        }
    }
}
项目:oscm-app    文件:TimerRefreshSubscriptions.java   
@PostConstruct
public void setTimer() {
    Collection<Timer> timers = timerService.getTimers();
    for (Timer timerVM : timers) {
        if (VM_TIMER_INFO.equals(timerVM.getInfo())) {
            timerVM.cancel();
        }
    }
    logger.info("Timer for subscription VMs will be created.");
    try {
        String timerIntervalSetting = configService
                .getProxyConfigurationSetting(PlatformConfigurationKey.APP_TIMER_REFRESH_SUBSCRIPTIONS);
        long interval = Long.parseLong(timerIntervalSetting);
        timerService.createTimer(0, interval, VM_TIMER_INFO);
        // timerService.createIntervalTimer(new Date(), interval,
        // new TimerConfig());
    } catch (ConfigurationException e) {
        timerService.createTimer(0, DEFAULT_TIMER_INTERVAL, VM_TIMER_INFO);
        logger.info("Timer interval for refreshing subcription VMs not set, switch to default 10 min.");
    }
}
项目:oscm-app    文件:TimerRefreshSubscriptions.java   
@Timeout
public void execute(Timer timer) {
    if (!VM_TIMER_INFO.equals(timer.getInfo())) {
        return;
    }
    List<ServiceInstance> instances = serviceInstanceService.getInstances();
    for (ServiceInstance serviceInstance : instances) {
        try {
            final APPlatformController controller = APPlatformControllerFactory
                    .getInstance(serviceInstance.getControllerId());

            int vmsNumber = controller.getServersNumber(serviceInstance.getInstanceId(),
                    serviceInstance.getSubscriptionId(), serviceInstance.getOrganizationId());

            ServiceInstance updatedServiceInstance = serviceInstanceService.updateVmsNumber(serviceInstance,
                    vmsNumber);
            serviceInstanceService.notifySubscriptionAboutVmsNumber(updatedServiceInstance);
        } catch (APPlatformException e) {
            logger.error("Subscription cannot be notified about VMs number: ", e);
        }
    }
}
项目:oscm    文件:InitializerTest.java   
@Before
public void setUp() throws Exception {
    testElm = new Initializer();
    controllerAccess = Mockito.mock(ControllerAccess.class);
    Mockito.when(controllerAccess.getControllerId()).thenReturn(
            "ess.common");
    testElm.setControllerAccess(controllerAccess);

    timerService = Mockito.mock(TimerService.class);
    Collection<Timer> timers = new ArrayList<Timer>();
    Mockito.when(timerService.getTimers()).thenReturn(timers);

    // Set timer resource
    Field field = testElm.getClass().getDeclaredField("timerService");
    field.setAccessible(true);
    field.set(testElm, timerService);

}
项目:oscm    文件:TimerServiceBean.java   
boolean isTimerCreated(TimerType timerType, TimerService timerService) {
    for (Timer timer : ParameterizedTypes.iterable(
            timerService.getTimers(), Timer.class)) {
        TimerType tType = (TimerType) timer.getInfo();
        if ((TimerType.BILLING_INVOCATION.equals(tType) && TimerType.BILLING_INVOCATION
                .equals(timerType))
                || (TimerType.DISCOUNT_END_CHECK.equals(tType) && TimerType.DISCOUNT_END_CHECK
                        .equals(timerType))) {
            long currentTime = System.currentTimeMillis();
            if (timer.getNextTimeout().getTime() - currentTime > 0) {
                return true;
            } else {
                timer.cancel();
            }
        }
    }
    return false;
}
项目:oscm    文件:TimerServiceBean.java   
/**
 * Determines all currently queued timers and cancel timer with target type.
 * 
 * @param timerService
 *            The timer service.
 * @param timerType
 *            The timer type.
 */
private void cancelObsoleteTimer(TimerService timerService,
        TimerType timerType) {

    for (Timer timer : ParameterizedTypes.iterable(
            timerService.getTimers(), Timer.class)) {
        Serializable info = timer.getInfo();
        if (info != null && info instanceof TimerType && timerType == info) {
            TimerType type = (TimerType) info;
            timer.cancel();
            logger.logInfo(Log4jLogger.SYSTEM_LOG,
                    LogMessageIdentifier.INFO_TIMER_REMOVED,
                    String.valueOf(type));
        }
    }

}
项目:oscm    文件:TimerServiceBean.java   
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public List<VOTimerInfo> getCurrentTimerExpirationDates() {
    List<VOTimerInfo> result = new ArrayList<VOTimerInfo>();

    for (Timer timer : ParameterizedTypes.iterable(ctx.getTimerService()
            .getTimers(), Timer.class)) {
        Serializable info = timer.getInfo();
        if (info != null && info instanceof TimerType) {
            TimerType type = (TimerType) info;
            long expirationTime = timer.getTimeRemaining()
                    + System.currentTimeMillis();
            VOTimerInfo timerInfo = new VOTimerInfo();
            timerInfo.setTimerType(type.name());
            timerInfo.setExpirationDate(new Date(expirationTime));
            result.add(timerInfo);
        }
    }

    return result;
}
项目:oscm    文件:APPTimerServiceBean.java   
/**
 * Initialize the timer for polling for the services
 */
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void initTimers_internal() {
    Collection<Timer> timers = timerService.getTimers();
    boolean appTimerExist = false;
    for (Timer timerAPP : timers) {
        if (APP_TIMER_INFO.equals(timerAPP.getInfo())) {
            appTimerExist = true;
        }
    }
    if (!appTimerExist) {
        logger.info("Timer create.");
        try {
            String timerIntervalSetting = configService
                    .getProxyConfigurationSetting(
                            PlatformConfigurationKey.APP_TIMER_INTERVAL);
            long interval = Long.parseLong(timerIntervalSetting);
            timerService.createTimer(0, interval, APP_TIMER_INFO);
        } catch (ConfigurationException e) {
            timerService.createTimer(0, DEFAULT_TIMER_INTERVAL,
                    APP_TIMER_INFO);
            logger.info(
                    "Timer interval not set, switch to default 15 sec.");
        }
    }
}
项目:oscm    文件:TimerRefreshSubscriptions.java   
@PostConstruct
public void setTimer() {
    Collection<Timer> timers = timerService.getTimers();
    for (Timer timerVM : timers) {
        if (VM_TIMER_INFO.equals(timerVM.getInfo())) {
            timerVM.cancel();
        }
    }
    logger.info("Timer for subscription VMs will be created.");
    try {
        String timerIntervalSetting = configService
                .getProxyConfigurationSetting(PlatformConfigurationKey.APP_TIMER_REFRESH_SUBSCRIPTIONS);
        long interval = Long.parseLong(timerIntervalSetting);
        timerService.createTimer(0, interval, VM_TIMER_INFO);
        // timerService.createIntervalTimer(new Date(), interval,
        // new TimerConfig());
    } catch (ConfigurationException e) {
        timerService.createTimer(0, DEFAULT_TIMER_INTERVAL, VM_TIMER_INFO);
        logger.info("Timer interval for refreshing subcription VMs not set, switch to default 10 min.");
    }
}
项目:oscm    文件:TimerRefreshSubscriptions.java   
@Timeout
public void execute(Timer timer) {
    if (!VM_TIMER_INFO.equals(timer.getInfo())) {
        return;
    }
    List<ServiceInstance> instances = serviceInstanceService.getInstances();
    for (ServiceInstance serviceInstance : instances) {
        try {
            final APPlatformController controller = APPlatformControllerFactory
                    .getInstance(serviceInstance.getControllerId());

            int vmsNumber = controller.getServersNumber(serviceInstance.getInstanceId(),
                    serviceInstance.getSubscriptionId(), serviceInstance.getOrganizationId());

            ServiceInstance updatedServiceInstance = serviceInstanceService.updateVmsNumber(serviceInstance,
                    vmsNumber);
            serviceInstanceService.notifySubscriptionAboutVmsNumber(updatedServiceInstance);
        } catch (APPlatformException e) {
            logger.error("Subscription cannot be notified about VMs number: ", e);
        }
    }
}
项目:oscm    文件:TimerServiceBean2Test.java   
@Test
public void handleTimer_handleTimerPeriodicVerifyNoReinitialization()
        throws Exception {
    TimerStub timer = new TimerStub();
    TimerType timerType = TimerType.ORGANIZATION_UNCONFIRMED;
    timer.setInfo(timerType);
    tss.createTimer(new Date(), timerType);

    tm.handleTimer(timer);

    Iterable<Timer> timers = ParameterizedTypes.iterable(tss.getTimers(),
            Timer.class);
    List<Timer> timerList = new ArrayList<Timer>();
    for (Timer t : timers) {
        timerList.add(t);
    }

    assertEquals(
            "No additional timer must have been initialized, as the present one is already periodid with a fix interval",
            1, timerList.size());
}
项目:oscm    文件:TimerServiceBean2Test.java   
@Test
public void initTimers_getCurrentTimerExpirationDates()
        throws ValidationException {

    tss = new TimerServiceStub() {
        @Override
        public Timer createTimer(Date arg0, Serializable arg1)
                throws IllegalArgumentException, IllegalStateException,
                EJBException {
            initTimer((TimerType) arg1, arg0);
            getTimers().add(timer);
            return null;
        }
    };
    when(ctx.getTimerService()).thenReturn(tss);
    List<VOTimerInfo> expirationDates;
    tm.initTimers();
    expirationDates = tm.getCurrentTimerExpirationDates();
    tm.initTimers();
    assertEquals(7, expirationDates.size());
}
项目:oscm    文件:TimerServiceBean2Test.java   
@Test(expected = ValidationException.class)
public void initTimers_nextExpirationDateNegative()
        throws ValidationException {

    tss = new TimerServiceStub() {
        @Override
        public Timer createTimer(Date arg0, Serializable arg1)
                throws IllegalArgumentException, IllegalStateException,
                EJBException {
            initTimer((TimerType) arg1, arg0);
            getTimers().add(timer);
            return null;
        }
    };
    when(ctx.getTimerService()).thenReturn(tss);
    cfs.setConfigurationSetting(
            ConfigurationKey.TIMER_INTERVAL_ORGANIZATION,
            "9223372036854775807");

    tm.initTimers();
}
项目:oscm    文件:TimerServiceBean2Test.java   
@Test(expected = ValidationException.class)
public void initTimers_nextExpirationDateNegative_userCount()
        throws ValidationException {
    // given
    tss = new TimerServiceStub() {
        @Override
        public Timer createTimer(Date arg0, Serializable arg1)
                throws IllegalArgumentException, IllegalStateException,
                EJBException {
            initTimer((TimerType) arg1, arg0);
            getTimers().add(timer);
            return null;
        }
    };
    when(ctx.getTimerService()).thenReturn(tss);
    cfs.setConfigurationSetting(ConfigurationKey.TIMER_INTERVAL_USER_COUNT,
            "9223372036854775807");
    // when
    tm.initTimers();

}
项目:USM    文件:InMemorySessionDao.java   
@Timeout
public void timeout(Timer timer) 
{
  LOGGER.info("timeout() - (ENTER)");

  Properties policy = policyProvider.getProperties(POLICY_SUBJECT);
  int ttlSession = policyProvider.getIntProperty(policy, "account.maxSessionDuration", 0);

  if (ttlSession > 0) {
    Date startedBefore = new Date(System.currentTimeMillis() - 
                           (ttlSession * ONE_SECOND));
    LOGGER.info("startedBefore: " + startedBefore);

    List<String> expired = findExpiredSessions(startedBefore);
    for (String sessionId : expired) {

      LOGGER.info("deleteing expired session: " + sessionId);
      deleteSession(sessionId);
    }
  }

  LOGGER.info("timeout() - (LEAVE)");
}
项目:myWMS    文件:ERPQueryInventoryBean.java   
@SuppressWarnings("unchecked")
public String statusCronJob() {
    String stat = null;
    for (Timer timer : (Collection<Timer>) timerService.getTimers()) {
        if (timer.getInfo() instanceof String) {
            if (((String) timer.getInfo())
                    .equals(ERPQueryInventory.TIME_OUT_INFO)) {
                log.info(" " + timer.toString());
                stat = "Running. Remaining: " + timer.getTimeRemaining();
                return stat;
            }
        }
    }

    return "Not running";
}
项目:exmatrikulator    文件:SemesterService.java   
/**
 * Generates a new Semester for every SoSe / WiSe ten years ahead.
 */
public void scheduledSemesterCreator(Timer timer) {
    Calendar cal = Calendar.getInstance();
    int year = cal.get(Calendar.YEAR);

    Semester soSe = new Semester();
    Semester wiSe = new Semester();

    soSe.setSemesterYear(year + 10);
    soSe.setIsWinter(false);
    wiSe.setSemesterYear(year + 10);
    wiSe.setIsWinter(true);

    em.persist(soSe);
    em.persist(wiSe);
}
项目:bookery    文件:BatchJobService.java   
public BatchJobConfiguration fireUpTimer(BatchJobConfiguration jobConfig) {
    if (jobConfig.isActive()) {
        logger.debug("Configured batch job " + jobConfig.getType().getDisplayName());
        TimerConfig timerConf = new TimerConfig(jobConfig, false);
        String[] splittedCronJob = jobConfig.getCronJobExpression().split(" ");
        ScheduleExpression schedExp = new ScheduleExpression();
        schedExp.second(splittedCronJob[0]);
        schedExp.minute(splittedCronJob[1]);
        schedExp.hour(splittedCronJob[2]);
        schedExp.dayOfMonth(splittedCronJob[3]);
        schedExp.month(splittedCronJob[4]);
        schedExp.year(splittedCronJob[5]);
        schedExp.dayOfWeek(splittedCronJob[6]);
        Timer timer = timerService.createCalendarTimer(schedExp, timerConf);
        jobConfig.setNextTimeout(timer.getNextTimeout());
        jobConfig = batchJobConfigurationDAO.update(jobConfig);
    }
    return jobConfig;
}
项目:bookery    文件:BookeryMailService.java   
@Timeout
public void createKindleMail(Timer timer) {
    try {
        Payload payload = (Payload)timer.getInfo();
        BookEntry book = payload.getBook();
        AppUser user = payload.getUser();
        byte[] attachment = solrHandler.getMobiFormat(book.getId()).get(0).getMobi();
        //1.Step Check if convert
        if (attachment == null) {
            convertEPubToMobi(book);
            attachment = solrHandler.getMobiFormat(book.getId()).get(0).getMobi();
        }
        //2. Step Send Email
        String filename = book.getTitle() + "-" + book.getAuthor();
        sendKindleMail(user, attachment, filename);
    } catch (SolrServerException | MessagingException | IOException | InterruptedException ex) {
        logger.error("failed to create Kindle mail.",ex);
    }
}
项目:development    文件:InitializerTest.java   
@Before
public void setUp() throws Exception {
    testElm = new Initializer();
    controllerAccess = Mockito.mock(ControllerAccess.class);
    Mockito.when(controllerAccess.getControllerId()).thenReturn(
            "ess.common");
    testElm.setControllerAccess(controllerAccess);

    timerService = Mockito.mock(TimerService.class);
    Collection<Timer> timers = new ArrayList<Timer>();
    Mockito.when(timerService.getTimers()).thenReturn(timers);

    // Set timer resource
    Field field = testElm.getClass().getDeclaredField("timerService");
    field.setAccessible(true);
    field.set(testElm, timerService);

}
项目:development    文件:TimerServiceBean.java   
void createTimerWithPeriod(TimerService timerService, TimerType timerType,
        long timerOffset, Period period) {
    if (isTimerCreated(timerType, timerService)) {
        return;
    }
    TimerConfig config = new TimerConfig();
    config.setInfo(timerType);
    Date startDate = getDateForNextTimerExpiration(period, timerOffset);
    ScheduleExpression schedleExpression = getExpressionForPeriod(period,
            startDate);
    Timer timer = timerService.createCalendarTimer(schedleExpression,
            config);
    Date nextStart = timer.getNextTimeout();
    SimpleDateFormat sdf = new SimpleDateFormat();
    logger.logInfo(Log4jLogger.SYSTEM_LOG,
            LogMessageIdentifier.INFO_TIMER_CREATED,
            String.valueOf(timerType), sdf.format(nextStart));
}
项目:development    文件:TimerServiceBean.java   
boolean isTimerCreated(TimerType timerType, TimerService timerService) {
    for (Timer timer : ParameterizedTypes.iterable(
            timerService.getTimers(), Timer.class)) {
        TimerType tType = (TimerType) timer.getInfo();
        if ((TimerType.BILLING_INVOCATION.equals(tType) && TimerType.BILLING_INVOCATION
                .equals(timerType))
                || (TimerType.DISCOUNT_END_CHECK.equals(tType) && TimerType.DISCOUNT_END_CHECK
                        .equals(timerType))) {
            long currentTime = System.currentTimeMillis();
            if (timer.getNextTimeout().getTime() - currentTime > 0) {
                return true;
            } else {
                timer.cancel();
            }
        }
    }
    return false;
}
项目:development    文件:TimerServiceBean.java   
/**
 * Determines all currently queued timers and cancel timer with target type.
 * 
 * @param timerService
 *            The timer service.
 * @param timerType
 *            The timer type.
 */
private void cancelObsoleteTimer(TimerService timerService,
        TimerType timerType) {

    for (Timer timer : ParameterizedTypes.iterable(
            timerService.getTimers(), Timer.class)) {
        Serializable info = timer.getInfo();
        if (info != null && info instanceof TimerType && timerType == info) {
            TimerType type = (TimerType) info;
            timer.cancel();
            logger.logInfo(Log4jLogger.SYSTEM_LOG,
                    LogMessageIdentifier.INFO_TIMER_REMOVED,
                    String.valueOf(type));
        }
    }

}
项目:development    文件:TimerServiceBean.java   
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public List<VOTimerInfo> getCurrentTimerExpirationDates() {
    List<VOTimerInfo> result = new ArrayList<VOTimerInfo>();

    for (Timer timer : ParameterizedTypes.iterable(ctx.getTimerService()
            .getTimers(), Timer.class)) {
        Serializable info = timer.getInfo();
        if (info != null && info instanceof TimerType) {
            TimerType type = (TimerType) info;
            long expirationTime = timer.getTimeRemaining()
                    + System.currentTimeMillis();
            VOTimerInfo timerInfo = new VOTimerInfo();
            timerInfo.setTimerType(type.name());
            timerInfo.setExpirationDate(new Date(expirationTime));
            result.add(timerInfo);
        }
    }

    return result;
}
项目:development    文件:APPTimerServiceBean.java   
/**
 * Initialize the timer for polling for the services
 */
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void initTimers_internal() {
    Collection<Timer> timers = timerService.getTimers();
    boolean appTimerExist = false;
    for (Timer timerAPP : timers) {
        if (APP_TIMER_INFO.equals(timerAPP.getInfo())) {
            appTimerExist = true;
        }
    }
    if (!appTimerExist) {
        logger.info("Timer create.");
        try {
            String timerIntervalSetting = configService
                    .getProxyConfigurationSetting(
                            PlatformConfigurationKey.APP_TIMER_INTERVAL);
            long interval = Long.parseLong(timerIntervalSetting);
            timerService.createTimer(0, interval, APP_TIMER_INFO);
        } catch (ConfigurationException e) {
            timerService.createTimer(0, DEFAULT_TIMER_INTERVAL,
                    APP_TIMER_INFO);
            logger.info(
                    "Timer interval not set, switch to default 15 sec.");
        }
    }
}
项目:development    文件:TimerServiceBean2Test.java   
@Test
public void initTimers_getCurrentTimerExpirationDates()
        throws ValidationException {

    tss = new TimerServiceStub() {
        @Override
        public Timer createTimer(Date arg0, Serializable arg1)
                throws IllegalArgumentException, IllegalStateException,
                EJBException {
            initTimer((TimerType) arg1, arg0);
            getTimers().add(timer);
            return null;
        }
    };
    when(ctx.getTimerService()).thenReturn(tss);
    List<VOTimerInfo> expirationDates;
    tm.initTimers();
    expirationDates = tm.getCurrentTimerExpirationDates();
    tm.initTimers();
    assertEquals(7, expirationDates.size());
}
项目:development    文件:TimerServiceBean2Test.java   
@Test(expected = ValidationException.class)
public void initTimers_nextExpirationDateNegative_userCount()
        throws ValidationException {
    // given
    tss = new TimerServiceStub() {
        @Override
        public Timer createTimer(Date arg0, Serializable arg1)
                throws IllegalArgumentException, IllegalStateException,
                EJBException {
            initTimer((TimerType) arg1, arg0);
            getTimers().add(timer);
            return null;
        }
    };
    when(ctx.getTimerService()).thenReturn(tss);
    cfs.setConfigurationSetting(ConfigurationKey.TIMER_INTERVAL_USER_COUNT,
            "9223372036854775807");
    // when
    tm.initTimers();

}
项目:vocloud    文件:TokenAuthBean.java   
@SuppressWarnings("unused")
@Timeout
@Lock(LockType.WRITE)
private void cleanseExpiredTokens(Timer timer) {
    // cancel all other queued timers
    for (Timer t : timerService.getTimers()) {
        try {
            t.cancel();
        } catch (NoSuchObjectLocalException ex) {
            //do nothing
        }
    }
    Iterator<AuthToken> it = tokenList.iterator();
    while (it.hasNext()) {
        AuthToken token = it.next();
        if (token.isExpired()) {
            it.remove();
            indexToken.remove(token.getToken());
        }
    }
}
项目:gangehi    文件:ReminderService.java   
@Timeout
public void timeout(Timer timer) {
    if (propertyService.getBoolean("mail.reminder.active")) {
        log.info("Reminder activated.");

        List<SimpleApproval> simpleApprovals = simpleApprovalDAO.findOpenApprovalsProcessInstanceId();
        for (SimpleApproval simpleApproval : simpleApprovals) {
            log.info("ProcessInstanceId: " + simpleApproval);
            // TODO: make the query more efficient
            List<Status> statusList = new ArrayList<Status>();
            statusList.add(Status.InProgress);
            statusList.add(Status.Reserved);
            List<TaskSummary> tasks = runtimeDataService.getTasksByStatusByProcessInstanceId(simpleApproval.getProcessInstanceId(), statusList, null);
            if (tasks.size() > 1) {
                log.warning("More then one task for processInstanceId: " + simpleApproval.getProcessInstanceId());
            }
            TaskSummary task = tasks.get(0);
            String actualOwner = task.getActualOwnerId();
            sendReminderEmail(actualOwner, simpleApproval.getProcessInstanceId(), simpleApproval.getSubject());
        }
    } else {
        log.warning("Reminder inactive!");
    }

}
项目:snoop    文件:EurekaClient.java   
@Timeout
public void health(Timer timer) {
   LOGGER.config(() -> "health update: " + Calendar.getInstance().getTime());
   LOGGER.config(() -> "Next: " + timer.getNextTimeout());

   EurekaConfig eurekaConfig = new EurekaConfig();
   eurekaConfig.setStatus("UP");
   Entity<InstanceConfig> entity = Entity.entity(new InstanceConfig(eurekaConfig), MediaType.APPLICATION_JSON);

   Response response = ClientBuilder.newClient()
           .target(serviceUrl + "apps/" + applicationName + "/" + applicationName)
           .request()
           .put(entity);

   LOGGER.config(() -> "PUT resulted in: " + response.getStatus() + ", " + response.getEntity());

}
项目:hopsworks    文件:JobScheduler.java   
/**
 * Execute the job given as extra info to the timer object.
 * <p/>
 * @param timer
 */
@Timeout
public void timeout(Timer timer) {
  Serializable jobId = timer.getInfo();
  //Valid id?
  if (!(jobId instanceof Integer)) {
    logger.log(Level.WARNING,
            "Trying to run a scheduled execution, but info is not of integer class.");
    return;
  }
  //Valid job?
  Jobs job = jobFacade.findById((Integer) jobId);
  if (job == null) {
    logger.log(Level.WARNING, "Trying to run a job with non-existing id.");
    return;
  }
  try {
    //Yes! Now execute!
    executionController.start(job, job.getCreator());
  } catch (IOException ex) {
    logger.log(Level.WARNING, "Exception while starting scheduled job " + job,
            ex);
  }
}
项目:hopsworks    文件:DelaSetupWorker.java   
private void delaContact(Timer timer) {
  LOG.log(Level.INFO, "state:{0}", state);
  AddressJSON delaTransferEndpoint;
  try {
    delaTransferEndpoint = SettingsHelper.delaTransferEndpoint(settings);
  } catch (ThirdPartyException tpe) {
    try {
      delaTransferEndpoint = getDelaTransferEndpoint(delaVersion);
      delaStateCtrl.transferDelaContacted();
      settings.setDELA_PUBLIC_ENDPOINT(delaTransferEndpoint);
      hopsSiteRegister(resetToRegister(timer), delaTransferEndpoint);
    } catch (ThirdPartyException tpe2) {
      LOG.log(Level.WARNING, "source:<{0}:{1}>:{2}",
        new Object[]{tpe2.getSource(), tpe2.getSourceDetails(), tpe2.getMessage()});
      //try again later - maybe it works
    }
  }

}
项目:Mastering-Java-EE-Development-with-WildFly    文件:ItemServiceBean.java   
@Timeout
@Interceptors(ExcludingInterceptor.class)
private void timeout(Timer timer) {
    timerServiceCalled = true;
    interceptorResults += "@Timeout";
    latch.countDown();
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:OldSpecsBean.java   
public void ejbTimeout(Timer theTimer) {

        // Any code typically placed in an EJB method can be placed here.

        String whyWasICalled = (String) theTimer.getInfo();
        this.whyWasICalled = whyWasICalled;
        logger.info("I was called because of" + whyWasICalled);
    }
项目:Mastering-Java-EE-Development-with-WildFly    文件:OldSpecsBean.java   
@Override
public void fireInThirtySeconds() throws EJBException {

    TimerService theTimerService = theEJBContext.getTimerService();
    String aLabel = "30SecondTimeout";
    Timer theTimer = theTimerService.createTimer(300, aLabel);
    logger.info("timer is: " + theTimer);
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:SchedulerTestCase.java   
@Test
public void testManualConfiguration() {
    Timer timer = schedulerBean.setTimer("10", new Date());
    ScheduleExpression scheduleExpression = timer.getSchedule();
    scheduleExpression.hour(10);
    scheduleExpression.start(new Date());
    assertEquals("The timer will start today at the 10", "10", scheduleExpression.getHour());
    assertEquals("The timer will start each Wednesday too", "Wed", scheduleExpression.getDayOfWeek());
}
项目:marathonv5    文件:SingletonSimulationBean.java   
@Timeout
public void timeout(Timer timer) {
    if (timer.equals(simulationTimer)){
        sim.run();
    }
    else if (timer.equals(hourlySalesTimer)){
        hourlySalesGenerator.run();
    }
}
项目:marathonv5    文件:SingletonSimulationBean.java   
@Timeout
public void timeout(Timer timer) {
    if (timer.equals(simulationTimer)){
        sim.run();
    }
    else if (timer.equals(hourlySalesTimer)){
        hourlySalesGenerator.run();
    }
}