1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
package org.mule.module.bpm.config; |
11 | |
|
12 | |
import org.mule.config.spring.handlers.AbstractMuleNamespaceHandler; |
13 | |
import org.mule.config.spring.parsers.collection.ChildMapEntryDefinitionParser; |
14 | |
import org.mule.config.spring.parsers.generic.MuleOrphanDefinitionParser; |
15 | |
import org.mule.config.spring.parsers.specific.ComponentDefinitionParser; |
16 | |
import org.mule.config.spring.parsers.specific.RouterDefinitionParser; |
17 | |
import org.mule.endpoint.URIBuilder; |
18 | |
import org.mule.module.bpm.Process; |
19 | |
import org.mule.module.bpm.ProcessComponent; |
20 | |
import org.mule.routing.outbound.EndpointSelector; |
21 | |
import org.mule.transport.bpm.ProcessConnector; |
22 | |
import org.mule.transport.bpm.jbpm.JBpmConnector; |
23 | |
|
24 | |
import org.springframework.beans.factory.support.BeanDefinitionBuilder; |
25 | |
import org.springframework.beans.factory.xml.ParserContext; |
26 | |
import org.w3c.dom.Element; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | 0 | public class BpmNamespaceHandler extends AbstractMuleNamespaceHandler |
32 | |
{ |
33 | |
public static final String PROCESS = "process"; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public static final String JBPM_WRAPPER_CLASS = "org.mule.module.jbpm.Jbpm"; |
40 | |
|
41 | |
public void init() |
42 | |
{ |
43 | 0 | registerStandardTransportEndpoints(ProcessConnector.PROTOCOL, new String[]{PROCESS}).addAlias(PROCESS, URIBuilder.PATH); |
44 | 0 | registerConnectorDefinitionParser(ProcessConnector.class); |
45 | 0 | registerBeanDefinitionParser("outbound-router", new BpmOutboundRouterDefinitionParser()); |
46 | |
|
47 | 0 | registerBeanDefinitionParser("process", new ProcessComponentDefinitionParser()); |
48 | |
|
49 | 0 | registerMuleBeanDefinitionParser("process-definition", new ChildMapEntryDefinitionParser("processDefinitions", "name", "resource")); |
50 | |
|
51 | |
try |
52 | |
{ |
53 | 0 | registerBeanDefinitionParser("jbpm", new MuleOrphanDefinitionParser(Class.forName(JBPM_WRAPPER_CLASS), true)); |
54 | |
} |
55 | 0 | catch (ClassNotFoundException e) |
56 | |
{ |
57 | 0 | logger.warn(e.getMessage()); |
58 | 0 | } |
59 | 0 | registerBeanDefinitionParser("jbpm-connector", new MuleOrphanDefinitionParser(JBpmConnector.class, true)); |
60 | 0 | } |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
class BpmOutboundRouterDefinitionParser extends RouterDefinitionParser |
68 | |
{ |
69 | |
public BpmOutboundRouterDefinitionParser() |
70 | 0 | { |
71 | 0 | super(EndpointSelector.class); |
72 | 0 | } |
73 | |
|
74 | |
protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) |
75 | |
{ |
76 | 0 | builder.addPropertyValue("evaluator", "header"); |
77 | 0 | builder.addPropertyValue("expression", Process.PROPERTY_ENDPOINT); |
78 | 0 | super.parseChild(element, parserContext, builder); |
79 | 0 | } |
80 | |
} |
81 | |
|
82 | 0 | class ProcessComponentDefinitionParser extends ComponentDefinitionParser |
83 | |
{ |
84 | |
public ProcessComponentDefinitionParser() |
85 | 0 | { |
86 | 0 | super(ProcessComponent.class); |
87 | 0 | addAlias("processName", "name"); |
88 | 0 | addAlias("processDefinition", "resource"); |
89 | 0 | } |
90 | |
} |
91 | |
} |
92 | |
|