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