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.module.bpm.ProcessComponent;
17 import org.mule.module.bpm.RulesComponent;
18
19
20
21
22 public class BpmNamespaceHandler extends AbstractMuleNamespaceHandler
23 {
24
25
26
27
28 public static final String JBPM_WRAPPER_CLASS = "org.mule.module.jbpm.Jbpm";
29
30
31
32
33
34 public static final String DROOLS_WRAPPER_CLASS = "org.mule.module.drools.Drools";
35
36 public void init()
37 {
38 registerBeanDefinitionParser("process", new ProcessComponentDefinitionParser());
39 registerMuleBeanDefinitionParser("process-definition", new ChildMapEntryDefinitionParser("processDefinitions", "name", "resource"));
40 try
41 {
42 registerBeanDefinitionParser("jbpm", new MuleOrphanDefinitionParser(Class.forName(JBPM_WRAPPER_CLASS), true));
43 }
44 catch (ClassNotFoundException e)
45 {
46 logger.debug("Element <bpm:jbpm> will not available because " + JBPM_WRAPPER_CLASS + " is not on the classpath");
47 }
48
49 registerBeanDefinitionParser("rules", new RulesComponentDefinitionParser());
50 try
51 {
52 registerBeanDefinitionParser("drools", new MuleOrphanDefinitionParser(Class.forName(DROOLS_WRAPPER_CLASS), true));
53 }
54 catch (ClassNotFoundException e)
55 {
56 logger.debug("Element <drools> will not available in the bpm: namespace because it is not on the classpath");
57 }
58 }
59
60 class ProcessComponentDefinitionParser extends ComponentDefinitionParser
61 {
62 public ProcessComponentDefinitionParser()
63 {
64 super(ProcessComponent.class);
65 addAlias("processName", "name");
66 addAlias("processDefinition", "resource");
67 }
68 }
69
70 class RulesComponentDefinitionParser extends ComponentDefinitionParser
71 {
72 public RulesComponentDefinitionParser()
73 {
74 super(RulesComponent.class);
75 addAlias("rulesDefinition", "resource");
76 }
77 }
78 }
79