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


Java JobDataMap.put方法代碼示例

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


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

示例1: updateMethodInovkeJob

import org.quartz.JobDataMap; //導入方法依賴的package包/類
public JobDetail updateMethodInovkeJob(String schedulerName, String jobName, String jobGroup, String jobClass,
                                    Object[] constructorArguments, String jobClassMethodName,
                                    Object[] jobClassMethodArgs, String description) throws SchedulerException {
    Assert.notNull(jobClass, "jobClass can not be null");
    Assert.notEmpty(schedulerName, "schedulerName can not be empty");
    Assert.notEmpty(jobName, "jobName can not be empty");
    Assert.notEmpty(jobGroup, "jobGroup can not be empty");
    Assert.notEmpty(jobClassMethodName, "jobClassMethodName can not be empty");
    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.put("jobClass", jobClass);
    jobDataMap.put("constructorArguments", constructorArguments);
    jobDataMap.put("jobClassMethodName", jobClassMethodName);
    jobDataMap.put("jobClassMethodArgs", jobClassMethodArgs);
    JobDetail jobDetail = JobBuilder.newJob(MethodInvokeJob.class).withIdentity(jobName, jobGroup)
            .withDescription(description).setJobData(jobDataMap).storeDurably().build();
    updateJob(schedulerName, jobDetail);
    return jobDetail;
}
 
開發者ID:quartzweb,項目名稱:quartz-web,代碼行數:19,代碼來源:QuartzManager.java

示例2: processUserMessage

import org.quartz.JobDataMap; //導入方法依賴的package包/類
private void processUserMessage(String messageContent, SlackUser messageSender, SlackSession session, SlackChannel channel) {
    // TODO change it to be processed asynchronously
    // Parse the message content
    String parsedMessage = parseMessage(messageContent);

    if (parsedMessage != null) {
        logger.info("=> Received message from amigo bot:" + parsedMessage);
        try {
            // Some unique job name
            String jobName = "SLACK-MESG-JOB-" + UUID.randomUUID().toString();
            String groupName = JOB_GRP_SLACKBOT;
            JobDataMap params = new JobDataMap();
            params.put(JOB_PARAM_MESSAGE, parsedMessage);
            params.put(JOB_PARAM_MSG_SENDER, messageSender);
            params.put(JOB_PARAM_SLACK_SESSION, session);
            params.put(JOB_PARAM_SLACK_CHANNEL, channel);
            params.put(JOB_PARAM_BOT_TOK, System.getenv("SLACK_BOT_TOKEN"));
            logger.info("Processing message async with params: " + params);
            JobManager.getInstance().scheduleJob(SlackMessageProcessorJob.class, jobName, groupName, params);

        } catch (Exception e) {
            logger.log(Level.SEVERE, "Error in processing message", e);
        }
    }
}
 
開發者ID:sjsucohort6,項目名稱:amigo-chatbot,代碼行數:26,代碼來源:MessageListener.java

示例3: processMessageAsync

import org.quartz.JobDataMap; //導入方法依賴的package包/類
private void processMessageAsync(String value) {
    if (value != null && !value.trim().isEmpty()) {
        try {
            // Some unique job name
            String jobName = "CP-MESG-JOB-" + UUID.randomUUID().toString();
            String groupName = JOB_GRP_CP;
            JobDataMap params = new JobDataMap();
            params.put(JOB_PARAM_MESSAGE, value);
            params.put(JOB_PARAM_DBCLIENT, dbClient);
            JobManager.getInstance().scheduleJob(MessageProcessorJob.class, jobName, groupName, params);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:sjsucohort6,項目名稱:amigo-chatbot,代碼行數:17,代碼來源:ConsumerLoop.java

示例4: createJob

import org.quartz.JobDataMap; //導入方法依賴的package包/類
/**
 * Create Quartz Job.
 * 
 * @param jobClass Class whose executeInternal() method needs to be called. 
 * @param isDurable Job needs to be persisted even after completion. if true, job will be persisted, not otherwise. 
 * @param context Spring application context.
 * @param jobName Job name.
 * @param jobGroup Job group.
 * 
 * @return JobDetail object
 */
protected static JobDetail createJob(Class<? extends QuartzJobBean> jobClass, boolean isDurable, 
		ApplicationContext context, String jobName, String jobGroup){
    JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
    factoryBean.setJobClass(jobClass);
    factoryBean.setDurability(isDurable);
    factoryBean.setApplicationContext(context);
    factoryBean.setName(jobName);
    factoryBean.setGroup(jobGroup);
       
    // set job data map
       JobDataMap jobDataMap = new JobDataMap();
       jobDataMap.put("myKey", "myValue");
       factoryBean.setJobDataMap(jobDataMap);
       
       factoryBean.afterPropertiesSet();
       
    return factoryBean.getObject();
}
 
開發者ID:javabypatel,項目名稱:spring-boot-quartz-demo,代碼行數:30,代碼來源:JobUtil.java

示例5: convert

import org.quartz.JobDataMap; //導入方法依賴的package包/類
@Override
public Trigger convert(After trigger) {
    OnDemandScheduleBuilder onDemandScheduleBuilder = OnDemandScheduleBuilder.onDemandSchedule();

    JobDataMap dataMap = new JobDataMap(trigger.getTriggerData());
    dataMap.put(Constants.CRONYX_TYPE, After.class);

    return newTrigger()
            .withIdentity(trigger.getTriggerKey().getName(), trigger.getTriggerKey().getGroup())
            .forJob(trigger.getJobKey().getName(), trigger.getJobKey().getGroup())
            .withDescription(trigger.getDescription())
            .withSchedule(onDemandScheduleBuilder)
            .usingJobData(dataMap)
            .build();
}
 
開發者ID:taboola,項目名稱:taboola-cronyx,代碼行數:16,代碼來源:AfterConverter.java

示例6: newJobDataMap

import org.quartz.JobDataMap; //導入方法依賴的package包/類
public static JobDataMap newJobDataMap(Map<String, Object> map) {
    JobDataMap jobDataMap = new JobDataMap();

    if(map != null) {
        for (final Iterator<String> pos = map.keySet().iterator(); pos.hasNext();) {
            String key = pos.next();
            jobDataMap.put(key, map.get(key));
        }
    }
    
    return jobDataMap;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:JobDataMapSupport.java

示例7: startScheduler

import org.quartz.JobDataMap; //導入方法依賴的package包/類
private void startScheduler() throws SchedulerException {
      log.warn("Starting scheduler (pid:" + ServerUtil.getCurrentPid() + ")");
      Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
      scheduler.start();

      JobDataMap jobDataMap = new JobDataMap();
      jobDataMap.put(ApiFactoryService.class.getName(), this.apiFactoryService);
      jobDataMap.put(DistributedApplianceConformJobFactory.class.getName(), this.daConformJobFactory);
      jobDataMap.put(DeploymentSpecConformJobFactory.class.getName(), this.dsConformJobFactory);
      jobDataMap.put(SecurityGroupConformJobFactory.class.getName(), this.sgConformJobFactory);
      jobDataMap.put(ManagerConnectorConformJobFactory.class.getName(), this.mcConformJobFactory);


      JobDetail syncDaJob = JobBuilder.newJob(SyncDistributedApplianceJob.class).usingJobData(jobDataMap).build();
      JobDetail syncSgJob = JobBuilder.newJob(SyncSecurityGroupJob.class).usingJobData(jobDataMap).build();

// TODO: Remove the delay, once plugin state listener is implemented.
      // Related issue: https://github.com/opensecuritycontroller/osc-core/issues/545
Trigger syncDaJobTrigger = TriggerBuilder.newTrigger()
		.startAt(Date.from(Instant.now().plusSeconds(SERVER_SYNC_DELAY))).withSchedule(SimpleScheduleBuilder
		.simpleSchedule().withIntervalInMinutes(this.scheduledSyncInterval).repeatForever()).build();

Trigger syncSgJobTrigger = TriggerBuilder.newTrigger()
		.startAt(Date.from(Instant.now().plusSeconds(SERVER_SYNC_DELAY))).withSchedule(SimpleScheduleBuilder
		.simpleSchedule().withIntervalInMinutes(this.scheduledSyncInterval).repeatForever()).build();

      scheduler.scheduleJob(syncDaJob, syncDaJobTrigger);
      scheduler.scheduleJob(syncSgJob, syncSgJobTrigger);

      this.archiveService.maybeScheduleArchiveJob();
  }
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:32,代碼來源:Server.java

示例8: buildTrigger

import org.quartz.JobDataMap; //導入方法依賴的package包/類
/**
 * Convenience method for building a Trigger
 * 
 * @return the Trigger associated with this descriptor
 */
public Trigger buildTrigger() {
	// @formatter:off
	if (!isEmpty(cron)) {
		if (!isValidExpression(cron))
			throw new IllegalArgumentException("Provided expression " + cron + " is not a valid cron expression");
		return newTrigger()
				.withIdentity(buildName(), group)
				.withSchedule(cronSchedule(cron)
						.withMisfireHandlingInstructionFireAndProceed()
						.inTimeZone(TimeZone.getTimeZone(systemDefault())))
				.usingJobData("cron", cron)
				.build();
	} else if (!isEmpty(fireTime)) {
		JobDataMap jobDataMap = new JobDataMap();
		jobDataMap.put("fireTime", fireTime);
		return newTrigger()
				.withIdentity(buildName(), group)
				.withSchedule(simpleSchedule()
						.withMisfireHandlingInstructionNextWithExistingCount())
				.startAt(Date.from(fireTime.atZone(systemDefault()).toInstant()))
				.usingJobData(jobDataMap)
				.build();
	}
	// @formatter:on
	throw new IllegalStateException("unsupported trigger descriptor " + this);
}
 
開發者ID:juliuskrah,項目名稱:quartz-manager,代碼行數:32,代碼來源:TriggerDescriptor.java

示例9: createJobDetail

import org.quartz.JobDataMap; //導入方法依賴的package包/類
static JobDetailImpl createJobDetail(RollupTask task, KairosDatastore dataStore, String hostName)
{
	JobDetailImpl jobDetail = new JobDetailImpl();
	jobDetail.setJobClass(RollUpJob.class);
	jobDetail.setKey(getJobKey(task));

	JobDataMap map = new JobDataMap();
	map.put("task", task);
	map.put("datastore", dataStore);
	map.put("hostName", hostName);
	jobDetail.setJobDataMap(map);
	return jobDetail;
}
 
開發者ID:quqiangsheng,項目名稱:abhot,代碼行數:14,代碼來源:RollUpManager.java

示例10: scheduleRecoveryIfNeeded

import org.quartz.JobDataMap; //導入方法依賴的package包/類
private void scheduleRecoveryIfNeeded(TriggerWrapper tw, FiredTrigger recovering) {
  JobWrapper jobWrapper = jobFacade.get(tw.getJobKey());

  if (jobWrapper == null) {
    getLog().error("No job found for orphaned trigger: " + tw);
    return;
  }

  if (jobWrapper.requestsRecovery()) {
    OperableTrigger recoveryTrigger = createRecoveryTrigger(tw, jobWrapper, "recover_" + terracottaClientId + "_"
                                                                        + ftrCtr++, recovering);

    JobDataMap jd = tw.getTriggerClone().getJobDataMap();
    jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_NAME, tw.getKey().getName());
    jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_GROUP, tw.getKey().getGroup());
    jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_FIRETIME_IN_MILLISECONDS, String.valueOf(recovering.getFireTime()));
    jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_SCHEDULED_FIRETIME_IN_MILLISECONDS, String.valueOf(recovering.getScheduledFireTime()));

    recoveryTrigger.setJobDataMap(jd);
    recoveryTrigger.computeFirstFireTime(null);

    try {
      storeTrigger(recoveryTrigger, false);
      if (!tw.mayFireAgain()) {
        removeTrigger(tw.getKey());
      }
      getLog().info("Recovered job " + jobWrapper + " for trigger " + tw);
    } catch (JobPersistenceException e) {
      getLog().error("Can't recover job " + jobWrapper + " for trigger " + tw, e);
    }
  }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:DefaultClusteredJobStore.java

示例11: addQuartzJob

import org.quartz.JobDataMap; //導入方法依賴的package包/類
/**
 * 添加繼承自 org.quartz.Job的類的方法
 * @param schedulerName
 * @param jobName
 * @param jobGroup
 * @param jobClass
 * @param jobDataMap
 * @param description
 * @return
 */
private JSONResult addQuartzJob(String schedulerName, String jobName, String jobGroup, String jobClass,
                                Map<String, Object> jobDataMap, String description) {
    try {
        Assert.notEmpty(schedulerName, "schedulerName can not be empty");
        Assert.notEmpty(jobName, "jobName can not be empty");
        Assert.notEmpty(jobGroup, "jobGroup can not be empty");
        if (!QuartzWebManager.checkClass(jobClass)) {
            throw new IllegalArgumentException("jobClass no class found [" + jobClass + "] exception");
        }
        Class beanClass = QuartzWebManager.getClass(jobClass);

        if (org.quartz.Job.class.isAssignableFrom(beanClass)) {
            // 開始添加job
            JobDataMap jobMap = new JobDataMap();
            if (jobDataMap != null) {
                for (Map.Entry<String, Object> entry : jobDataMap.entrySet()) {
                    if (!StringUtils.isEmpty(entry.getKey())) {
                        jobMap.put(entry.getKey(), entry.getValue());
                    }
                }
            }

            JobDetail jobDetail = JobBuilder.newJob(beanClass).withIdentity(jobName, jobGroup)
                    .withDescription(description).setJobData(jobMap).storeDurably().build();
            if (!QuartzWebManager.checkJobExist(schedulerName, jobName, jobGroup)) {
                QuartzWebManager.addJob(schedulerName, jobDetail);
            } else {
                QuartzWebManager.updateJob(schedulerName, jobDetail);
            }
            return JSONResult.build(JSONResult.RESULT_CODE_SUCCESS, "ok");
        } else {
            throw new UnsupportedClassException(jobClass + " must extends org.quartz.Job ");
        }
    } catch (Exception e) {
        e.printStackTrace();
        return JSONResult.build(JSONResult.RESULT_CODE_ERROR, e.getMessage());
    }
}
 
開發者ID:quartzweb,項目名稱:quartz-web,代碼行數:49,代碼來源:JobServiceStrategy.java

示例12: setupTimer

import org.quartz.JobDataMap; //導入方法依賴的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

示例13: newJobDataMap

import org.quartz.JobDataMap; //導入方法依賴的package包/類
public static JobDataMap newJobDataMap(TabularData tabularData) {
	JobDataMap jobDataMap = new JobDataMap();

	for (final Iterator pos = tabularData.values().iterator(); pos
			.hasNext();) {
		CompositeData cData = (CompositeData) pos.next();
		jobDataMap.put((String) cData.get("key"), (String) cData
				.get("value"));
	}

	return jobDataMap;
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:13,代碼來源:JobDataMapSupport.java

示例14: testJobLocking

import org.quartz.JobDataMap; //導入方法依賴的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

示例15: maybeScheduleArchiveJob

import org.quartz.JobDataMap; //導入方法依賴的package包/類
/**
 * Schedule the archiving job based on the interval defined in the DB.
 *
 * If archiving is disabled, deletes the archiving job.
 */
@Override
public void maybeScheduleArchiveJob() {
    try {
        BaseDtoResponse<JobsArchiveDto> reponse = this.jobsArchiveService.dispatch(new Request() {
        });

        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        boolean doesJobExists = scheduler.checkExists(new JobKey(ARCHIVE_JOB_NAME,
                ARCHIVE_GROUP_NAME));

        if (reponse.getDto().getAutoSchedule() && !doesJobExists) {
            JobDataMap jobDataMap = new JobDataMap();
            jobDataMap.put(GetJobsArchiveServiceApi.class.getName(), this.jobsArchiveService);
            jobDataMap.put(ArchiveServiceApi.class.getName(), this);

            JobDetail archiveJob = JobBuilder.newJob(ArchiveScheduledJob.class)
                    .usingJobData(jobDataMap)
                    .withIdentity(ARCHIVE_JOB_NAME, ARCHIVE_GROUP_NAME).build();

            Trigger archiveTrigger = TriggerBuilder
                    .newTrigger()
                    .startAt(DateUtils.addMinutes(new Date(), ARCHIVE_STARTUP_DELAY_IN_MIN))
                    .withSchedule(
                            SimpleScheduleBuilder.simpleSchedule().withIntervalInHours(24).repeatForever()
                            .withMisfireHandlingInstructionFireNow()).build();

            scheduler.scheduleJob(archiveJob, archiveTrigger);

            log.info("Archiving job check is scheduled to run every 24 hours. Starting at: "
                    + archiveTrigger.getStartTime());

        } else if (!reponse.getDto().getAutoSchedule()) {
            // If archiving is disabled, delete the job if it exists
            if (scheduler.deleteJob(new JobKey(ArchiveScheduledJob.ARCHIVE_JOB_NAME, ARCHIVE_GROUP_NAME))) {
                log.info("Archiving job Deleted");
            }
        }
    } catch (Exception e) {
        log.error("Scheduler fail to start/stop Archiving job", e);
        this.alertGenerator.processSystemFailureEvent(SystemFailureType.ARCHIVE_FAILURE,
                new LockObjectReference(1L, "Archive Settings", ObjectType.ARCHIVE),
                "Failure during archive schedule configuration " + e.getMessage());
    }
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:50,代碼來源:ArchiveService.java


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