EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[all classes][org.springframework.batch.core.configuration.annotation]

COVERAGE SUMMARY FOR SOURCE FILE [DefaultBatchConfigurer.java]

nameclass, %method, %block, %line, %
DefaultBatchConfigurer.java100% (1/1)100% (9/9)92%  (68/74)92%  (23/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DefaultBatchConfigurer100% (1/1)100% (9/9)92%  (68/74)92%  (23/25)
initialize (): void 100% (1/1)62%  (10/16)67%  (4/6)
DefaultBatchConfigurer (): void 100% (1/1)100% (3/3)100% (1/1)
DefaultBatchConfigurer (DataSource): void 100% (1/1)100% (6/6)100% (3/3)
createJobLauncher (): JobLauncher 100% (1/1)100% (12/12)100% (4/4)
createJobRepository (): JobRepository 100% (1/1)100% (18/18)100% (5/5)
getJobLauncher (): JobLauncher 100% (1/1)100% (3/3)100% (1/1)
getJobRepository (): JobRepository 100% (1/1)100% (3/3)100% (1/1)
getTransactionManager (): PlatformTransactionManager 100% (1/1)100% (3/3)100% (1/1)
setDataSource (DataSource): void 100% (1/1)100% (10/10)100% (3/3)

1/*
2 * Copyright 2012-2013 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.annotation;
17 
18import javax.annotation.PostConstruct;
19import javax.sql.DataSource;
20 
21import org.springframework.batch.core.configuration.BatchConfigurationException;
22import org.springframework.batch.core.launch.JobLauncher;
23import org.springframework.batch.core.launch.support.SimpleJobLauncher;
24import org.springframework.batch.core.repository.JobRepository;
25import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
26import org.springframework.beans.factory.annotation.Autowired;
27import org.springframework.jdbc.datasource.DataSourceTransactionManager;
28import org.springframework.stereotype.Component;
29import org.springframework.transaction.PlatformTransactionManager;
30 
31@Component
32public class DefaultBatchConfigurer implements BatchConfigurer {
33 
34        private DataSource dataSource;
35        private PlatformTransactionManager transactionManager;
36        private JobRepository jobRepository;
37        private JobLauncher jobLauncher;
38 
39        @Autowired
40        public void setDataSource(DataSource dataSource) {
41                this.dataSource = dataSource;
42                this.transactionManager = new DataSourceTransactionManager(dataSource);
43        }
44 
45        protected DefaultBatchConfigurer() {}
46 
47        public DefaultBatchConfigurer(DataSource dataSource) {
48                setDataSource(dataSource);
49        }
50 
51        @Override
52        public JobRepository getJobRepository() {
53                return jobRepository;
54        }
55 
56        @Override
57        public PlatformTransactionManager getTransactionManager() {
58                return transactionManager;
59        }
60 
61        @Override
62        public JobLauncher getJobLauncher() {
63                return jobLauncher;
64        }
65 
66        @PostConstruct
67        public void initialize() throws BatchConfigurationException {
68                try {
69                        this.jobRepository = createJobRepository();
70                        this.jobLauncher = createJobLauncher();
71                } catch (Exception e) {
72                        throw new BatchConfigurationException(e);
73                }
74        }
75 
76        private JobLauncher createJobLauncher() throws Exception {
77                SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
78                jobLauncher.setJobRepository(jobRepository);
79                jobLauncher.afterPropertiesSet();
80                return jobLauncher;
81        }
82 
83        protected JobRepository createJobRepository() throws Exception {
84                JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
85                factory.setDataSource(dataSource);
86                factory.setTransactionManager(transactionManager);
87                factory.afterPropertiesSet();
88                return  (JobRepository) factory.getObject();
89        }
90 
91}

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