当前位置: 首页>>代码示例>>Java>>正文


Java TimerService.createTimer方法代码示例

本文整理汇总了Java中javax.ejb.TimerService.createTimer方法的典型用法代码示例。如果您正苦于以下问题:Java TimerService.createTimer方法的具体用法?Java TimerService.createTimer怎么用?Java TimerService.createTimer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ejb.TimerService的用法示例。


在下文中一共展示了TimerService.createTimer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fireInThirtySeconds

import javax.ejb.TimerService; //导入方法依赖的package包/类
@Override
public void fireInThirtySeconds() throws EJBException {

	TimerService theTimerService = theEJBContext.getTimerService();
	String aLabel = "30SecondTimeout";
	Timer theTimer = theTimerService.createTimer(300, aLabel);
	logger.info("timer is: " + theTimer);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:9,代码来源:OldSpecsBean.java

示例2: createCronJob

import javax.ejb.TimerService; //导入方法依赖的package包/类
public void createCronJob() {
	
	Long intervall = 10 * 1000L;

	String value;
	try {
		value = configService
				.getValue(LocationSanityBusiness.class, contextService.getCallersUser()
						.getClient(), LocationSanityBusiness.TIME_OUT_KEY);
		if (value != null) {
			try {
				intervall = Long.parseLong(value);
			} catch (NumberFormatException ex) {
				log.warn(ex.getMessage());
				intervall = 10 * 1000L;
			}
		}
	} catch (EntityNotFoundException e) {
		log.error(e.getMessage(), e);
	}

	if (getTimer() != null){
		cancelCronJob();
	}
	TimerService timerService = ctx.getTimerService();
    timerService.createTimer(new Date(System.currentTimeMillis() + intervall), intervall,
    		LocationSanityBusiness.TIME_OUT_INFO);

}
 
开发者ID:salimvanak,项目名称:myWMS,代码行数:30,代码来源:LocationSanityBusinessBean.java

示例3: createTimerWithInterval

import javax.ejb.TimerService; //导入方法依赖的package包/类
private void createTimerWithInterval(TimerService timerService,
        TimerType timerType, long timerInterval, long timerOffset)
        throws ValidationException {
    // FIXME: this is quick fix for bug 11241. To avoid generate the
    // same constraint of timer, set timerInterval to
    // TIMER_HANDLING_DISTANCE if the timerInterval is smaller than
    // TIMER_HANDLING_DISTANCE.
    if (timerInterval <= TIMER_HANDLING_DISTANCE) {
        timerInterval = TIMER_HANDLING_DISTANCE;
    }

    Date nextStart = getDateForNextTimerExpiration(timerInterval,
            timerOffset);
    ValidationException validationException;
    String[] params;
    if (nextStart.getTime() < 0) {
        if (timerType.name().equals(TimerType.USER_NUM_CHECK.name())) {
            params = new String[] { timerType.name(),
                    timerType.getKeyForIntervalTime().name() };
            validationException = new ValidationException(
                    ValidationException.ReasonEnum.TIMER_USERCOUNT_EXPIRATIONDATE_INVALID,
                    null, params);
            logger.logError(
                    Log4jLogger.SYSTEM_LOG,
                    validationException,
                    LogMessageIdentifier.ERROR_TIMER_USERCOUNT_EXPIRATIONDATE_INVALID,
                    params);
        } else {
            params = new String[] { timerType.name(),
                    timerType.getKeyForIntervalTime().name(),
                    timerType.getKeyForIntervalOffset().name() };
            validationException = new ValidationException(
                    ValidationException.ReasonEnum.TIMER_EXPIRATIONDATE_INVALID,
                    null, params);
            logger.logError(
                    Log4jLogger.SYSTEM_LOG,
                    validationException,
                    LogMessageIdentifier.ERROR_TIMER_EXPIRATIONDATE_INVALID,
                    params);
        }
        throw validationException;
    }

    cancelObsoleteTimer(timerService, timerType);

    timerService.createTimer(nextStart, timerInterval, timerType);

    SimpleDateFormat sdf = new SimpleDateFormat();
    logger.logInfo(Log4jLogger.SYSTEM_LOG,
            LogMessageIdentifier.INFO_TIMER_CREATED_WITH_INTERVAL,
            timerType.toString(), sdf.format(nextStart),
            Long.toString(timerInterval));
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:54,代码来源:TimerServiceBean.java


注:本文中的javax.ejb.TimerService.createTimer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。