本文整理汇总了Java中org.quartz.impl.StdScheduler类的典型用法代码示例。如果您正苦于以下问题:Java StdScheduler类的具体用法?Java StdScheduler怎么用?Java StdScheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StdScheduler类属于org.quartz.impl包,在下文中一共展示了StdScheduler类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterChange
import org.quartz.impl.StdScheduler; //导入依赖的package包/类
protected void afterChange(Form<?> form, AjaxRequestTarget target) {
Settings settings = (Settings) form.getModelObject();
if (!oldCronExpression.equals(settings.getCleanHistory().getCronExpression())) {
// reschedule clean history
StdScheduler scheduler = (StdScheduler) NextServerApplication.get().getSpringBean("scheduler");
CronTriggerImpl cronTrigger = (CronTriggerImpl) NextServerApplication.get()
.getSpringBean("cleanHistoryTrigger");
try {
cronTrigger.setCronExpression(settings.getCleanHistory().getCronExpression());
scheduler.rescheduleJob(cronTrigger.getKey(), cronTrigger);
} catch (Exception e) {
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
}
示例2: afterChange
import org.quartz.impl.StdScheduler; //导入依赖的package包/类
protected void afterChange(Form<?> form, AjaxRequestTarget target) {
Settings settings = (Settings)form.getModelObject();
if (!oldCronExpression.equals(settings.getSynchronizer().getCronExpression())) {
// reschedule user synchronizer
StdScheduler scheduler = (StdScheduler) NextServerApplication.get().getSpringBean("scheduler");
CronTriggerImpl cronTrigger = (CronTriggerImpl) NextServerApplication.get().getSpringBean("userSynchronizerTrigger");
try {
cronTrigger.setCronExpression(settings.getSynchronizer().getCronExpression());
scheduler.rescheduleJob(cronTrigger.getKey(), cronTrigger);
} catch (Exception e) {
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
}
示例3: createAndUpdateSchedule
import org.quartz.impl.StdScheduler; //导入依赖的package包/类
@Test
public void createAndUpdateSchedule() throws Exception {
final ApplicationContext mockContext = Mockito.mock(ApplicationContext.class);
final VmScheduleRepository vmScheduleRepository = Mockito.mock(VmScheduleRepository.class);
final VmResource mockResource = Mockito.mock(VmResource.class);
final Subscription entity = this.subscriptionRepository.findOneExpected(subscription);
Mockito.when(mockContext.getBean(VmScheduleRepository.class)).thenReturn(vmScheduleRepository);
Mockito.when(mockContext.getBean(SecurityHelper.class)).thenReturn(Mockito.mock(SecurityHelper.class));
Mockito.when(mockContext.getBean(VmResource.class)).thenReturn(mockResource);
final StdScheduler scheduler = (StdScheduler) vmSchedulerFactoryBean.getScheduler();
final QuartzScheduler qscheduler = (QuartzScheduler) FieldUtils.getField(StdScheduler.class, "sched", true).get(scheduler);
final QuartzSchedulerResources resources = (QuartzSchedulerResources) FieldUtils.getField(QuartzScheduler.class, "resources", true)
.get(qscheduler);
final JobDetail jobDetail = scheduler.getJobDetail(scheduler.getJobKeys(GroupMatcher.anyJobGroup()).iterator().next());
// "ON" call would fail
Mockito.doThrow(new RuntimeException()).when(mockResource).execute(entity, VmOperation.ON);
try {
// Mock the factory
jobDetail.getJobDataMap().put("context", mockContext);
((RAMJobStore) resources.getJobStore()).storeJob(jobDetail, true);
Assert.assertEquals(1, this.vmScheduleRepository.findAll().size());
// Schedule all operations within the next 2 seconds
final String cron = "" + ((DateUtils.newCalendar().get(Calendar.SECOND) + 2) % 60) + " * * * * ?";
final int id = mockSchedule(vmScheduleRepository, resource.createSchedule(newSchedule(cron, VmOperation.OFF)));
mockSchedule(vmScheduleRepository, resource.createSchedule(newSchedule(cron + " *", VmOperation.ON)));
Assert.assertEquals(3, this.vmScheduleRepository.findAll().size());
// Yield for the schedules
Thread.sleep(2500);
// Check the executions
Mockito.verify(mockResource).execute(entity, VmOperation.OFF);
Mockito.verify(mockResource).execute(entity, VmOperation.ON); // Failed
Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.REBOOT);
Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.RESET);
Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.SHUTDOWN);
Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.SUSPEND);
// Update the CRON and the operation
final VmScheduleVo vo = newSchedule("" + ((DateUtils.newCalendar().get(Calendar.SECOND) + 2) % 60) + " * * * * ?",
VmOperation.SHUTDOWN);
vo.setId(id);
vo.setSubscription(subscription);
resource.updateSchedule(vo);
Assert.assertEquals(3, this.vmScheduleRepository.findAll().size());
// Yield for the schedules
Thread.sleep(2500);
Mockito.verify(mockResource).execute(entity, VmOperation.SHUTDOWN);
} finally {
// Restore the factory's context
jobDetail.getJobDataMap().put("context", applicationContext);
((RAMJobStore) resources.getJobStore()).storeJob(jobDetail, true);
}
}
示例4: getScheduler
import org.quartz.impl.StdScheduler; //导入依赖的package包/类
public StdScheduler getScheduler() {
return scheduler;
}
示例5: setScheduler
import org.quartz.impl.StdScheduler; //导入依赖的package包/类
public void setScheduler(StdScheduler scheduler) {
this.scheduler = scheduler;
}