2 * Copyright (C) 2007-2012 Argeo GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.slc
.core
.execution
.xml
;
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
;
25 public class ParamDecorator
extends AbstractSingleBeanDefinitionParser
{
27 // public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder
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());
44 protected void doParse(Element element
, ParserContext parserContext
,
45 BeanDefinitionBuilder builder
) {
46 String paramName
= element
.getAttribute("name");
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
);
58 protected Class
<ParameterRef
> getBeanClass(Element element
) {
59 return ParameterRef
.class;