2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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.
17 package org
.argeo
.slc
.core
.execution
.xml
;
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
;
26 public class ParamDecorator
extends AbstractSingleBeanDefinitionParser
{
28 // public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder
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());
45 protected void doParse(Element element
, ParserContext parserContext
,
46 BeanDefinitionBuilder builder
) {
47 String paramName
= element
.getAttribute("name");
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
);
59 protected Class
<ParameterRef
> getBeanClass(Element element
) {
60 return ParameterRef
.class;