Coverage Report - org.apache.camel.spring.xml.ScriptDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
ScriptDefinitionParser
25% 
0% 
0
 
 1  
 /**
 2  
  *
 3  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 4  
  * contributor license agreements.  See the NOTICE file distributed with
 5  
  * this work for additional information regarding copyright ownership.
 6  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 7  
  * (the "License"); you may not use this file except in compliance with
 8  
  * the License.  You may obtain a copy of the License at
 9  
  *
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 package org.apache.camel.spring.xml;
 19  
 
 20  
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 21  
 import org.springframework.beans.factory.xml.ParserContext;
 22  
 import org.springframework.util.xml.DomUtils;
 23  
 import org.w3c.dom.Element;
 24  
 
 25  
 /**
 26  
  * A parser of the various scripting language expressions
 27  
  * @version $Revision: 1.1 $
 28  
  */
 29  
 public class ScriptDefinitionParser extends LazyLoadingBeanDefinitionParser {
 30  
     private final String scriptEngineName;
 31  
 
 32  
     public ScriptDefinitionParser(String scriptEngineName) {
 33  144
         super("org.apache.camel.builder.script.ScriptBuilder", "camel-script");
 34  144
         this.scriptEngineName = scriptEngineName;
 35  144
     }
 36  
 
 37  
     @Override
 38  
     protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
 39  
         // lets create a child context
 40  0
         String engine = scriptEngineName;
 41  0
         if (engine == null) {
 42  0
             engine = element.getAttribute("language");
 43  
         }
 44  0
         builder.addConstructorArg(engine);
 45  0
         super.doParse(element, parserContext, builder);
 46  0
         String scriptText = DomUtils.getTextValue(element).trim();
 47  0
         if (scriptText.length() > 0) {
 48  0
             builder.addPropertyValue("scriptText", scriptText);
 49  
         }
 50  0
     }
 51  
 
 52  
 }