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

COVERAGE SUMMARY FOR SOURCE FILE [AbstractJob.java]

nameclass, %method, %block, %line, %
AbstractJob.java100% (1/1)82%  (14/17)68%  (85/125)78%  (27.4/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractJob100% (1/1)82%  (14/17)68%  (85/125)78%  (27.4/35)
AbstractJob (String): void 0%   (0/1)0%   (0/19)0%   (0/6)
registerJobExecutionListener (JobExecutionListener): void 0%   (0/1)0%   (0/5)0%   (0/2)
toString (): String 0%   (0/1)0%   (0/16)0%   (0/1)
AbstractJob (): void 100% (1/1)100% (16/16)100% (5/5)
addStep (Step): void 100% (1/1)100% (6/6)100% (2/2)
afterPropertiesSet (): void 100% (1/1)100% (5/5)100% (2/2)
getCompositeListener (): CompositeExecutionJobListener 100% (1/1)100% (3/3)100% (1/1)
getJobRepository (): JobRepository 100% (1/1)100% (3/3)100% (1/1)
getName (): String 100% (1/1)100% (3/3)100% (1/1)
getSteps (): List 100% (1/1)100% (3/3)100% (1/1)
isRestartable (): boolean 100% (1/1)100% (3/3)100% (1/1)
setBeanName (String): void 100% (1/1)100% (7/7)100% (3/3)
setJobExecutionListeners (JobExecutionListener []): void 100% (1/1)100% (15/15)100% (3/3)
setJobRepository (JobRepository): void 100% (1/1)100% (4/4)100% (2/2)
setName (String): void 100% (1/1)100% (4/4)100% (2/2)
setRestartable (boolean): void 100% (1/1)100% (4/4)100% (2/2)
setSteps (List): void 100% (1/1)100% (9/9)100% (3/3)

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 */
16 
17package org.springframework.batch.core.job;
18 
19import java.util.ArrayList;
20import java.util.List;
21 
22import org.springframework.batch.core.Job;
23import org.springframework.batch.core.JobExecutionListener;
24import org.springframework.batch.core.Step;
25import org.springframework.batch.core.listener.CompositeExecutionJobListener;
26import org.springframework.batch.core.repository.JobRepository;
27import org.springframework.beans.factory.BeanNameAware;
28import org.springframework.beans.factory.InitializingBean;
29import org.springframework.util.Assert;
30import org.springframework.util.ClassUtils;
31 
32/**
33 * Batch domain object representing a job. Job is an explicit abstraction
34 * representing the configuration of a job specified by a developer. It should
35 * be noted that restart policy is applied to the job as a whole and not to a
36 * step.
37 * 
38 * @author Lucas Ward
39 * @author Dave Syer
40 */
41public abstract class AbstractJob implements Job, BeanNameAware, InitializingBean {
42 
43        private List steps = new ArrayList();
44 
45        private String name;
46 
47        private boolean restartable = false;
48 
49        private JobRepository jobRepository;
50 
51        private CompositeExecutionJobListener listener = new CompositeExecutionJobListener();
52 
53        /**
54         * Default constructor.
55         */
56        public AbstractJob() {
57                super();
58        }
59 
60        /**
61         * Convenience constructor to immediately add name (which is mandatory but
62         * not final).
63         * 
64         * @param name
65         */
66        public AbstractJob(String name) {
67                super();
68                this.name = name;
69        }
70 
71        /**
72         * Set the name property if it is not already set. Because of the order of
73         * the callbacks in a Spring container the name property will be set first
74         * if it is present. Care is needed with bean definition inheritance - if a
75         * parent bean has a name, then its children need an explicit name as well,
76         * otherwise they will not be unique.
77         * 
78         * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
79         */
80        public void setBeanName(String name) {
81                if (this.name == null) {
82                        this.name = name;
83                }
84        }
85 
86        /**
87         * Set the name property. Always overrides the default value if this object
88         * is a Spring bean.
89         * 
90         * @see #setBeanName(java.lang.String)
91         */
92        public void setName(String name) {
93                this.name = name;
94        }
95 
96        /* (non-Javadoc)
97         * @see org.springframework.batch.core.domain.IJob#getName()
98         */
99        public String getName() {
100                return name;
101        }
102 
103        /* (non-Javadoc)
104         * @see org.springframework.batch.core.domain.IJob#getSteps()
105         */
106        public List getSteps() {
107                return steps;
108        }
109 
110        public void setSteps(List steps) {
111                this.steps.clear();
112                this.steps.addAll(steps);
113        }
114 
115        public void addStep(Step step) {
116                this.steps.add(step);
117        }
118 
119        public void setRestartable(boolean restartable) {
120                this.restartable = restartable;
121        }
122 
123        /* (non-Javadoc)
124         * @see org.springframework.batch.core.domain.IJob#isRestartable()
125         */
126        public boolean isRestartable() {
127                return restartable;
128        }
129 
130        public String toString() {
131                return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]";
132        }
133 
134        /**
135         * Public setter for injecting {@link JobExecutionListener}s. They will all
136         * be given the listener callbacks at the appropriate point in the job.
137         * 
138         * @param listeners the listeners to set.
139         */
140        public void setJobExecutionListeners(JobExecutionListener[] listeners) {
141                for (int i = 0; i < listeners.length; i++) {
142                        this.listener.register(listeners[i]);
143                }
144        }
145 
146        /**
147         * Register a single listener for the {@link JobExecutionListener}
148         * callbacks.
149         * 
150         * @param listener a {@link JobExecutionListener}
151         */
152        public void registerJobExecutionListener(JobExecutionListener listener) {
153                this.listener.register(listener);
154        }
155 
156        /**
157         * Public setter for the {@link JobRepository} that is needed to manage the
158         * state of the batch meta domain (jobs, steps, executions) during the life
159         * of a job.
160         * 
161         * @param jobRepository
162         */
163        public void setJobRepository(JobRepository jobRepository) {
164                this.jobRepository = jobRepository;
165        }
166        
167        public void afterPropertiesSet() throws Exception {
168                Assert.notNull(getJobRepository(), "JobRepository must be set");
169        }
170 
171        protected JobRepository getJobRepository() {
172                return jobRepository;
173        }
174 
175        protected CompositeExecutionJobListener getCompositeListener() {
176                return listener;
177        }
178}

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