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