01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.springframework.context.config;
18:
19: import org.w3c.dom.Element;
20:
21: import org.springframework.beans.factory.config.BeanDefinition;
22: import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
23: import org.springframework.beans.factory.support.BeanDefinitionBuilder;
24: import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
25: import org.springframework.util.StringUtils;
26:
27: /**
28: * Parser for the <context:property-placeholder/> element.
29: *
30: * @author Juergen Hoeller
31: * @since 2.5
32: */
33: class PropertyPlaceholderBeanDefinitionParser extends
34: AbstractSingleBeanDefinitionParser {
35:
36: protected Class getBeanClass(Element element) {
37: return PropertyPlaceholderConfigurer.class;
38: }
39:
40: protected boolean shouldGenerateId() {
41: return true;
42: }
43:
44: protected void doParse(Element element,
45: BeanDefinitionBuilder builder) {
46: String location = element.getAttribute("location");
47: String[] locations = StringUtils
48: .commaDelimitedListToStringArray(location);
49: builder.addPropertyValue("locations", locations);
50: builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
51: }
52:
53: }
|