1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring.parsers.specific; |
12 | |
|
13 | |
import org.mule.config.spring.parsers.generic.ChildDefinitionParser; |
14 | |
import org.mule.enricher.MessageEnricher.EnrichExpressionPair; |
15 | |
import org.mule.util.StringUtils; |
16 | |
|
17 | |
import org.springframework.beans.factory.support.BeanDefinitionBuilder; |
18 | |
import org.springframework.beans.factory.support.GenericBeanDefinition; |
19 | |
import org.springframework.beans.factory.support.ManagedList; |
20 | |
import org.springframework.beans.factory.xml.ParserContext; |
21 | |
import org.w3c.dom.Element; |
22 | |
|
23 | |
public class MessageEnricherDefinitionParser extends ChildDefinitionParser |
24 | |
{ |
25 | |
|
26 | |
public MessageEnricherDefinitionParser(String setterMethod, Class clazz) |
27 | |
{ |
28 | 0 | super(setterMethod, clazz); |
29 | 0 | } |
30 | |
|
31 | |
@Override |
32 | |
protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) |
33 | |
{ |
34 | 0 | if (!StringUtils.isEmpty(element.getAttribute("source")) || !StringUtils.isEmpty(element.getAttribute("target"))) |
35 | |
{ |
36 | 0 | GenericBeanDefinition objectFactoryBeanDefinition = new GenericBeanDefinition(); |
37 | 0 | objectFactoryBeanDefinition.setBeanClass(EnrichExpressionPair.class); |
38 | 0 | objectFactoryBeanDefinition.getPropertyValues().addPropertyValue("source", |
39 | |
element.getAttribute("source")); |
40 | 0 | objectFactoryBeanDefinition.getPropertyValues().addPropertyValue("target", |
41 | |
element.getAttribute("target")); |
42 | 0 | ManagedList<GenericBeanDefinition> list = new ManagedList<GenericBeanDefinition>(); |
43 | 0 | list.add(objectFactoryBeanDefinition); |
44 | 0 | builder.addPropertyValue("enrichExpressionPairs", list); |
45 | |
} |
46 | |
|
47 | 0 | super.parseChild(element, parserContext, builder); |
48 | 0 | } |
49 | |
} |