You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by us...@apache.org on 2012/10/08 06:24:22 UTC

svn commit: r1395449 - in /synapse/trunk/java/modules/core: ./ src/main/java/org/apache/synapse/libraries/eip/ src/test/java/org/apache/synapse/libraries/eip/ src/test/resources/synapse-libraries/assembly/ src/test/resources/synapse-libraries/synapse-e...

Author: uswick
Date: Mon Oct  8 04:24:21 2012
New Revision: 1395449

URL: http://svn.apache.org/viewvc?rev=1395449&view=rev
Log:
committing patch https://issues.apache.org/jira/browse/SYNAPSE-745 for libarary based EIP patterns

Added:
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/CalloutBlockMediator.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/ContentBasedRouterMediator.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/DynamicRouterMediator.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/EIPUtils.java
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/assembly/assemble-eipcore-lib.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/assembly/assemble-eiptest-lib.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/artifacts.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/artifact.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_aggregator.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_callout_block.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_content_based_router.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_dynamic_router.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_recipient_list.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_scatter_gather.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_splitter.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_splitter_aggregator.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_systemManagement/
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_systemManagement/artifact.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_systemManagement/template_wire_tap.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/artifacts.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/eip_systemManagement/
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/eip_systemManagement/artifact.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/eip_systemManagement/template_splitter.xml
Removed:
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/assembly/assemble-eip-lib.xml
Modified:
    synapse/trunk/java/modules/core/pom.xml
    synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/libraries/eip/AbstractEipLibTestCase.java
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/artifacts.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/eip_systemManagement/artifact.xml
    synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/eip_systemManagement/template_splitter.xml

Modified: synapse/trunk/java/modules/core/pom.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/pom.xml?rev=1395449&r1=1395448&r2=1395449&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/pom.xml (original)
+++ synapse/trunk/java/modules/core/pom.xml Mon Oct  8 04:24:21 2012
@@ -103,14 +103,33 @@
                             <goal>attached</goal>
                         </goals>
                         <configuration>
-                            <finalName>synapse-eip-lib</finalName>
+                            <finalName>synapse-eiptest-lib</finalName>
                             <filters>
                                 <filter>
                                     ${basedir}/src/test/resources/synapse-libraries/assembly/filter.properties
                                 </filter>
                             </filters>
                             <descriptors>
-                                <descriptor>src/test/resources/synapse-libraries/assembly/assemble-eip-lib.xml
+                                <descriptor>src/test/resources/synapse-libraries/assembly/assemble-eiptest-lib.xml
+                                </descriptor>
+                            </descriptors>
+                        </configuration>
+                    </execution>
+                     <execution>
+                        <id>eipcore-library-assembly</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>attached</goal>
+                        </goals>
+                        <configuration>
+                            <finalName>synapse-eipcore-lib</finalName>
+                            <filters>
+                                <filter>
+                                    ${basedir}/src/test/resources/synapse-libraries/assembly/filter.properties
+                                </filter>
+                            </filters>
+                            <descriptors>
+                                <descriptor>src/test/resources/synapse-libraries/assembly/assemble-eipcore-lib.xml
                                 </descriptor>
                             </descriptors>
                         </configuration>
@@ -133,8 +152,10 @@
                                 <mkdir dir="target/test_repos/synapse/services"/>
                                 <mkdir dir="target/test_repos/client/modules"/>
                                 <mkdir dir="target/test_repos/synapse/synapse-libraries"/>
+                                <mkdir dir="target/library_repos"/>
                                 <copy file="target/synapse-test-lib.zip" todir="target/test_repos/synapse/synapse-libraries"/>
-                                <copy file="target/synapse-eip-lib.zip" todir="target/test_repos/synapse/synapse-libraries"/>
+                                <copy file="target/synapse-eiptest-lib.zip" todir="target/test_repos/synapse/synapse-libraries"/>
+                                <copy file="target/synapse-eipcore-lib.zip" todir="target/library_repos"/>
                             </tasks>
                         </configuration>
                         <goals>
@@ -147,7 +168,8 @@
                         <configuration>
                             <tasks>
                                 <delete file="target/synapse-test-lib.zip"/>
-                                <delete file="target/synapse-eip-lib.zip"/>
+                                <delete file="target/synapse-eiptest-lib.zip"/>
+                                <delete file="target/synapse-eipcore-lib.zip"/>
                             </tasks>
                         </configuration>
                         <goals>

Added: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/CalloutBlockMediator.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/CalloutBlockMediator.java?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/CalloutBlockMediator.java (added)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/CalloutBlockMediator.java Mon Oct  8 04:24:21 2012
@@ -0,0 +1,379 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.synapse.libraries.eip;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.synapse.*;
+import org.apache.synapse.core.SynapseEnvironment;
+import org.apache.synapse.core.axis2.Axis2MessageContext;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.util.MessageHelper;
+import org.apache.synapse.util.xpath.SynapseXPath;
+import org.jaxen.JaxenException;
+
+import java.util.Iterator;
+import java.util.List;
+
+/*
+ *This pattern blocks external service invocation during mediation.The list of endpoints through
+ *which the message should pass will be given at the design time via callout blocks.
+ *Each time the message returns from an endpoint, it will proceed to next callout block defined.
+ */
+
+public class CalloutBlockMediator extends AbstractMediator implements ManagedLifecycle {
+
+    private ThreadLocal<String> serviceURL = new ThreadLocal<String>();
+    private ThreadLocal<String> action = new ThreadLocal<String>();
+    private ThreadLocal<String> requestKey = new ThreadLocal<String>();
+    private ThreadLocal<SynapseXPath> requestXPath = new ThreadLocal<SynapseXPath>();
+    private ThreadLocal<SynapseXPath> targetXPath = new ThreadLocal<SynapseXPath>();
+    private ThreadLocal<String> targetKey = new ThreadLocal<String>();
+
+    private ConfigurationContext configCtx = null;
+    private String clientRepository = null;
+    private String axis2xml = null;
+    private boolean passHeaders = false;
+    public final static String DEFAULT_CLIENT_REPO = "./samples/axis2Client/client_repo";
+    public final static String DEFAULT_AXIS2_XML = "./samples/axis2Client/client_repo/conf/axis2.xml";
+
+    /**
+     * Blocks external service invocation
+     *
+     * @param synCtx the current message for mediation
+     * @return true
+     */
+    public boolean mediate(MessageContext synCtx) {
+
+        SynapseLog synLog = getLog(synCtx);
+
+        if (synLog.isTraceOrDebugEnabled()) {
+            synLog.traceOrDebug("Start : Callout mediator");
+
+            if (synLog.isTraceTraceEnabled()) {
+                synLog.traceTrace("Message : " + synCtx.getEnvelope());
+            }
+        }
+
+        initParams(synCtx);
+
+
+        try {
+            ServiceClient sc = new ServiceClient(configCtx, null);
+            Options options = new Options();
+            options.setTo(new EndpointReference(getServiceURL()));
+
+            if (getAction() != null) {
+                options.setAction(getAction());
+            } else {
+                if (synCtx.isSOAP11()) {
+                    options.setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, true);
+                } else {
+                    Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
+                    org.apache.axis2.context.MessageContext axis2MessageCtx =
+                            axis2smc.getAxis2MessageContext();
+                    axis2MessageCtx.getTransportOut().addParameter(
+                            new Parameter(HTTPConstants.OMIT_SOAP_12_ACTION, true));
+                }
+            }
+
+            if (passHeaders) {
+                SOAPHeader header = synCtx.getEnvelope().getHeader();
+                if (header != null) {
+                    Iterator headerElements = header.cloneOMElement().getChildElements();
+                    while (headerElements.hasNext()) {
+                        sc.addHeader((OMElement) headerElements.next());
+                    }
+                }
+            }
+
+            options.setProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);
+            sc.setOptions(options);
+
+            OMElement request = getRequestPayload(synCtx);
+            if (synLog.isTraceOrDebugEnabled()) {
+                synLog.traceOrDebug("About to invoke service : " + getServiceURL() + (getAction() != null ?
+                        " with action : " + getAction() : ""));
+                if (synLog.isTraceTraceEnabled()) {
+                    synLog.traceTrace("Request message payload : " + request);
+                }
+            }
+
+            OMElement result = null;
+            try {
+                options.setCallTransportCleanup(true);
+                result = sc.sendReceive(request);
+            } catch (AxisFault axisFault) {
+                handleFault(synCtx, axisFault);
+            }
+
+            if (synLog.isTraceTraceEnabled()) {
+                synLog.traceTrace("Response payload received : " + result);
+            }
+
+            if (result != null) {
+                if (getTargetXPath() != null) {
+                    Object o = getTargetXPath().evaluate(synCtx);
+
+                    if (o != null && o instanceof OMElement) {
+                        OMNode tgtNode = (OMElement) o;
+                        tgtNode.insertSiblingAfter(result);
+                        tgtNode.detach();
+                    } else if (o != null && o instanceof List && !((List) o).isEmpty()) {
+                        // Always fetches *only* the first
+                        OMNode tgtNode = (OMElement) ((List) o).get(0);
+                        tgtNode.insertSiblingAfter(result);
+                        tgtNode.detach();
+                    } else {
+                        handleException("Evaluation of target XPath expression : " +
+                                getTargetXPath().toString() + " did not yeild an OMNode", synCtx);
+                    }
+                }
+                if (getTargetKey() != null) {
+                    synCtx.setProperty(getTargetKey(), result);
+                }
+            } else {
+                synLog.traceOrDebug("Service returned a null response");
+            }
+
+        } catch (AxisFault e) {
+            handleException("Error invoking service : " + getServiceURL() +
+                    (getAction() != null ? " with action : " + getAction() : ""), e, synCtx);
+        } catch (JaxenException e) {
+            handleException("Error while evaluating the XPath expression: " + getTargetXPath(),
+                    e, synCtx);
+        }
+
+        synLog.traceOrDebug("End : Callout mediator");
+        return true;
+    }
+
+    /**
+     * Initialize parameters via the values fetched from templates
+     * @param synCtx MessageContext
+     */
+    private void initParams(MessageContext synCtx) {
+
+        String serURL = (String) EIPUtils.lookupFunctionParam(synCtx, "service_URL");
+
+        if (serURL != null && !serURL.trim().equals("")) {
+            setServiceURL(serURL);
+        } else {
+            handleException("The 'serviceURL' attribute is required for the Callout mediator", synCtx);
+        }
+
+        String soapAction = (String) EIPUtils.lookupFunctionParam(synCtx, "action");
+
+        if (soapAction != null && !soapAction.trim().equals("")) {
+            setAction(soapAction);
+        }
+
+        Object sXpath = EIPUtils.lookupFunctionParam(synCtx, "source_xpath");
+        Object sKey = EIPUtils.lookupFunctionParam(synCtx, "source_key");
+
+        if (sXpath != null && sXpath instanceof SynapseXPath) {
+            try {
+                setRequestXPath((SynapseXPath) sXpath);
+            } catch (JaxenException e) {
+                handleException("Invalid source XPath  ",synCtx);
+            }
+        } else if (sKey != null) {
+            setRequestKey((String) sKey);
+        } else {
+            handleException("The message 'source' must be specified for a Callout mediator", synCtx);
+        }
+
+        Object tXpath = EIPUtils.lookupFunctionParam(synCtx, "target_xpath");
+        Object tKey = EIPUtils.lookupFunctionParam(synCtx, "target_key");
+
+        if (tXpath != null && tXpath instanceof SynapseXPath) {
+            try {
+                setTargetXPath((SynapseXPath) tXpath);
+            } catch (JaxenException e) {
+                handleException("Invalid target XPath  ",synCtx);
+            }
+        } else if (tKey != null) {
+            setTargetKey((String) tKey);
+        } else {
+            handleException("The message 'target' must be specified for a Callout mediator", synCtx);
+        }
+
+
+    }
+
+
+    /**
+     * Fault Handler
+     * @param synCtx MessageContext
+     * @param axisFault AxisFault
+     */
+    private void handleFault(MessageContext synCtx, AxisFault axisFault) {
+        synCtx.setProperty(SynapseConstants.SENDING_FAULT, Boolean.TRUE);
+        if (axisFault.getFaultCodeElement() != null) {
+            synCtx.setProperty(SynapseConstants.ERROR_CODE,
+                    axisFault.getFaultCodeElement().getText());
+        } else {
+            synCtx.setProperty(SynapseConstants.ERROR_CODE,
+                    SynapseConstants.CALLOUT_OPERATION_FAILED);
+        }
+
+        if (axisFault.getFaultReasonElement() != null) {
+            synCtx.setProperty(SynapseConstants.ERROR_MESSAGE,
+                    axisFault.getFaultReasonElement().getText());
+        } else {
+            synCtx.setProperty(SynapseConstants.ERROR_MESSAGE, "Error while performing " +
+                    "the callout operation");
+        }
+
+        if (axisFault.getFaultDetailElement() != null) {
+            if (axisFault.getFaultDetailElement().getFirstElement() != null) {
+                synCtx.setProperty(SynapseConstants.ERROR_DETAIL,
+                        axisFault.getFaultDetailElement().getFirstElement());
+            } else {
+                synCtx.setProperty(SynapseConstants.ERROR_DETAIL,
+                        axisFault.getFaultDetailElement().getText());
+            }
+        }
+
+        synCtx.setProperty(SynapseConstants.ERROR_EXCEPTION, axisFault);
+        throw new SynapseException("Error while performing the callout operation", axisFault);
+    }
+
+    /**
+     *
+     * @param synCtx MessageContext
+     * @return null
+     * @throws AxisFault
+     */
+    private OMElement getRequestPayload(MessageContext synCtx) throws AxisFault {
+
+        if (getRequestKey() != null) {
+            Object request = synCtx.getProperty(getRequestKey());
+            if (request == null) {
+                request = synCtx.getEntry(getRequestKey());
+            }
+            if (request != null && request instanceof OMElement) {
+                return (OMElement) request;
+            } else {
+                handleException("The property : " + getRequestKey() + " is not an OMElement", synCtx);
+            }
+        } else if (getRequestXPath() != null) {
+            try {
+                Object o = getRequestXPath().evaluate(MessageHelper.cloneMessageContext(synCtx));
+
+                if (o instanceof OMElement) {
+                    return (OMElement) o;
+                } else if (o instanceof List && !((List) o).isEmpty()) {
+                    return (OMElement) ((List) o).get(0);  // Always fetches *only* the first
+                } else {
+                    handleException("The evaluation of the XPath expression : "
+                            + getRequestXPath().toString() + " did not result in an OMElement", synCtx);
+                }
+            } catch (JaxenException e) {
+                handleException("Error evaluating XPath expression : "
+                        + getRequestXPath().toString(), e, synCtx);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Initialize synapse environment
+     * @param synEnv SynapseEnvironment
+     */
+    public void init(SynapseEnvironment synEnv) {
+        try {
+            configCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(
+                    clientRepository != null ? clientRepository : DEFAULT_CLIENT_REPO,
+                    axis2xml != null ? axis2xml : DEFAULT_AXIS2_XML);
+        } catch (AxisFault e) {
+            String msg = "Error initializing callout mediator : " + e.getMessage();
+            log.error(msg, e);
+            throw new SynapseException(msg, e);
+        }
+    }
+
+    public void destroy() {
+        try {
+            configCtx.terminate();
+        } catch (AxisFault ignore) {
+        }
+    }
+
+    public void setServiceURL(String serviceURL) {
+        this.serviceURL.set(serviceURL);
+    }
+
+    public void setAction(String action) {
+        this.action.set(action);
+    }
+
+    public void setRequestKey(String requestKey) {
+        this.requestKey.set(requestKey);
+    }
+
+    public void setRequestXPath(SynapseXPath requestXPath) throws JaxenException {
+        this.requestXPath.set(requestXPath);
+    }
+
+    public void setTargetXPath(SynapseXPath targetXPath) throws JaxenException {
+        this.targetXPath.set(targetXPath);
+    }
+
+    public void setTargetKey(String targetKey) {
+        this.targetKey.set(targetKey);
+    }
+
+    public String getServiceURL() {
+        return serviceURL.get();
+    }
+
+    public String getAction() {
+        return action.get();
+    }
+
+    public String getRequestKey() {
+        return requestKey.get();
+    }
+
+    public SynapseXPath getRequestXPath() {
+        return requestXPath.get();
+    }
+
+    public SynapseXPath getTargetXPath() {
+        return targetXPath.get();
+    }
+
+    public String getTargetKey() {
+        return targetKey.get();
+    }
+}
\ No newline at end of file

Added: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/ContentBasedRouterMediator.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/ContentBasedRouterMediator.java?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/ContentBasedRouterMediator.java (added)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/ContentBasedRouterMediator.java Mon Oct  8 04:24:21 2012
@@ -0,0 +1,189 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.synapse.libraries.eip;
+
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.config.xml.AnonymousListMediator;
+import org.apache.synapse.config.xml.SwitchCase;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.mediators.Value;
+import org.apache.synapse.mediators.base.SequenceMediator;
+import org.apache.synapse.mediators.filters.SwitchMediator;
+import org.apache.synapse.util.xpath.SynapseXPath;
+
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+/*
+ *
+ * Content Base Router Mediator implements the Content Base Router EIP,
+ * This pattern route messages to the appropriate sequence,
+ * according to the message contents.
+ * Routing decision is taken by matching given Xpath expression and RegEx
+ */
+public class ContentBasedRouterMediator extends AbstractMediator {
+    private static final String DELIMITER_1 = ";";
+    private static final String DELIMITER_2 = ",";
+    private static final String DELIMITER_3 = ":";
+
+    /**
+     * Route messages to the appropriate sequence according to the message contents
+     *
+     * @param messageContext the current message for mediation
+     * @return  true
+     */
+    public boolean mediate(MessageContext messageContext) {
+        SwitchMediator switchMediator = new SwitchMediator();
+        initParams(messageContext, switchMediator);
+        switchMediator.mediate(messageContext);
+        return true;
+    }
+
+    /**
+     * For each message we build the routing mediators programmatically
+     *
+     * @param synCtx         MessageContext
+     * @param switchMediator SwitchMediator Object
+     */
+    private void initParams(MessageContext synCtx, SwitchMediator switchMediator) {
+        //fetch routung expression
+        Object sourceXpath = EIPUtils.lookupFunctionParam(synCtx, "routing_exp");
+        if (sourceXpath == null) {
+            String msg = "A 'source' XPath attribute is required for a switch mediator";
+            log.error(msg);
+            throw new SynapseException(msg);
+        } else {
+            try {
+                switchMediator.setSource((SynapseXPath) sourceXpath);
+            } catch (Exception e) {
+                String msg = "Invalid XPath for attribute 'source'";
+                log.error(msg);
+                throw new SynapseException(msg);
+            }
+        }
+        String matchContent = (String) EIPUtils.lookupFunctionParam(synCtx, "match_content");
+        String[] contentSet = matchContent.split(DELIMITER_1);
+        if (contentSet.length == 1) {
+            String caseItr = contentSet[0].trim();
+            createCases(switchMediator, caseItr);
+        } else if (contentSet.length == 2) {
+            String caseItr = contentSet[0].trim();
+            createCases(switchMediator, caseItr);
+
+            String caseDefault = contentSet[1].trim();
+            if (caseDefault == null || "".equals(caseDefault)) {
+                String msg = "Default Sequence Reference is not defined";
+                log.error(msg);
+            }
+            AnonymousListMediator mediator = new AnonymousListMediator();
+            SequenceMediator sequenceMediator = new SequenceMediator();
+            Value value = new Value(caseDefault);
+            sequenceMediator.setKey(value);
+            mediator.addChild(sequenceMediator);
+            SwitchCase defaultCase = new SwitchCase();
+            defaultCase.setCaseMediator(mediator);
+            switchMediator.setDefaultCase(defaultCase);
+
+        } else {
+            String msg = "Invalid match content";
+            log.error(msg);
+        }
+
+    }
+
+    /**
+     * Creates cases for the switch mediator
+     *
+     * @param switchMediator SwitchMediator Object
+     * @param caseItr        String parameter for Cases
+     * @return true
+     */
+    private boolean createCases(SwitchMediator switchMediator, String caseItr) {
+        String[] caseSet = caseItr.split(DELIMITER_2);
+        if (caseSet.length == 0) {
+            log.warn("No Definitions found for dynamic routing");
+            return false;
+        }
+
+        SwitchCase aCase;
+        for (String newCase : caseSet) {
+            if (newCase != null && !"".equals(newCase.trim())) {
+                aCase = createCase(newCase.trim());
+                switchMediator.addCase(aCase);
+            } else {
+                String msg = "Sequence Reference has not defined";
+                log.error(msg);
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Creates case Object for the switch mediator
+     *
+     * @param caseConfig String parameter for Case expression
+     * @return SwitchCase Object
+     */
+    private SwitchCase createCase(String caseConfig) {
+        SwitchCase aCase = new SwitchCase();
+        String[] caseAttr = caseConfig.split(DELIMITER_3);
+        String regEx = null;
+        String seqRef = null;
+
+        if (caseAttr.length == 2) {
+            regEx = caseAttr[0].trim();
+            seqRef = caseAttr[1].trim();
+        } else if (caseAttr.length == 1) {
+            regEx = caseAttr[0].trim();
+            seqRef = "main";
+        } else {
+            String msg = "Unsupported routing condition";
+            log.error(msg);
+        }
+
+        if (regEx == null || "".equals(regEx.trim())) {
+            String msg = "The 'regex' attribute is required for a switch case definition";
+            log.error(msg);
+            throw new SynapseException(msg);
+        }
+        try {
+            aCase.setRegex(Pattern.compile(regEx));
+        } catch (PatternSyntaxException pse) {
+            String msg = "Invalid Regular Expression for attribute 'regex' : " + regEx;
+            log.error(msg);
+            throw new SynapseException(msg);
+        }
+
+        if (seqRef == null || "".equals(seqRef.trim())) {
+            String msg = "Sequence Reference has not defined";
+            log.error(msg);
+
+        }
+        AnonymousListMediator mediator = new AnonymousListMediator();
+        SequenceMediator sequenceMediator = new SequenceMediator();
+        Value value = new Value(seqRef);
+        sequenceMediator.setKey(value);
+        mediator.addChild(sequenceMediator);
+        aCase.setCaseMediator(mediator);
+
+        return aCase;
+    }
+}

Added: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/DynamicRouterMediator.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/DynamicRouterMediator.java?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/DynamicRouterMediator.java (added)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/DynamicRouterMediator.java Mon Oct  8 04:24:21 2012
@@ -0,0 +1,293 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.synapse.libraries.eip;
+
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.commons.evaluators.*;
+import org.apache.synapse.commons.evaluators.source.HeaderTextRetriever;
+import org.apache.synapse.commons.evaluators.source.SourceTextRetriever;
+import org.apache.synapse.commons.evaluators.source.URLTextRetriever;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.mediators.eip.Target;
+import org.apache.synapse.mediators.filters.router.ConditionalRoute;
+import org.apache.synapse.mediators.filters.router.ConditionalRouterMediator;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/*
+ *
+ * The Dynamic Router Mediator implements the Dynamic Router EIP ,
+ * this pattern route a message consecutively through a series of condition steps, which is parsed by the conditions parameter
+ * The list of sequences through which the message should pass is decided dynamically at run time.
+ * Checks whether the route condition evaluates to true and mediates using the given sequence
+ * Routing decision is based on the message contents such as HTTP url,HTTP headers or combination of both
+ */
+
+
+public class DynamicRouterMediator extends AbstractMediator {
+    private static final String DELIMITER_1 = ",";
+    private static final String DELIMITER_2 = ";";
+    private static final String DELIMITER_3 = "=";
+    private static final String DELIMITER_4 = ":";
+    private static final String DELIMITER_5 = "\\{AND}";
+    private static final String DELIMITER_6 = "\\{OR}";
+    MessageContext synCtx;
+
+    /**
+     * Route a message consecutively through a series of condition steps
+     *
+     * @param msgCtx the current message for mediation
+     * @return
+     */
+    public boolean mediate(MessageContext msgCtx) {
+        synCtx = msgCtx;
+        ConditionalRouterMediator conditionalRouterMediator = new ConditionalRouterMediator();
+        conditionalRouterMediator.setContinueAfter(false);
+        createDynamicRoute(msgCtx, conditionalRouterMediator);
+        conditionalRouterMediator.mediate(msgCtx);
+
+        return true;
+    }
+
+    /**
+     * Initialize dynamic route with the given String of parameters
+     *
+     * @param synCtx                    MessageContext
+     * @param conditionalRouterMediator ConditionalRouterMediator
+     * @return true
+     */
+    private boolean createDynamicRoute(MessageContext synCtx, ConditionalRouterMediator conditionalRouterMediator) {
+        String conditionRouts = (String) EIPUtils.lookupFunctionParam(synCtx, "conditions");
+        String[] conditionsSet = conditionRouts.split(DELIMITER_1);
+        if (conditionsSet.length == 0) {
+            log.warn("No Definitions found for dynamic routing");
+            return false;
+        }
+
+        ConditionalRoute conditionalRoute;
+
+        for (String conditionRoute : conditionsSet) {
+            if (conditionRoute != null && !"".equals(conditionRoute.trim())) {
+                conditionalRoute = createConRoute(conditionRoute.trim());
+                conditionalRouterMediator.addRoute(conditionalRoute);
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Creates ConditionalRoute with given the String of parameters
+     *
+     * @param conRoute String of expression
+     * @return conditionalRoute ConditionalRoute
+     */
+    private ConditionalRoute createConRoute(String conRoute) {
+        ConditionalRoute conditionalRoute = new ConditionalRoute();
+        String[] conditionDefs = conRoute.split(DELIMITER_2);
+        conditionalRoute.setBreakRoute(false);
+        if (conditionDefs.length < 2) {
+            handleException("Conditional Route is not defined", synCtx);
+            return null;
+        }
+
+        String condition = conditionDefs[0];
+        String target = conditionDefs[1];
+
+        if (condition != null && !"".equals(condition.trim())) {
+            createCondition(conditionalRoute, condition.trim());
+        } else {
+            handleException("Routing condition can not be empty", synCtx);
+        }
+        if (target != null && !"".equals(target.trim())) {
+            createTarget(conditionalRoute, target);
+        } else {
+            handleException("Routing Target can not be empty", synCtx);
+        }
+
+
+        return conditionalRoute;
+    }
+
+    /**
+     * Creates Condition parameter for ConditionalRoute
+     *
+     * @param conRoute  ConditionalRoute
+     * @param condition String expression
+     */
+    private void createCondition(ConditionalRoute conRoute, String condition) {
+
+
+        if (!condition.contains("{AND}") && !condition.contains("{OR}")) {
+            Evaluator evaluator = createMatchEvaluator(condition);
+            conRoute.setEvaluator(evaluator);
+        } else if (condition.contains("{AND}") && !condition.contains("{OR}")) {
+            Evaluator andEvaluator = createAndEvaluator(condition);
+            conRoute.setEvaluator(andEvaluator);
+        } else if (condition.contains("{OR}") && !condition.contains("{AND}")) {
+            Evaluator orEvaluator = createOrEvaluator(condition);
+            conRoute.setEvaluator(orEvaluator);
+        } else {
+            handleException("Routing condition is wrong", synCtx);
+        }
+
+
+    }
+
+    /**
+     * Creates Evaluator parameters for Condition
+     *
+     * @param matchElements String expression
+     * @return matchEvaluator Evaluator
+     */
+    private Evaluator createMatchEvaluator(String matchElements) {
+        String[] matchElem = matchElements.split(DELIMITER_3);
+
+        String matchValue = matchElem[0].trim();
+        String matchConfig = matchElem[1].trim();
+        MatchEvaluator matchEvaluator = new MatchEvaluator();
+        String[] matchParams = matchConfig.split(DELIMITER_4);
+
+        SourceTextRetriever textRetriever = null;
+        String regEx = null;
+        String source ;
+        if (matchParams.length == 1) {
+            regEx = matchParams[0].trim();
+            if (matchValue.equals(EvaluatorConstants.URL)) {
+                textRetriever = new URLTextRetriever();
+            }
+        } else if (matchParams.length == 2) {
+            source = matchParams[0].trim();
+
+            if (matchValue.equals(EvaluatorConstants.HEADER)) {
+                if (source != null) {
+                    textRetriever = new HeaderTextRetriever(source);
+                } else {
+                    handleException(EvaluatorConstants.SOURCE + " attribute is required", synCtx);
+                }
+            } else if (matchValue.equals(EvaluatorConstants.URL)) {
+                textRetriever = new URLTextRetriever();
+                if (source != null) {
+                    ((URLTextRetriever) textRetriever).setSource(source);
+                }
+            } else {
+                handleException("Unsupported evaluator:" + matchValue, synCtx);
+            }
+
+            regEx = matchParams[1].trim();
+        } else {
+            handleException("Unsupported condition" + matchConfig, synCtx);
+        }
+
+        matchEvaluator.setTextRetriever(textRetriever);
+
+        if (regEx == null) {
+            handleException(EvaluatorConstants.REGEX + " attribute is required", synCtx);
+            return null;
+        }
+        matchEvaluator.setRegex(Pattern.compile(regEx));
+
+        return matchEvaluator;
+    }
+
+    /**
+     * Creates AndEvaluator parameters for Condition
+     *
+     * @param andConfig String expression
+     * @return andEvaluator Evaluator
+     */
+    private Evaluator createAndEvaluator(String andConfig) {
+
+        String[] andEvals = andConfig.split(DELIMITER_5);
+        AndEvaluator andEvaluator = new AndEvaluator();
+        List<Evaluator> evaluators = new ArrayList<Evaluator>();
+
+        for (String matchElements : andEvals) {
+
+            if (matchElements != null && !"".equals(matchElements.trim())) {
+                Evaluator evaluator = createMatchEvaluator(matchElements.trim());
+                evaluators.add(evaluator);
+
+            }
+        }
+
+        if (evaluators.size() > 1) {
+            andEvaluator.setEvaluators(evaluators.toArray(new Evaluator[evaluators.size()]));
+
+        } else {
+            handleException("Two or more expressions should be provided under And", synCtx);
+
+        }
+        return andEvaluator;
+    }
+
+    /**
+     * Creates OrEvaluator parameters for Condition
+     *
+     * @param orConfig String expression
+     * @return orEvaluator Evaluator
+     */
+    private Evaluator createOrEvaluator(String orConfig) {
+
+        String[] orEvals = orConfig.split(DELIMITER_6);
+        OrEvaluator orEvaluator = new OrEvaluator();
+        List<Evaluator> evaluators = new ArrayList<Evaluator>();
+
+        for (String matchElements : orEvals) {
+
+            if (matchElements != null && !"".equals(matchElements.trim())) {
+                Evaluator evaluator = createMatchEvaluator(matchElements.trim());
+                evaluators.add(evaluator);
+
+            }
+        }
+
+        if (evaluators.size() > 1) {
+            orEvaluator.setEvaluators(evaluators.toArray(new Evaluator[evaluators.size()]));
+        } else {
+            handleException("Two or more expressions should be provided under Or", synCtx);
+
+        }
+        return orEvaluator;
+    }
+
+    /**
+     * Creates Target parameter for ConditionalRoute
+     *
+     * @param conRoute  ConditionalRoute
+     * @param targetVal String expression
+     */
+    private void createTarget(ConditionalRoute conRoute, String targetVal) {
+        Target target = new Target();
+        String[] elements = targetVal.split(DELIMITER_3);
+        String type = elements[0].trim();
+        String value = elements[1].trim();
+        if (type.equalsIgnoreCase("seq")) {
+            target.setAsynchronous(false);
+            target.setSequenceRef(value);
+            conRoute.setTarget(target);
+        } else {
+            handleException("Target Sequence has defined wrong", synCtx);
+        }
+
+    }
+
+}

Added: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/EIPUtils.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/EIPUtils.java?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/EIPUtils.java (added)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/libraries/eip/EIPUtils.java Mon Oct  8 04:24:21 2012
@@ -0,0 +1,26 @@
+package org.apache.synapse.libraries.eip;
+
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseConstants;
+import org.apache.synapse.mediators.template.TemplateContext;
+
+import java.util.Stack;
+
+/**
+ * This is an utility class to fetch parameter values parsed by call template mediators
+ */
+public class EIPUtils {
+
+    /**
+     * Fetch parameter values parsed by call template mediators
+     * @param synCtx MessageContext
+     * @param paramName String name
+     * @return paramValue Object
+     */
+    public static Object lookupFunctionParam(MessageContext synCtx, String paramName) {
+        Stack<TemplateContext> funcStack = (Stack) synCtx.getProperty(SynapseConstants.SYNAPSE__FUNCTION__STACK);
+        TemplateContext currentFuncHolder = funcStack.peek();
+        Object paramValue = currentFuncHolder.getParameterValue(paramName);
+        return paramValue;
+    }
+}

Modified: synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/libraries/eip/AbstractEipLibTestCase.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/libraries/eip/AbstractEipLibTestCase.java?rev=1395449&r1=1395448&r2=1395449&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/libraries/eip/AbstractEipLibTestCase.java (original)
+++ synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/libraries/eip/AbstractEipLibTestCase.java Mon Oct  8 04:24:21 2012
@@ -15,7 +15,7 @@ public abstract class AbstractEipLibTest
     protected String getResourcePath() {
         try {
             if (path == null) {
-                path = new File("./target/test_repos/synapse/synapse-libraries/synapse-eip-lib.zip").getAbsolutePath();
+                path = new File("./target/test_repos/synapse/synapse-libraries/synapse-eiptest-lib.zip").getAbsolutePath();
             }
         } catch (Exception e) {
             return null;

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/assembly/assemble-eipcore-lib.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/assembly/assemble-eipcore-lib.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/assembly/assemble-eipcore-lib.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/assembly/assemble-eipcore-lib.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+    <formats>
+        <format>zip</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <fileSets>
+        <fileSet>
+            <directory>src/test/resources/synapse-libraries/synapse-eipcore-lib</directory>
+            <outputDirectory></outputDirectory>
+        </fileSet>
+        <fileSet>
+            <directory>target/classes/org/apache/synapse/libraries/eip</directory>
+            <outputDirectory>org/apache/synapse/libraries/eip</outputDirectory>
+            <excludes>
+                <exclude>**/metrics_module.xml</exclude>
+                <exclude>**/META-INF/*</exclude>
+            </excludes>
+        </fileSet>
+    </fileSets>
+</assembly>

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/assembly/assemble-eiptest-lib.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/assembly/assemble-eiptest-lib.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/assembly/assemble-eiptest-lib.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/assembly/assemble-eiptest-lib.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+    <formats>
+        <format>zip</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <fileSets>
+        <fileSet>
+            <directory>src/test/resources/synapse-libraries/synapse-eiptest-lib</directory>
+            <outputDirectory></outputDirectory>
+        </fileSet>
+        <fileSet>
+            <directory>target/classes</directory>
+            <outputDirectory></outputDirectory>
+            <excludes>
+                <exclude>**/metrics_module.xml</exclude>
+                <exclude>**/META-INF/*</exclude>
+            </excludes>
+        </fileSet>
+    </fileSets>
+    
+    
+</assembly>

Modified: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/artifacts.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/artifacts.xml?rev=1395449&r1=1395448&r2=1395449&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/artifacts.xml (original)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/artifacts.xml Mon Oct  8 04:24:21 2012
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<artifacts>
-    <artifact name="EipLibrary" package="synapse.lang.eip" >
-        <dependency artifact="systemManagement" />
-        <description>eip synapse library</description>
-    </artifact>
-</artifacts>

Modified: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/eip_systemManagement/artifact.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/eip_systemManagement/artifact.xml?rev=1395449&r1=1395448&r2=1395449&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/eip_systemManagement/artifact.xml (original)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/eip_systemManagement/artifact.xml Mon Oct  8 04:24:21 2012
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<artifact name="systemManagement" type="synapse/template">
-
-    <subArtifacts>
-        <artifact name="splitter">
-            <file>template_splitter.xml</file>
-            <description>Splitter library function</description>
-        </artifact>
-    </subArtifacts>
-
-</artifact>
\ No newline at end of file

Modified: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/eip_systemManagement/template_splitter.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/eip_systemManagement/template_splitter.xml?rev=1395449&r1=1395448&r2=1395449&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/eip_systemManagement/template_splitter.xml (original)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eip-lib/eip_systemManagement/template_splitter.xml Mon Oct  8 04:24:21 2012
@@ -1,20 +0,0 @@
-<template xmlns="http://ws.apache.org/ns/synapse" name="splitter">
-    <parameter name="iterate_exp"/>
-    <parameter name="endpoint_uri"/>
-    <parameter name="attach_path" default="{{//original}}" optional="true"/>
-    <parameter name="sequence_ref"/>
-    <sequence>
-        <property name="ItrExp" expression="$func:iterate_exp" />
-        <property name="EndPUri" expression="$func:endpoint_uri" />
-        <property name="AttachPath" expression="$func:attach_path" />
-        <property name="SRef" expression="$func:sequence_ref" />
-        <property name="Endpoint_1" expression="get-property('To')" />
-        <header name="To" expression="$func:endpoint_uri"/>
-        <iterate xmlns:ns="http://org.apache.synapse/xsd" continueParent="true" preservePayload="true" attachPath="$func:attach_path" expression="$func:iterate_exp">
-            <target>
-              <sequence key="{$func:sequence_ref}"/>
-            </target>
-        </iterate>
-        <property name="Endpoint_2" expression="get-property('To')" />
-    </sequence>
-</template>

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/artifacts.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/artifacts.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/artifacts.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/artifacts.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+                <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!-- Root artifact of EIP library shipped with the Apache Synapse -->
+<artifacts>
+    <artifact name="EipLibrary" package="synapse.lang.eip" >
+        <dependency artifact="systemManagement" />
+        <dependency artifact="messageRouting" />
+        <description>eip synapse library</description>
+    </artifact>
+</artifacts>

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/artifact.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/artifact.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/artifact.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/artifact.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!-- Message routing sub artifact of EIP library shipped with the Apache Synapse -->
+<artifact name="messageRouting" type="synapse/template">
+
+    <subArtifacts>
+        <artifact name="recipient_list">
+            <file>template_recipient_list.xml</file>
+            <description>Recipient List eip library function</description>
+        </artifact>
+        <artifact name="callout_block">
+            <file>template_callout_block.xml</file>
+            <description>Callout Block eip library function</description>
+        </artifact>
+         <artifact name="scatter_gather">
+            <file>template_scatter_gather.xml</file>
+            <description>Scatter-Gather eip library function</description>
+        </artifact>
+         <artifact name="dynamic_router">
+            <file>template_dynamic_router.xml</file>
+            <description>Dynamic Router eip library function</description>
+        </artifact>
+         <artifact name="content_based_router">
+            <file>template_content_based_router.xml</file>
+            <description>Content Based Router eip library function</description>
+        </artifact>
+        <artifact name="splitter">
+            <file>template_splitter.xml</file>
+            <description>Splitter library function</description>
+        </artifact>
+        <artifact name="aggregator">
+            <file>template_aggregator.xml</file>
+            <description>Aggregator library function</description>
+        </artifact>
+        <artifact name="splitter_aggregator">
+            <file>template_splitter_aggregator.xml</file>
+            <description>Splitter_Aggregator library function</description>
+        </artifact>
+    </subArtifacts>
+
+</artifact>
\ No newline at end of file

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_aggregator.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_aggregator.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_aggregator.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_aggregator.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!--Aggregator eip library function template shipped with the Apache Synapse -->
+<template xmlns="http://ws.apache.org/ns/synapse" name="aggregator">
+    <parameter name="aggregator_exp"/>
+    <parameter name="oncomplete_seq_enabled" default="false" optional="true"/>
+    <parameter name="sequence_ref" optional="true"/>
+    <sequence>
+        <aggregate>
+            <completeCondition>
+                <messageCount min="-1" max="-1"/>
+            </completeCondition>
+            <onComplete expression="$func:aggregator_exp">
+                <filter xpath="$func:oncomplete_seq_enabled='true'">
+                    <then>
+                        <sequence key="{$func:sequence_ref}"/>
+                    </then>
+                    <else>
+                        <send/>
+                    </else>
+                </filter>
+            </onComplete>
+        </aggregate>
+    </sequence>
+</template>
\ No newline at end of file

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_callout_block.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_callout_block.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_callout_block.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_callout_block.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!-- Callout Block library function template shipped with the Apache Synapse -->
+<template xmlns="http://ws.apache.org/ns/synapse" name="callout_block">
+    <parameter name="service_URL"/>
+    <parameter name="action" optional="true"/>
+    <parameter name="source_xpath" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s12="http://www.w3.org/2003/05/soap-envelope"  default="{{s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]}}" optional="true"/>
+    <parameter name="target_xpath" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s12="http://www.w3.org/2003/05/soap-envelope"  default="{{s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]}}" optional="true"/>
+    <parameter name="source_key" optional="true"/>
+    <parameter name="target_key" optional="true"/>
+
+    <sequence>
+        <class name="org.apache.synapse.libraries.eip.CalloutBlockMediator"/>
+    </sequence>
+</template>

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_content_based_router.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_content_based_router.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_content_based_router.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_content_based_router.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!-- Content Base Router eip library function template shipped with the Apache Synapse -->
+<template xmlns="http://ws.apache.org/ns/synapse" name="content_based_router">
+    <parameter name="routing_exp"/>
+    <parameter name="match_content"/>
+    <sequence>
+        <class name="org.apache.synapse.libraries.eip.ContentBasedRouterMediator"/>
+    </sequence>
+</template>
\ No newline at end of file

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_dynamic_router.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_dynamic_router.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_dynamic_router.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_dynamic_router.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!-- Dynamic Router eip library function template shipped with the Apache Synapse -->
+<template xmlns="http://ws.apache.org/ns/synapse" name="dynamic_router">
+    <parameter name="conditions"/>
+    <sequence>
+        <class name="org.apache.synapse.libraries.eip.DynamicRouterMediator"/>
+    </sequence>
+</template>
\ No newline at end of file

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_recipient_list.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_recipient_list.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_recipient_list.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_recipient_list.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!-- Recipient List eip library function template shipped with the Apache Synapse -->
+<template xmlns="http://ws.apache.org/ns/synapse" name="recipient_list">
+    <parameter name="recipient_list"/>
+    <sequence>
+        <send>
+            <endpoint>
+                <recipientlist>
+                    <endpoints value="{$func:recipient_list}"/>
+                </recipientlist>
+            </endpoint>
+        </send>
+    </sequence>
+</template>

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_scatter_gather.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_scatter_gather.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_scatter_gather.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_scatter_gather.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!-- Scatter-Gather eip library function template shipped with the Apache Synapse -->
+<template xmlns="http://ws.apache.org/ns/synapse" name="scatter_gather">
+    <parameter name="recipient_list"/>
+    <parameter name="aggregator_exp"/>
+    <parameter name="oncomplete_seq_enabled" default="false" optional="true"/>
+    <parameter name="sequence_ref" optional="true"/>
+    <sequence>
+        <in>
+        <send>
+            <endpoint>
+                <recipientlist>
+                    <endpoints value="{$func:recipient_list}"/>
+                </recipientlist>
+            </endpoint>
+        </send>
+        </in>
+        <out>
+             <aggregate>
+                <completeCondition>
+                    <messageCount min="-1" max="-1"/>
+                </completeCondition>
+                <onComplete expression="$func:aggregator_exp">
+                    <filter xpath="$func:oncomplete_seq_enabled='true'">
+                        <then>
+                            <sequence key="{$func:sequence_ref}"/>
+                        </then>
+                        <else>
+                            <send/>
+                        </else>
+                    </filter>
+                </onComplete>
+            </aggregate>
+        </out>
+    </sequence>
+</template>

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_splitter.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_splitter.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_splitter.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_splitter.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!-- Splitter eip library function template shipped with the Apache Synapse -->
+<template xmlns="http://ws.apache.org/ns/synapse" name="splitter">
+    <parameter name="iterate_exp"/>
+    <parameter name="attach_path" optional="true"/>
+    <parameter name="endpoint_uri"/>
+    <parameter name="attach_path_enabled" default="false" optional="true"/>
+    <sequence>
+        <filter xpath="$func:attach_path_enabled='true'">
+            <then>
+                <iterate xmlns:ns="http://org.apache.synapse/xsd" preservePayload="true" attachPath="$func:attach_path"
+                         expression="$func:iterate_exp">
+                    <target>
+                        <sequence>
+                            <header name="To" expression="$func:endpoint_uri"/>
+                            <send/>
+                        </sequence>
+                    </target>
+                </iterate>
+            </then>
+            <else>
+                <iterate xmlns:ns="http://org.apache.synapse/xsd" expression="$func:iterate_exp">
+                    <target>
+                        <sequence>
+                            <header name="To" expression="$func:endpoint_uri"/>
+                            <send/>
+                        </sequence>
+                    </target>
+                </iterate>
+            </else>
+        </filter>
+    </sequence>
+</template>

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_splitter_aggregator.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_splitter_aggregator.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_splitter_aggregator.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_messageRouting/template_splitter_aggregator.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!-- Splitter-Aggregator eip library function template shipped with the Apache Synapse -->
+<template xmlns="http://ws.apache.org/ns/synapse" name="splitter_aggregator">
+    <parameter name="iterate_exp"/>
+    <parameter name="attach_path" optional="true"/>
+    <parameter name="aggregator_exp"/>
+    <parameter name="endpoint_uri"/>
+    <parameter name="sequence_ref" optional="true"/>
+    <parameter name="attach_path_enabled" default="false" optional="true"/>
+    <parameter name="oncomplete_seq_enabled" default="false" optional="true"/>
+    <sequence>
+        <in>
+            <filter xpath="$func:attach_path_enabled='true'">
+                <then>
+                    <iterate xmlns:ns="http://org.apache.synapse/xsd" preservePayload="true"
+                             attachPath="$func:attach_path" expression="$func:iterate_exp">
+                        <target>
+                            <sequence>
+                                <header name="To" expression="$func:endpoint_uri"/>
+                                <send/>
+                            </sequence>
+                        </target>
+                    </iterate>
+                </then>
+                <else>
+                    <iterate xmlns:ns="http://org.apache.synapse/xsd" expression="$func:iterate_exp">
+                        <target>
+                            <sequence>
+                                <header name="To" expression="$func:endpoint_uri"/>
+                                <send/>
+                            </sequence>
+                        </target>
+                    </iterate>
+                </else>
+            </filter>
+        </in>
+        <out>
+            <aggregate>
+                <completeCondition>
+                    <messageCount min="-1" max="-1"/>
+                </completeCondition>
+                <onComplete expression="$func:aggregator_exp">
+                    <filter xpath="$func:oncomplete_seq_enabled='true'">
+                        <then>
+                            <sequence key="{$func:sequence_ref}"/>
+                        </then>
+                        <else>
+                            <send/>
+                        </else>
+                    </filter>
+                </onComplete>
+            </aggregate>
+        </out>
+    </sequence>
+</template>
\ No newline at end of file

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_systemManagement/artifact.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_systemManagement/artifact.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_systemManagement/artifact.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_systemManagement/artifact.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!-- System management sub artifact of EIP library shipped with the Apache Synapse -->
+<artifact name="systemManagement" type="synapse/template">
+
+    <subArtifacts>
+        <artifact name="wire_tap">
+            <file>template_wire_tap.xml</file>
+            <description>Wire Tap eip library function</description>
+        </artifact>
+    </subArtifacts>
+
+</artifact>
\ No newline at end of file

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_systemManagement/template_wire_tap.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_systemManagement/template_wire_tap.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_systemManagement/template_wire_tap.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eipcore-lib/eip_systemManagement/template_wire_tap.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+        <!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<!-- Wire Tap eip library function template shipped with the Apache Synapse -->
+<template xmlns="http://ws.apache.org/ns/synapse" name="wire_tap">
+        <parameter name="destination_uri"/>
+        <parameter name="wiretap_uri"/>
+        <sequence>
+            <clone>
+                <target>
+                    <sequence>
+                        <header name="To" expression="$func:wiretap_uri"/>
+                        <send/>
+                    </sequence>
+                </target>
+                <target>
+                    <sequence>
+                        <header name="To" expression="$func:destination_uri"/>
+                        <send/>
+                    </sequence>
+                </target>
+            </clone>
+        </sequence>
+</template>
\ No newline at end of file

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/artifacts.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/artifacts.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/artifacts.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/artifacts.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<artifacts>
+    <artifact name="EipLibrary" package="synapse.lang.eip" >
+        <dependency artifact="systemManagement" />
+        <description>eip synapse library</description>
+    </artifact>
+</artifacts>

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/eip_systemManagement/artifact.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/eip_systemManagement/artifact.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/eip_systemManagement/artifact.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/eip_systemManagement/artifact.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<artifact name="systemManagement" type="synapse/template">
+
+    <subArtifacts>
+        <artifact name="splitter">
+            <file>template_splitter.xml</file>
+            <description>Splitter library function</description>
+        </artifact>
+    </subArtifacts>
+
+</artifact>
\ No newline at end of file

Added: synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/eip_systemManagement/template_splitter.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/eip_systemManagement/template_splitter.xml?rev=1395449&view=auto
==============================================================================
--- synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/eip_systemManagement/template_splitter.xml (added)
+++ synapse/trunk/java/modules/core/src/test/resources/synapse-libraries/synapse-eiptest-lib/eip_systemManagement/template_splitter.xml Mon Oct  8 04:24:21 2012
@@ -0,0 +1,20 @@
+<template xmlns="http://ws.apache.org/ns/synapse" name="splitter">
+    <parameter name="iterate_exp"/>
+    <parameter name="endpoint_uri"/>
+    <parameter name="attach_path" default="{{//original}}" optional="true"/>
+    <parameter name="sequence_ref"/>
+    <sequence>
+        <property name="ItrExp" expression="$func:iterate_exp" />
+        <property name="EndPUri" expression="$func:endpoint_uri" />
+        <property name="AttachPath" expression="$func:attach_path" />
+        <property name="SRef" expression="$func:sequence_ref" />
+        <property name="Endpoint_1" expression="get-property('To')" />
+        <header name="To" expression="$func:endpoint_uri"/>
+        <iterate xmlns:ns="http://org.apache.synapse/xsd" continueParent="true" preservePayload="true" attachPath="$func:attach_path" expression="$func:iterate_exp">
+            <target>
+              <sequence key="{$func:sequence_ref}"/>
+            </target>
+        </iterate>
+        <property name="Endpoint_2" expression="get-property('To')" />
+    </sequence>
+</template>