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