EMMA Coverage Report (generated Fri Jan 30 13:20:29 EST 2009)
[all classes][org.springframework.batch.core.step.tasklet]

COVERAGE SUMMARY FOR SOURCE FILE [TaskletStep.java]

nameclass, %method, %block, %line, %
TaskletStep.java100% (1/1)75%  (6/8)81%  (34/42)78%  (14/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TaskletStep100% (1/1)75%  (6/8)81%  (34/42)78%  (14/18)
setStepListeners (StepExecutionListener []): void 0%   (0/1)0%   (0/4)0%   (0/2)
setTasklet (Tasklet): void 0%   (0/1)0%   (0/4)0%   (0/2)
TaskletStep (): void 100% (1/1)100% (3/3)100% (2/2)
TaskletStep (Tasklet, JobRepository): void 100% (1/1)100% (9/9)100% (4/4)
afterPropertiesSet (): void 100% (1/1)100% (16/16)100% (5/5)
close (ExecutionContext): void 100% (1/1)100% (1/1)100% (1/1)
doExecute (StepExecution): ExitStatus 100% (1/1)100% (4/4)100% (1/1)
open (ExecutionContext): void 100% (1/1)100% (1/1)100% (1/1)

1/*
2 * Copyright 2006-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.springframework.batch.core.step.tasklet;
17 
18import org.springframework.batch.core.Step;
19import org.springframework.batch.core.StepExecution;
20import org.springframework.batch.core.StepExecutionListener;
21import org.springframework.batch.core.repository.JobRepository;
22import org.springframework.batch.core.step.AbstractStep;
23import org.springframework.batch.item.ExecutionContext;
24import org.springframework.batch.repeat.ExitStatus;
25import org.springframework.util.Assert;
26 
27/**
28 * A {@link Step} that executes a {@link Tasklet} directly. This step does not
29 * manage transactions or any looping functionality. The tasklet should do this
30 * on its own.
31 * 
32 * If the {@link Tasklet} itself implements {@link StepExecutionListener} it
33 * will be registered automatically, but its injected dependencies will not be.
34 * This is a good way to get access to job parameters and execution context if
35 * the tasklet is parameterized.
36 * 
37 * @author Ben Hale
38 * @author Robert Kasanicky
39 */
40public class TaskletStep extends AbstractStep {
41 
42        private Tasklet tasklet;
43 
44        /**
45         * Register each of the objects as listeners.
46         * 
47         * @deprecated use
48         * {@link #setStepExecutionListeners(StepExecutionListener[])} instead
49         */
50        public void setStepListeners(StepExecutionListener[] listeners) {
51                setStepExecutionListeners(listeners);
52        }
53 
54        /**
55         * Check mandatory properties.
56         * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
57         */
58        public void afterPropertiesSet() throws Exception {
59                super.afterPropertiesSet();
60                Assert.notNull(tasklet, "Tasklet is mandatory for TaskletStep");
61                if (tasklet instanceof StepExecutionListener) {
62                        registerStepExecutionListener((StepExecutionListener) tasklet);
63                }
64        }
65 
66        /**
67         * Default constructor is useful for XML configuration.
68         */
69        public TaskletStep() {
70                super();
71        }
72 
73        /**
74         * Creates a new <code>Step</code> for executing a <code>Tasklet</code>
75         * 
76         * @param tasklet The <code>Tasklet</code> to execute
77         * @param jobRepository The <code>JobRepository</code> to use for
78         * persistence of incremental state
79         */
80        public TaskletStep(Tasklet tasklet, JobRepository jobRepository) {
81                this();
82                this.tasklet = tasklet;
83                setJobRepository(jobRepository);
84        }
85 
86        /**
87         * Public setter for the {@link Tasklet}.
88         * @param tasklet the {@link Tasklet} to set
89         */
90        public void setTasklet(Tasklet tasklet) {
91                this.tasklet = tasklet;
92        }
93 
94        /**
95         * Delegate to tasklet.
96         */
97        protected ExitStatus doExecute(StepExecution stepExecution) throws Exception {
98                return tasklet.execute();
99        }
100 
101        protected void close(ExecutionContext ctx) throws Exception {
102        }
103 
104        protected void open(ExecutionContext ctx) throws Exception {
105        }
106 
107        
108 
109        
110 
111}

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