Java Reference
In-Depth Information
JobExecution . This is a runtime context for a version of the job . Ideally, for every JobInstance there'd be
only one JobExecution : the JobExecution that was created the first time the JobInstance ran. However, if
there were any errors, the JobInstance should be restarted; the subsequent run would create another
JobExecution . For every step in the original job , there is a StepExecution in the JobExecution .
Thus, you can see that Spring Batch has a mirrored object graph, one reflecting the design/build
time view of a job , and another reflecting the runtime view of a job . This split between the prototype and
the instance is very similar to the way many workflow engines work, including jBPM.
For example, suppose that a daily report is generated at 2 AM. The parameter to the job would be
the date (most likely the previous day's date). The job , in this case, would model a loading step , a
summary step , and an output step . Each day the job is run, a new JobInstance and JobExecution would
be created. If there are any retries of the same JobInstance , conceivably many JobExecution s would be
created.
9-1. Getting Started with the Spring Batch Distribution
Problem
You want to get started with Spring Batch, but the JARs aren't in the standard Spring framework
distribution.
Solution
You can use Maven or Ivy, or you can download them manually as a separate project. If you choose the
Maven/Ivy route or want to use OSGi, there are some things to consider.
How It Works
The simplest thing to do is to simply download the JARS from http://static.springsource.org/spr ing-
batch/ , as usual, and add the JARs provided to your classpath. If you decide you want to use OSGi, you
can use the SpringSource enterprise repository, which provides OSGi JARs. Be careful if you decide to
use those JARs with Maven, however, because they import all other SpringSource enterprise JARs for the
core Spring framework and other OSGi-friendly, third-party libraries. If you already have Spring and all
other packages imported, relying on the SpringSource enterprise JARs will yield two of every JAR in the
Spring framework! Yikes!
Instead, for Maven/Ivy, use the public ones available on the main Maven repositories. I included a
sample POM in the source code for this topic. I extract the salient dependency here. As of this writing,
Spring Batch 2.0 had just been released.
<dependency>
<groupId>org.springframework.batch</groupId>
<version>2.0.1.RELEASE</version>
<artifactId>spring-batch-core</artifactId>
</dependency>
Although all the Spring projects are pretty exhaustively documented, the Spring Batch project has a
notably large sampling of demonstration projects. For this reason alone it might be worth downloading
individually.
 
Search WWH ::




Custom Search