当前位置: 首页>>代码示例>>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;未经允许,请勿转载。