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

COVERAGE SUMMARY FOR SOURCE FILE [JobRepositoryParser.java]

nameclass, %method, %block, %line, %
JobRepositoryParser.java100% (1/1)100% (4/4)96%  (114/119)97%  (29/30)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JobRepositoryParser100% (1/1)100% (4/4)96%  (114/119)97%  (29/30)
doParse (Element, ParserContext, BeanDefinitionBuilder): void 100% (1/1)95%  (98/103)96%  (23/24)
JobRepositoryParser (): void 100% (1/1)100% (3/3)100% (1/1)
getBeanClassName (Element): String 100% (1/1)100% (2/2)100% (1/1)
resolveId (Element, AbstractBeanDefinition, ParserContext): String 100% (1/1)100% (11/11)100% (4/4)

1/*
2 * Copyright 2006-2008 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.xml;
17 
18import org.springframework.beans.factory.BeanDefinitionStoreException;
19import org.springframework.beans.factory.config.BeanDefinition;
20import org.springframework.beans.factory.config.RuntimeBeanReference;
21import org.springframework.beans.factory.support.AbstractBeanDefinition;
22import org.springframework.beans.factory.support.BeanDefinitionBuilder;
23import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
24import org.springframework.beans.factory.xml.ParserContext;
25import org.springframework.transaction.support.DefaultTransactionDefinition;
26import org.springframework.util.StringUtils;
27import org.w3c.dom.Element;
28 
29/**
30 * Parser for the lt;job-repository/gt; element in the Batch namespace. Sets up
31 * and returns a JobRepositoryFactoryBean.
32 *
33 * @author Thomas Risberg
34 * @since 2.0
35 *
36 */
37public class JobRepositoryParser extends AbstractSingleBeanDefinitionParser {
38 
39        @Override
40        protected String getBeanClassName(Element element) {
41                return "org.springframework.batch.core.repository.support.JobRepositoryFactoryBean";
42        }
43 
44        @Override
45        protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
46                        throws BeanDefinitionStoreException {
47 
48                String id = element.getAttribute(ID_ATTRIBUTE);
49                if (!StringUtils.hasText(id)) {
50                        id = "jobRepository";
51                }
52 
53                return id;
54 
55        }
56 
57        /**
58         * Parse and create a bean definition for a
59         * {@link org.springframework.batch.core.repository.support.JobRepositoryFactoryBean}
60         * .
61         */
62        @Override
63        protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
64 
65                CoreNamespaceUtils.autoregisterBeansForNamespace(parserContext, element);
66 
67                String dataSource = element.getAttribute("data-source");
68 
69                String transactionManager = element.getAttribute("transaction-manager");
70 
71                String isolationLevelForCreate = element.getAttribute("isolation-level-for-create");
72 
73                String tablePrefix = element.getAttribute("table-prefix");
74 
75                String maxVarCharLength = element.getAttribute("max-varchar-length");
76 
77                String lobHandler = element.getAttribute("lob-handler");
78 
79                String serializer = element.getAttribute("serializer");
80 
81                RuntimeBeanReference ds = new RuntimeBeanReference(dataSource);
82                builder.addPropertyValue("dataSource", ds);
83                RuntimeBeanReference tx = new RuntimeBeanReference(transactionManager);
84                builder.addPropertyValue("transactionManager", tx);
85                if (StringUtils.hasText(isolationLevelForCreate)) {
86                        builder.addPropertyValue("isolationLevelForCreate", DefaultTransactionDefinition.PREFIX_ISOLATION
87                                        + isolationLevelForCreate);
88                }
89                if (StringUtils.hasText(tablePrefix)) {
90                        builder.addPropertyValue("tablePrefix", tablePrefix);
91                }
92                if (StringUtils.hasText(lobHandler)) {
93                        builder.addPropertyReference("lobHandler", lobHandler);
94                }
95                if (StringUtils.hasText(maxVarCharLength)) {
96                        builder.addPropertyValue("maxVarCharLength", maxVarCharLength);
97                }
98                if (StringUtils.hasText(serializer)) {
99                        builder.addPropertyReference("serializer", serializer);
100                }
101 
102                builder.setRole(BeanDefinition.ROLE_SUPPORT);
103 
104        }
105}

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