1
2
3
4
5
6
7
8
9
10 package org.mule.config.spring.parsers.specific;
11
12 import org.mule.config.spring.parsers.assembly.BeanAssembler;
13 import org.mule.config.spring.parsers.generic.MuleOrphanDefinitionParser;
14
15 import org.springframework.beans.factory.xml.ParserContext;
16 import org.springframework.util.SystemPropertyUtils;
17 import org.w3c.dom.Element;
18
19 public class GlobalPropertyDefinitionParser extends MuleOrphanDefinitionParser
20 {
21 private final String VALUE_ATTR = "value";
22 private final String NAME_ATTR = "name";
23
24 public GlobalPropertyDefinitionParser()
25 {
26 super(true);
27 addIgnored(NAME_ATTR);
28 addIgnored(VALUE_ATTR);
29 }
30
31 protected Class getBeanClass(Element element)
32 {
33 return String.class;
34 }
35
36 protected void postProcess(ParserContext context, BeanAssembler assembler, Element element)
37 {
38 String name = element.getAttribute(NAME_ATTR);
39 if(name.indexOf(' ') != -1)
40 {
41 logger.warn("Environment property name should not contain spaces: \"" + name + "\"");
42 }
43
44 String value = element.getAttribute(VALUE_ATTR);
45 assembler.getBean().addConstructorArgValue(SystemPropertyUtils.resolvePlaceholders(value));
46 super.postProcess(context, assembler, element);
47 }
48 }