View Javadoc

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