1
2
3
4
5
6
7
8
9
10
11 package org.mule.config.spring.parsers.specific.endpoint.support;
12
13 import org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser;
14 import org.mule.config.spring.parsers.generic.AutoIdUtils;
15 import org.mule.config.spring.parsers.generic.ChildDefinitionParser;
16 import org.mule.util.StringUtils;
17 import org.mule.endpoint.AbstractEndpointBuilder;
18
19 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
20 import org.springframework.beans.factory.xml.ParserContext;
21 import org.w3c.dom.Element;
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public class ChildEndpointDefinitionParser extends ChildDefinitionParser
37 {
38
39 public ChildEndpointDefinitionParser(Class endpoint)
40 {
41 super("endpoint", endpoint);
42 addIgnored(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF);
43 EndpointUtils.addProperties(this);
44 EndpointUtils.addPostProcess(this);
45 }
46
47
48 public BeanDefinitionBuilder createBeanDefinitionBuilder(Element element, Class beanClass)
49 {
50 BeanDefinitionBuilder builder = super.createBeanDefinitionBuilder(element, beanClass);
51 String global = element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF);
52 if (StringUtils.isNotBlank(global))
53 {
54 builder.addConstructorArgReference(global);
55 builder.addDependsOn(global);
56 }
57 return builder;
58 }
59
60
61 public String getBeanName(Element element)
62 {
63 if (null != element.getAttributeNode(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF))
64 {
65 return AutoIdUtils.uniqueValue("ref:" + element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF));
66 }
67 else
68 {
69 return super.getBeanName(element);
70 }
71 }
72
73
74 protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
75 {
76
77 if (element.getParentNode().getNodeName().equals("chaining-router")
78 || element.getParentNode().getNodeName().equals("exception-based-router"))
79 {
80 builder.addPropertyValue(AbstractEndpointBuilder.PROPERTY_REMOTE_SYNC, Boolean.TRUE);
81 }
82
83 super.parseChild(element, parserContext, builder);
84 }
85
86 }