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

COVERAGE SUMMARY FOR SOURCE FILE [ApplicationContextJobFactory.java]

nameclass, %method, %block, %line, %
ApplicationContextJobFactory.java100% (1/1)100% (3/3)100% (20/20)100% (6/6)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ApplicationContextJobFactory100% (1/1)100% (3/3)100% (20/20)100% (6/6)
ApplicationContextJobFactory (String, ApplicationContextFactory): void 100% (1/1)100% (13/13)100% (4/4)
createJob (): Job 100% (1/1)100% (3/3)100% (1/1)
getJobName (): String 100% (1/1)100% (4/4)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.configuration.support;
17 
18import org.springframework.batch.core.Job;
19import org.springframework.batch.core.configuration.JobFactory;
20import org.springframework.context.ApplicationContext;
21import org.springframework.context.ConfigurableApplicationContext;
22 
23/**
24 * A {@link JobFactory} that creates its own {@link ApplicationContext} and
25 * pulls a bean out when asked to create a {@link Job}.
26 * 
27 * @author Dave Syer
28 * 
29 */
30public class ApplicationContextJobFactory implements JobFactory {
31 
32        private final Job job;
33 
34        /**
35         * @param jobName the id of the {@link Job} in the application context to be
36         * created
37         * @param applicationContextFactory a factory for an application context
38         * containing a job with the job name provided
39         */
40        public ApplicationContextJobFactory(String jobName, ApplicationContextFactory applicationContextFactory) {
41                ConfigurableApplicationContext context = applicationContextFactory.createApplicationContext();
42                this.job = (Job) context.getBean(jobName, Job.class);
43        }
44 
45        /**
46         * Create an {@link ApplicationContext} from the factory provided and pull
47         * out a bean with the name given during initialization.
48         * 
49         * @see org.springframework.batch.core.configuration.JobFactory#createJob()
50         */
51        public final Job createJob() {
52                return job;
53        }
54        
55        /**
56         * Just return the name of instance passed in on initialization.
57         * 
58         * @see JobFactory#getJobName()
59         */
60        public String getJobName() {
61                return job.getName();
62        }
63 
64}

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