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 | 0 | super("messageProcessor", endpoint); |
36 | 0 | addIgnored(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF); |
37 | 0 | EndpointUtils.addProperties(this); |
38 | 0 | EndpointUtils.addPostProcess(this); |
39 | 0 | } |
40 | |
|
41 | |
@Override |
42 | |
public BeanDefinitionBuilder createBeanDefinitionBuilder(Element element, Class beanClass) |
43 | |
{ |
44 | 0 | BeanDefinitionBuilder builder = super.createBeanDefinitionBuilder(element, beanClass); |
45 | 0 | String global = element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF); |
46 | 0 | if (StringUtils.isNotBlank(global)) |
47 | |
{ |
48 | 0 | builder.addConstructorArgReference(global); |
49 | 0 | builder.addDependsOn(global); |
50 | |
} |
51 | 0 | return builder; |
52 | |
} |
53 | |
|
54 | |
@Override |
55 | |
public String getPropertyName(Element e) |
56 | |
{ |
57 | 0 | String parent = e.getParentNode().getLocalName().toLowerCase(); |
58 | 0 | if (e.getLocalName() != null |
59 | |
&& (e.getLocalName().toLowerCase().endsWith("inbound-endpoint") || e.getLocalName() |
60 | |
.toLowerCase() |
61 | |
.equals("poll"))) |
62 | |
{ |
63 | 0 | return "messageSource"; |
64 | |
} |
65 | 0 | else if ("wire-tap".equals(parent) || "wire-tap-router".equals(parent)) |
66 | |
{ |
67 | 0 | return "tap"; |
68 | |
} |
69 | 0 | else if ("binding".equals(parent) || "java-interface-binding".equals(parent) |
70 | |
|| "publish-notifications".equals(parent) || "remote-dispatcher-agent".equals(parent)) |
71 | |
{ |
72 | 0 | return "endpoint"; |
73 | |
} |
74 | |
else |
75 | |
{ |
76 | 0 | return super.getPropertyName(e); |
77 | |
} |
78 | |
} |
79 | |
|
80 | |
@Override |
81 | |
public String getBeanName(Element element) |
82 | |
{ |
83 | 0 | if (null != element.getAttributeNode(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF)) |
84 | |
{ |
85 | 0 | return AutoIdUtils.uniqueValue("ref:" |
86 | |
+ element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF)); |
87 | |
} |
88 | |
else |
89 | |
{ |
90 | 0 | return super.getBeanName(element); |
91 | |
} |
92 | |
} |
93 | |
} |