• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Timer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中commonj.timers.Timer的典型用法代码示例。如果您正苦于以下问题:Java Timer类的具体用法?Java Timer怎么用?Java Timer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: afterPropertiesSet

import commonj.timers.Timer; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws NamingException {
	super.afterPropertiesSet();
	if (this.scheduledTimerListeners != null) {
		TimerManager timerManager = getTimerManager();
		for (ScheduledTimerListener scheduledTask : this.scheduledTimerListeners) {
			Timer timer;
			if (scheduledTask.isOneTimeTask()) {
				timer = timerManager.schedule(scheduledTask.getTimerListener(), scheduledTask.getDelay());
			}
			else {
				if (scheduledTask.isFixedRate()) {
					timer = timerManager.scheduleAtFixedRate(
							scheduledTask.getTimerListener(), scheduledTask.getDelay(), scheduledTask.getPeriod());
				}
				else {
					timer = timerManager.schedule(
							scheduledTask.getTimerListener(), scheduledTask.getDelay(), scheduledTask.getPeriod());
				}
			}
			this.timers.add(timer);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:TimerManagerFactoryBean.java


示例2: destroy

import commonj.timers.Timer; //导入依赖的package包/类
/**
 * Cancels all statically registered Timers on shutdown,
 * and stops the underlying TimerManager (if not shared).
 * @see commonj.timers.Timer#cancel()
 * @see commonj.timers.TimerManager#stop()
 */
@Override
public void destroy() {
	// Cancel all registered timers.
	for (Timer timer : this.timers) {
		try {
			timer.cancel();
		}
		catch (Throwable ex) {
			logger.warn("Could not cancel CommonJ Timer", ex);
		}
	}
	this.timers.clear();

	// Stop the TimerManager itself.
	super.destroy();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:TimerManagerFactoryBean.java


示例3: afterPropertiesSet

import commonj.timers.Timer; //导入依赖的package包/类
public void afterPropertiesSet() throws NamingException {
	super.afterPropertiesSet();
	if (this.scheduledTimerListeners != null) {
		TimerManager timerManager = getTimerManager();
		for (ScheduledTimerListener scheduledTask : this.scheduledTimerListeners) {
			Timer timer;
			if (scheduledTask.isOneTimeTask()) {
				timer = timerManager.schedule(scheduledTask.getTimerListener(), scheduledTask.getDelay());
			}
			else {
				if (scheduledTask.isFixedRate()) {
					timer = timerManager.scheduleAtFixedRate(
							scheduledTask.getTimerListener(), scheduledTask.getDelay(), scheduledTask.getPeriod());
				}
				else {
					timer = timerManager.schedule(
							scheduledTask.getTimerListener(), scheduledTask.getDelay(), scheduledTask.getPeriod());
				}
			}
			this.timers.add(timer);
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:TimerManagerFactoryBean.java


示例4: schedule

import commonj.timers.Timer; //导入依赖的package包/类
@Override
public ScheduledFuture<?> schedule(Runnable task, Date startTime) {
	TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, false));
	Timer timer = getTimerManager().schedule(futureTask, startTime);
	futureTask.setTimer(timer);
	return futureTask;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:TimerManagerTaskScheduler.java


示例5: scheduleAtFixedRate

import commonj.timers.Timer; //导入依赖的package包/类
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, Date startTime, long period) {
	TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true));
	Timer timer = getTimerManager().scheduleAtFixedRate(futureTask, startTime, period);
	futureTask.setTimer(timer);
	return futureTask;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:TimerManagerTaskScheduler.java


示例6: scheduleWithFixedDelay

import commonj.timers.Timer; //导入依赖的package包/类
@Override
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, Date startTime, long delay) {
	TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true));
	Timer timer = getTimerManager().schedule(futureTask, startTime, delay);
	futureTask.setTimer(timer);
	return futureTask;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:TimerManagerTaskScheduler.java


示例7: timerExpired

import commonj.timers.Timer; //导入依赖的package包/类
@Override
public void timerExpired(Timer timer) {
	Date actualExecutionTime = new Date();
	super.timerExpired(timer);
	Date completionTime = new Date();
	this.triggerContext.update(this.scheduledExecutionTime, actualExecutionTime, completionTime);
	if (!this.cancelled) {
		schedule();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:TimerManagerTaskScheduler.java


示例8: timerExpired

import commonj.timers.Timer; //导入依赖的package包/类
public void timerExpired(Timer timer) {
  System.out.println("timer expired called on " + timer);
  // some useful work here ...
  // let's just cancel the timer
  System.out.println("cancelling timer ...");
  timer.cancel();
}
 
开发者ID:windup,项目名称:windup-rulesets,代码行数:8,代码来源:TimerServlet.java


示例9: schedule

import commonj.timers.Timer; //导入依赖的package包/类
public synchronized Timer schedule(TimerListener listener, Date when) throws IllegalArgumentException,
    IllegalStateException {

    DefaultTimerTask task = new DefaultTimerTask(timerCount++, listener);
    timers.put(timerCount, task);

    // schedule to fire
    timer.schedule(task, when);

    return task;
}
 
开发者ID:OSEHRA-Sandbox,项目名称:MOCHA,代码行数:12,代码来源:TimerFactory.java


示例10: timerExpired

import commonj.timers.Timer; //导入依赖的package包/类
/**
 * Invoked when the time has elapsed.
 * 
 * @param timer timer reference
 * 
 * @see commonj.timers.TimerListener#timerExpired(commonj.timers.Timer)
 */
public void timerExpired(Timer timer) {
    LOG.debug(name + " fired on " + DateTimeUtility.toString(getScheduledTime()));

    try {
        updater.execute();
    }
    catch (Throwable t) {
        LOG.error("Error encountered during scheduled FDB-DIF update process", t);
    }

    scheduleNextTimer(); // schedule next timer event
}
 
开发者ID:OSEHRA-Sandbox,项目名称:MOCHA,代码行数:20,代码来源:DifUpdateScheduler.java


示例11: timerExpired

import commonj.timers.Timer; //导入依赖的package包/类
/**
 * Delegates execution to the underlying Runnable.
 */
@Override
public void timerExpired(Timer timer) {
	this.runnable.run();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:DelegatingTimerListener.java


示例12: setTimer

import commonj.timers.Timer; //导入依赖的package包/类
public void setTimer(Timer timer) {
	this.timer = timer;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:TimerManagerTaskScheduler.java


示例13: timerExpired

import commonj.timers.Timer; //导入依赖的package包/类
/**
 * Delegates execution to the underlying Runnable.
 */
public void timerExpired(Timer timer) {
	this.runnable.run();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:7,代码来源:DelegatingTimerListener.java


示例14: schedule

import commonj.timers.Timer; //导入依赖的package包/类
public ScheduledFuture schedule(Runnable task, Date startTime) {
	TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, false));
	Timer timer = getTimerManager().schedule(futureTask, startTime);
	futureTask.setTimer(timer);
	return futureTask;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:7,代码来源:TimerManagerTaskScheduler.java


示例15: scheduleAtFixedRate

import commonj.timers.Timer; //导入依赖的package包/类
public ScheduledFuture scheduleAtFixedRate(Runnable task, Date startTime, long period) {
	TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true));
	Timer timer = getTimerManager().scheduleAtFixedRate(futureTask, startTime, period);
	futureTask.setTimer(timer);
	return futureTask;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:7,代码来源:TimerManagerTaskScheduler.java


示例16: scheduleWithFixedDelay

import commonj.timers.Timer; //导入依赖的package包/类
public ScheduledFuture scheduleWithFixedDelay(Runnable task, Date startTime, long delay) {
	TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true));
	Timer timer = getTimerManager().schedule(futureTask, startTime, delay);
	futureTask.setTimer(timer);
	return futureTask;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:7,代码来源:TimerManagerTaskScheduler.java


示例17: scheduleAtFixedRate

import commonj.timers.Timer; //导入依赖的package包/类
public synchronized Timer scheduleAtFixedRate(TimerListener arg0, Date arg1, long arg2)
    throws IllegalArgumentException, IllegalStateException {
    throw new UnsupportedOperationException();
}
 
开发者ID:OSEHRA-Sandbox,项目名称:MOCHA,代码行数:5,代码来源:TimerFactory.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ResourceManager类代码示例发布时间:2022-05-22
下一篇:
Java OMOutputFormat类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap