org.quartz.Trigger.setStartTime()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(210)

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

Trigger.setStartTime介绍

[英]The time at which the trigger's scheduling should start. May or may not be the first actual fire time of the trigger, depending upon the type of trigger and the settings of the other properties of the trigger. However the first actual first time will not be before this date.

Setting a value in the past may cause a new trigger to compute a first fire time that is in the past, which may cause an immediate misfire of the trigger.
[中]触发器计划应开始的时间。可能是也可能不是触发器的第一次实际触发时间,具体取决于触发器的类型和触发器其他属性的设置。然而,第一次实际的第一次将不会在此日期之前。
设置过去的值可能会导致新触发器计算过去的首次点火时间,这可能会导致触发器立即失火。

代码示例

代码示例来源:origin: com.opensymphony.quartz/com.springsource.org.quartz

public void addTrigger(Trigger trigger) {
  if (trigger.getStartTime() == null) {
    trigger.setStartTime(new Date());
  }
  
  triggers.add(trigger);
}

代码示例来源:origin: quartz/quartz-all

public void addTrigger(Trigger trigger) {
  if (trigger.getStartTime() == null) {
    trigger.setStartTime(new Date());
  }
  
  triggers.add(trigger);
}

代码示例来源:origin: org.kuali.kfs/kfs-core

/**
 * @see org.kuali.kfs.sys.batch.TriggerDescriptor#completeTriggerDescription(org.quartz.Trigger)
 */
protected void completeTriggerDescription(Trigger trigger) {
  if (startTime == null) {
    startTime = trigger.getStartTime();
  }
  // prevent setting of the trigger information in test mode
  if (!isTestMode()) {
    trigger.setStartTime(new Date(startTime.getTime() + startDelay));
    ((SimpleTrigger) trigger).setRepeatCount(repeatCount);
  }
  else {
    trigger.setStartTime(new Date(new Date().getTime() + 525600000L));
  }
}

代码示例来源:origin: approvals/ApprovalTests.Java

/***********************************************************************/
 public static Trigger createTrigger(Trigger trigger, String name, String defaultGroup)
 {
  trigger.setName(name);
  trigger.setGroup(defaultGroup);
  trigger.setStartTime(new Date());
  trigger.setEndTime(new Date(Long.MAX_VALUE));
  return trigger;
 }
}

代码示例来源:origin: org.kuali.kfs/kfs-core

public Trigger getTrigger() {
  Trigger trigger = null;
  if (getClass().equals(SimpleTriggerDescriptor.class)) {
    trigger = new SimpleTrigger(name, group);
  }
  else {
    trigger = new CronTrigger(name, group);
  }
  trigger.setJobName(jobName);
  trigger.setJobGroup(group);
  trigger.setStartTime(dateTimeService.getCurrentDate());
  completeTriggerDescription(trigger);
  return trigger;
}

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

/**
 * Set the schedule and start or restart the scheduler.
 */
public void schedule() {
 if (quartz == null || schedulerPeriod <= 0) {
  logger.debug("Cancel scheduling of workspace cleaner due to invalid scheduling period");
  return;
 }
 logger.debug("Scheduling workspace cleaner to run every {} seconds.", schedulerPeriod);
 try {
  final Trigger trigger = TriggerUtils.makeSecondlyTrigger(schedulerPeriod);
  trigger.setStartTime(new Date());
  trigger.setName(TRIGGER_NAME);
  trigger.setGroup(TRIGGER_GROUP);
  trigger.setJobName(JOB_NAME);
  trigger.setJobGroup(JOB_GROUP);
  if (quartz.getTriggersOfJob(JOB_NAME, JOB_GROUP).length == 0) {
   quartz.scheduleJob(trigger);
  } else {
   quartz.rescheduleJob(TRIGGER_NAME, TRIGGER_GROUP, trigger);
  }
 } catch (Exception e) {
  logger.error("Error scheduling Quartz job", e);
 }
}

代码示例来源:origin: org.terracotta.modules/tim-tree-map-cache

public static void start() throws SchedulerException {
  if (_enabled) {
    _sched.start();
    JobDetail jobDetail = null;
    try {
      jobDetail = new JobDetail("SimpleEvictorJob",
                         null,
                         Class.forName(_evictorClass));
    } catch (ClassNotFoundException e) {
      jobDetail = new JobDetail("SimpleEvictorJob",
                         null,
                         SimpleTTLEvictor.class);
    }
    Trigger trigger;
    try {
      trigger = new CronTrigger("TCEvictionTrigger","TCEvictionGroup",_evictorIntervalTrigger);
    } catch (ParseException e) {
      _LOGGER.info("Could not parse evictor interval trigger expression '"+_evictorIntervalTrigger+"'");
      _LOGGER.info("Falling back on default behavior: Evictor will run every hour");
      trigger = TriggerUtils.makeHourlyTrigger();
      trigger.setName("TCEvictionTrigger");
      trigger.setGroup("TCEvictionGroup");
    }
    trigger.setStartTime(new Date());  // start right now
    trigger.setJobName(jobDetail.getName());
    _sched.scheduleJob(jobDetail, trigger);
    System.out.println("");
  }
}

代码示例来源:origin: org.fusesource.insight/insight-graph

private void scheduleJob(Server server) throws SchedulerException, ParseException {
  Scheduler scheduler = getScheduler();
  String name = server.getHost() + ":" + server.getPort() + "-" + System.currentTimeMillis();
  JobDetail jd = new JobDetail(name, "ServerJob", ServerJob.class);
  JobDataMap map = new JobDataMap();
  map.put(Server.class.getName(), server);
  map.put(Server.JMX_CONNECTION_FACTORY_POOL, this.getObjectPoolMap().get(Server.JMX_CONNECTION_FACTORY_POOL));
  jd.setJobDataMap(map);
  Trigger trigger = null;
  if ((server.getCronExpression() != null) && CronExpression.isValidExpression(server.getCronExpression())) {
    trigger = new CronTrigger();
    ((CronTrigger) trigger).setCronExpression(server.getCronExpression());
    ((CronTrigger) trigger).setName(server.getHost() + ":" + server.getPort() + "-" + Long.valueOf(System.currentTimeMillis()).toString());
    ((CronTrigger) trigger).setStartTime(new Date());
  } else {
    Trigger minuteTrigger = TriggerUtils.makeSecondlyTrigger(SECONDS_BETWEEN_SERVER_JOB_RUNS);
    minuteTrigger.setName(server.getHost() + ":" + server.getPort() + "-" + Long.valueOf(System.currentTimeMillis()).toString());
    minuteTrigger.setStartTime(new Date());
    trigger = minuteTrigger;
  }
  scheduler.scheduleJob(jd, trigger);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Scheduled job: " + jd.getName() + " for server: " + server);
  }
}

代码示例来源:origin: com.opensymphony.quartz/com.springsource.org.quartz

t.setStartTime(from);
t.setEndTime(to);
t.computeFirstFireTime(cal);

代码示例来源:origin: quartz/quartz-all

t.setStartTime(from);
t.setEndTime(to);
t.computeFirstFireTime(cal);

代码示例来源:origin: org.ikasan/ikasan-framework

recoveryTrigger.setJobGroup(getJobGroup());          
recoveryTrigger.setStartTime(new Date(System.currentTimeMillis() + delay));

代码示例来源:origin: tzolov/geode-dashboard

private void scheduleJob(Server server) throws ParseException, SchedulerException {
  String name = server.getHost() + ":" + server.getPort() + "-" + System.currentTimeMillis() + "-" + RandomStringUtils.randomNumeric(10);
  JobDetail jd = new JobDetail(name, "ServerJob", ServerJob.class);
  JobDataMap map = new JobDataMap();
  map.put(Server.class.getName(), server);
  jd.setJobDataMap(map);
  Trigger trigger;
  if ((server.getCronExpression() != null) && CronExpression.isValidExpression(server.getCronExpression())) {
    trigger = new CronTrigger();
    ((CronTrigger) trigger).setCronExpression(server.getCronExpression());
    trigger.setName(server.getHost() + ":" + server.getPort() + "-" + Long.toString(System.currentTimeMillis()));
    trigger.setStartTime(computeSpreadStartDate(configuration.getRunPeriod()));
  }
  else {
    int runPeriod = configuration.getRunPeriod();
    if (server.getRunPeriodSeconds() != null) runPeriod = server.getRunPeriodSeconds();
    Trigger minuteTrigger = TriggerUtils.makeSecondlyTrigger(runPeriod);
    minuteTrigger.setName(server.getHost() + ":" + server.getPort() + "-" + Long.toString(System.currentTimeMillis()));
    minuteTrigger.setStartTime(computeSpreadStartDate(runPeriod));
    trigger = minuteTrigger;
    // TODO replace Quartz with a ScheduledExecutorService
  }
  serverScheduler.scheduleJob(jd, trigger);
  if (log.isDebugEnabled()) {
    log.debug("Scheduled job: " + jd.getName() + " for server: " + server);
  }
}

代码示例来源:origin: deas/alfresco

/**
 * Build the cron trigger
 * 
 * @return The trigger
 * @throws Exception
 */
public Trigger getTrigger() throws Exception
{
  Trigger trigger = new CronTrigger(getBeanName(), Scheduler.DEFAULT_GROUP, getCronExpression());
  if (this.startDelay > 0)
  {
    trigger.setStartTime(new Date(System.currentTimeMillis() + this.startDelay));
  }
  JobDetail jd = super.getJobDetail();
  if (jd != null)
  {
    String jobName = super.getJobDetail().getKey().getName();
    if (jobName != null && !jobName.isEmpty())
    {
      trigger.setJobName(jobName);
    }
    String jobGroup = super.getJobDetail().getKey().getGroup();
    if (jobGroup != null && !jobGroup.isEmpty())
    {
      trigger.setJobGroup(jobGroup);
    }
  }
  return trigger;
}

代码示例来源:origin: org.apache.camel/camel-quartz

long interval = EndpointHelper.resolveParameter(getCamelContext(), intervalString, Long.class);
trigger.setStartTime(new Date(System.currentTimeMillis() - interval));

代码示例来源:origin: org.apache.camel/camel-quartz

public void addTrigger(final Trigger trigger, final JobDetail detail) throws SchedulerException {
  // lets default the trigger name to the job name
  if (trigger.getName() == null) {
    trigger.setName(detail.getName());
  }
  // lets default the trigger group to the job group
  if (trigger.getGroup() == null) {
    trigger.setGroup(detail.getGroup());
  }
  // default start time to now if not specified
  if (trigger.getStartTime() == null) {
    trigger.setStartTime(new Date());
  }
  detail.getJobDataMap().put(QuartzConstants.QUARTZ_ENDPOINT_URI, getEndpointUri());
  if (isUsingFixedCamelContextName()) {
    detail.getJobDataMap().put(QuartzConstants.QUARTZ_CAMEL_CONTEXT_NAME, getCamelContext().getName());
  } else {
    // must use management name as it should be unique in the same JVM
    detail.getJobDataMap().put(QuartzConstants.QUARTZ_CAMEL_CONTEXT_NAME, QuartzHelper.getQuartzContextName(getCamelContext()));
  }
  if (detail.getJobClass() == null) {
    detail.setJobClass(isStateful() ? StatefulCamelJob.class : CamelJob.class);
  }
  if (detail.getName() == null) {
    detail.setName(getJobName());
  }
  getComponent().addJob(detail, trigger);
}

代码示例来源:origin: org.apache.camel/camel-quartz

LOG.debug("Trigger: {}/{} already exists and will be updated by Quartz.", trigger.getGroup(), trigger.getName());
trigger.setStartTime(new Date());
  LOG.debug("Trigger: {}/{} already exists and will be resumed by Quartz.", trigger.getGroup(), trigger.getName());
  trigger.setStartTime(new Date());

代码示例来源:origin: org.jmxtrans/jmxtrans-core

private Trigger createTrigger(Server server) throws ParseException {
  int runPeriod = configuration.getRunPeriod();
  Trigger trigger;
  if (server.getCronExpression() != null && CronExpression.isValidExpression(server.getCronExpression())) {
    CronTrigger cTrigger = new CronTrigger();
    cTrigger.setCronExpression(server.getCronExpression());
    trigger = cTrigger;
  } else {
    if (server.getRunPeriodSeconds() != null) {
      runPeriod = server.getRunPeriodSeconds();
    }
    trigger = TriggerUtils.makeSecondlyTrigger(runPeriod);
    // TODO replace Quartz with a ScheduledExecutorService
  }
  trigger.setName(server.getHost() + ":" + server.getPort() + "-" + Long.toString(System.nanoTime()));
  trigger.setStartTime(computeSpreadStartDate(runPeriod));
  return trigger;
}

代码示例来源:origin: com.opensymphony.quartz/com.springsource.org.quartz

trigger.setStartTime(new Date());

代码示例来源:origin: quartz/quartz-all

trigger.setStartTime(new Date());

相关文章