EMMA Coverage Report (generated Thu Jan 24 13:37:04 CST 2013)
[all classes][org.springframework.batch.core.job.flow]

COVERAGE SUMMARY FOR SOURCE FILE [FlowStep.java]

nameclass, %method, %block, %line, %
FlowStep.java100% (1/1)60%  (3/5)25%  (19/75)35%  (7/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FlowStep100% (1/1)60%  (3/5)25%  (19/75)35%  (7/20)
FlowStep (Flow): void 0%   (0/1)0%   (0/5)0%   (0/2)
doExecute (StepExecution): void 0%   (0/1)0%   (0/51)0%   (0/11)
FlowStep (): void 100% (1/1)100% (4/4)100% (2/2)
afterPropertiesSet (): void 100% (1/1)100% (11/11)100% (3/3)
setFlow (Flow): void 100% (1/1)100% (4/4)100% (2/2)

1package org.springframework.batch.core.job.flow;
2 
3import org.springframework.batch.core.JobExecutionException;
4import org.springframework.batch.core.StepExecution;
5import org.springframework.batch.core.job.SimpleStepHandler;
6import org.springframework.batch.core.job.StepHandler;
7import org.springframework.batch.core.repository.JobRepository;
8import org.springframework.batch.core.step.AbstractStep;
9import org.springframework.util.Assert;
10 
11import com.sun.org.apache.xerces.internal.impl.xpath.XPath.Step;
12 
13/**
14 * A {@link Step} implementation that delegates to a {@link Flow}. Useful for
15 * logical grouping of steps, and especially for partitioning with multiple
16 * steps per execution. If the flow has steps then when the {@link FlowStep}
17 * executes, all steps including the parent {@link FlowStep} will have
18 * executions in the {@link JobRepository} (one for the parent and one each for
19 * the flow steps).
20 * 
21 * @author Dave Syer
22 * 
23 */
24public class FlowStep extends AbstractStep {
25 
26        private Flow flow;
27 
28        /**
29         * Default constructor convenient for configuration purposes.
30         */
31        public FlowStep() {
32                super(null);
33        }
34 
35        /**
36         * Constructor for a {@link FlowStep} that sets the flow and of the step
37         * explicitly.
38         */
39        public FlowStep(Flow flow) {
40                super(flow.getName());
41        }
42 
43        /**
44         * Public setter for the flow.
45         * 
46         * @param flow the flow to set
47         */
48        public void setFlow(Flow flow) {
49                this.flow = flow;
50        }
51 
52        /**
53         * Ensure that the flow is set.
54         * @see AbstractStep#afterPropertiesSet()
55         */
56        @Override
57        public void afterPropertiesSet() throws Exception {
58                super.afterPropertiesSet();
59                Assert.state(flow != null, "A Flow must be provided");
60        }
61 
62        /**
63         * Delegate to the flow provided for the execution of the step.
64         * 
65         * @see AbstractStep#doExecute(StepExecution)
66         */
67        @Override
68        protected void doExecute(StepExecution stepExecution) throws Exception {
69                try {
70                        StepHandler stepHandler = new SimpleStepHandler(getJobRepository(), stepExecution.getExecutionContext());
71                        FlowExecutor executor = new JobFlowExecutor(getJobRepository(), stepHandler, stepExecution.getJobExecution());
72                        executor.updateJobExecutionStatus(flow.start(executor).getStatus());
73                        stepExecution.upgradeStatus(executor.getJobExecution().getStatus());
74                        stepExecution.setExitStatus(executor.getJobExecution().getExitStatus());
75                }
76                catch (FlowExecutionException e) {
77                        if (e.getCause() instanceof JobExecutionException) {
78                                throw (JobExecutionException) e.getCause();
79                        }
80                        throw new JobExecutionException("Flow execution ended unexpectedly", e);
81                }
82        }
83 
84}

[all classes][org.springframework.batch.core.job.flow]
EMMA 2.0.5312 (C) Vladimir Roubtsov