EMMA Coverage Report (generated Thu Jan 24 13:37:04 CST 2013)
[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)95%  (102/107)96%  (26/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JobRepositoryParser100% (1/1)100% (4/4)95%  (102/107)96%  (26/27)
doParse (Element, ParserContext, BeanDefinitionBuilder): void 100% (1/1)95%  (86/91)95%  (20/21)
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        protected String getBeanClassName(Element element) {
40                return "org.springframework.batch.core.repository.support.JobRepositoryFactoryBean";
41        }
42 
43        @Override
44        protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
45                        throws BeanDefinitionStoreException {
46 
47                String id = element.getAttribute(ID_ATTRIBUTE);
48                if (!StringUtils.hasText(id)) {
49                        id = "jobRepository";
50                }
51 
52                return id;
53 
54        }
55 
56        /**
57         * Parse and create a bean definition for a
58         * {@link org.springframework.batch.core.repository.support.JobRepositoryFactoryBean}
59         * .
60         */
61        @Override
62        protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
63 
64                CoreNamespaceUtils.autoregisterBeansForNamespace(parserContext, element);
65 
66                String dataSource = element.getAttribute("data-source");
67 
68                String transactionManager = element.getAttribute("transaction-manager");
69 
70                String isolationLevelForCreate = element.getAttribute("isolation-level-for-create");
71 
72                String tablePrefix = element.getAttribute("table-prefix");
73 
74                String maxVarCharLength = element.getAttribute("max-varchar-length");
75 
76                String lobHandler = element.getAttribute("lob-handler");
77 
78                RuntimeBeanReference ds = new RuntimeBeanReference(dataSource);
79                builder.addPropertyValue("dataSource", ds);
80                RuntimeBeanReference tx = new RuntimeBeanReference(transactionManager);
81                builder.addPropertyValue("transactionManager", tx);
82                if (StringUtils.hasText(isolationLevelForCreate)) {
83                        builder.addPropertyValue("isolationLevelForCreate", DefaultTransactionDefinition.PREFIX_ISOLATION
84                                        + isolationLevelForCreate);
85                }
86                if (StringUtils.hasText(tablePrefix)) {
87                        builder.addPropertyValue("tablePrefix", tablePrefix);
88                }
89                if (StringUtils.hasText(lobHandler)) {
90                        builder.addPropertyReference("lobHandler", lobHandler);
91                }
92                if (StringUtils.hasText(maxVarCharLength)) {
93                        builder.addPropertyValue("maxVarCharLength", maxVarCharLength);
94                }
95 
96                builder.setRole(BeanDefinition.ROLE_SUPPORT);
97 
98        }
99}

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