]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/xml/ParamDecorator.java
Adapt to new build number approach
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / xml / ParamDecorator.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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
17 package org.argeo.slc.core.execution.xml;
18
19 import org.argeo.slc.core.execution.ParameterRef;
20 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
21 import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
22 import org.springframework.beans.factory.xml.ParserContext;
23 import org.springframework.util.StringUtils;
24 import org.w3c.dom.Element;
25
26 public class ParamDecorator extends AbstractSingleBeanDefinitionParser {
27
28 // public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder
29 // bean,
30 // ParserContext ctx) {
31 // String paramName = ((Element) node).getAttribute("name");
32 // String propertyName = ((Element) node.getParentNode())
33 // .getAttribute("name");
34 // BeanDefinitionBuilder parameterRef = BeanDefinitionBuilder
35 // .genericBeanDefinition(ParameterRef.class);
36 // parameterRef.addPropertyReference("instantiationManager",
37 // "instantiationManager");
38 // parameterRef.addConstructorArgValue(paramName);
39 // bean.getBeanDefinition().getPropertyValues().addPropertyValue(
40 // propertyName, parameterRef.getBeanDefinition());
41 // return bean;
42 // }
43
44 @Override
45 protected void doParse(Element element, ParserContext parserContext,
46 BeanDefinitionBuilder builder) {
47 String paramName = element.getAttribute("name");
48
49 String instantationManagerRef = element
50 .getAttribute("instantiationManager");
51 if (!StringUtils.hasText(instantationManagerRef))
52 instantationManagerRef = "instantiationManager";
53 builder.addPropertyReference("instantiationManager",
54 instantationManagerRef);
55 builder.addConstructorArgValue(paramName);
56 }
57
58 @Override
59 protected Class<ParameterRef> getBeanClass(Element element) {
60 return ParameterRef.class;
61 }
62 }