[jboss-svn-commits] JBL Code SVN: r29503 - in labs/jbossesb/trunk: product/rosetta/src/org/jboss/soa/esb/actions and 12 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Sep 29 10:01:41 EDT 2009


Author: tfennelly
Date: 2009-09-29 10:01:41 -0400 (Tue, 29 Sep 2009)
New Revision: 29503

Added:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedRouter.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/AbstractPropertyRulesRouter.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/RoutingRule.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/XPathRouter.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/XPathRouterUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/config.xml
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/rules.properties
Removed:
   labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedRouter.java
   labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedWiretap.java
Modified:
   labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
   labs/jbossesb/trunk/product/docs/ServicesGuide.odt
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerTagNames.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouter.java
   labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/SampleOrder.xml
   labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/build.xml
   labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/deployment.xml
   labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jbm-queue-service.xml
   labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jbmq-queue-service.xml
   labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jboss-esb.xml
   labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/readme.txt
   labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/src/org/jboss/soa/esb/samples/quickstart/funcbr/test/SendJMSMessage.java
   labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2POJO/jboss-esb.xml
   labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2POJO/src/org/jboss/soa/esb/samples/quickstart/transformxml2pojo/MyJMSListenerAction.java
   labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/FunCBRTest.java
Log:
https://jira.jboss.org/jira/browse/JBESB-2583
Add support for XPath routing

Modified: labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
===================================================================
(Binary files differ)

Modified: labs/jbossesb/trunk/product/docs/ServicesGuide.odt
===================================================================
(Binary files differ)

Copied: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedRouter.java (from rev 29432, labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedRouter.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedRouter.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedRouter.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.actions;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+/**
+ * ContentBasedRouter implements the Content Based Routing pattern. 
+ * It routes a message to one or more destination services based on the message content 
+ * and the rule set it is evaluating it  against. 
+ * <p/>
+ * For configuration details see
+ * 
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ * @author kstam at jboss.com
+ * 
+ * @see ContentBasedWiretap
+ *
+ */
+public class ContentBasedRouter extends ContentBasedWiretap
+{
+    public ContentBasedRouter(ConfigTree config) throws ConfigurationException, RegistryException, MessageRouterException
+    {
+        super(config) ;
+    }
+    /** Route the message to one or more destinations, using the ContentBasedRouter to figure out
+     *  to which destinations it is going to be routed too.
+     *  
+     * @param message
+     * @return Message
+     * @throws ActionProcessingException
+     */
+    public Message process(Message message) throws ActionProcessingException
+    {
+        super.process(message) ;
+        return null ;
+    }
+
+    /** 
+     * @deprecated no longer needed, leaving this in here for backwards compatibility,
+     * use the default "process".
+     * */
+    public Message split(Message message) throws ActionProcessingException
+    {
+        _logger.warn("Depricated, please use the default 'process' method in your configuration");
+        return process(message);
+    }
+
+    protected static Logger _logger = Logger.getLogger(ContentBasedRouter.class);
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedRouter.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java (from rev 29432, labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedWiretap.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -0,0 +1,326 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.actions;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.actions.cbr.XPathRouter;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.client.MessageMulticaster;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.mapping.ObjectMapper;
+import org.jboss.soa.esb.message.mapping.ObjectMappingException;
+import org.jboss.soa.esb.services.registry.Registry;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.registry.RegistryFactory;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+import org.jboss.soa.esb.services.routing.cbr.ContentBasedRouterFactory;
+
+/**
+ * ContentBasedWirtap implements the WireTap pattern. 
+ * The WireTap is an Enterprise Integration Pattern (EIP) where a copy of the message is 
+ * sent to a control channel.
+ * <br>
+ * The CBR­WT is identical in functionality to the ContentBasedRouter, 
+ * however it does not terminate the pipeline which makes it suitable to be used as a WireTap. 
+ * <p/> 
+ * 
+ * Configuration Example:
+ *<pre>{@code
+ *
+ *<action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="OrderDiscountBasedOnCustomerHistory">
+ *    <property name="ruleSet" value="OrderDiscountOnMultipleOrders.drl" />
+ *    <property name="ruleReload" value="false" />
+ *    <property name="stateful" value="true" />
+ *    <property name="object-paths">
+ *        <object-path esb="body.TheOrderHeader" />
+ *        <object-path esb="body.TheCustomer" />
+ *    </property>
+ *    <property name="destinations">
+ *        <route-to destination-name="blue"  service-category="BlueTeam"  service-name="GoBlue" />
+ *        <route-to destination-name="red"   service-category="RedTeam"   service-name="GoRed" />
+ *        <route-to destination-name="green" service-category="GreenTeam" service-name="GoGreen" />
+ *    </property>
+ *</action>
+ *
+ * }</pre>
+ * Property description:
+ * <lu>
+ * <li> <i>class</i>		action class, one of : org.jboss.soa.esb.actions.ContentBasedRouter, org.jboss.soa.esb.actions.ContentBasedWireTap,<br>
+ * 							or org.jboss.soa.esb.actions.MessageFilter
+ * <li> <i>ruleSet</i>		Name of the filename containing the Drools ruleSet.
+ * <li> <i>ruleLanguage</i>	Optional reference to a file containing the definition of a Domain Specific Language to be used for evaluating 
+ * 							the rule set.
+ * <li> <i>ruleReload</i>	Optional property which can be to true to enable 'hot' redeployment of rule sets. 
+ * <li> <i>stateful</i>		Optional property which tells the RuleService to use a stateful session where facts will be 
+ * 							remembered between invokations.
+ * <li> <i>object-paths</i> Optional property to pass Message objects into Rule Services WorkingMemory.
+ * <li> <i>destinations</i> A set of route-­to properties each containing the logical name 
+ * 							of the destination along with the Service category and name 
+ *  						as referenced in the registry.<br> The logical name is the name 
+ *  						which should be used in the rule set.
+ * </lu>
+ * </br>
+ * 
+ * 
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ * @author kstam at jboss.com
+ * @author kevin.conner at jboss.com
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ */
+public class ContentBasedWiretap extends AbstractActionPipelineProcessor {
+
+    public static final String ROUTE_TO_TAG = "route-to";
+
+    public static final String OBJECT_PATH_TAG = "object-path";
+
+    public static final String OBJECT_PATH = "esb";
+    
+    public static final String ENTRY_POINT = "entry-point";
+
+    public static final String DEFAULT_CBR_CLASS = "org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter";
+
+    ServiceInvoker dlQueueInvoker;
+
+    public ContentBasedWiretap(ConfigTree config)
+            throws ConfigurationException, RegistryException,
+            MessageRouterException {
+        _config = config;
+        checkMyParms();
+        _registry = RegistryFactory.getRegistry();
+        _cbr = ContentBasedRouterFactory.getRouter(_cbrClass);
+        _cbr.setConfigTree(config);
+        _mapper = new ObjectMapper(config);
+        try {
+            dlQueueInvoker = new ServiceInvoker(ServiceInvoker.INTERNAL_SERVICE_CATEGORY, ServiceInvoker.DEAD_LETTER_SERVICE_NAME);
+        } catch (MessageDeliverException e) {
+            throw new MessageRouterException(e);
+        }
+    }
+
+    public void initialise() { }
+
+    /**
+     * Router the message to one or more destinations, using the
+     * ContentBasedRouter to figure out to which destinations it is going to
+     * be routed too.
+     *
+     * @param message
+     * @return Message
+     * @throws ActionProcessingException
+     */
+    public Message process(Message message) throws ActionProcessingException 
+    {
+        try {
+            List<Service> outgoingDestinations = executeRules(message);
+            if (outgoingDestinations.size()==0) {
+                String error = "No rule destination(s) "+ _destinations.keySet() + " were matched, "
+                           + ". Please fix your configuration and/or routing rules.";
+                _logger.error(error);
+                try {
+                    _logger.debug("Sending message to the DeadLetterService");
+                    dlQueueInvoker.deliverAsync(message);
+                    throw new ActionProcessingException(error);
+                } catch (MessageDeliverException e) {
+                    throw new MessageRouterException("Failed to deliver message to Dead Letter Channel.", e);
+                }
+            } else {
+                routeMessage(message, outgoingDestinations);
+            }
+        } catch (MessageRouterException e) {
+            throw new ActionProcessingException(e);
+        }
+        return message;
+    }
+    
+    protected List<Service> executeRules(Message message)
+        throws MessageRouterException 
+    {
+        List<Service> outgoingDestinations = new ArrayList<Service>();
+        try {
+            List<Object> objectList = _mapper.createObjectList(message,
+                    _messagePathList);
+            List<String> destinations = _cbr.route(_ruleSet, _ruleLanguage,
+                    _ruleReload, message, objectList);
+            for (String destination : destinations) {
+                if (_destinations.containsKey(destination)) {
+                    outgoingDestinations.add(_destinations.get(destination));
+                } else {
+                    throw new MessageRouterException("Destination " + destination + " does not exist your configuration");
+                }
+            }
+        } catch (ObjectMappingException ome) {
+            throw new MessageRouterException(ome);
+        }
+        return outgoingDestinations;
+    }
+
+    protected final void routeMessage(Message message, List<Service> outgoingDestinations)
+        throws MessageRouterException 
+    {  
+        try {
+            messageMulticaster.sendToSubset(message, outgoingDestinations);
+        } catch (RegistryException e) {
+            throw new MessageRouterException(e);
+        } catch (MessageDeliverException e) {
+            throw new MessageRouterException(e);
+        }
+    }
+
+    /**
+     * Reading the piece of configTree specific to the CBR, and setting the
+     * configuration.
+     *
+     * @throws ConfigurationException
+     */
+    protected void checkMyParms() throws ConfigurationException {
+        _ruleSet = _config.getAttribute(ListenerTagNames.RULE_SET_TAG);
+        _ruleLanguage = _config.getAttribute(ListenerTagNames.RULE_LANGUAGE_TAG);
+        String ruleReload = _config.getAttribute(ListenerTagNames.RULE_RELOAD_TAG);
+        if (ruleReload != null && "true".equals(ruleReload)) {
+            _ruleReload = true;
+        }
+
+        String cbrAlias = _config.getAttribute(ListenerTagNames.CBR_ALIAS);
+
+        _cbrClass = _config.getAttribute(ListenerTagNames.CBR_CLASS);
+        if(cbrAlias != null && _cbrClass != null) {
+            throw new ConfigurationException("Invalid " + getClass().getSimpleName() + " configuration.  Cannot configure both '" + ListenerTagNames.CBR_ALIAS + "' and '" + ListenerTagNames.CBR_CLASS + "' properties on the same action configuration.");
+        }
+
+        if(_cbrClass == null) {
+            if(cbrAlias == null) {
+                _cbrClass = DEFAULT_CBR_CLASS;
+            } else if(cbrAlias.equalsIgnoreCase("JBRules") || cbrAlias.equalsIgnoreCase("Drools")) {
+                _cbrClass = DEFAULT_CBR_CLASS;
+            } else if(cbrAlias.equalsIgnoreCase("XPath")) {
+                _cbrClass = XPathRouter.class.getName();
+            } else {
+                throw new ConfigurationException("Invalid " + getClass().getSimpleName() + " configuration.  Unsupported '" + ListenerTagNames.CBR_ALIAS + "' property value '" + cbrAlias + "'.");
+            }
+        }
+
+        _destinations = new HashMap<String, Service>();
+        ConfigTree[] destList = _config.getChildren(ROUTE_TO_TAG);
+        if (destList != null) {
+            for (ConfigTree curr : destList) {
+                try {
+                    String key = buildDestinationKey(curr);
+                    String category = curr.getAttribute(
+                            ListenerTagNames.SERVICE_CATEGORY_NAME_TAG, "");
+                    String name = curr
+                            .getRequiredAttribute(ListenerTagNames.SERVICE_NAME_TAG);
+                    Service service = new Service(category, name);
+                    _destinations.put(key, service);
+                    messageMulticaster.addRecipient(service);
+                }
+                catch (Exception e) {
+                    throw new ConfigurationException(
+                            "Problems with destination list", e);
+                }
+            }
+        }
+        _messagePathList = new ArrayList<String>();
+        entryPointMap = new HashMap<String, List<String>>();
+        ConfigTree[] objectList = _config.getChildren(OBJECT_PATH_TAG);
+        if (objectList != null) {
+            for (ConfigTree curr : objectList) {
+                try {
+                    final String objectPath = curr.getRequiredAttribute(OBJECT_PATH);
+                    final String entryPoint = curr.getAttribute(ENTRY_POINT);
+                    if (entryPoint != null)
+                    {
+                        List<String> list = entryPointMap.get(entryPoint);
+                        if (list == null)
+                        {
+                            list = new ArrayList<String>();
+                            // Add the list to the entrypoint map indexed by the entry-point name.
+                            entryPointMap.put(entryPoint, list);
+                        }
+                        // Add the object path to the entry-point list.
+                        list.add(objectPath);
+                    }
+                    else
+                    {
+                        _messagePathList.add(objectPath);
+                    }
+                }
+                catch (Exception e) {
+                    throw new ConfigurationException( "Problems with object path list", e);
+                }
+            }
+        }
+        
+
+    }
+
+    public static String buildDestinationKey(ConfigTree destinationConfig) throws ConfigurationException {
+        String key = destinationConfig.getAttribute(ListenerTagNames.DESTINATION_NAME_TAG);
+
+        if(key != null) {
+            return key;
+        }
+
+        // Otherwise, build a key from the service category and name...
+        String category = destinationConfig.getAttribute(ListenerTagNames.SERVICE_CATEGORY_NAME_TAG, "");
+        String name = destinationConfig.getRequiredAttribute(ListenerTagNames.SERVICE_NAME_TAG);
+
+        return category + "-" + name;
+    }
+
+    protected ConfigTree _config;
+
+    protected Map<String, Service> _destinations;
+
+    protected MessageMulticaster messageMulticaster = new MessageMulticaster();
+
+    protected String _cbrClass;
+
+    protected String _ruleSet;
+
+    protected String _ruleLanguage;
+
+    protected boolean _ruleReload;
+
+    protected List<String> _messagePathList;
+    
+    protected Map<String, List<String>> entryPointMap;
+
+    protected ObjectMapper _mapper;
+
+    protected Registry _registry;
+
+    protected org.jboss.soa.esb.services.routing.cbr.ContentBasedRouter _cbr;
+
+    protected static Logger _logger = Logger
+            .getLogger(ContentBasedWiretap.class);
+
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/AbstractPropertyRulesRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/AbstractPropertyRulesRouter.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/AbstractPropertyRulesRouter.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -0,0 +1,187 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.cbr;
+
+import org.jboss.soa.esb.services.routing.cbr.ContentBasedRouter;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.MessagePayloadProxy;
+import org.jboss.soa.esb.message.mapping.ObjectMapper;
+import org.jboss.soa.esb.message.mapping.ObjectMappingException;
+import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.actions.ContentBasedWiretap;
+import org.jboss.soa.esb.ConfigurationException;
+import org.apache.log4j.Logger;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * Abstract Property Rules Router.
+ * <p/>
+ * Abstract base class for rules based routers that define their rules in
+ * in {@link Properties} based formats (.properties files).
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+abstract class AbstractPropertyRulesRouter implements ContentBasedRouter {
+
+    protected Logger logger;
+    private String ruleSetConfig;
+    private File ruleSetFile;
+    private long lastLoaded = 0L;
+    private Map<String, RoutingRule> routingMap;
+    private MessagePayloadProxy payloadProxy;
+
+    protected AbstractPropertyRulesRouter() {
+        logger = Logger.getLogger(getClass());
+    }
+
+    public void setConfigTree(ConfigTree configTree) throws MessageRouterException {
+        ruleSetConfig = configTree.getAttribute(ListenerTagNames.RULE_SET_TAG);
+        if(ruleSetConfig != null) {
+            ruleSetFile = new File(ruleSetConfig);
+            routingMap = buildRoutingMap(loadRules());
+        } else {
+            ConfigTree[] routeToConfigs = configTree.getChildren(ContentBasedWiretap.ROUTE_TO_TAG);
+
+            Properties rules = new Properties();
+            for(ConfigTree routeToConfig : routeToConfigs) {
+                try {
+                    String destinationName = ContentBasedWiretap.buildDestinationKey(routeToConfig);
+                    String expression = routeToConfig.getRequiredAttribute("expression");
+
+                    rules.setProperty(destinationName, expression);
+                } catch (ConfigurationException e) {
+                    throw new MessageRouterException("Error processing <rule> configuration.", e);
+                }
+            }
+            routingMap = buildRoutingMap(rules);
+        }
+
+        payloadProxy = new MessagePayloadProxy(configTree);
+    }
+
+    public Map<String, RoutingRule> getRoutingMap() {
+        return routingMap;
+    }
+
+    public abstract Map<String, RoutingRule> buildRoutingMap(Properties rules) throws MessageRouterException;
+
+    public List<String> route(String ruleSet, String ruleLanguage, boolean ruleReload, Message message, List<Object> objectList) throws MessageRouterException {
+        return route(ruleSet, ruleReload, message, objectList);
+    }
+
+    public List<String> route(String ruleSet, boolean ruleReload, Message message, List<Object> objectList) throws MessageRouterException {
+        if(ruleReload && ruleSetFile != null) {
+            if(ruleSetFile.exists() && ruleSetFile.lastModified() != lastLoaded) {
+                routingMap = buildRoutingMap(loadRules());
+            }
+        }
+
+        List<Object> objectsToTest = getMessageObjectsToTest(message, objectList);
+        List<String> destinations = new ArrayList<String>();
+        Set<Map.Entry<String, RoutingRule>> routingRules = routingMap.entrySet();
+
+        for(Map.Entry<String, RoutingRule> routingRule : routingRules) {
+            for(Object objectToTest : objectsToTest) {
+                if(routingRule.getValue().evaluate(objectToTest)) {
+                    destinations.add(routingRule.getKey());
+                }
+            }
+        }
+
+        return destinations;
+    }
+
+    private Properties loadRules() throws MessageRouterException {
+        InputStream ruleStream;
+
+        // Get the properties file stream...
+        if(ruleSetFile.exists()) {
+            try {
+                ruleStream = new FileInputStream(ruleSetFile);
+            } catch (FileNotFoundException e) {
+                throw new MessageRouterException("Unable to open rule properties file '" + ruleSetFile.getAbsolutePath() + "'.", e);
+            }
+            lastLoaded = ruleSetFile.lastModified();
+        } else {
+            ruleStream = ClassUtil.getResourceAsStream(ruleSetConfig, AbstractPropertyRulesRouter.class);
+        }
+
+        if(ruleStream == null) {
+            throw new MessageRouterException("Unable to open rule properties file '" + ruleSetConfig + "'.");
+        }
+
+        // Load the rule properties...
+        Properties rules = new Properties();
+        try {
+            try {
+                rules.load(ruleStream);
+            } catch (IOException e) {
+                throw new MessageRouterException("Error reading rule properties file '" + ruleSetConfig + "'.", e);
+            }
+        } finally {
+            try {
+                ruleStream.close();
+            } catch (IOException e) {
+                throw new MessageRouterException("Error closing rule properties file '" + ruleSetConfig + "'.", e);
+            }
+        }
+
+        return rules;
+    }
+
+    private List<Object> getMessageObjectsToTest(Message message, List<Object> objectList) throws MessageRouterException {
+        List<Object> objectsToTest = new ArrayList<Object>();
+
+        if(objectList == null || objectList.isEmpty()) {
+            try {
+                objectsToTest.add(payloadProxy.getPayload(message));
+            } catch (MessageDeliverException e) {
+                throw new MessageRouterException("Failed to get message payload from message.", e);
+            }
+        } else {
+            ObjectMapper objectMapper = new ObjectMapper();
+
+            for(Object object : objectList) {
+                if(object instanceof String) {
+                    try {
+                        Object mappedObject = objectMapper.getObjectFromMessage(message, (String) object);
+
+                        if(mappedObject == null) {
+                            logger.debug("Object '" + object + "' not present on message.");
+                            continue;
+                        }
+
+                        objectsToTest.add(mappedObject);
+                    } catch (ObjectMappingException e) {
+                        logger.debug("Object '" + object + "' not present on message.");
+                    }
+                }
+            }
+        }
+
+        return objectsToTest;
+    }
+}

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/RoutingRule.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/RoutingRule.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/RoutingRule.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.cbr;
+
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+
+/**
+ * Routing Rule.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public interface RoutingRule {
+
+    /**
+     * Evaluate the rule for the supplied Object.
+     * @param objectToTest The object to test.
+     * @return True if the object "matches" the rule, otherwise false.
+     * @throws MessageRouterException Error evaluating the rule against the object.
+     */
+    boolean evaluate(Object objectToTest) throws MessageRouterException;
+}

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/XPathRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/XPathRouter.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/cbr/XPathRouter.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.cbr;
+
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.util.XPathNamespaceContext;
+import org.jboss.soa.esb.ConfigurationException;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import javax.xml.xpath.*;
+import java.util.*;
+import java.io.*;
+
+/**
+ * XPath Content Based Router implementation.
+ * 
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class XPathRouter extends AbstractPropertyRulesRouter {
+
+    private XPathNamespaceContext namespaceContext;
+
+    public void setConfigTree(ConfigTree configTree) throws MessageRouterException {
+        try {
+            namespaceContext = new NamespaceContext(configTree.getChildren("namespace"));
+        } catch (ConfigurationException e) {
+            throw new MessageRouterException("Error loading namespace prefix mappings.", e);
+        }
+
+        super.setConfigTree(configTree);
+    }
+
+    public Map<String, RoutingRule> buildRoutingMap(Properties rules) throws MessageRouterException {
+        XPathFactory xPathFactory = XPathFactory.newInstance();
+        XPath xpath = xPathFactory.newXPath();
+        Map<String, RoutingRule> routingMap = new HashMap<String, RoutingRule>();
+
+        xpath.setNamespaceContext(namespaceContext);
+
+        Set<Map.Entry<Object, Object>> ruleSet = rules.entrySet();
+        for(Map.Entry<Object, Object> rule : ruleSet) {
+            String destinationName = (String) rule.getKey();
+            String expression = (String) rule.getValue();
+            try {
+                routingMap.put(destinationName, new XPathRoutingRule(xpath.compile(expression)));
+            } catch (XPathExpressionException e) {
+                throw new MessageRouterException("Error compiling XPath expression '" + expression + "'.", e);
+            }
+        }
+
+        return routingMap;
+    }
+
+    public javax.xml.namespace.NamespaceContext getNamespaceContext() {
+        return namespaceContext;
+    }
+
+    private class XPathRoutingRule implements RoutingRule {
+
+        private XPathExpression xpathExpression;
+
+        private XPathRoutingRule(XPathExpression xpathExpression) {
+            this.xpathExpression = xpathExpression;
+        }
+
+        public boolean evaluate(Object objectToTest) throws MessageRouterException {
+            try {
+                if(objectToTest instanceof String) {
+                    return (Boolean) xpathExpression.evaluate(new InputSource(new StringReader((String) objectToTest)), XPathConstants.BOOLEAN);
+                } else if(objectToTest instanceof byte[]) {
+                    return (Boolean) xpathExpression.evaluate(new InputSource(new ByteArrayInputStream((byte[]) objectToTest)), XPathConstants.BOOLEAN);
+                } else if(objectToTest instanceof Node || objectToTest instanceof NodeList) {
+                    return (Boolean) xpathExpression.evaluate(objectToTest, XPathConstants.BOOLEAN);
+                } else {
+                    logger.debug("Unsupported XPath evaluation type '" + objectToTest.getClass().getName() + "'.");
+                }
+            } catch (XPathExpressionException e) {
+                logger.debug("Error evaluating xpath expression.", e);
+            }
+
+            return false;
+        }
+    }
+
+    private class NamespaceContext extends XPathNamespaceContext {
+
+        public NamespaceContext(ConfigTree[] namespaces) throws ConfigurationException {
+            if(namespaces != null) {
+                for(ConfigTree namespace : namespaces) {
+                    String prefix = namespace.getRequiredAttribute("prefix");
+                    String uri = namespace.getRequiredAttribute("uri");
+
+                    setMapping(prefix, uri);
+                }
+            }
+        }
+    }
+}

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerTagNames.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerTagNames.java	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerTagNames.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -113,6 +113,7 @@
     /** Content Based Routing */
     /** RuleSet reference (Filename) */
     public static final String CBR_CLASS                    = "cbrClass";
+    public static final String CBR_ALIAS                    = "cbrAlias";
     public static final String RULE_SET_TAG                 = "ruleSet";
     public static final String RULE_LANGUAGE_TAG            = "ruleLanguage";
     public static final String RULE_RELOAD_TAG              = "ruleReload";

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouter.java	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouter.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -27,6 +27,7 @@
 
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.services.routing.MessageRouterException;
+import org.jboss.soa.esb.ConfigurationException;
 
 /**
  * Content Based Router Interface. Separates implementation from the runtime, allowing
@@ -37,7 +38,7 @@
  */
 public interface ContentBasedRouter
 {  
-	public abstract void setConfigTree(ConfigTree configTree);
+	public abstract void setConfigTree(ConfigTree configTree) throws MessageRouterException;
 	
 	/**
 	 * Route a message using a certain ruleSet and reference a custom

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/XPathRouterUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/XPathRouterUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/XPathRouterUnitTest.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.cbr.xpath;
+
+import junit.framework.TestCase;
+import org.jboss.soa.esb.testutils.ESBConfigUtil;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+import org.jboss.soa.esb.actions.cbr.XPathRouter;
+import org.jboss.soa.esb.actions.cbr.RoutingRule;
+import org.xml.sax.SAXException;
+
+import javax.xml.namespace.NamespaceContext;
+import java.io.IOException;
+import java.io.File;
+import java.io.ByteArrayInputStream;
+import java.util.Map;
+import java.util.List;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class XPathRouterUnitTest extends TestCase {
+
+    public void test_rulefile_load_classpath() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+        test("1");
+    }
+
+    public void test_rulefile_load_filesys() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+        String cwd = new File(".").getAbsolutePath().replace("\\", "/");
+        if(!cwd.endsWith("product/.")) {
+            throw new IllegalStateException("Invalid working directory for test.  Must be the 'product/rosetta/tests' dir.  Current working directory is '" + cwd + "'.");
+        }
+
+        test("2");
+    }
+
+    public void test_inlineRules() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+        test("3");
+    }
+
+    public void test_namespaces_undefined() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+        try {
+            test("4");
+            fail("Expected MessageRouterException");
+        } catch (MessageRouterException e) {
+            assertEquals("Error compiling XPath expression '/a:order/b:header[@cat='blue']'.", e.getMessage());
+        }
+    }
+
+    public void test_namespaces_defined() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+        NamespaceContext nsContext = test("5");
+
+        assertEquals("http://a", nsContext.getNamespaceURI("a"));
+        assertEquals("http://b", nsContext.getNamespaceURI("b"));
+    }
+
+    private NamespaceContext test(String configName) throws MessageRouterException, IOException, SAXException, ConfigurationException {
+        ESBConfigUtil esbConfig = new ESBConfigUtil(getClass().getResourceAsStream("config.xml"));
+        ConfigTree configTree = esbConfig.getActionConfig("null-listener", configName);
+        XPathRouter router = new XPathRouter();
+
+        router.setConfigTree(configTree);
+
+        Map<String, RoutingRule> map = router.getRoutingMap();
+        assertEquals(3, map.size());
+        assertNotNull(map.get("scat-red"));
+        assertNotNull(map.get("scat-green"));
+        assertNotNull(map.get("scat-blue"));
+
+        return router.getNamespaceContext();
+    }
+
+    public static final String GREEN_MESSAGE = "<order xmlns='http://a' xmlns:bbbb='http://b'><bbbb:header cat='green'/></order>";
+
+    public void test_routing_String() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+        Message message = MessageFactory.getInstance().getMessage();
+
+        message.getBody().add(GREEN_MESSAGE);
+        test_routing(message, null);
+    }
+
+    public void test_routing_bytes() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+        Message message = MessageFactory.getInstance().getMessage();
+
+        message.getBody().add(GREEN_MESSAGE.getBytes());
+        test_routing(message, null);
+    }
+
+    public void test_routing_dom() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+        Message message = MessageFactory.getInstance().getMessage();
+
+        message.getBody().add(YADOMUtil.parseStream(new ByteArrayInputStream(GREEN_MESSAGE.getBytes()), true, true, true));
+        test_routing(message, null);
+    }
+
+    public void test_routing_ObjectList() throws IOException, SAXException, ConfigurationException, MessageRouterException {
+        Message message = MessageFactory.getInstance().getMessage();
+
+        message.getBody().add("x", "<x/>");
+        message.getBody().add("y", GREEN_MESSAGE);        
+        test_routing(message, Arrays.asList("y"));
+        test_routing(message, Arrays.asList("body.y"));
+    }
+
+    public void test_routing(Message message, List objectLists) throws IOException, SAXException, ConfigurationException, MessageRouterException {
+        ESBConfigUtil esbConfig = new ESBConfigUtil(getClass().getResourceAsStream("config.xml"));
+        ConfigTree configTree = esbConfig.getActionConfig("null-listener", "5");
+        XPathRouter router = new XPathRouter();
+
+        router.setConfigTree(configTree);
+
+        List<String> destinations = router.route(null, false, message, objectLists);
+        assertEquals("[scat-green]", destinations.toString());
+    }
+}

Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/config.xml (from rev 29436, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/aggregation/action-configs-01.xml)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/config.xml	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/config.xml	2009-09-29 14:01:41 UTC (rev 29503)
@@ -0,0 +1,54 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
+
+    <providers>
+        <bus-provider name="null"><bus busid="null"/></bus-provider>
+    </providers>
+
+    <services>
+        <service category="scat" name="sname" description="boo">
+
+            <listeners>
+                <listener name="null-listener" busidref="null" />
+            </listeners>
+
+            <actions mep="OneWay">
+                <action name="1" class="org.jboss.soa.esb.actions.ContentBasedRouter">
+                    <property name="ruleSet" value="/org/jboss/soa/esb/actions/cbr/xpath/rules.properties"/>
+                </action>
+
+                <action name="2" class="org.jboss.soa.esb.actions.ContentBasedRouter">
+                    <property name="ruleSet" value="rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/rules.properties"/>
+                </action>
+
+                <action name="3" class="org.jboss.soa.esb.actions.ContentBasedRouter">
+                    <property name="destinations">
+                        <route-to service-category="scat" service-name="blue"  expression="/order/header[@cat='blue']" />
+                        <route-to service-category="scat" service-name="red"   expression="/order/header[@cat='red']" />
+                        <route-to service-category="scat" service-name="green" expression="/order/header[@cat='green']" />
+                    </property>
+                </action>
+
+                <!-- Undefined namespaces.. should get an error... -->
+                <action name="4" class="org.jboss.soa.esb.actions.ContentBasedRouter">
+                    <property name="destinations">
+                        <route-to service-category="scat" service-name="blue"  expression="/a:order/b:header[@cat='blue']" />
+                    </property>
+                </action>
+
+                <action name="5" class="org.jboss.soa.esb.actions.ContentBasedRouter">
+                    <property name="destinations">
+                        <route-to service-category="scat" service-name="blue"  expression="/a:order/b:header[@cat='blue']" />
+                        <route-to service-category="scat" service-name="red"   expression="/a:order/b:header[@cat='red']" />
+                        <route-to service-category="scat" service-name="green" expression="/a:order/b:header[@cat='green']" />
+                    </property>
+                    <property name="namespaces">
+                        <namespace prefix="a" uri="http://a" />
+                        <namespace prefix="b" uri="http://b" />
+                    </property>
+                </action>
+
+            </actions>
+        </service>
+    </services>
+</jbossesb>


Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/config.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/rules.properties
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/rules.properties	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/cbr/xpath/rules.properties	2009-09-29 14:01:41 UTC (rev 29503)
@@ -0,0 +1,3 @@
+scat-blue=/order/header[@cat='blue']
+scat-red=/order/header[@cat='red']
+scat-green=/order/header[@cat='green']
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/SampleOrder.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/SampleOrder.xml	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/SampleOrder.xml	2009-09-29 14:01:41 UTC (rev 29503)
@@ -1,4 +1,4 @@
-<Order xmlns="http://org.jboss.soa.esb/Order" orderId="1" orderDate="Wed Nov 15 13:45:28 EST 2006" statusCode="2" 
+<Order xmlns="http://org.jboss.soa.esb/Order" orderId="1" orderDate="Wed Nov 15 13:45:28 EST 2006" statusCode="0" 
 netAmount="59.97" totalAmount="64.92" tax="4.95">
 	<Customer userName="user1" firstName="Harry" lastName="Fletcher" state="SD"/>
 	<OrderLines>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/build.xml	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/build.xml	2009-09-29 14:01:41 UTC (rev 29503)
@@ -12,14 +12,24 @@
 	<import file="../conf/base-build.xml"/>
 	
 	
-  <target name="runtest" depends="compile"
-	description="willl receive JMS message to tigger the actions in the ESB">
-     <echo>Runs Test JMS Sender</echo>
-     <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.funcbr.test.SendJMSMessage" failonerror="true">
-		<classpath refid="exec-classpath" />
-     </java>
-  </target>  
-	
+    <target name="runtest" depends="runtestXPath" description="Send JMS message to tigger the actions in the ESB" />
+
+    <target name="runtestXPath" depends="compile" description="Send JMS message to tigger the actions in the ESB">
+       <echo>Runs XPath Example</echo>
+       <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.funcbr.test.SendJMSMessage" failonerror="true">
+          <classpath refid="exec-classpath" />
+          <arg value="quickstart_Fun_XPathCBR_Request_GW" />
+       </java>
+    </target>
+
+    <target name="runtestDrools" depends="compile" description="Send JMS message to tigger the actions in the ESB">
+       <echo>Runs Drools Example</echo>
+       <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.funcbr.test.SendJMSMessage" failonerror="true">
+          <classpath refid="exec-classpath" />
+          <arg value="quickstart_Fun_DroolsCBR_Request_GW" />
+       </java>
+    </target>
+
   <target name="receiveBlue" depends="compile"
 	description="willl receive a message from the quickstart_FunCBR_Green_Blue queue">
 	 <echo>Runs Test JMS Receiver</echo>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/deployment.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/deployment.xml	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/deployment.xml	2009-09-29 14:01:41 UTC (rev 29503)
@@ -2,8 +2,8 @@
 <jbossesb-deployment>
   <depends>jboss.esb:deployment=smooks.esb</depends>
   <depends>jboss.esb:deployment=jbrules.esb</depends>
-  <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_Request_GW</depends>
-  <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_Request_ESB</depends>
+  <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_XPathCBR_Request_GW</depends>
+  <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_DroolsCBR_Request_GW</depends>
   <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_ToBlue</depends>
   <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_Blue_Alert</depends>
   <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_ToRed</depends>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jbm-queue-service.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jbm-queue-service.xml	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jbm-queue-service.xml	2009-09-29 14:01:41 UTC (rev 29503)
@@ -3,18 +3,18 @@
   
   <!-- Fun CBR Demo -->
   <mbean code="org.jboss.jms.server.destination.QueueService"
-    name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_Request_GW"
+    name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_XPathCBR_Request_GW"
     xmbean-dd="xmdesc/Queue-xmbean.xml">
     <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
 	<depends>jboss.messaging:service=PostOffice</depends>
   </mbean>
+    <mbean code="org.jboss.jms.server.destination.QueueService"
+      name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_DroolsCBR_Request_GW"
+      xmbean-dd="xmdesc/Queue-xmbean.xml">
+      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+      <depends>jboss.messaging:service=PostOffice</depends>
+    </mbean>
   <mbean code="org.jboss.jms.server.destination.QueueService"
-    name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_Request_ESB"
-    xmbean-dd="xmdesc/Queue-xmbean.xml">
-    <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
-	<depends>jboss.messaging:service=PostOffice</depends>
-  </mbean>
-  <mbean code="org.jboss.jms.server.destination.QueueService"
     name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_ToBlue"
     xmbean-dd="xmdesc/Queue-xmbean.xml">
     <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jbmq-queue-service.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jbmq-queue-service.xml	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jbmq-queue-service.xml	2009-09-29 14:01:41 UTC (rev 29503)
@@ -3,18 +3,18 @@
   
   <!-- Fun CBR Demo -->
   <mbean code="org.jboss.mq.server.jmx.Queue"
-    name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_Request_GW">
+    name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_XPathCBR_Request_GW">
     <depends optional-attribute-name="DestinationManager">
       jboss.mq:service=DestinationManager
     </depends>
   </mbean>
+    <mbean code="org.jboss.mq.server.jmx.Queue"
+      name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_DroolsCBR_Request_GW">
+      <depends optional-attribute-name="DestinationManager">
+        jboss.mq:service=DestinationManager
+      </depends>
+    </mbean>
   <mbean code="org.jboss.mq.server.jmx.Queue"
-    name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_Request_ESB">
-    <depends optional-attribute-name="DestinationManager">
-      jboss.mq:service=DestinationManager
-    </depends>
-  </mbean>
-  <mbean code="org.jboss.mq.server.jmx.Queue"
     name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_ToBlue">
     <depends optional-attribute-name="DestinationManager">
       jboss.mq:service=DestinationManager

Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jboss-esb.xml	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/jboss-esb.xml	2009-09-29 14:01:41 UTC (rev 29503)
@@ -3,11 +3,11 @@
 
     <providers>
           <jms-provider name="JBossMQ" connection-factory="ConnectionFactory">
-             <jms-bus busid="quickstartGwChannel">
-                 <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_Fun_CBR_Request_GW"/>
+             <jms-bus busid="xpathQuickstartGwChannel">
+                 <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_Fun_XPathCBR_Request_GW"/>
              </jms-bus>
-             <jms-bus busid="quickstartEsbChannel">
-                 <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_Fun_CBR_Request_ESB"/>
+             <jms-bus busid="droolsQuickstartGwChannel">
+                 <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_Fun_DroolsCBR_Request_GW"/>
              </jms-bus>
              <jms-bus busid="Fun_CBR_ToBlue">
                  <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_Fun_CBR_ToBlue"/>
@@ -25,35 +25,46 @@
       </providers>
       
       <services>
-        <!-- ESB CBR Service -->
-        <service 
-        	category="Fun_CBRServices_ESB" 
-        	name="FunCBRService_ESB" 
-        	description="ESB Listener - for the native clients">
-        	<listeners>
-        		  <!-- Gateway -->
-        		  <jms-listener name="TheGateway"
-        			   busidref="quickstartGwChannel"
-        			   is-gateway="true"                            
-        		  />     
-                  <jms-listener name="XPathContentBasedRouter"
-                        busidref="quickstartEsbChannel">                
-	             </jms-listener>
-             </listeners>
-        	<actions mep="OneWay">
-        		<action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="ContentBasedRouter">
-        			<property name="ruleSet" value="FunCBRRules-XPath.drl"/>
-        			<property name="ruleLanguage" value="XPathLanguage.dsl"/>
-        			<property name="ruleReload" value="true"/> 
-        			<property name="destinations">
-        				<route-to destination-name="blue"  service-category="BlueTeam"  service-name="GoBlue" /> 
-        				<route-to destination-name="red"   service-category="RedTeam"   service-name="GoRed" /> 
-        				<route-to destination-name="green" service-category="GreenTeam" service-name="GoGreen" /> 
-        			</property> 
-        		</action>
-        	</actions>
-        </service>
-        
+          <!-- ESB XPath CBR Service -->
+          <service category="Fun_CBRServices_ESB" name="XPath_FunCBRService_ESB" description="ESB Listener - for the native clients" invmScope="GLOBAL">
+              <listeners>
+                  <!-- Gateway -->
+                  <jms-listener name="TheGateway" busidref="xpathQuickstartGwChannel" is-gateway="true" />
+               </listeners>
+              <actions mep="OneWay">
+                  <action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="ContentBasedRouter">
+                      <property name="cbrAlias" value="XPath"/>
+                      <property name="destinations">
+                          <namespace prefix="ord" uri="http://org.jboss.soa.esb/Order" />
+
+                          <route-to service-category="BlueTeam"  service-name="GoBlue"  expression="/ord:Order[@statusCode='0']" />
+                          <route-to service-category="RedTeam"   service-name="GoRed"   expression="/ord:Order[@statusCode='1']" />
+                          <route-to service-category="GreenTeam" service-name="GoGreen" expression="/ord:Order[@statusCode='2']" />
+                      </property>
+                  </action>
+              </actions>
+          </service>
+
+        <!-- ESB Drools CBR Service -->
+          <service category="Fun_CBRServices_ESB" name="Drools_FunCBRService_ESB" description="ESB Listener - for the native clients" invmScope="GLOBAL">
+              <listeners>
+                    <!-- Gateway -->
+                    <jms-listener name="TheGateway" busidref="droolsQuickstartGwChannel" is-gateway="true" />
+               </listeners>
+              <actions mep="OneWay">
+                  <action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="ContentBasedRouter">
+                      <property name="ruleSet" value="FunCBRRules-XPath.drl"/>
+                      <property name="ruleLanguage" value="XPathLanguage.dsl"/>
+                      <property name="ruleReload" value="true"/>
+                      <property name="destinations">
+                          <route-to destination-name="blue"  service-category="BlueTeam"  service-name="GoBlue" />
+                          <route-to destination-name="red"   service-category="RedTeam"   service-name="GoRed" />
+                          <route-to destination-name="green" service-category="GreenTeam" service-name="GoGreen" />
+                      </property>
+                  </action>
+              </actions>
+          </service>
+
         <!-- Blue -->
         <service
   	      category="BlueTeam"

Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/readme.txt
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/readme.txt	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/readme.txt	2009-09-29 14:01:41 UTC (rev 29503)
@@ -1,13 +1,14 @@
 Overview:
 =========
   This example has three "teams" of order processors.  All new orders that flow
-  into the system are evaluated via the rules engine.  These routing rules will
-  determine which team receives the order for actually processing.   In the case
-  of the green team, the order is first transformed to a different format prior
-  to routing.
-  This quickstart also show how namepaces can be used with xpath expressions. 
-
+  into the system can be evaluated via the XPath or Drools rule processors.
+  These routing rules will determine which team receives the order for actually
+  processing.   In the case of the green team, the order is first transformed to a
+  different format prior to routing.
+  
+  This quickstart also show how namepaces can be used with xpath expressions. 
 
+
 Running this quickstart:
 ========================
   Please refer to 'ant help-quickstarts' for prerequisites about the quickstarts
@@ -22,7 +23,8 @@
      'ant receiveRed'.
   4. In a command terminal window in this folder ("Window4"), type
      'ant receiveGreen'.
-  5. In "Window1", type 'ant runtest'.
+  5. In "Window1", type 'ant runtestXPath' (or 'ant runtestDrools'). See the build.xml
+     and jboss-esb.xml files.
   6. Switch back to the Application Server console, "Window2", "Window3" and
      "Window4" to see the output from the ESB
   7. When finished, interrupt the receivers using Ctrl-C.

Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/src/org/jboss/soa/esb/samples/quickstart/funcbr/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/src/org/jboss/soa/esb/samples/quickstart/funcbr/test/SendJMSMessage.java	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/src/org/jboss/soa/esb/samples/quickstart/funcbr/test/SendJMSMessage.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -45,7 +45,7 @@
     Queue que;
     
     
-    public void setupConnection() throws JMSException, NamingException
+    public void setupConnection(String queueName) throws JMSException, NamingException
     {
         Properties properties1 = new Properties();
         properties1.put(Context.INITIAL_CONTEXT_FACTORY,
@@ -58,7 +58,7 @@
     	Object tmp = iniCtx.lookup("ConnectionFactory");
     	QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
     	conn = qcf.createQueueConnection();
-    	que = (Queue) iniCtx.lookup("queue/quickstart_Fun_CBR_Request_GW");
+    	que = (Queue) iniCtx.lookup("queue/" + queueName);
     	session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
     	conn.start();
     	System.out.println("Connection Started");
@@ -110,7 +110,7 @@
     public static void main(String args[]) throws Exception
     {        	    	
     	SendJMSMessage sm = new SendJMSMessage();
-    	sm.setupConnection();
+    	sm.setupConnection(args[0]);
     	String fileContent = sm.readAsciiFile("SampleOrder.xml");
     	System.out.println("---------------------------------------------");
     	System.out.println(fileContent);

Modified: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2POJO/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2POJO/jboss-esb.xml	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2POJO/jboss-esb.xml	2009-09-29 14:01:41 UTC (rev 29503)
@@ -42,7 +42,7 @@
                 <action name="transform" class="org.jboss.soa.esb.smooks.SmooksAction">
                     <property name="smooksConfig" value="/smooks-res.xml" />
                     <property name="resultType" value="JAVA" />
-                    <!-- property name="reportPath" value="/zap/smooks-report.html" / -->
+                    <property name="reportPath" value="/zap/smooks-report.html" />
                 </action>
 
                 <action name="convertPOJO2Message" class="org.jboss.soa.esb.dvdstore.DVDStoreAction"	/>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2POJO/src/org/jboss/soa/esb/samples/quickstart/transformxml2pojo/MyJMSListenerAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2POJO/src/org/jboss/soa/esb/samples/quickstart/transformxml2pojo/MyJMSListenerAction.java	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2POJO/src/org/jboss/soa/esb/samples/quickstart/transformxml2pojo/MyJMSListenerAction.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -77,7 +77,7 @@
             ReturnJMSMessage.sendMessage(message, "quickstart_simple_transformation_Response", _config);
         } catch (Exception e) {
             logHeader();
-            System.out.println(e.getMessage());
+            e.printStackTrace();
             logFooter();
         }
         return message; //nothing was done to this but action methods must return a Message

Deleted: labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedRouter.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedRouter.java	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedRouter.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.actions;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.routing.MessageRouterException;
-/**
- * ContentBasedRouter implements the Content Based Routing pattern. 
- * It routes a message to one or more destination services based on the message content 
- * and the rule set it is evaluating it  against. 
- * <p/>
- * For configuration details see
- * 
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- * @author kstam at jboss.com
- * 
- * @see ContentBasedWiretap
- *
- */
-public class ContentBasedRouter extends ContentBasedWiretap
-{
-    public ContentBasedRouter(ConfigTree config) throws ConfigurationException, RegistryException, MessageRouterException
-    {
-        super(config) ;
-    }
-    /** Route the message to one or more destinations, using the ContentBasedRouter to figure out
-     *  to which destinations it is going to be routed too.
-     *  
-     * @param message
-     * @return Message
-     * @throws ActionProcessingException
-     */
-    public Message process(Message message) throws ActionProcessingException
-    {
-        super.process(message) ;
-        return null ;
-    }
-
-    /** 
-     * @deprecated no longer needed, leaving this in here for backwards compatibility,
-     * use the default "process".
-     * */
-    public Message split(Message message) throws ActionProcessingException
-    {
-        _logger.warn("Depricated, please use the default 'process' method in your configuration");
-        return process(message);
-    }
-
-    protected static Logger _logger = Logger.getLogger(ContentBasedRouter.class);
-}

Deleted: labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedWiretap.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedWiretap.java	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedWiretap.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -1,300 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.actions;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.services.rules.RuleInfoBuilder;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.Service;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.client.ServiceInvoker;
-import org.jboss.soa.esb.client.MessageMulticaster;
-import org.jboss.soa.esb.listeners.message.MessageDeliverException;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.mapping.ObjectMapper;
-import org.jboss.soa.esb.message.mapping.ObjectMappingException;
-import org.jboss.soa.esb.services.registry.Registry;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.RegistryFactory;
-import org.jboss.soa.esb.services.routing.MessageRouterException;
-import org.jboss.soa.esb.services.routing.cbr.ContentBasedRouterFactory;
-
-/**
- * ContentBasedWirtap implements the WireTap pattern. 
- * The WireTap is an Enterprise Integration Pattern (EIP) where a copy of the message is 
- * sent to a control channel.
- * <br>
- * The CBR­WT is identical in functionality to the ContentBasedRouter, 
- * however it does not terminate the pipeline which makes it suitable to be used as a WireTap. 
- * <p/> 
- * 
- * Configuration Example:
- *<pre>{@code
- *
- *<action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="OrderDiscountBasedOnCustomerHistory">
- *    <property name="ruleSet" value="OrderDiscountOnMultipleOrders.drl" />
- *    <property name="ruleReload" value="false" />
- *    <property name="stateful" value="true" />
- *    <property name="object-paths">
- *        <object-path esb="body.TheOrderHeader" />
- *        <object-path esb="body.TheCustomer" />
- *    </property>
- *    <property name="destinations">
- *        <route-to destination-name="blue"  service-category="BlueTeam"  service-name="GoBlue" />
- *        <route-to destination-name="red"   service-category="RedTeam"   service-name="GoRed" />
- *        <route-to destination-name="green" service-category="GreenTeam" service-name="GoGreen" />
- *    </property>
- *</action>
- *
- * }</pre>
- * Property description:
- * <lu>
- * <li> <i>class</i>		action class, one of : org.jboss.soa.esb.actions.ContentBasedRouter, org.jboss.soa.esb.actions.ContentBasedWireTap,<br>
- * 							or org.jboss.soa.esb.actions.MessageFilter
- * <li> <i>ruleSet</i>		Name of the filename containing the Drools ruleSet.
- * <li> <i>ruleLanguage</i>	Optional reference to a file containing the definition of a Domain Specific Language to be used for evaluating 
- * 							the rule set.
- * <li> <i>ruleReload</i>	Optional property which can be to true to enable 'hot' redeployment of rule sets. 
- * <li> <i>stateful</i>		Optional property which tells the RuleService to use a stateful session where facts will be 
- * 							remembered between invokations.
- * <li> <i>object-paths</i> Optional property to pass Message objects into Rule Services WorkingMemory.
- * <li> <i>destinations</i> A set of route-­to properties each containing the logical name 
- * 							of the destination along with the Service category and name 
- *  						as referenced in the registry.<br> The logical name is the name 
- *  						which should be used in the rule set.
- * </lu>
- * </br>
- * 
- * 
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- * @author kstam at jboss.com
- * @author kevin.conner at jboss.com
- * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
- */
-public class ContentBasedWiretap extends AbstractActionPipelineProcessor {
-
-    public static final String ROUTE_TO_TAG = "route-to";
-
-    public static final String OBJECT_PATH_TAG = "object-path";
-
-    public static final String OBJECT_PATH = "esb";
-    
-    public static final String ENTRY_POINT = "entry-point";
-
-    public static final String DEFAULT_CBR_CLASS = "org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter";
-
-    ServiceInvoker dlQueueInvoker;
-
-    public ContentBasedWiretap(ConfigTree config)
-            throws ConfigurationException, RegistryException,
-            MessageRouterException {
-        _config = config;
-        checkMyParms();
-        _registry = RegistryFactory.getRegistry();
-        _cbr = ContentBasedRouterFactory.getRouter(_cbrClass);
-        _cbr.setConfigTree(config);
-        _mapper = new ObjectMapper(config);
-        try {
-            dlQueueInvoker = new ServiceInvoker(ServiceInvoker.INTERNAL_SERVICE_CATEGORY, ServiceInvoker.DEAD_LETTER_SERVICE_NAME);
-        } catch (MessageDeliverException e) {
-            throw new MessageRouterException(e);
-        }
-    }
-
-    public void initialise() { }
-
-    /**
-     * Router the message to one or more destinations, using the
-     * ContentBasedRouter to figure out to which destinations it is going to
-     * be routed too.
-     *
-     * @param message
-     * @return Message
-     * @throws ActionProcessingException
-     */
-    public Message process(Message message) throws ActionProcessingException 
-    {
-        try {
-            List<Service> outgoingDestinations = executeRules(message);
-            if (outgoingDestinations.size()==0) {
-                String error = "No rule destination(s) "+ _destinations.keySet() + " were matched, "
-                           + ". Please fix your configuration and/or routing rules.";
-                _logger.error(error);
-                try {
-                    _logger.debug("Sending message to the DeadLetterService");
-                    dlQueueInvoker.deliverAsync(message);
-                    throw new ActionProcessingException(error);
-                } catch (MessageDeliverException e) {
-                    throw new MessageRouterException("Failed to deliver message to Dead Letter Channel.", e);
-                }
-            } else {
-                routeMessage(message, outgoingDestinations);
-            }
-        } catch (MessageRouterException e) {
-            throw new ActionProcessingException(e);
-        }
-        return message;
-    }
-    
-    protected List<Service> executeRules(Message message)
-        throws MessageRouterException 
-    {
-        List<Service> outgoingDestinations = new ArrayList<Service>();
-        try {
-            List<Object> objectList = _mapper.createObjectList(message,
-                    _messagePathList);
-            List<String> destinations = _cbr.route(_ruleSet, _ruleLanguage,
-                    _ruleReload, message, objectList);
-            for (String destination : destinations) {
-                if (_destinations.containsKey(destination)) {
-                    outgoingDestinations.add(_destinations.get(destination));
-                } else {
-                    throw new MessageRouterException("Destination " + destination + " does not exist your configuration");
-                }
-            }
-        } catch (ObjectMappingException ome) {
-            throw new MessageRouterException(ome);
-        }
-        return outgoingDestinations;
-    }
-
-    protected final void routeMessage(Message message, List<Service> outgoingDestinations)
-        throws MessageRouterException 
-    {  
-        try {
-            messageMulticaster.sendToSubset(message, outgoingDestinations);
-        } catch (RegistryException e) {
-            throw new MessageRouterException(e);
-        } catch (MessageDeliverException e) {
-            throw new MessageRouterException(e);
-        }
-    }
-
-    /**
-     * Reading the piece of configTree specific to the CBR, and setting the
-     * configuration.
-     *
-     * @throws ConfigurationException
-     */
-    protected void checkMyParms() throws ConfigurationException {
-        _ruleSet = _config.getAttribute(ListenerTagNames.RULE_SET_TAG);
-        _ruleLanguage = _config.getAttribute(ListenerTagNames.RULE_LANGUAGE_TAG);
-        String ruleReload = _config.getAttribute(ListenerTagNames.RULE_RELOAD_TAG);
-        if (ruleReload != null && "true".equals(ruleReload)) {
-            _ruleReload = true;
-        }
-            
-        if (_config.getAttribute(ListenerTagNames.CBR_CLASS) != null) {
-            _cbrClass = _config.getAttribute(ListenerTagNames.CBR_CLASS);
-        } else {
-            _cbrClass = DEFAULT_CBR_CLASS;
-        }
-
-        _destinations = new HashMap<String, Service>();
-        ConfigTree[] destList = _config.getChildren(ROUTE_TO_TAG);
-        if (destList != null) {
-            for (ConfigTree curr : destList) {
-                try {
-                    String key = curr
-                            .getRequiredAttribute(ListenerTagNames.DESTINATION_NAME_TAG);
-                    String category = curr.getAttribute(
-                            ListenerTagNames.SERVICE_CATEGORY_NAME_TAG, "");
-                    String name = curr
-                            .getRequiredAttribute(ListenerTagNames.SERVICE_NAME_TAG);
-                    Service service = new Service(category, name);
-                    _destinations.put(key, service);
-                    messageMulticaster.addRecipient(service);
-                }
-                catch (Exception e) {
-                    throw new ConfigurationException(
-                            "Problems with destination list", e);
-                }
-            }
-        }
-        _messagePathList = new ArrayList<String>();
-        entryPointMap = new HashMap<String, List<String>>();
-        ConfigTree[] objectList = _config.getChildren(OBJECT_PATH_TAG);
-        if (objectList != null) {
-            for (ConfigTree curr : objectList) {
-                try {
-                    final String objectPath = curr.getRequiredAttribute(OBJECT_PATH);
-                    final String entryPoint = curr.getAttribute(ENTRY_POINT);
-                    if (entryPoint != null)
-                    {
-                        List<String> list = entryPointMap.get(entryPoint);
-                        if (list == null)
-                        {
-                            list = new ArrayList<String>();
-                            // Add the list to the entrypoint map indexed by the entry-point name.
-                            entryPointMap.put(entryPoint, list);
-                        }
-                        // Add the object path to the entry-point list.
-                        list.add(objectPath);
-                    }
-                    else
-                    {
-                        _messagePathList.add(objectPath);
-                    }
-                }
-                catch (Exception e) {
-                    throw new ConfigurationException( "Problems with object path list", e);
-                }
-            }
-        }
-        
-
-    }
-
-    protected ConfigTree _config;
-
-    protected Map<String, Service> _destinations;
-
-    protected MessageMulticaster messageMulticaster = new MessageMulticaster();
-
-    protected String _cbrClass;
-
-    protected String _ruleSet;
-
-    protected String _ruleLanguage;
-
-    protected boolean _ruleReload;
-
-    protected List<String> _messagePathList;
-    
-    protected Map<String, List<String>> entryPointMap;
-
-    protected ObjectMapper _mapper;
-
-    protected Registry _registry;
-
-    protected org.jboss.soa.esb.services.routing.cbr.ContentBasedRouter _cbr;
-
-    protected static Logger _logger = Logger
-            .getLogger(ContentBasedWiretap.class);
-
-}

Modified: labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/FunCBRTest.java
===================================================================
--- labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/FunCBRTest.java	2009-09-29 13:13:16 UTC (rev 29502)
+++ labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/FunCBRTest.java	2009-09-29 14:01:41 UTC (rev 29503)
@@ -54,7 +54,7 @@
 
 	public void sendMessage() throws Exception {
 		SendJMSMessage sm = new SendJMSMessage();
-		sm.setupConnection();
+		sm.setupConnection("quickstart_Fun_DroolsCBR_Request_GW");
 		sm.sendAMessage(theXML);
 		sm.stop();
 	} /* method */



More information about the jboss-svn-commits mailing list