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


Java ClassLoadHelper.initialize方法代码示例

本文整理汇总了Java中org.quartz.spi.ClassLoadHelper.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java ClassLoadHelper.initialize方法的具体用法?Java ClassLoadHelper.initialize怎么用?Java ClassLoadHelper.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.quartz.spi.ClassLoadHelper的用法示例。


在下文中一共展示了ClassLoadHelper.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
@BeforeClass
public void setUp()
  throws SchedulerException, InterruptedException {

  fSignaler = new SampleSignaler();

  Config config = new Config();
  config.setProperty("hazelcast.logging.type", "slf4j");
  hazelcastInstance = Hazelcast.newHazelcastInstance(config);

  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  HazelcastJobStore.setHazelcastClient(hazelcastInstance);
  jobStore = createJobStore("AbstractJobStoreTest");
  jobStore.initialize(loadHelper, this.fSignaler);
  jobStore.schedulerStarted();

  jobDetail = JobBuilder.newJob(NoOpJob.class).withIdentity("job1", "jobGroup1").build();
  jobStore.storeJob(jobDetail, false);
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:22,代码来源:HazelcastJobStoreTest.java

示例2: testStoreAndRetrieveJobs

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
@Test
public void testStoreAndRetrieveJobs()
  throws Exception {

  final int nJobs = 10;

  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testStoreAndRetrieveJobs");
  store.initialize(loadHelper, schedSignaler);

  // Store jobs.
  for (int i = 0; i < nJobs; i++) {
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i).build();
    store.storeJob(job, false);
  }

  // Retrieve jobs.
  for (int i = 0; i < nJobs; i++) {
    JobKey jobKey = JobKey.jobKey("job" + i);
    JobDetail storedJob = store.retrieveJob(jobKey);
    Assert.assertEquals(storedJob.getKey(), jobKey);
  }
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:27,代码来源:HazelcastJobStoreTest.java

示例3: testStoreAndRetrieveJobs

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
@Test()
public void testStoreAndRetrieveJobs() throws Exception {
  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testStoreAndRetrieveJobs");
  store.initialize(loadHelper, schedSignaler);

  // Store jobs.
  for (int i = 0; i < 10; i++) {
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i)
        .build();
    store.storeJob(job, false);
  }
  // Retrieve jobs.
  for (int i = 0; i < 10; i++) {
    JobKey jobKey = JobKey.jobKey("job" + i);
    JobDetail storedJob = store.retrieveJob(jobKey);
    Assert.assertEquals(jobKey, storedJob.getKey());
  }
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:23,代码来源:TestHazelcastJobStore.java

示例4: setUp

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
@BeforeClass
public void setUp() throws SchedulerException, InterruptedException {

  Config config = new Config();
  config.setProperty("hazelcast.logging.type", "slf4j");
  hazelcastInstance = Hazelcast.newHazelcastInstance(config);

  this.fSignaler = new SampleSignaler();

  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  this.jobStore = createJobStore("AbstractJobStoreTest");
  this.jobStore.initialize(loadHelper, this.fSignaler);
  this.jobStore.schedulerStarted();

  this.fJobDetail = new JobDetailImpl("job1", "jobGroup1", NoOpJob.class);
  this.fJobDetail.setDurability(true);
  this.jobStore.storeJob(this.fJobDetail, false);
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:21,代码来源:AbstractTestHazelcastJobStore.java

示例5: initialize

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
/**
 * Called to give the ClassLoadHelper a chance to initialize itself,
 * including the opportunity to "steal" the class loader off of the calling
 * thread, which is the thread that is initializing Quartz.
 */
public void initialize() {
    loadHelpers = new LinkedList<ClassLoadHelper>();

    loadHelpers.add(new LoadingLoaderClassLoadHelper());
    loadHelpers.add(new SimpleClassLoadHelper());
    loadHelpers.add(new ThreadContextClassLoadHelper());
    loadHelpers.add(new InitThreadContextClassLoadHelper());
    
    for(ClassLoadHelper loadHelper: loadHelpers) {
        loadHelper.initialize();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:CascadingClassLoadHelper.java

示例6: initialize

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
/**
 * Called to give the ClassLoadHelper a chance to initialize itself,
 * including the opportunity to "steal" the class loader off of the calling
 * thread, which is the thread that is initializing Quartz.
 */
public void initialize() {
    loadHelpers = new LinkedList();

    loadHelpers.add(new LoadingLoaderClassLoadHelper());
    loadHelpers.add(new SimpleClassLoadHelper());
    loadHelpers.add(new ThreadContextClassLoadHelper());
    loadHelpers.add(new InitThreadContextClassLoadHelper());
    
    Iterator iter = loadHelpers.iterator();
    while (iter.hasNext()) {
        ClassLoadHelper loadHelper = (ClassLoadHelper) iter.next();
        loadHelper.initialize();
    }
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:20,代码来源:CascadingClassLoadHelper.java

示例7: setUp

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();
  this.jobStore = createJobStore();
  this.jobStore.start();
  this.jobStore.initialize(loadHelper, new SampleSignaler());
  this.jobStore.schedulerStarted();
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:10,代码来源:JobStoreImplTest.java

示例8: testStoreAndRetriveTriggers

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
@Test
public void testStoreAndRetriveTriggers()
  throws Exception {

  final int nJobs = 10;

  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testStoreAndRetriveTriggers");
  store.initialize(loadHelper, schedSignaler);

  // Store jobs and triggers.
  for (int i = 0; i < nJobs; i++) {
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i).build();
    store.storeJob(job, true);

    OperableTrigger trigger = buildTrigger("job" + i, DEFAULT_GROUP, job);
    store.storeTrigger((OperableTrigger) trigger, true);
  }
  // Retrieve jobs and triggers.
  for (int i = 0; i < nJobs; i++) {
    JobKey jobKey = JobKey.jobKey("job" + i);
    JobDetail storedJob = store.retrieveJob(jobKey);
    Assert.assertEquals(storedJob.getKey(), jobKey);

    TriggerKey triggerKey = TriggerKey.triggerKey("job" + i);
    OperableTrigger storedTrigger = store.retrieveTrigger(triggerKey);
    Assert.assertEquals(storedTrigger.getKey(), triggerKey);
  }
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:33,代码来源:HazelcastJobStoreTest.java

示例9: testStoreAndRetriveTriggers

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
@Test()
public void testStoreAndRetriveTriggers() throws Exception {
  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testStoreAndRetriveTriggers");
  store.initialize(loadHelper, schedSignaler);

  // Store jobs and triggers.
  for (int i = 0; i < 10; i++) {
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i)
        .build();
    store.storeJob(job, true);
    SimpleScheduleBuilder schedule = SimpleScheduleBuilder.simpleSchedule();
    Trigger trigger = TriggerBuilder.newTrigger().withIdentity("job" + i)
        .withSchedule(schedule).forJob(job).build();
    store.storeTrigger((OperableTrigger) trigger, true);
  }
  // Retrieve job and trigger.
  for (int i = 0; i < 10; i++) {
    JobKey jobKey = JobKey.jobKey("job" + i);
    JobDetail storedJob = store.retrieveJob(jobKey);
    Assert.assertEquals(jobKey, storedJob.getKey());

    TriggerKey triggerKey = TriggerKey.triggerKey("job" + i);
    Trigger storedTrigger = store.retrieveTrigger(triggerKey);
    Assert.assertEquals(triggerKey, storedTrigger.getKey());
  }
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:31,代码来源:TestHazelcastJobStore.java

示例10: registerJobsAndTriggers

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
/**
 * Register jobs and triggers (within a transaction, if possible).
 */
protected void registerJobsAndTriggers() throws SchedulerException {
	TransactionStatus transactionStatus = null;
	if (this.transactionManager != null) {
		transactionStatus = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
	}

	try {
		if (this.jobSchedulingDataLocations != null) {
			ClassLoadHelper clh = new ResourceLoaderClassLoadHelper(this.resourceLoader);
			clh.initialize();
			XMLSchedulingDataProcessor dataProcessor = new XMLSchedulingDataProcessor(clh);
			for (String location : this.jobSchedulingDataLocations) {
				dataProcessor.processFileAndScheduleJobs(location, getScheduler());
			}
		}

		// Register JobDetails.
		if (this.jobDetails != null) {
			for (JobDetail jobDetail : this.jobDetails) {
				addJobToScheduler(jobDetail);
			}
		}
		else {
			// Create empty list for easier checks when registering triggers.
			this.jobDetails = new LinkedList<JobDetail>();
		}

		// Register Calendars.
		if (this.calendars != null) {
			for (String calendarName : this.calendars.keySet()) {
				Calendar calendar = this.calendars.get(calendarName);
				getScheduler().addCalendar(calendarName, calendar, true, true);
			}
		}

		// Register Triggers.
		if (this.triggers != null) {
			for (Trigger trigger : this.triggers) {
				addTriggerToScheduler(trigger);
			}
		}
	}

	catch (Throwable ex) {
		if (transactionStatus != null) {
			try {
				this.transactionManager.rollback(transactionStatus);
			}
			catch (TransactionException tex) {
				logger.error("Job registration exception overridden by rollback exception", ex);
				throw tex;
			}
		}
		if (ex instanceof SchedulerException) {
			throw (SchedulerException) ex;
		}
		if (ex instanceof Exception) {
			throw new SchedulerException("Registration of jobs and triggers failed: " + ex.getMessage(), ex);
		}
		throw new SchedulerException("Registration of jobs and triggers failed: " + ex.getMessage());
	}

	if (transactionStatus != null) {
		this.transactionManager.commit(transactionStatus);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:70,代码来源:SchedulerAccessor.java

示例11: testAcquireTriggers

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
@Test
public void testAcquireTriggers()
  throws Exception {

  final int nJobs = 10;

  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testAcquireTriggers");
  store.initialize(loadHelper, schedSignaler);

  // Setup: Store jobs and triggers.
  long MIN = 60 * 1000L;
  Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from
  // now.
  for (int i = 0; i < nJobs; i++) {
    Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i).build();
    SimpleScheduleBuilder schedule = SimpleScheduleBuilder.repeatMinutelyForever(2);
    OperableTrigger trigger = (OperableTrigger) newTrigger()
        .withIdentity("job" + i)
        .withSchedule(schedule).forJob(job)
        .startAt(startTime)
        .build();

    // Manually trigger the first fire time computation that scheduler would
    // do. Otherwise
    // the store.acquireNextTriggers() will not work properly.
    Date fireTime = trigger.computeFirstFireTime(null);
    Assert.assertNotNull(fireTime);

    store.storeJobAndTrigger(job, trigger);
  }

  // Test acquire one trigger at a time
  for (int i = 0; i < nJobs; i++) {
    long noLaterThan = (startTime0.getTime() + i * MIN);
    int maxCount = 1;
    long timeWindow = 0;
    List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan, maxCount, timeWindow);
    Assert.assertEquals(triggers.size(), 1);
    Assert.assertEquals(triggers.get(0).getKey().getName(), "job" + i);

    // Let's remove the trigger now.
    store.removeJob(triggers.get(0).getJobKey());
  }
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:50,代码来源:HazelcastJobStoreTest.java

示例12: testAcquireTriggersInBatch

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
@Test
public void testAcquireTriggersInBatch()
  throws Exception {

  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testAcquireTriggersInBatch");
  store.initialize(loadHelper, schedSignaler);

  // Setup: Store jobs and triggers.
  long MIN = 60 * 1000L;
  Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from
  // now.
  for (int i = 0; i < 10; i++) {
    Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i).build();
    SimpleScheduleBuilder schedule = SimpleScheduleBuilder.repeatMinutelyForever(2);
    OperableTrigger trigger = (OperableTrigger) newTrigger()
        .withIdentity("job" + i)
        .withSchedule(schedule)
        .forJob(job)
        .startAt(startTime)
        .build();

    // Manually trigger the first fire time computation that scheduler would
    // do. Otherwise
    // the store.acquireNextTriggers() will not work properly.
    Date fireTime = trigger.computeFirstFireTime(null);
    Assert.assertNotNull(fireTime);

    store.storeJobAndTrigger(job, trigger);
  }

  // Test acquire batch of triggers at a time
  long noLaterThan = startTime0.getTime() + 10 * MIN;
  int maxCount = 7;
  // time window needs to be big to be able to pick up multiple triggers when
  // they are a minute apart
  long timeWindow = 8 * MIN;
  List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan, maxCount, timeWindow);
  Assert.assertEquals(triggers.size(), 7);
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:45,代码来源:HazelcastJobStoreTest.java

示例13: testAcquireTriggers

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
@Test()
public void testAcquireTriggers() throws Exception {
  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testAcquireTriggers");
  store.initialize(loadHelper, schedSignaler);

  // Setup: Store jobs and triggers.
  long MIN = 60 * 1000L;
  Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from
                                                                // now.
  for (int i = 0; i < 10; i++) {
    Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i)
        .build();
    SimpleScheduleBuilder schedule = SimpleScheduleBuilder
        .repeatMinutelyForever(2);
    OperableTrigger trigger = (OperableTrigger) TriggerBuilder.newTrigger()
        .withIdentity("job" + i).withSchedule(schedule).forJob(job)
        .startAt(startTime).build();

    // Manually trigger the first fire time computation that scheduler would
    // do. Otherwise
    // the store.acquireNextTriggers() will not work properly.
    Date fireTime = trigger.computeFirstFireTime(null);
    Assert.assertEquals(true, fireTime != null);

    store.storeJobAndTrigger(job, trigger);
  }

  // Test acquire one trigger at a time
  for (int i = 0; i < 10; i++) {
    long noLaterThan = (startTime0.getTime() + i * MIN);
    int maxCount = 1;
    long timeWindow = 0;
    List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan,
        maxCount, timeWindow);
    Assert.assertEquals(1, triggers.size());
    Assert.assertEquals("job" + i, triggers.get(0).getKey().getName());

    // Let's remove the trigger now.
    store.removeJob(triggers.get(0).getJobKey());
  }
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:47,代码来源:TestHazelcastJobStore.java

示例14: testAcquireTriggersInBatch

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的package包/类
@Test()
public void testAcquireTriggersInBatch() throws Exception {
  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testAcquireTriggersInBatch");
  store.initialize(loadHelper, schedSignaler);

  // Setup: Store jobs and triggers.
  long MIN = 60 * 1000L;
  Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from
                                                                // now.
  for (int i = 0; i < 10; i++) {
    Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i)
        .build();
    SimpleScheduleBuilder schedule = SimpleScheduleBuilder
        .repeatMinutelyForever(2);
    OperableTrigger trigger = (OperableTrigger) TriggerBuilder.newTrigger()
        .withIdentity("job" + i).withSchedule(schedule).forJob(job)
        .startAt(startTime).build();

    // Manually trigger the first fire time computation that scheduler would
    // do. Otherwise
    // the store.acquireNextTriggers() will not work properly.
    Date fireTime = trigger.computeFirstFireTime(null);
    Assert.assertEquals(true, fireTime != null);

    store.storeJobAndTrigger(job, trigger);
  }

  // Test acquire batch of triggers at a time
  long noLaterThan = startTime0.getTime() + 10 * MIN;
  int maxCount = 7;
  // time window needs to be big to be able to pick up multiple triggers when
  // they are a minute apart
  long timeWindow = 8 * MIN;
  List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan,
      maxCount, timeWindow);
  Assert.assertEquals(7, triggers.size());
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:43,代码来源:TestHazelcastJobStore.java

示例15: getScheduler

import org.quartz.spi.ClassLoadHelper; //导入方法依赖的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


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