我有一个春季批处理作业,我在其中放置了一个文件名作为作业参数,我需要在决策程序中使用此参数。
我的决定者:
public class MyDecider implements JobExecutionDecider
{
public FlowExecutionStatus decide(JobExecution jobExecution,
org.springframework.batch.core.StepExecution stepExecution)
{
String fileName=jobExecution.getExecutionContext().getString("file");
System.out.println(" filae name from step execution : "+fileName);
FileRead fileRead=new FileRead();
if (fileName.equals("aaaa"))
{
return FlowExecutionStatus.COMPLETED;
}
else
{
return FlowExecutionStatus.FAILED;
}
}
}
答案 0 :(得分:1)
JobExecutionDecider#decide
方法使用类型为JobExecution
的参数,该参数允许您使用JobExecution.getJobParameters
获取作业参数。这是一个简单的示例:
class MyDecider implements JobExecutionDecider {
@Override
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
JobParameters jobParameters = jobExecution.getJobParameters();
// get the job parameter from jobParameters
return null; // return the FlowExecutionStatus as needed
}
}