當前位置: 首頁>>代碼示例>>Java>>正文


Java Timer.getInfo方法代碼示例

本文整理匯總了Java中javax.ejb.Timer.getInfo方法的典型用法代碼示例。如果您正苦於以下問題:Java Timer.getInfo方法的具體用法?Java Timer.getInfo怎麽用?Java Timer.getInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.ejb.Timer的用法示例。


在下文中一共展示了Timer.getInfo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: programmaticTimeout

import javax.ejb.Timer; //導入方法依賴的package包/類
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();
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:18,代碼來源:TimerBean.java

示例2: isTimerCreated

import javax.ejb.Timer; //導入方法依賴的package包/類
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;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:19,代碼來源:TimerServiceBean.java

示例3: cancelObsoleteTimer

import javax.ejb.Timer; //導入方法依賴的package包/類
/**
 * 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));
        }
    }

}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:25,代碼來源:TimerServiceBean.java

示例4: getCurrentTimerExpirationDates

import javax.ejb.Timer; //導入方法依賴的package包/類
@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;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:21,代碼來源:TimerServiceBean.java

示例5: statusCronJob

import javax.ejb.Timer; //導入方法依賴的package包/類
@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";
}
 
開發者ID:salimvanak,項目名稱:myWMS,代碼行數:17,代碼來源:ERPQueryInventoryBean.java

示例6: createKindleMail

import javax.ejb.Timer; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:felixhusse,項目名稱:bookery,代碼行數:20,代碼來源:BookeryMailService.java

示例7: ejbTimeout

import javax.ejb.Timer; //導入方法依賴的package包/類
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);
	}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:9,代碼來源:OldSpecsBean.java

示例8: cancelAllObsoleteTimer

import javax.ejb.Timer; //導入方法依賴的package包/類
/**
 * Determines all currently queued timers and cancels them.
 */
private void cancelAllObsoleteTimer() {
    for (Timer timer : ParameterizedTypes.iterable(ctx.getTimerService()
            .getTimers(), Timer.class)) {
        Serializable info = timer.getInfo();
        if (info != null && info instanceof TimerType) {
            TimerType type = (TimerType) info;
            timer.cancel();
            logger.logInfo(Log4jLogger.SYSTEM_LOG,
                    LogMessageIdentifier.INFO_TIMER_REMOVED,
                    String.valueOf(type));
        }
    }

}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:18,代碼來源:TimerServiceBean.java

示例9: cancelCronJob

import javax.ejb.Timer; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void cancelCronJob() {
	for (Timer timer : (Collection<Timer>) timerService.getTimers()) {
		if (timer.getInfo() instanceof String) {
			if (((String) timer.getInfo())
					.equals(TIME_OUT_INFO)) {
				timer.cancel();
				log.info("Cancel timer: " + timer.toString());
				return;
			}
		}
	}
}
 
開發者ID:salimvanak,項目名稱:myWMS,代碼行數:14,代碼來源:ERPQueryInventoryBean.java

示例10: cancelCronJob

import javax.ejb.Timer; //導入方法依賴的package包/類
public void cancelCronJob() {
	TimerService timerService = ctx.getTimerService();
	for (Timer timer : (Collection<Timer>) timerService.getTimers()) {
		if (timer.getInfo() instanceof String) {
			if (((String) timer.getInfo())
					.equals(LocationSanityBusiness.TIME_OUT_INFO)) {
				timer.cancel();
				log.info("Cancel timer: " + timer.toString());
				return;
			}
		}
	}
}
 
開發者ID:salimvanak,項目名稱:myWMS,代碼行數:14,代碼來源:LocationSanityBusinessBean.java

示例11: getTimer

import javax.ejb.Timer; //導入方法依賴的package包/類
public Timer getTimer() {
	TimerService timerService = ctx.getTimerService();
	for (Timer timer : (Collection<Timer>) timerService.getTimers()) {
		if (timer.getInfo() instanceof String) {
			if (((String) timer.getInfo())
					.equals(LocationSanityBusiness.TIME_OUT_INFO)) {
				log.info(" " + timer.toString());
				return timer;
			}
		}
	}
	
	return null;
}
 
開發者ID:salimvanak,項目名稱:myWMS,代碼行數:15,代碼來源:LocationSanityBusinessBean.java

示例12: handleTimer

import javax.ejb.Timer; //導入方法依賴的package包/類
@Timeout
public void handleTimer(final Timer timer) {
   SchedulerTimerConfig config = (SchedulerTimerConfig) timer.getInfo();
   log.info("run EE Timer " + config.getSchedulerName());

   try {
      Context.internalRequestScope().setManaged(false);
      Context.start();
      if (config.getPersistenceReference() != null) {
         setApplicationEntityManager(config.getPersistenceReference());
      }

      Context.sessionScope().setUser("SchedulerTask-" + config.getSchedulerName());

      EntityManager em = Context.internalRequestScope().getOrCreateEntityManager(false);
      TypedQuery<Controllable> q = em.createNamedQuery(Controllable.SEL_SCHED_BY_DATE, Controllable.class);
      q.setParameter("actuator", config.getSchedulerName());
      q.setParameter("currentDate", new Date(), TemporalType.TIMESTAMP);
      List<Controllable> list = q.getResultList();
      log.info(list.size() + " due scheduled business cases found");
      for (Controllable co : list) {
         co.decrypt();
         process(co);
      }

   } catch (Exception e) {
      log.error("Failed to execute EEScheduledTask Timer " + config.getSchedulerName() + ": " + e.getMessage(), e);
   } finally {
      Context.end();
   }
}
 
開發者ID:Wolfgang-Winter,項目名稱:cibet,代碼行數:32,代碼來源:EESchedulerTask.java

示例13: resetBatchJobs

import javax.ejb.Timer; //導入方法依賴的package包/類
public void resetBatchJobs() {
    
    Collection<Timer> timers = batchJobService.getAllTimer();
    logger.debug("found " + timers.size() + " running timers");
    for (Timer timer : timers) {
        BatchJobConfiguration batchJob = (BatchJobConfiguration)timer.getInfo();
        logger.debug("Canceling " + batchJob.getType().getDisplayName() + " ("+batchJob.getId()+")");
        batchJobService.cancelJob(batchJob);
    }
}
 
開發者ID:felixhusse,項目名稱:bookery,代碼行數:11,代碼來源:AdminPresenter.java

示例14: timeout

import javax.ejb.Timer; //導入方法依賴的package包/類
@Timeout
public void timeout(Timer timer) {
    try {
        logger.debug("Executing Timer ");
        BatchJobConfiguration jobConfig = (BatchJobConfiguration)timer.getInfo();
        logger.debug("Executing Batch Job " + jobConfig.getType().getDisplayName());
        BatchJobInterface batchJob = (BatchJobInterface)InitialContext.doLookup(jobConfig.getType().getModuleName());
        
        batchJob.executeJob(timer); //Asynchronous method
    } catch(NamingException ex) {
        logger.error(ex,ex);
    }
}
 
開發者ID:felixhusse,項目名稱:bookery,代碼行數:14,代碼來源:BatchJobService.java

示例15: updateJob

import javax.ejb.Timer; //導入方法依賴的package包/類
public BatchJobConfiguration updateJob(BatchJobConfiguration batchJobConfiguration) {
    Timer timer = getTimer(batchJobConfiguration);
    if (timer != null) {
        BatchJobConfiguration jobConfig = (BatchJobConfiguration)timer.getInfo();
        logger.debug("Canceling Timer " + jobConfig.getType().getDisplayName());
        timer.cancel();
    }
    BatchJobConfiguration result = batchJobConfigurationDAO.update(batchJobConfiguration);
    result = fireUpTimer(result);
    return result;
}
 
開發者ID:felixhusse,項目名稱:bookery,代碼行數:12,代碼來源:BatchJobService.java


注:本文中的javax.ejb.Timer.getInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。