BatchSample.java
import static java.lang.System.out; import javax.batch.operations.JobOperator; import javax.batch.runtime.BatchRuntime; public final class BatchSample { public static void main(final String[] args) throws Exception { final JobOperator jobOperator = BatchRuntime.getJobOperator(); out.println(jobOperator.start("samplejob", null)); } }
SampleBatchlet.java
import javax.batch.api.AbstractBatchlet; public final class SampleBatchlet extends AbstractBatchlet { public String process() { return "COMPLETED"; } }
META-INF/batch-jobs/samplejob.xml
<?xml version="1.0" encoding="UTF-8"?> <job xmlns="http://xmlns.jcp.org/xml/ns/javaee" id="samplejob"> <step id="step1"> <batchlet ref="sampleBatchlet" /> <next on="COMPLETED" to="step2" /> <!-- go the "step2" if the exit status is "COMPLETED" --> </step> <step id="step2"> ... </step> </job>
META-INF/batch.xml
<?xml version="1.0" encoding="UTF-8"?> <batch-artifacts xmlns="http://xmlns.jcp.org/xml/ns/javaee"> <ref id="sampleBatchlet" class="SampleBatchlet" /> </batch-artifacts>
Advertisements