javax.ejb.Timer.getTimeRemaining()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中javax.ejb.Timer.getTimeRemaining()方法的一些代码示例,展示了Timer.getTimeRemaining()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timer.getTimeRemaining()方法的具体详情如下:
包路径:javax.ejb.Timer
类名称:Timer
方法名:getTimeRemaining

Timer.getTimeRemaining介绍

[英]Get the number of milliseconds that will elapse before the next scheduled timer expiration.
[中]获取下一个计划的计时器过期之前将经过的毫秒数。

代码示例

代码示例来源:origin: wildfly/wildfly

private static void addTimeRemaining(Timer timer, ModelNode timerNode, final String componentName) {
  try {
    final ModelNode detailNode = timerNode.get(TIME_REMAINING);
    long time = timer.getTimeRemaining();
    detailNode.set(time);
  } catch (IllegalStateException e) {
    // ignore
  } catch (NoSuchObjectLocalException e) {
    // ignore
  } catch (EJBException e) {
    logTimerFailure(componentName, e);
  }
}

代码示例来源:origin: org.jboss.seam/jboss-seam

public Object call() 
  {
    return timer.getTimeRemaining();
  }
});

代码示例来源:origin: org.jboss.as/jboss-as-ejb3

private static void addTimeRemaining(Timer timer, ModelNode timerNode, final String componentName) {
  try {
    final ModelNode detailNode = timerNode.get(TIME_REMAINING);
    long time = timer.getTimeRemaining();
    detailNode.set(time);
  } catch (IllegalStateException e) {
    // ignore
  } catch (NoSuchObjectLocalException e) {
    // ignore
  } catch (EJBException e) {
    logTimerFailure(componentName, e);
  }
}

代码示例来源:origin: imixs/imixs-workflow

/**
 * Updates the timer details of a running timer service. The method updates the
 * properties netxtTimeout and timeRemaining and store them into the timer
 * configuration.
 * 
 * @param configuration - the current scheduler configuration to be updated.
 */
public void updateTimerDetails(ItemCollection configuration) {
  if (configuration == null)
    return;// configuration;
  String id = configuration.getUniqueID();
  Timer timer;
  try {
    timer = this.findTimer(id);
    if (timer != null) {
      // load current timer details
      configuration.replaceItemValue("nextTimeout", timer.getNextTimeout());
      configuration.replaceItemValue("timeRemaining", timer.getTimeRemaining());
    } else {
      configuration.removeItem("nextTimeout");
      configuration.removeItem("timeRemaining");
    }
  } catch (Exception e) {
    logger.warning("unable to updateTimerDetails: " + e.getMessage());
    configuration.removeItem("nextTimeout");
    configuration.removeItem("timeRemaining");
  }
}

代码示例来源:origin: imixs/imixs-workflow

/**
 * Update the timer details of a running timer service. The method updates the
 * properties netxtTimeout and timeRemaining and store them into the timer
 * configuration.
 * 
 * @param configuration
 */
private ItemCollection updateTimerDetails(ItemCollection configuration) {
  if (configuration == null)
    return configuration;
  String id = configuration.getUniqueID();
  Timer timer;
  try {
    timer = this.findTimer(id);
    if (timer != null) {
      // load current timer details
      configuration.replaceItemValue("nextTimeout", timer.getNextTimeout());
      configuration.replaceItemValue("timeRemaining", timer.getTimeRemaining());
    } else {
      configuration.removeItem("nextTimeout");
      configuration.removeItem("timeRemaining");
    }
  } catch (Exception e) {
    logger.warning("unable to updateTimerDetails: " + e.getMessage());
    configuration.removeItem("nextTimeout");
    configuration.removeItem("timeRemaining");
  }
  return configuration;
}

代码示例来源:origin: org.objectweb.jonas/jonas-ejb-2.1

/**
 * {@inheritDoc}
 */
public Timer restartTimer(JTimerHandleInfo info) {
  // get the Bean TimerService
  JTimerService timerservice = getJTimerService(info);
  // Recreate a Timer with recomputed initial duration.
  long newDuration = info.getDuration() + info.getStartTime() - System.currentTimeMillis();
  if (newDuration < 100) {
    newDuration = 100;
  }
  // assign new value.
  info.setDuration(newDuration);
  Timer timer = timerservice.createTimer(info.getDuration(),
                      info.getPeriod(),
                      info.getInfo());
  if (timer.getTimeRemaining() > 0) {
    TraceTimer.logger.log(BasicLevel.DEBUG, "timer restarted");
  } else {
    TraceTimer.logger.log(BasicLevel.DEBUG, "timer terminated");
    timer.cancel();
  }
  return timer;
}

相关文章