Java EE JSR 352 - Jberet 动态作业生成器和执行
Java EE JSR 352 - Jberet Dynamic Job Builder and Execution
从 Jberet 了解到 userguide 可以动态构建作业以替代静态 xml,但是该指南没有关于如何执行作业构建的任何输入,所以愿意知道如何执行工作。
Job job = new JobBuilder(jobName)
.restartable(false)
.property("jobk1", "J")
.property("jobk2", "J")
.listener("jobListener1", new String[]{"jobListenerk1", "#{jobParameters['jobListenerPropVal']}"},
new String[]{"jobListenerk2", "#{jobParameters['jobListenerPropVal']}"})
.step(new StepBuilder(stepName)
.properties(new String[]{"stepk1", "S"}, new String[]{"stepk2", "S"})
.batchlet(batchlet1Name, new String[]{"batchletk1", "B"}, new String[]{"batchletk2", "B"})
.listener("stepListener1", stepListenerProps)
.stopOn("STOP").restartFrom(stepName).exitStatus()
.endOn("END").exitStatus("new status for end")
.failOn("FAIL").exitStatus()
.nextOn("*").to(step2Name)
.build())
.step(new StepBuilder(step2Name)
.batchlet(batchlet1Name)
.build())
.build();
简而言之,您使用以下方法启动使用 Java JSL 创建的作业:
org.jberet.operations.AbstractJobOperator#start(org.jberet.job.model.Job, java.util.Properties)
版本 1.3.0 测试版
由于JavaJSL是一个额外的特性,你需要获取JobOperator的JBeret实现并调用上面的启动方法:
import org.jberet.job.model.Job;
import org.jberet.operations.JobOperatorImpl;
import org.jberet.spi.JobOperatorContext;
JobOperatorImpl jobOperator = (JobOperatorImpl) JobOperatorContext.getJobOperatorContext().getJobOperator();
Job job = new JobBuilder(jobName)
.step(new StepBuilder(stepName)
.reader(...)
.writer(...)
.build())
.build();
Properties params = null;
long jobExecutionId = jobOperator.start(job, params);
版本 1.2.0-Final
JobOperatorImpl jobOperator = (JobOperatorImpl) BatchRuntime.getJobOperator();
Properties jobProperties = new Properties();
long jobExecutionId = jobOperator.start(job, jobProperties);
有关详细信息,请参阅 JBeret sample app javaJSL, and code how to get JBeret job operator。
从 Jberet 了解到 userguide 可以动态构建作业以替代静态 xml,但是该指南没有关于如何执行作业构建的任何输入,所以愿意知道如何执行工作。
Job job = new JobBuilder(jobName)
.restartable(false)
.property("jobk1", "J")
.property("jobk2", "J")
.listener("jobListener1", new String[]{"jobListenerk1", "#{jobParameters['jobListenerPropVal']}"},
new String[]{"jobListenerk2", "#{jobParameters['jobListenerPropVal']}"})
.step(new StepBuilder(stepName)
.properties(new String[]{"stepk1", "S"}, new String[]{"stepk2", "S"})
.batchlet(batchlet1Name, new String[]{"batchletk1", "B"}, new String[]{"batchletk2", "B"})
.listener("stepListener1", stepListenerProps)
.stopOn("STOP").restartFrom(stepName).exitStatus()
.endOn("END").exitStatus("new status for end")
.failOn("FAIL").exitStatus()
.nextOn("*").to(step2Name)
.build())
.step(new StepBuilder(step2Name)
.batchlet(batchlet1Name)
.build())
.build();
简而言之,您使用以下方法启动使用 Java JSL 创建的作业:
org.jberet.operations.AbstractJobOperator#start(org.jberet.job.model.Job, java.util.Properties)
版本 1.3.0 测试版
由于JavaJSL是一个额外的特性,你需要获取JobOperator的JBeret实现并调用上面的启动方法:
import org.jberet.job.model.Job;
import org.jberet.operations.JobOperatorImpl;
import org.jberet.spi.JobOperatorContext;
JobOperatorImpl jobOperator = (JobOperatorImpl) JobOperatorContext.getJobOperatorContext().getJobOperator();
Job job = new JobBuilder(jobName)
.step(new StepBuilder(stepName)
.reader(...)
.writer(...)
.build())
.build();
Properties params = null;
long jobExecutionId = jobOperator.start(job, params);
版本 1.2.0-Final
JobOperatorImpl jobOperator = (JobOperatorImpl) BatchRuntime.getJobOperator();
Properties jobProperties = new Properties();
long jobExecutionId = jobOperator.start(job, jobProperties);
有关详细信息,请参阅 JBeret sample app javaJSL, and code how to get JBeret job operator。