本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例7: isValidDataMap
import org.quartz.JobDataMap; //导入方法依赖的package包/类
/**
*/
private boolean isValidDataMap(final JobDataMap dataMap) {
if (dataMap.containsKey(BUILD_ID_KEY)) {
return true;
}
reportErrorBuildNotFound();
return false;
}
示例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();
}
}
示例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);
}