EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[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)33%  (27/83)41%  (9/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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