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
18 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
19 import org.w3c.dom.Element;
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 public class ChildEndpointDefinitionParser extends ChildDefinitionParser
35 {
36
37 public ChildEndpointDefinitionParser(Class endpoint)
38 {
39 super("messageProcessor", endpoint);
40 addIgnored(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF);
41 EndpointUtils.addProperties(this);
42 EndpointUtils.addPostProcess(this);
43 }
44
45 @Override
46 public BeanDefinitionBuilder createBeanDefinitionBuilder(Element element, Class beanClass)
47 {
48 BeanDefinitionBuilder builder = super.createBeanDefinitionBuilder(element, beanClass);
49 String global = element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF);
50 if (StringUtils.isNotBlank(global))
51 {
52 builder.addConstructorArgReference(global);
53 builder.addDependsOn(global);
54 }
55 return builder;
56 }
57
58 @Override
59 public String getPropertyName(Element e)
60 {
61 String parent = e.getParentNode().getLocalName().toLowerCase();
62 if (e.getLocalName() != null
63 && (e.getLocalName().toLowerCase().endsWith("inbound-endpoint") || e.getLocalName()
64 .toLowerCase()
65 .equals("poll")))
66 {
67 return "messageSource";
68 }
69 else if ("wire-tap".equals(parent) || "wire-tap-router".equals(parent))
70 {
71 return "tap";
72 }
73 else if ("binding".equals(parent) || "java-interface-binding".equals(parent)
74 || "publish-notifications".equals(parent) || "remote-dispatcher-agent".equals(parent))
75 {
76 return "endpoint";
77 }
78 else
79 {
80 return super.getPropertyName(e);
81 }
82 }
83
84 @Override
85 public String getBeanName(Element element)
86 {
87 if (null != element.getAttributeNode(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF))
88 {
89 return AutoIdUtils.uniqueValue("ref:"
90 + element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF));
91 }
92 else
93 {
94 return super.getBeanName(element);
95 }
96 }
97 }