本文整理汇总了Java中org.quartz.SimpleTrigger类的典型用法代码示例。如果您正苦于以下问题:Java SimpleTrigger类的具体用法?Java SimpleTrigger怎么用?Java SimpleTrigger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleTrigger类属于org.quartz包,在下文中一共展示了SimpleTrigger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeIntervalTrigger
import org.quartz.SimpleTrigger; //导入依赖的package包/类
private static final Trigger makeIntervalTrigger(String type, String interval,
String repititions) throws ParseException {
try {
final int i = Integer.parseInt(interval);
int r = SimpleTrigger.REPEAT_INDEFINITELY;
if (!repititions.trim().equals("")) {
r = Integer.parseInt(repititions);
}
if (type.equals(FREQUENCY_SECONDLY)) {
return TriggerUtils.makeSecondlyTrigger(i, r);
} else if (type.equals(FREQUENCY_MINUTELY)) {
return TriggerUtils.makeMinutelyTrigger(i, r);
} else if (type.equals(FREQUENCY_HOURLY)) {
return TriggerUtils.makeHourlyTrigger(i, r);
}
return null;
} catch (final NumberFormatException e) {
throw new ParseException("Invalid interval or repitition value.", -1);
}
}
示例2: updateOneTimeJob
import org.quartz.SimpleTrigger; //导入依赖的package包/类
/**
* Update one time scheduled job.
*/
@Override
public boolean updateOneTimeJob(String jobName, Date date) {
System.out.println("Request received for updating one time job.");
String jobKey = jobName;
System.out.println("Parameters received for updating one time job : jobKey :"+jobKey + ", date: "+date);
try {
//Trigger newTrigger = JobUtil.createSingleTrigger(jobKey, date, SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT);
Trigger newTrigger = JobUtil.createSingleTrigger(jobKey, date, SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW);
Date dt = schedulerFactoryBean.getScheduler().rescheduleJob(TriggerKey.triggerKey(jobKey), newTrigger);
System.out.println("Trigger associated with jobKey :"+jobKey+ " rescheduled successfully for date :"+dt);
return true;
} catch ( Exception e ) {
System.out.println("SchedulerException while updating one time job with key :"+jobKey + " message :"+e.getMessage());
e.printStackTrace();
return false;
}
}
示例3: updateCronJob
import org.quartz.SimpleTrigger; //导入依赖的package包/类
/**
* Update scheduled cron job.
*/
@Override
public boolean updateCronJob(String jobName, Date date, String cronExpression) {
System.out.println("Request received for updating cron job.");
String jobKey = jobName;
System.out.println("Parameters received for updating cron job : jobKey :"+jobKey + ", date: "+date);
try {
//Trigger newTrigger = JobUtil.createSingleTrigger(jobKey, date, SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT);
Trigger newTrigger = JobUtil.createCronTrigger(jobKey, date, cronExpression, SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW);
Date dt = schedulerFactoryBean.getScheduler().rescheduleJob(TriggerKey.triggerKey(jobKey), newTrigger);
System.out.println("Trigger associated with jobKey :"+jobKey+ " rescheduled successfully for date :"+dt);
return true;
} catch ( Exception e ) {
System.out.println("SchedulerException while updating cron job with key :"+jobKey + " message :"+e.getMessage());
e.printStackTrace();
return false;
}
}
示例4: startIndexerJob
import org.quartz.SimpleTrigger; //导入依赖的package包/类
private void startIndexerJob() throws SchedulerException {
Scheduler scheduler = Singleton.getScheduler();
// Setup the indexer which runs forever indexing
JobDetail job = newJob(IndexJob.class)
.withIdentity("indexjob")
.build();
SimpleTrigger trigger = newTrigger()
.withIdentity("indexerjob")
.withSchedule(simpleSchedule()
.withIntervalInHours(24)
.repeatForever()
)
.build();
scheduler.scheduleJob(job, trigger);
scheduler.start();
}
示例5: insertExtendedTriggerProperties
import org.quartz.SimpleTrigger; //导入依赖的package包/类
public int insertExtendedTriggerProperties(Connection conn, OperableTrigger trigger, String state, JobDetail jobDetail) throws SQLException, IOException {
SimpleTrigger simpleTrigger = (SimpleTrigger)trigger;
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(Util.rtp(INSERT_SIMPLE_TRIGGER, tablePrefix, schedNameLiteral));
ps.setString(1, trigger.getKey().getName());
ps.setString(2, trigger.getKey().getGroup());
ps.setInt(3, simpleTrigger.getRepeatCount());
ps.setBigDecimal(4, new BigDecimal(String.valueOf(simpleTrigger.getRepeatInterval())));
ps.setInt(5, simpleTrigger.getTimesTriggered());
return ps.executeUpdate();
} finally {
Util.closeStatement(ps);
}
}
示例6: updateExtendedTriggerProperties
import org.quartz.SimpleTrigger; //导入依赖的package包/类
public int updateExtendedTriggerProperties(Connection conn, OperableTrigger trigger, String state, JobDetail jobDetail) throws SQLException, IOException {
SimpleTrigger simpleTrigger = (SimpleTrigger)trigger;
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(Util.rtp(UPDATE_SIMPLE_TRIGGER, tablePrefix, schedNameLiteral));
ps.setInt(1, simpleTrigger.getRepeatCount());
ps.setBigDecimal(2, new BigDecimal(String.valueOf(simpleTrigger.getRepeatInterval())));
ps.setInt(3, simpleTrigger.getTimesTriggered());
ps.setString(4, simpleTrigger.getKey().getName());
ps.setString(5, simpleTrigger.getKey().getGroup());
return ps.executeUpdate();
} finally {
Util.closeStatement(ps);
}
}
示例7: getScheduleBuilder
import org.quartz.SimpleTrigger; //导入依赖的package包/类
/**
* Get a {@link ScheduleBuilder} that is configured to produce a
* schedule identical to this trigger's schedule.
*
* @see #getTriggerBuilder()
*/
@Override
public ScheduleBuilder<SimpleTrigger> getScheduleBuilder() {
SimpleScheduleBuilder sb = SimpleScheduleBuilder.simpleSchedule()
.withIntervalInMilliseconds(getRepeatInterval())
.withRepeatCount(getRepeatCount());
switch(getMisfireInstruction()) {
case MISFIRE_INSTRUCTION_FIRE_NOW : sb.withMisfireHandlingInstructionFireNow();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT : sb.withMisfireHandlingInstructionNextWithExistingCount();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT : sb.withMisfireHandlingInstructionNextWithRemainingCount();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithExistingCount();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithRemainingCount();
break;
}
return sb;
}
示例8: toCompositeData
import org.quartz.SimpleTrigger; //导入依赖的package包/类
public static CompositeData toCompositeData(SimpleTrigger trigger) {
try {
return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
new Object[] {
trigger.getRepeatCount(),
trigger.getRepeatInterval(),
trigger.getTimesTriggered(),
trigger.getKey().getName(),
trigger.getKey().getGroup(),
trigger.getJobKey().getName(),
trigger.getJobKey().getGroup(),
trigger.getDescription(),
JobDataMapSupport.toTabularData(trigger
.getJobDataMap()),
trigger.getCalendarName(),
((OperableTrigger)trigger).getFireInstanceId(),
trigger.getMisfireInstruction(),
trigger.getPriority(), trigger.getStartTime(),
trigger.getEndTime(), trigger.getNextFireTime(),
trigger.getPreviousFireTime(),
trigger.getFinalFireTime() });
} catch (OpenDataException e) {
throw new RuntimeException(e);
}
}
示例9: insertSimpleTrigger
import org.quartz.SimpleTrigger; //导入依赖的package包/类
/**
* <p>
* Insert the simple trigger data.
* </p>
*
* @param conn
* the DB Connection
* @param trigger
* the trigger to insert
* @return the number of rows inserted
*/
public int insertSimpleTrigger(Connection conn, SimpleTrigger trigger)
throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(rtp(INSERT_SIMPLE_TRIGGER));
ps.setString(1, trigger.getName());
ps.setString(2, trigger.getGroup());
ps.setInt(3, trigger.getRepeatCount());
ps.setBigDecimal(4, new BigDecimal(String.valueOf(trigger
.getRepeatInterval())));
ps.setInt(5, trigger.getTimesTriggered());
return ps.executeUpdate();
} finally {
closeStatement(ps);
}
}
示例10: updateSimpleTrigger
import org.quartz.SimpleTrigger; //导入依赖的package包/类
/**
* <p>
* Update the simple trigger data.
* </p>
*
* @param conn
* the DB Connection
* @param trigger
* the trigger to insert
* @return the number of rows updated
*/
public int updateSimpleTrigger(Connection conn, SimpleTrigger trigger)
throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(rtp(UPDATE_SIMPLE_TRIGGER));
ps.setInt(1, trigger.getRepeatCount());
ps.setBigDecimal(2, new BigDecimal(String.valueOf(trigger
.getRepeatInterval())));
ps.setInt(3, trigger.getTimesTriggered());
ps.setString(4, trigger.getName());
ps.setString(5, trigger.getGroup());
return ps.executeUpdate();
} finally {
closeStatement(ps);
}
}
示例11: enableSessionValidation
import org.quartz.SimpleTrigger; //导入依赖的package包/类
public void enableSessionValidation() {
if (log.isDebugEnabled()) {
log.debug("Scheduling session validation job using Quartz with session validation interval of ["
+ this.sessionValidationInterval + "]ms...");
}
try {
SimpleTrigger trigger = TriggerBuilder.newTrigger().startNow().withIdentity(JOB_NAME, Scheduler.DEFAULT_GROUP)
.withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInMilliseconds(sessionValidationInterval))
.build();
JobDetail detail = JobBuilder.newJob(QuartzSessionValidationJob.class)
.withIdentity(JOB_NAME, Scheduler.DEFAULT_GROUP).build();
detail.getJobDataMap().put(SESSION_MANAGER_KEY, this.sessionManager);
Scheduler scheduler = getScheduler();
scheduler.scheduleJob(detail, trigger);
if (this.schedulerImplicitlyCreated) {
scheduler.start();
if (log.isDebugEnabled()) {
log.debug("Successfully started implicitly created Quartz Scheduler instance.");
}
}
this.enabled = true;
if (log.isDebugEnabled())
log.debug("Session validation job successfully scheduled with Quartz.");
} catch (SchedulerException e) {
if (log.isErrorEnabled())
log.error("Error starting the Quartz session validation job. Session validation may not occur.", e);
}
}
示例12: createTrigger
import org.quartz.SimpleTrigger; //导入依赖的package包/类
/** Creates a SimpleTrigger with an interval computed from the hours, minutes and seconds.
*/
private static AbstractTrigger<?> createTrigger(ScheduledTask task, Recurrence.Often recurrence) throws FrameworkException, ApplicationExceptions {
// Compute the repeatInterval for the SimpleTrigger in milliseconds
long repeatInterval = 0;
if (recurrence.getHours() != null)
repeatInterval += recurrence.getHours() * 60 * 60 * 1000;
if (recurrence.getMinutes() != null)
repeatInterval += recurrence.getMinutes() * 60 * 1000;
if (recurrence.getSeconds() != null)
repeatInterval += recurrence.getSeconds() * 1000;
SimpleTriggerImpl trigger = new SimpleTriggerImpl();
if (repeatInterval > 0) {
trigger.setRepeatInterval(repeatInterval);
trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
}
return trigger;
}
示例13: schedule
import org.quartz.SimpleTrigger; //导入依赖的package包/类
@Override
public void schedule(String name, Date startTime, Date endTime,
int repeatCount, long repeatInterval) {
if (name == null || name.trim().equals("")) {
name = UUID.randomUUID().toString();
}
try {
scheduler.addJob(jobDetail, true);
SimpleTrigger simpleTrigger = new SimpleTrigger(name,
Scheduler.DEFAULT_GROUP, jobDetail.getName(),
Scheduler.DEFAULT_GROUP, startTime, endTime, repeatCount,
repeatInterval);
scheduler.scheduleJob(simpleTrigger);
scheduler.rescheduleJob(name, Scheduler.DEFAULT_GROUP,
simpleTrigger);
} catch (SchedulerException e) {
log.error(e);
throw new RuntimeException(e);
}
}
示例14: start
import org.quartz.SimpleTrigger; //导入依赖的package包/类
public void start(final long interval) {
try {
// Grab the Scheduler instance from the Factory
final org.quartz.Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
// define the job and tie it to our NokiaHereAdapter class
final JobDetail jd = new JobDetail(this.name, Scheduler.DEFAULT_GROUP, AdapterJob.class);
// triggers all 120 seconds the execution of execution, never ends
final SimpleTrigger simpleTrigger = new SimpleTrigger(this.name, Scheduler.DEFAULT_GROUP, new Date(), null, SimpleTrigger.REPEAT_INDEFINITELY, interval * 1000);
// Tell quartz to schedule the job using our trigger
scheduler.scheduleJob(jd, simpleTrigger);
scheduler.start();
} catch (final SchedulerException se) {
se.printStackTrace();
}
}
示例15: testConfigureGroupAndName
import org.quartz.SimpleTrigger; //导入依赖的package包/类
@Test
public void testConfigureGroupAndName() throws Exception {
QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz2://myGroup/myName?trigger.repeatCount=3&trigger.repeatInterval=1000");
Scheduler scheduler = endpoint.getComponent().getScheduler();
TriggerKey triggerKey = endpoint.getTriggerKey();
Trigger trigger = scheduler.getTrigger(triggerKey);
JobDetail jobDetail = scheduler.getJobDetail(JobKey.jobKey(triggerKey.getName(), triggerKey.getGroup()));
assertEquals("getName()", "myName", triggerKey.getName());
assertEquals("getGroup()", "myGroup", triggerKey.getGroup());
assertEquals("getJobName", "myName", jobDetail.getKey().getName());
assertEquals("getJobGroup", "myGroup", jobDetail.getKey().getGroup());
SimpleTrigger simpleTrigger = assertIsInstanceOf(SimpleTrigger.class, trigger);
assertEquals("getRepeatCount()", 3, simpleTrigger.getRepeatCount());
}