Coverage Report - org.mule.module.bpm.config.BpmNamespaceHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
BpmNamespaceHandler
0%
0/13
N/A
1.25
BpmNamespaceHandler$BpmOutboundRouterDefinitionParser
0%
0/7
N/A
1.25
BpmNamespaceHandler$ProcessComponentDefinitionParser
0%
0/5
N/A
1.25
 
 1  
 /*
 2  
  * $Id: BpmNamespaceHandler.java 19710 2010-09-23 16:29:07Z tcarlson $
 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.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  
  * Registers a Bean Definition Parsers for the "bpm" namespace.
 30  
  */
 31  0
 public class BpmNamespaceHandler extends AbstractMuleNamespaceHandler
 32  
 {
 33  
     public static final String PROCESS = "process";
 34  
 
 35  
     /** 
 36  
      * Allows simple configuration of jBPM from the generic "bpm" namespace.  Otherwise you would need to include both the 
 37  
      * "bpm" and "jbpm" namespaces in your config, which is not really justified.
 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  
      * This is merely a shortcut for:
 64  
      *   <endpoint-selector-router evaluator="header" expression="MULE_BPM_ENDPOINT"> 
 65  
      * @deprecated It is recommended to configure BPM as a component rather than a transport for 3.x
 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