本文整理汇总了Java中org.quartz.core.QuartzScheduler类的典型用法代码示例。如果您正苦于以下问题:Java QuartzScheduler类的具体用法?Java QuartzScheduler怎么用?Java QuartzScheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QuartzScheduler类属于org.quartz.core包,在下文中一共展示了QuartzScheduler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBasicInfo
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
public static BasicInfo getBasicInfo() {
String versionIteration = QuartzScheduler.getVersionIteration();
String versionMajor = QuartzScheduler.getVersionMajor();
String versionMinor = QuartzScheduler.getVersionMinor();
BasicInfo basicInfo = new BasicInfo();
basicInfo.setQuartzWebVersion(VERSION.getVersionNumber());
basicInfo.setVersionMajor(versionMajor);
basicInfo.setVersionMinor(versionMinor);
basicInfo.setVersionIteration(versionIteration);
basicInfo.setQuartzVersion(versionMajor + "." + versionMinor + "." + versionIteration);
basicInfo.setJavaVMStartTime(DateUtils.getVMStartTime());
basicInfo.setJavaVMName(System.getProperty("java.vm.name"));
basicInfo.setJavaVersion(System.getProperty("java.version"));
basicInfo.setJavaClassPath(System.getProperty("java.class.path"));
return basicInfo;
}
示例2: doStart
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
// create new scheduler
scheduler = createScheduler();
try {
// access internal scheduler to simulate signals for remote updates
Field schedField = scheduler.getClass().getDeclaredField("sched");
schedField.setAccessible(true);
quartzScheduler = (QuartzScheduler) schedField.get(scheduler);
}
catch (Exception | LinkageError e) {
log.error("Cannot find QuartzScheduler", e);
throw e;
}
// re-attach listeners right after scheduler is available
reattachJobListeners();
}
示例3: instantiate
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
@Override
protected Scheduler instantiate(QuartzSchedulerResources rsrcs, QuartzScheduler qs)
{
Scheduler scheduler = super.instantiate(rsrcs, qs);
JobStore jobStore = rsrcs.getJobStore();
if (jobStore instanceof SchedulerAware)
{
((SchedulerAware) jobStore).setScheduler(scheduler);
}
return scheduler;
}
示例4: shutdownFromInstantiateException
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
private void shutdownFromInstantiateException(ThreadPool tp, QuartzScheduler qs, boolean tpInited, boolean qsInited) {
try {
if(qsInited)
qs.shutdown(false);
else if(tpInited)
tp.shutdown(false);
} catch (Exception e) {
getLog().error("Got another exception while shutting down after instantiation exception", e);
}
}
示例5: instantiate
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
protected Scheduler instantiate(QuartzSchedulerResources rsrcs, QuartzScheduler qs) {
SchedulingContext schedCtxt = new SchedulingContext();
schedCtxt.setInstanceId(rsrcs.getInstanceId());
Scheduler scheduler = new StdScheduler(qs, schedCtxt);
return scheduler;
}
示例6: shutdownFromInstantiateException
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
private void shutdownFromInstantiateException(ThreadPool tp, QuartzScheduler qs, boolean tpInited, boolean qsInited) {
try {
if (qsInited) qs.shutdown(false);
else if (tpInited) tp.shutdown(false);
} catch (Exception e) {
getLog().error("Got another exception while shutting down after instantiation exception", e);
}
}
示例7: createAndUpdateSchedule
import org.quartz.core.QuartzScheduler; //导入依赖的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);
}
}
示例8: getQuartzVersion
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
private String getQuartzVersion() {
return String.format("%s.%s.%s", QuartzScheduler.getVersionMajor(), QuartzScheduler.getVersionMinor(),
QuartzScheduler.getVersionIteration());
}
示例9: main
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
public static void main(String[] args) {
System.out.println("Quartz version: " + QuartzScheduler.getVersionMajor()
+ "." + QuartzScheduler.getVersionMinor() + "."
+ QuartzScheduler.getVersionIteration());
}
示例10: instantiate
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
protected Scheduler instantiate(QuartzSchedulerResources rsrcs, QuartzScheduler qs) {
Scheduler scheduler = new StdScheduler(qs);
return scheduler;
}
示例11: getScheduler
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
private QuartzScheduler getScheduler() {
Logger logger = LoggerFactory.getLogger(this.getClass());
if (scheduler == null) {
try {
QuartzSchedulerResources qsr = getQuartzSchedulerResources();
if (qsr.getThreadExecutor() == null) {
qsr.setThreadExecutor(new DefaultThreadExecutor());
}
qsr.getThreadPool().initialize();
QuartzScheduler qs = new QuartzScheduler(qsr, getDefaultIdleWaitTime(), -1);
ClassLoadHelper classLoadHelper = getJobStoreClassLoadHelper();
classLoadHelper.initialize();
qsr.getJobStore().initialize(classLoadHelper, qs.getSchedulerSignaler());
qsr.getJobRunShellFactory().initialize(this);
qs.initialize();
qs.setJobFactory(getInitialJobFactory());
logger.info("Quartz scheduler '" + qsr.getName());
logger.info("Quartz scheduler version: " + qs.getVersion());
scheduler = qs;
} catch (Exception ex) {
logger.error("Exception creating scheduler!", ex);
}
}
return scheduler;
}
示例12: register
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
/**
* Puts the submitted resource under the purview of this {@code ManagementServer}.
*
* @param managedResource the resource to be managed
*/
public void register(QuartzScheduler managedResource);
示例13: unregister
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
/**
* Removes the submitted resource under the purview of this {@code ManagementServer}.
*
* @param managedResource the resource to be managed
*/
public void unregister(QuartzScheduler managedResource);
示例14: StdScheduler
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
/**
* <p>
* Construct a <code>StdScheduler</code> instance to proxy the given
* <code>QuartzScheduler</code> instance, and with the given <code>SchedulingContext</code>.
* </p>
*/
public StdScheduler(QuartzScheduler sched) {
this.sched = sched;
}
示例15: StdScheduler
import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
/**
* <p>
* Construct a <code>StdScheduler</code> instance to proxy the given
* <code>QuartzScheduler</code> instance, and with the given <code>SchedulingContext</code>.
* </p>
*/
public StdScheduler(QuartzScheduler sched, SchedulingContext schedCtxt) {
this.sched = sched;
this.schedCtxt = schedCtxt;
}