EMMA Coverage Report (generated Tue Mar 05 16:36:55 GMT 2013)
[all classes][org.springframework.data.elasticsearch.config]

COVERAGE SUMMARY FOR SOURCE FILE [TransportClientBeanDefinitionParser.java]

nameclass, %method, %block, %line, %
TransportClientBeanDefinitionParser.java100% (1/1)100% (4/4)100% (36/36)100% (9/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TransportClientBeanDefinitionParser100% (1/1)100% (4/4)100% (36/36)100% (9/9)
TransportClientBeanDefinitionParser (): void 100% (1/1)100% (3/3)100% (1/1)
getSourcedBeanDefinition (BeanDefinitionBuilder, Element, ParserContext): Abs... 100% (1/1)100% (10/10)100% (3/3)
parseInternal (Element, ParserContext): AbstractBeanDefinition 100% (1/1)100% (13/13)100% (3/3)
setClusterNodes (Element, BeanDefinitionBuilder): void 100% (1/1)100% (10/10)100% (2/2)

1/*
2 * Copyright 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 */
16 
17package org.springframework.data.elasticsearch.config;
18 
19import org.springframework.beans.factory.support.AbstractBeanDefinition;
20import org.springframework.beans.factory.support.BeanDefinitionBuilder;
21import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
22import org.springframework.beans.factory.xml.ParserContext;
23import org.springframework.data.elasticsearch.client.TransportClientFactoryBean;
24import org.w3c.dom.Element;
25 
26import static org.apache.commons.lang.StringUtils.split;
27/**
28 *  TransportClientBeanDefinitionParser
29 *
30 * @author Rizwan Idrees
31 * @author Mohsin Husen
32 */
33 
34public class TransportClientBeanDefinitionParser extends AbstractBeanDefinitionParser {
35 
36    private static final String SEPARATOR_CHARS = ",";
37 
38    @Override
39    protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
40        BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(TransportClientFactoryBean.class);
41        setClusterNodes(element, builder);
42        return getSourcedBeanDefinition(builder,element, parserContext);
43    }
44 
45    private void setClusterNodes(Element element, BeanDefinitionBuilder builder){
46        builder.addPropertyValue("clusterNodes", split(element.getAttribute("cluster-nodes"), SEPARATOR_CHARS));
47    }
48 
49    private AbstractBeanDefinition getSourcedBeanDefinition(BeanDefinitionBuilder builder, Element source,
50                                                            ParserContext context) {
51        AbstractBeanDefinition definition = builder.getBeanDefinition();
52        definition.setSource(context.extractSource(source));
53        return definition;
54    }
55}

[all classes][org.springframework.data.elasticsearch.config]
EMMA 2.0.5312 (C) Vladimir Roubtsov