当前位置: 首页>>代码示例>>Java>>正文


Java QuartzScheduler类代码示例

本文整理汇总了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;
}
 
开发者ID:quartzweb,项目名称:quartz-web,代码行数:17,代码来源:QuartzWebManager.java

示例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();
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:20,代码来源:QuartzSchedulerSPI.java

示例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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:12,代码来源:AlfrescoSchedulerFactory.java

示例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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:StdSchedulerFactory.java

示例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;
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:8,代码来源:StdSchedulerFactory.java

示例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);
    }
}
 
开发者ID:inter12,项目名称:swiftly,代码行数:9,代码来源:ExtendStdSchedulerFactory.java

示例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);
	}
}
 
开发者ID:ligoj,项目名称:plugin-vm,代码行数:61,代码来源:VmResourceTest.java

示例8: getQuartzVersion

import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
private String getQuartzVersion() {
  return String.format("%s.%s.%s", QuartzScheduler.getVersionMajor(), QuartzScheduler.getVersionMinor(),
                       QuartzScheduler.getVersionIteration());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:UpdateChecker.java

示例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());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:VersionPrinter.java

示例10: instantiate

import org.quartz.core.QuartzScheduler; //导入依赖的package包/类
protected Scheduler instantiate(QuartzSchedulerResources rsrcs, QuartzScheduler qs) {

        Scheduler scheduler = new StdScheduler(qs);
        return scheduler;
    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:StdSchedulerFactory.java

示例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;
    }
 
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:38,代码来源:AbstractSchedulerProvider.java

示例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);
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ManagementServer.java

示例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);
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ManagementServer.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:StdScheduler.java

示例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;
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:11,代码来源:StdScheduler.java


注:本文中的org.quartz.core.QuartzScheduler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。