本文整理汇总了Java中org.quartz.JobExecutionContext.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java JobExecutionContext.getResult方法的具体用法?Java JobExecutionContext.getResult怎么用?Java JobExecutionContext.getResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.JobExecutionContext
的用法示例。
在下文中一共展示了JobExecutionContext.getResult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
/**
* @param context {@link JobExecutionContext}
* @param jobException {@link JobExecutionException}
*/
@Trace(metricName = "JobListener{save}", async = true, dispatcher = true)
private void save(JobExecutionContext context, JobExecutionException jobException) throws IOException {
JobResult jobResult = (JobResult) context.getResult();
ExecutionStatusEntity.ExecutionStatusEntityBuilder builder = ExecutionStatusEntity.builder();
builder.created(new Date());
builder.nextFireTime(context.getNextFireTime());
builder.fireTime(context.getFireTime());
builder.jobRunTime(context.getJobRunTime());
builder.prevFireTime(context.getPreviousFireTime());
builder.scheduledFireTime(context.getScheduledFireTime());
if (jobResult != null && jobResult.getTmpFile() != null) {
builder.output(FileUtils.readFileToString(jobResult.getTmpFile().toFile()));
builder.exitCode(jobResult.getExitValue());
if (jobResult.getExitValue() != 0)
builder.errors(true);
if (jobResult.getTmpFile().toFile().delete())
logger.debug(String.format("%s file deleted", jobResult.getTmpFile().toAbsolutePath()));
} else {
builder.output("No output");
builder.exitCode(-1);
builder.errors(true);
}
if (jobException != null) {
builder.errors(true);
builder.errorMessage(jobException.getMessage());
}
builder.job(getJob());
executionStatusRepository.save(builder.build());
}
示例2: convert
import org.quartz.JobExecutionContext; //导入方法依赖的package包/类
public CronyxExecutionContext convert(JobExecutionContext context) {
String contextKey = context.get(CONTEXT_KEY).toString();
JobDefinition jobDef = (JobDefinition) context.getMergedJobDataMap().get(JOB_DEFINITION);
TriggerDefinition triggerDef = quartzToCronyxSelector.convert(context.getTrigger());
Instant scheduledTime = context.getScheduledFireTime().toInstant();
Instant actualTime = context.getFireTime().toInstant();
Map<String, Object> jobData = new HashMap<>(context.getMergedJobDataMap());
Throwable jobException = (Throwable) context.get(JOB_EXCEPTION);
Object jobResult = context.getResult();
int attemptNumber = context.getRefireCount() + 1;
return new CronyxExecutionContext(contextKey, jobDef, triggerDef, attemptNumber, scheduledTime,
actualTime, jobData, jobResult, jobException, FIRED);
}