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

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

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

Timer.getNextTimeout介绍

[英]Get the point in time at which the next timer expiration is scheduled to occur.
[中]获取计划下一个计时器过期的时间点。

代码示例

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

private static void addNextTimeout(Timer timer, ModelNode timerNode, final String componentName) {
  try {
    final ModelNode detailNode = timerNode.get(NEXT_TIMEOUT);
    Date d = timer.getNextTimeout();
    if (d != null) {
      detailNode.set(d.getTime());
    }
  } 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.getNextTimeout();
  }
});

代码示例来源:origin: net.sf.tsl2nano/tsl2.nano.serviceaccess

protected Date getNextTimeout(Timer timer) {
  try {
    return timer.getNextTimeout();
  } catch (Exception e) {
    LOG.warn(e.toString());
    return null;
  }
}

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

private static void addNextTimeout(Timer timer, ModelNode timerNode, final String componentName) {
  try {
    final ModelNode detailNode = timerNode.get(NEXT_TIMEOUT);
    Date d = timer.getNextTimeout();
    if (d != null) {
      detailNode.set(d.getTime());
    }
  } catch (IllegalStateException e) {
    // ignore
  } catch (NoSuchObjectLocalException e) {
    // ignore
  } catch (EJBException e) {
    logTimerFailure(componentName, e);
  }
}

代码示例来源:origin: it.rebase/rebot-packt-free-learning-plugin

@Timeout
public void scheduler(Timer timer) {
  populate(true);
  log.fine("Timer executed, next timeout [" + timer.getNextTimeout() + "]");
}

代码示例来源:origin: ivargrimstad/snoop

@Timeout
public void health(Timer timer) {
  LOGGER.config(() -> "health update: " + Calendar.getInstance().getTime());
  LOGGER.config(() -> "Next: " + timer.getNextTimeout());
  sendMessage(STATUS_ENDPOINT + applicationConfig.getServiceName(), applicationConfig.toJSON());
}

代码示例来源:origin: net.sf.tsl2nano/tsl2.nano.serviceaccess

/**
 * constructor
 * 
 * @param timerHandle handle belonging to the created ejb-timer
 * @param callbacks runnables to be executed on timer-timeout
 * @param creator creator of this job
 * @param stopOnError if true, the job will stop on any error
 * @param stopOnConcurrent if true, the job is not startable, if another job is running
 */
public Job(String name,
    TimerHandle timerHandle,
    Collection<RUNNABLE> callbacks,
    Serializable context,
    Object creator,
    boolean stopOnError,
    boolean stopOnConcurrent) {
  super();
  this.name = name;
  this.timerHandle = timerHandle;
  if (timerHandle != null) {
    nextStart = timerHandle.getTimer().getNextTimeout();
  }
  this.callbacks = callbacks;
  this.context = context;
  this.stopOnError = stopOnError;
  this.stopOnConcurrent = stopOnConcurrent;
  this.creator = creator;
  this.createdAt = System.currentTimeMillis();
}

代码示例来源:origin: eu.agilejava/snoop

@Timeout
public void health(Timer timer) {
  LOGGER.config(() -> "health update: " + Calendar.getInstance().getTime());
  LOGGER.config(() -> "Next: " + timer.getNextTimeout());
  sendMessage(STATUS_ENDPOINT + applicationConfig.getServiceName(), applicationConfig.toJSON());
}

代码示例来源:origin: net.sf.tsl2nano/tsl2.nano.serviceaccess

/**
 * called by framework
 * 
 * @param ex (optional) exception if failed, othewise null
 */
public void setAsStopped(Exception ex) {
  stoppedAt = System.currentTimeMillis();
  try {
    nextStart = timerHandle.getTimer().getNextTimeout();
  } catch (Exception ex1) {
    // --> timer expired
    nextStart = null;
  }
  LOG.info("stopping job " + toString() + " with " + callbacks.size()
    + " processes. started at: "
    + DateFormat.getDateInstance().format(new Date(startedAt))
    + " duration: "
    + DateFormat.getTimeInstance().format(new Date(stoppedAt - startedAt))
    + "\n   next start: "
    + (nextStart == null ? "expired!" : DateFormat.getDateInstance().format(nextStart))
    + (ex != null ? "\n   error: " + ex : ""));
    setLastException(ex);
}

代码示例来源:origin: net.sf.tsl2nano/tsl2.nano.serviceaccess

/**
 * unused yet...
 * @param time time for next timeout
 * @param interval period before and after 'time' to be valid for job 
 * @return first job that has a next timeout at time +- interval
 */
public Job<RUNNABLE> getJobAt(Date time, long interval) {
  for (Job<RUNNABLE> job : getCurrentJobs()) {
      Date nextTimeout = job.getTimerHandle().getTimer().getNextTimeout();
      long differenceInMS = time.getTime() - nextTimeout.getTime();
      // time between jobs is less than configured interval
      if (differenceInMS > -interval && differenceInMS < interval) {
        LOG.debug("found job for time" + time + ": " + job);
        return job;
      }
    }
  return null;
}

代码示例来源:origin: be.fedict.eid-dss/eid-dss-model

/**
 * {@inheritDoc}
 */
@Timeout
public void timeOut(Timer timer) {
  String timerInfo = (String) timer.getInfo();
  LOG.debug("timeout: " + timerInfo);
  if (null == timerInfo) {
    LOG.error("no timer info ?? cancel timer");
    timer.cancel();
    return;
  }
  if (timerInfo.equals(TIMER_ID)) {
    cleanup();
    LOG.debug("Next cleanup: " + timer.getNextTimeout());
  }
}

代码示例来源:origin: net.sf.tsl2nano/tsl2.nano.serviceaccess

/**
 * called by framework
 * 
 * @param timerHandle the timers handle
 */
public TimerHandle setTimerHandle(Timer timer) {
  assert this.timerHandle == null : "timer should only be set once!";
  this.timerHandle = timer.getHandle();
  nextStart = timer.getNextTimeout();
  LOG.info("creating timer ==> nextstart: " + nextStart
    + ", handle: "
    + timer.getHandle()
    + ", unique-name: "
    + getUniqueName());
  return timerHandle;
}

代码示例来源:origin: be.fedict.eid-trust-service/eid-trust-service-model

/**
 * {@inheritDoc}
 */
public void startTimerNow(TrustPointEntity trustPoint) {
  TimerConfig timerConfig = new TimerConfig();
  timerConfig.setInfo(trustPoint.getName());
  timerConfig.setPersistent(false);
  Timer timer = this.timerService.createSingleActionTimer(1000 * 10,
      timerConfig);
  LOG.debug("created single action timer for trustpoint "
      + trustPoint.getName() + " at "
      + timer.getNextTimeout().toString());
}

代码示例来源:origin: be.fedict.eid-dss/eid-dss-model

/**
 * {@inheritDoc}
 */
public void startTimer(String cronSchedule)
    throws InvalidCronExpressionException {
  LOG.debug("start document service's cleanup task timer");
  if (null == cronSchedule || cronSchedule.isEmpty()) {
    // TODO: error message sufficient? or explode here?...
    LOG.error("No interval set for document service cleanup task!");
    return;
  }
  // remove old timers
  cancelTimers();
  TimerConfig timerConfig = new TimerConfig();
  timerConfig.setInfo(TIMER_ID);
  timerConfig.setPersistent(true);
  ScheduleExpression schedule = getScheduleExpression(cronSchedule);
  Timer timer;
  try {
    timer = this.timerService
        .createCalendarTimer(schedule, timerConfig);
  } catch (Exception e) {
    LOG.error("Exception while creating timer for document service "
        + "cleanup task: " + e.getMessage(), e);
    throw new InvalidCronExpressionException(e);
  }
  LOG.debug("created timer for document service cleanup task: next="
      + timer.getNextTimeout().toString());
}

代码示例来源:origin: be.fedict.eid-trust-service/eid-trust-service-model

+ timer.getNextTimeout().toString());
clockDriftConfig.setFireDate(timer.getNextTimeout());

代码示例来源:origin: org.lorislab.armonitor/armonitor-ejb

/**
 * Start the timer.
 */
public void start() {
  Timer timer = getTimer();
  if (timer == null) {
    TimerConfig config = configService.getConfiguration(TimerConfig.class);
    if (config.start) {
      ScheduleExpression expression = new ScheduleExpression();
      expression.second(config.second).minute(config.minute).hour(config.hour);
      javax.ejb.TimerConfig timerConfig = new javax.ejb.TimerConfig(TIMER_INFO, false);
      Timer tmp = timerService.createCalendarTimer(expression, timerConfig);
      LOGGER.log(Level.INFO, "The timer service was started with next timeout: {0}", tmp.getNextTimeout());
    } else {
      LOGGER.log(Level.INFO, "The timer {0} is not started.", TIMER_INFO);
    }
  } else {
    LOGGER.log(Level.INFO, "The timer {0} is all ready running.", TIMER_INFO);
  }
}

代码示例来源:origin: be.fedict.eid-trust-service/eid-trust-service-model

+ " at " + timer.getNextTimeout().toString());
trustPoint.setFireDate(timer.getNextTimeout());

代码示例来源: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: com.evasion/Plugin-GeoLoc

new ScheduleExpression().month(month).dayOfMonth(day).hour(hour).minute(min),
      new TimerConfig(Constante.IMPORT_TIMER_NAME, false));
  LOGGER.info("Last geoloc import: {}", timer.getNextTimeout());
} catch (IllegalArgumentException ex) {
  LOGGER.error("Illegal argument exception on " + Constante.IMPORT_TIMER_INTERVAL + " parameter", ex);

相关文章