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


Java JobDataMap.containsKey方法代碼示例

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


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

示例1: execute

import org.quartz.JobDataMap; //導入方法依賴的package包/類
public void execute(JobExecutionContext context)
    throws JobExecutionException {

    JobDataMap data = context.getMergedJobDataMap();
    
    String command = data.getString(PROP_COMMAND);

    String parameters = data.getString(PROP_PARAMETERS);

    if (parameters == null) {
        parameters = "";
    }

    boolean wait = true;
    if(data.containsKey(PROP_WAIT_FOR_PROCESS)) {
        wait = data.getBooleanValue(PROP_WAIT_FOR_PROCESS);
    }
    boolean consumeStreams = false;
    if(data.containsKey(PROP_CONSUME_STREAMS)) {
        consumeStreams = data.getBooleanValue(PROP_CONSUME_STREAMS);
    }
        
    Integer exitCode = this.runNativeCommand(command, parameters, wait, consumeStreams);
    context.setResult(exitCode);
    
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:27,代碼來源:NativeJob.java

示例2: execute

import org.quartz.JobDataMap; //導入方法依賴的package包/類
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    final int numberOfRetries;
    JobDataMap jobDataMap = context.getMergedJobDataMap();
    numberOfRetries = jobDataMap.containsKey(NUMBER_OF_RETRIES_PARAM) ?
            jobDataMap.getIntValue(NUMBER_OF_RETRIES_PARAM) : DEFAULT_NUMBER_OF_RETRIES;
    //check if running job class has the "NonRetryable" annotation
    boolean isRetryable = jobDataMap.containsKey(Constants.JOB_DEFINITION) ?
            ((JobDefinition)jobDataMap.get(Constants.JOB_DEFINITION)).isRetryable() : true;
    try {
        job.execute(context);
        //reset retry param, just in case
        jobDataMap.putAsString(NUMBER_OF_RETRIES_PARAM, 0);
    } catch (Exception e) {
        //do not retry if job is not retryable or no more retries left
        if (!isRetryable || numberOfRetries <= 0) {
            throwAndFinish(jobDataMap, context, e);
        }
        triggerRefire(jobDataMap, numberOfRetries, context, e);
    } catch (Throwable t) {
        //do not retry on throwable
        throwAndFinish(jobDataMap, context, t);
    }
}
 
開發者ID:taboola,項目名稱:taboola-cronyx,代碼行數:25,代碼來源:ErrorHandlingJob.java

示例3: triggerRefire

import org.quartz.JobDataMap; //導入方法依賴的package包/類
private void triggerRefire(JobDataMap jobDataMap, int numberOfRetries, JobExecutionContext context, Throwable t)
        throws JobExecutionException {
    final long sleepTimeBetweenRetries = jobDataMap.containsKey(SLEEP_TIME_BETWEEN_RETRIES_PARAM) ?
            jobDataMap.getLongValue(SLEEP_TIME_BETWEEN_RETRIES_PARAM) : DEFAULT_SLEEP_TIME_BETWEEN_RETRIES;
    try {
        Thread.sleep(sleepTimeBetweenRetries);
    } catch (InterruptedException e) {}
    context.put(Constants.JOB_EXCEPTION, t);
    jobDataMap.putAsString(NUMBER_OF_RETRIES_PARAM, --numberOfRetries);
    //set refire flag as true
    throw new JobExecutionException(t, true);
}
 
開發者ID:taboola,項目名稱:taboola-cronyx,代碼行數:13,代碼來源:ErrorHandlingJob.java

示例4: execute

import org.quartz.JobDataMap; //導入方法依賴的package包/類
public void execute(JobExecutionContext context) throws JobExecutionException {
	JobDataMap map=context.getJobDetail().getJobDataMap();
	if(map.containsKey("overdueDays")){
		int overdueDays=map.getInt("overdueDays");
		Date createDate=(Date)map.get("createDate");
		if(defaultCalculateOverdueDays(overdueDays,createDate)){
			if(map.getBoolean("overdueMethodSendMessage")){
				executeRemind(map);											
			}else{
				String overdueCustomBeanProcessor=map.getString("overdueCustomBeanProcessor");
				ITaskOverdueProcessor processor=ContextHolder.getBean(overdueCustomBeanProcessor);
				processor.process(map.getString("taskId"));
				String reminderJobId=map.getString("reminderJobId");
				CancelReminderJobBean cancelReminderJobBean=ContextHolder.getBean(CancelReminderJobBean.BEAN_ID);
				cancelReminderJobBean.cancelReminderJob(reminderJobId);
			}
		}
	}else{
		executeRemind(map);			
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:22,代碼來源:TaskReminderJob.java

示例5: longOrDefault

import org.quartz.JobDataMap; //導入方法依賴的package包/類
private long longOrDefault(JobDataMap map, String key, long defaultValue) {
    try {
        if (map.containsKey(key)) {
            return map.getLongValue(key);
        }
    } catch (Exception e) {
        log.warn("Could not get long from {} -> {}", key, map.get(key));
    }
    return defaultValue;
}
 
開發者ID:quanticc,項目名稱:sentry,代碼行數:11,代碼來源:StreamPoller.java

示例6: doubleOrDefault

import org.quartz.JobDataMap; //導入方法依賴的package包/類
private double doubleOrDefault(JobDataMap map, String key, double defaultValue) {
    try {
        if (map.containsKey(key)) {
            return map.getDoubleValue(key);
        }
    } catch (Exception e) {
        log.warn("Could not get double from {} -> {}", key, map.get(key));
    }
    return defaultValue;
}
 
開發者ID:quanticc,項目名稱:sentry,代碼行數:11,代碼來源:StreamPoller.java

示例7: isValidDataMap

import org.quartz.JobDataMap; //導入方法依賴的package包/類
/**
 */
private boolean isValidDataMap(final JobDataMap dataMap) {
  if (dataMap.containsKey(BUILD_ID_KEY)) {
    return true;
  }
  reportErrorBuildNotFound();
  return false;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:10,代碼來源:RepeatableScheduleJob.java

示例8: jobWasExecuted

import org.quartz.JobDataMap; //導入方法依賴的package包/類
public void jobWasExecuted(JobExecutionContext context,
		JobExecutionException jobException) {
	JobDetail jobDetail = context.getJobDetail();
	if (!(jobDetail instanceof SpringBeanJobExecutorDetail)) {
		return;
	}
	JobDataMap map = jobDetail.getJobDataMap();
	if (!map.containsKey(IJobDefinitionService.JOB_DEFINITION_ID)) {
		return;
	}
	Date end = new Date();
	String exception = getExceptionStackMessage(jobException);
	JobHistory history = new JobHistory();
	history.setSuccessful(exception == null ? true : false);
	if (exception != null) {
		history.setExceptionMessage(exception.length() > 1500 ? exception
				.substring(0, 1500) : exception);
	}
	history.setEndDate(end);
	history.setStartDate((Date)map.get(START_DATE_KEY));
	history.setId(UUID.randomUUID().toString());
	history.setJobId(map.getString(IJobDefinitionService.JOB_DEFINITION_ID));
	Session session = getSessionFactory().openSession();
	try {
		session.save(history);
	} finally {
		session.flush();
		session.close();
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:31,代碼來源:JobExecutionHistoryListener.java

示例9: execute

import org.quartz.JobDataMap; //導入方法依賴的package包/類
/** 
 * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
 */
public void execute(JobExecutionContext context) throws JobExecutionException {
    JobDataMap mergedJobDataMap = context.getMergedJobDataMap();
    SchedulerContext schedCtxt = null;
    try {
        schedCtxt = context.getScheduler().getContext();
    } catch (SchedulerException e) {
        throw new JobExecutionException("Error obtaining scheduler context.", e, false);
    }
    
    String fileName = mergedJobDataMap.getString(FILE_NAME);
    String listenerName = mergedJobDataMap.getString(FILE_SCAN_LISTENER_NAME);
    
    if(fileName == null) {
        throw new JobExecutionException("Required parameter '" + 
                FILE_NAME + "' not found in merged JobDataMap");
    }
    if(listenerName == null) {
        throw new JobExecutionException("Required parameter '" + 
                FILE_SCAN_LISTENER_NAME + "' not found in merged JobDataMap");
    }

    FileScanListener listener = (FileScanListener)schedCtxt.get(listenerName);
    
    if(listener == null) {
        throw new JobExecutionException("FileScanListener named '" + 
                listenerName + "' not found in SchedulerContext");
    }
    
    long lastDate = -1;
    if(mergedJobDataMap.containsKey(LAST_MODIFIED_TIME)) {
        lastDate = mergedJobDataMap.getLong(LAST_MODIFIED_TIME);
    }
    
    long newDate = getLastModifiedDate(fileName);

    if(newDate < 0) {
        log.warn("File '"+fileName+"' does not exist.");
        return;
    }
    
    if(lastDate > 0 && (newDate != lastDate)) {
        // notify call back...
        log.info("File '"+fileName+"' updated, notifying listener.");
        listener.fileUpdated(fileName); 
    } else if (log.isDebugEnabled()) {
        log.debug("File '"+fileName+"' unchanged.");
    }
    
    // It is the JobDataMap on the JobDetail which is actually stateful
    context.getJobDetail().getJobDataMap().put(LAST_MODIFIED_TIME, newDate);
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:55,代碼來源:FileScanJob.java


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