本文整理汇总了Java中org.quartz.spi.OperableTrigger.computeFirstFireTime方法的典型用法代码示例。如果您正苦于以下问题:Java OperableTrigger.computeFirstFireTime方法的具体用法?Java OperableTrigger.computeFirstFireTime怎么用?Java OperableTrigger.computeFirstFireTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.spi.OperableTrigger
的用法示例。
在下文中一共展示了OperableTrigger.computeFirstFireTime方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeFireTimes
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
/**
* Returns a list of Dates that are the next fire times of a
* <code>Trigger</code>.
* The input trigger will be cloned before any work is done, so you need
* not worry about its state being altered by this method.
*
* @param trigg
* The trigger upon which to do the work
* @param cal
* The calendar to apply to the trigger's schedule
* @param numTimes
* The number of next fire times to produce
* @return List of java.util.Date objects
*/
public static List<Date> computeFireTimes(OperableTrigger trigg, org.quartz.Calendar cal,
int numTimes) {
LinkedList<Date> lst = new LinkedList<Date>();
OperableTrigger t = (OperableTrigger) trigg.clone();
if (t.getNextFireTime() == null) {
t.computeFirstFireTime(cal);
}
for (int i = 0; i < numTimes; i++) {
Date d = t.getNextFireTime();
if (d != null) {
lst.add(d);
t.triggered(cal);
} else {
break;
}
}
return java.util.Collections.unmodifiableList(lst);
}
示例2: scheduleJob
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
/**
* <p>
* Schedule the given <code>{@link org.quartz.Trigger}</code> with the
* <code>Job</code> identified by the <code>Trigger</code>'s settings.
* </p>
*
* @throws SchedulerException
* if the indicated Job does not exist, or the Trigger cannot be
* added to the Scheduler, or there is an internal Scheduler
* error.
*/
public Date scheduleJob(Trigger trigger)
throws SchedulerException {
validateState();
if (trigger == null) {
throw new SchedulerException("Trigger cannot be null");
}
OperableTrigger trig = (OperableTrigger)trigger;
trig.validate();
Calendar cal = null;
if (trigger.getCalendarName() != null) {
cal = resources.getJobStore().retrieveCalendar(trigger.getCalendarName());
if(cal == null) {
throw new SchedulerException(
"Calendar not found: " + trigger.getCalendarName());
}
}
Date ft = trig.computeFirstFireTime(cal);
if (ft == null) {
throw new SchedulerException(
"Based on configured schedule, the given trigger '" + trigger.getKey() + "' will never fire.");
}
resources.getJobStore().storeTrigger(trig, false);
notifySchedulerThread(trigger.getNextFireTime().getTime());
notifySchedulerListenersSchduled(trigger);
return ft;
}
示例3: triggerJob
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
/**
* <p>
* Trigger the identified <code>{@link org.quartz.Job}</code> (execute it
* now) - with a non-volatile trigger.
* </p>
*/
@SuppressWarnings("deprecation")
public void triggerJob(JobKey jobKey, JobDataMap data) throws SchedulerException {
validateState();
OperableTrigger trig = (OperableTrigger) newTrigger().withIdentity(newTriggerId(), Scheduler.DEFAULT_GROUP).forJob(jobKey).build();
trig.computeFirstFireTime(null);
if(data != null) {
trig.setJobDataMap(data);
}
boolean collision = true;
while (collision) {
try {
resources.getJobStore().storeTrigger(trig, false);
collision = false;
} catch (ObjectAlreadyExistsException oaee) {
trig.setKey(new TriggerKey(newTriggerId(), Scheduler.DEFAULT_GROUP));
}
}
notifySchedulerThread(trig.getNextFireTime().getTime());
notifySchedulerListenersSchduled(trig);
}
示例4: scheduleRecoveryIfNeeded
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
private void scheduleRecoveryIfNeeded(TriggerWrapper tw, FiredTrigger recovering) {
JobWrapper jobWrapper = jobFacade.get(tw.getJobKey());
if (jobWrapper == null) {
getLog().error("No job found for orphaned trigger: " + tw);
return;
}
if (jobWrapper.requestsRecovery()) {
OperableTrigger recoveryTrigger = createRecoveryTrigger(tw, jobWrapper, "recover_" + terracottaClientId + "_"
+ ftrCtr++, recovering);
JobDataMap jd = tw.getTriggerClone().getJobDataMap();
jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_NAME, tw.getKey().getName());
jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_GROUP, tw.getKey().getGroup());
jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_FIRETIME_IN_MILLISECONDS, String.valueOf(recovering.getFireTime()));
jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_SCHEDULED_FIRETIME_IN_MILLISECONDS, String.valueOf(recovering.getScheduledFireTime()));
recoveryTrigger.setJobDataMap(jd);
recoveryTrigger.computeFirstFireTime(null);
try {
storeTrigger(recoveryTrigger, false);
if (!tw.mayFireAgain()) {
removeTrigger(tw.getKey());
}
getLog().info("Recovered job " + jobWrapper + " for trigger " + tw);
} catch (JobPersistenceException e) {
getLog().error("Can't recover job " + jobWrapper + " for trigger " + tw, e);
}
}
}
示例5: computeFireTimesBetween
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
/**
* Returns a list of Dates that are the next fire times of a
* <code>Trigger</code>
* that fall within the given date range. The input trigger will be cloned
* before any work is done, so you need not worry about its state being
* altered by this method.
*
* <p>
* NOTE: if this is a trigger that has previously fired within the given
* date range, then firings which have already occurred will not be listed
* in the output List.
* </p>
*
* @param trigg
* The trigger upon which to do the work
* @param cal
* The calendar to apply to the trigger's schedule
* @param from
* The starting date at which to find fire times
* @param to
* The ending date at which to stop finding fire times
* @return List of java.util.Date objects
*/
public static List<Date> computeFireTimesBetween(OperableTrigger trigg,
org.quartz.Calendar cal, Date from, Date to) {
LinkedList<Date> lst = new LinkedList<Date>();
OperableTrigger t = (OperableTrigger) trigg.clone();
if (t.getNextFireTime() == null) {
t.setStartTime(from);
t.setEndTime(to);
t.computeFirstFireTime(cal);
}
while (true) {
Date d = t.getNextFireTime();
if (d != null) {
if (d.before(from)) {
t.triggered(cal);
continue;
}
if (d.after(to)) {
break;
}
lst.add(d);
t.triggered(cal);
} else {
break;
}
}
return java.util.Collections.unmodifiableList(lst);
}
示例6: rescheduleJob
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
/**
* <p>
* Remove (delete) the <code>{@link org.quartz.Trigger}</code> with the
* given name, and store the new given one - which must be associated
* with the same job.
* </p>
* @param newTrigger
* The new <code>Trigger</code> to be stored.
*
* @return <code>null</code> if a <code>Trigger</code> with the given
* name & group was not found and removed from the store, otherwise
* the first fire time of the newly scheduled trigger.
*/
public Date rescheduleJob(TriggerKey triggerKey,
Trigger newTrigger) throws SchedulerException {
validateState();
if (triggerKey == null) {
throw new IllegalArgumentException("triggerKey cannot be null");
}
if (newTrigger == null) {
throw new IllegalArgumentException("newTrigger cannot be null");
}
OperableTrigger trig = (OperableTrigger)newTrigger;
Trigger oldTrigger = getTrigger(triggerKey);
if (oldTrigger == null) {
return null;
} else {
trig.setJobKey(oldTrigger.getJobKey());
}
trig.validate();
Calendar cal = null;
if (newTrigger.getCalendarName() != null) {
cal = resources.getJobStore().retrieveCalendar(
newTrigger.getCalendarName());
}
Date ft = trig.computeFirstFireTime(cal);
if (ft == null) {
throw new SchedulerException(
"Based on configured schedule, the given trigger will never fire.");
}
if (resources.getJobStore().replaceTrigger(triggerKey, trig)) {
notifySchedulerThread(newTrigger.getNextFireTime().getTime());
notifySchedulerListenersUnscheduled(triggerKey);
notifySchedulerListenersSchduled(newTrigger);
} else {
return null;
}
return ft;
}
示例7: computeFireTimesWithStart
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
public static Date computeFireTimesWithStart(OperableTrigger trigg,org.quartz.Calendar cal, Date from) {
OperableTrigger t = (OperableTrigger) trigg.clone();
if (t.getNextFireTime() == null) {
t.setStartTime(from);
t.computeFirstFireTime(cal);
}
return t.getNextFireTime();
}