當前位置: 首頁>>代碼示例>>Java>>正文


Java JobDetail.setJobDataMap方法代碼示例

本文整理匯總了Java中org.quartz.JobDetail.setJobDataMap方法的典型用法代碼示例。如果您正苦於以下問題:Java JobDetail.setJobDataMap方法的具體用法?Java JobDetail.setJobDataMap怎麽用?Java JobDetail.setJobDataMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.quartz.JobDetail的用法示例。


在下文中一共展示了JobDetail.setJobDataMap方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newJobDetail

import org.quartz.JobDetail; //導入方法依賴的package包/類
/**
 * @param cData
 * @return JobDetail
 */
public static JobDetail newJobDetail(CompositeData cData) {
	JobDetail jobDetail = new JobDetail();

	int i = 0;
	jobDetail.setName((String) cData.get(ITEM_NAMES[i++]));
	jobDetail.setGroup((String) cData.get(ITEM_NAMES[i++]));
	jobDetail.setDescription((String) cData.get(ITEM_NAMES[i++]));
	try {
		Class c = Class.forName((String) cData.get(ITEM_NAMES[i++]));
		jobDetail.setJobClass(c);
	} catch (ClassNotFoundException cnfe) {
		/**/
	}
	jobDetail.setJobDataMap(JobDataMapSupport
			.newJobDataMap((TabularData) cData.get(ITEM_NAMES[i++])));
	jobDetail.setVolatility((Boolean) cData.get(ITEM_NAMES[i++]));
	jobDetail.setDurability((Boolean) cData.get(ITEM_NAMES[i++]));
	jobDetail.setRequestsRecovery((Boolean) cData.get(ITEM_NAMES[i++]));

	return jobDetail;
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:26,代碼來源:JobDetailSupport.java

示例2: setupTimer

import org.quartz.JobDetail; //導入方法依賴的package包/類
protected void setupTimer()
{
	try
	{
           final String jobName = "SolrWatcher";
           final String jobGroup = "Solr";
           
           // If a Quartz job already exists with this name and group then we want to replace it.
           // It is not expected that this will occur during production, but it is possible during automated testing
           // where application contexts could be rebuilt between test cases, leading to multiple creations of
           // equivalent Quartz jobs. Quartz disallows the scheduling of multiple jobs with the same name and group.
           JobDetail existingJob = scheduler.getJobDetail(jobName, jobGroup);
           if (existingJob != null)
           {
               scheduler.deleteJob(jobName, jobGroup);
           }
     
     JobDetail job = new JobDetail(jobName, jobGroup, SOLRWatcherJob.class);
     JobDataMap jobDataMap = new JobDataMap();
     jobDataMap.put("SOLR_TRACKER", this);
     job.setJobDataMap(jobDataMap);

        trigger = new CronTrigger("SolrWatcherTrigger", jobGroup, solrPingCronExpression);
        scheduler.scheduleJob(job, trigger);
	}
	catch(Exception e)
	{
		throw new AlfrescoRuntimeException("Unable to set up SOLRTracker timer", e);
	}
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:31,代碼來源:SOLRAdminClient.java

示例3: getJobDetail

import org.quartz.JobDetail; //導入方法依賴的package包/類
/**
 * Get the job detail.
 * 
 * @return - the job detail.
 */
private JobDetail getJobDetail()
{
    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.put(ACTION_JOB_DATA_MAP_KEY, this);

    JobDetail jobDetail = new JobDetail();
    jobDetail.setName(getJobName());
    jobDetail.setGroup(getJobGroup());
    jobDetail.setJobDataMap(jobDataMap);
    jobDetail.setJobClass(JobDefinition.class);
    return jobDetail;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:18,代碼來源:AbstractScheduledAction.java

示例4: testJobLocking

import org.quartz.JobDetail; //導入方法依賴的package包/類
@Test
public void testJobLocking() throws Exception
{
    HBBaseDataCollector simpleCollector = mock(HBBaseDataCollector.class);
    when(simpleCollector.getCollectorId()).thenReturn("c1");
    when(simpleCollector.getCronExpression()).thenReturn("0 0 0 ? * *");

    // mock the job context
    JobExecutionContext mockJobExecutionContext = mock(JobExecutionContext.class);
    JobDetail jobDetail = new JobDetail();
    when(mockJobExecutionContext.getJobDetail()).thenReturn(jobDetail);

    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.put("collector", simpleCollector);
    jobDataMap.put("hbDataSenderService", mockDataSenderService);
    jobDataMap.put("jobLockService", mockJobLockService);
    jobDetail.setJobDataMap(jobDataMap);

    // Simulate job lock service
    String lockToken = "token";
    when(mockJobLockService.getLock(isA(QName.class), anyLong()))
            .thenReturn(lockToken)                                    // first job gets the lock
            .thenThrow(new LockAcquisitionException("", ""));         // second job doesn't get the lock

    // Run two heart beat jobs
    new HeartBeatJob().execute(mockJobExecutionContext);
    new HeartBeatJob().execute(mockJobExecutionContext);

    // Verify that the collector only collects data once, since only one job got the lock
    verify(simpleCollector, Mockito.times(1)).collectData();
    // Verify that data was passed to data sender
    verify(mockDataSenderService, Mockito.times(1)).sendData(any(List.class));
    verify(mockDataSenderService, Mockito.times(0)).sendData(any(HBData.class));
    // Verify that both jobs tried to get the lock
    verify(mockJobLockService, Mockito.times(2)).getLock(any(QName.class), anyLong());
    // Verify that a callback was registered once
    verify(mockJobLockService, Mockito.times(1)).refreshLock(eq(lockToken), any(QName.class),
            anyLong(),
            any(JobLockService.JobLockRefreshCallback.class));
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:41,代碼來源:HeartBeatJobTest.java

示例5: scheduleJobs

import org.quartz.JobDetail; //導入方法依賴的package包/類
private void scheduleJobs() throws ParseException, SchedulerException {
  if (log.isDebugEnabled()) log.debug("Creating jobs for buildID: " + activeBuildID);
  if (buildRunner == null) throw new SchedulerException("Build runner for scheduler is undefined");
  if (!triggerKeyList.isEmpty()) throw new SchedulerException("Jobs should be unscheduled before scheduling jobs.");

  // create schedule triggers for this build
  if (log.isDebugEnabled()) log.debug("Creating schedule triggers for buildID: " + activeBuildID);
  int nameIndex = 0;

  final List itemList = ConfigurationManager.getInstance().getScheduleItems(activeBuildID);
  for (final Iterator iter = itemList.iterator(); iter.hasNext();) {

    // create trigger
    final ScheduleItem scheduleItem = (ScheduleItem) iter.next();
    final CronTrigger[] triggers = makeCronTriggers(activeBuildID, scheduleItem);

    // go through the list of triggers
    for (int i = 0; i < triggers.length; i++) {

      final CronTrigger trigger = triggers[i];
      trigger.setName(makeTriggerName(nameIndex));
      final TriggerKey key = new TriggerKey(trigger.getName(), trigger.getGroup());
      triggerKeyList.add(key);

      // make job detail
      final JobDetail jobDetail = makeJobDetail(activeBuildID, RepeatableScheduleJob.class);
      jobDetail.setName(makeJobName(nameIndex));

      // set build parameters
      final JobDataMap dataMap = new JobDataMap();
      dataMap.put(RepeatableScheduleJob.BUILD_ID_KEY, activeBuildID);
      dataMap.put(RepeatableScheduleJob.BUILD_RUNNER_KEY, buildRunner);
      dataMap.put(RepeatableScheduleJob.CLEAN_CHECKOUT_COUNTER, cleanCheckoutCounter);
      dataMap.put(RepeatableScheduleJob.FORCE_CLEAN_CHECKOUT, Boolean.valueOf(scheduleItem.isCleanCheckout()));
      dataMap.put(RepeatableScheduleJob.RUN_IF_NO_CHANGES, Boolean.valueOf(scheduleItem.isRunIfNoChanges()));
      jobDetail.setJobDataMap(dataMap);

      // schedule
      if (log.isDebugEnabled()) log.debug("Scheduling job for buildID: " + activeBuildID);
      scheduler.scheduleJob(jobDetail, trigger);
      nameIndex++;
    }
  }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:45,代碼來源:RepeatableScheduler.java


注:本文中的org.quartz.JobDetail.setJobDataMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。