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