View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.bpm.config;
8   
9   import org.mule.config.spring.handlers.AbstractMuleNamespaceHandler;
10  import org.mule.config.spring.parsers.collection.ChildMapEntryDefinitionParser;
11  import org.mule.config.spring.parsers.generic.MuleOrphanDefinitionParser;
12  import org.mule.config.spring.parsers.specific.ComponentDefinitionParser;
13  import org.mule.module.bpm.ProcessComponent;
14  
15  /**
16   * Registers a Bean Definition Parsers for the "bpm" namespace.
17   */
18  public class BpmNamespaceHandler extends AbstractMuleNamespaceHandler
19  {
20      /** 
21       * Allows simple configuration of jBPM from the generic "bpm" namespace.  Otherwise you would need to include both the 
22       * "bpm" and "jbpm" namespaces in your config, which is not really justified.
23       */
24      public static final String JBPM_WRAPPER_CLASS = "org.mule.module.jbpm.Jbpm";
25  
26      public void init()
27      {
28          registerBeanDefinitionParser("process", new ProcessComponentDefinitionParser());
29  
30          registerMuleBeanDefinitionParser("process-definition", new ChildMapEntryDefinitionParser("processDefinitions", "name", "resource"));
31  
32          try
33          {
34              registerBeanDefinitionParser("jbpm", new MuleOrphanDefinitionParser(Class.forName(JBPM_WRAPPER_CLASS), true));
35          }
36          catch (ClassNotFoundException e)
37          {
38              logger.warn(e.getMessage());
39          }
40      }
41      
42      class ProcessComponentDefinitionParser extends ComponentDefinitionParser
43      {
44          public ProcessComponentDefinitionParser()
45          {
46              super(ProcessComponent.class);
47              addAlias("processName", "name");
48              addAlias("processDefinition", "resource");
49          }
50      }
51  }
52