1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring.parsers.specific; |
12 | |
|
13 | |
import org.mule.config.spring.factories.SimpleServiceFactoryBean; |
14 | |
import org.mule.config.spring.parsers.processors.CheckExclusiveAttributes; |
15 | |
import org.mule.config.spring.parsers.processors.CheckExclusiveAttributesAndChildren; |
16 | |
import org.mule.util.StringUtils; |
17 | |
import org.springframework.beans.factory.support.BeanDefinitionBuilder; |
18 | |
import org.springframework.beans.factory.xml.ParserContext; |
19 | |
import org.w3c.dom.Element; |
20 | |
|
21 | |
public class SimpleServiceDefinitionParser extends AbstractFlowConstructDefinitionParser |
22 | |
{ |
23 | |
private static final String COMPONENT_CLASS_ATTRIBUTE = "component-class"; |
24 | |
private static final String COMPONENT_REF_ATTRIBUTE = "component-ref"; |
25 | |
|
26 | |
public SimpleServiceDefinitionParser() |
27 | 0 | { |
28 | 0 | super.addAlias("endpoint", "endpointBuilder"); |
29 | |
|
30 | 0 | super.registerPreProcessor(new CheckExclusiveAttributes(new String[][]{ |
31 | |
new String[]{ADDRESS_ATTRIBUTE}, new String[]{ENDPOINT_REF_ATTRIBUTE}})); |
32 | |
|
33 | 0 | super.registerPreProcessor(new CheckExclusiveAttributes(new String[][]{ |
34 | |
new String[]{COMPONENT_CLASS_ATTRIBUTE}, new String[]{COMPONENT_REF_ATTRIBUTE}})); |
35 | |
|
36 | 0 | super.registerPreProcessor(new CheckExclusiveAttributesAndChildren(new String[]{ |
37 | |
ENDPOINT_REF_ATTRIBUTE, ADDRESS_ATTRIBUTE, TRANSFORMER_REFS_ATTRIBUTE, |
38 | |
RESPONSE_TRANSFORMER_REFS_ATTRIBUTE}, new String[]{INBOUND_ENDPOINT_CHILD})); |
39 | 0 | } |
40 | |
|
41 | |
@Override |
42 | |
protected Class<?> getBeanClass(Element element) |
43 | |
{ |
44 | 0 | return SimpleServiceFactoryBean.class; |
45 | |
} |
46 | |
|
47 | |
@Override |
48 | |
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) |
49 | |
{ |
50 | 0 | final String componentRefAttribute = element.getAttribute(COMPONENT_REF_ATTRIBUTE); |
51 | 0 | if (StringUtils.isNotBlank(componentRefAttribute)) |
52 | |
{ |
53 | 0 | builder.addPropertyValue("componentBeanName", componentRefAttribute); |
54 | |
} |
55 | 0 | element.removeAttribute(COMPONENT_REF_ATTRIBUTE); |
56 | |
|
57 | 0 | super.doParse(element, parserContext, builder); |
58 | 0 | } |
59 | |
} |