本文整理汇总了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;未经允许,请勿转载。 |
请发表评论