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