View Javadoc

1   /*
2    * $Id: BpmNamespaceHandler.java 11659 2008-04-30 02:18:29Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.transport.bpm.config;
11  
12  import org.mule.config.spring.handlers.AbstractMuleNamespaceHandler;
13  import org.mule.config.spring.parsers.specific.RouterDefinitionParser;
14  import org.mule.endpoint.URIBuilder;
15  import org.mule.routing.outbound.EndpointSelector;
16  import org.mule.transport.bpm.ProcessConnector;
17  
18  import org.springframework.beans.factory.support.BeanDefinitionBuilder;
19  import org.springframework.beans.factory.xml.ParserContext;
20  import org.w3c.dom.Element;
21  
22  /**
23   * Registers a Bean Definition Parsers for the "bpm" namespace.
24   */
25  public class BpmNamespaceHandler extends AbstractMuleNamespaceHandler
26  {
27      public static final String PROCESS = "process";
28  
29      public void init()
30      {
31          registerStandardTransportEndpoints(ProcessConnector.PROTOCOL, new String[]{PROCESS}).addAlias(PROCESS, URIBuilder.PATH);
32          registerConnectorDefinitionParser(ProcessConnector.class);
33          registerBeanDefinitionParser("outbound-router", new BpmOutboundRouterDefinitionParser());
34          // TODO MULE-3205
35          //registerBeanDefinitionParser("component", new ComponentDefinitionParser(ProcessComponent.class));
36      }
37  
38      /**
39       * This is merely a shortcut for:
40       *   <endpoint-selector-router evaluator="header" expression="MULE_BPM_ENDPOINT"> 
41       */
42      class BpmOutboundRouterDefinitionParser extends RouterDefinitionParser
43      {
44          public BpmOutboundRouterDefinitionParser()
45          {
46              super(EndpointSelector.class);
47          }
48  
49          protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
50          {
51              builder.addPropertyValue("evaluator", "header");
52              builder.addPropertyValue("expression", ProcessConnector.PROPERTY_ENDPOINT);
53              super.parseChild(element, parserContext, builder);
54          }
55          
56      }
57  }
58