You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by sa...@apache.org on 2006/05/16 16:15:44 UTC

svn commit: r406952 [1/2] - in /incubator/synapse/trunk/java: bin/ etc/ modules/core/ modules/core/src/org/apache/synapse/ modules/core/src/org/apache/synapse/config/ modules/core/src/org/apache/synapse/config/xml/ modules/core/src/org/apache/synapse/c...

Author: saminda
Date: Tue May 16 07:15:40 2006
New Revision: 406952

URL: http://svn.apache.org/viewcvs?rev=406952&view=rev
Log:
committing for asankha
Fix validation, introduce samples..

Added:
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/InMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/OutMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseAxis2Interceptor.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/InMediator.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/OutMediator.java
    incubator/synapse/trunk/java/modules/core/test-resources/misc/validate2.xsd
    incubator/synapse/trunk/java/modules/samples/src/samples/mediation/
    incubator/synapse/trunk/java/modules/samples/src/samples/mediation/AdvancedQuoteClient.java
    incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomQuoteXMLHandler.java
    incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomStockQuoteClient.java
    incubator/synapse/trunk/java/repository/conf/sample/
    incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_0.xml
    incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_1.xml
    incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_2.xml
    incubator/synapse/trunk/java/repository/conf/sample/transform.xslt
    incubator/synapse/trunk/java/repository/conf/sample/transform_back.xslt
    incubator/synapse/trunk/java/repository/conf/sample/validate.xsd
Modified:
    incubator/synapse/trunk/java/bin/synapse.bat
    incubator/synapse/trunk/java/etc/project.properties
    incubator/synapse/trunk/java/etc/project.xml
    incubator/synapse/trunk/java/modules/core/maven.xml
    incubator/synapse/trunk/java/modules/core/project.xml
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Constants.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/MessageContext.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Util.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Endpoint.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/AbstractMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/FaultMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/FilterMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/HeaderMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/LogMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/MediatorFactoryFinder.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/MediatorPropertyFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/PropertyMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SendMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SwitchMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/TransformMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/ValidateMediatorFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContext.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContextFinder.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2Sender.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseDispatcher.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/GetPropertyFunction.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/ValidateMediator.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java
    incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestMessageContext.java
    incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java
    incubator/synapse/trunk/java/repository/conf/axis2.xml
    incubator/synapse/trunk/java/repository/conf/synapse.xml

Modified: incubator/synapse/trunk/java/bin/synapse.bat
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/bin/synapse.bat?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/bin/synapse.bat (original)
+++ incubator/synapse/trunk/java/bin/synapse.bat Tue May 16 07:15:40 2006
@@ -24,12 +24,16 @@
 set DEFAULT_SYNAPSE_HOME=
 
 set _USE_CLASSPATH=yes
+set _SYNAPSE_XML=
 
 rem Slurp the command line arguments. This loop allows for an unlimited number
 rem of arguments (up to the command line limit, anyway).
+if ""%1""==""-sample"" goto synapseSample
+
 set SYNAPSE_CMD_LINE_ARGS=%1
 if ""%1""=="""" goto doneStart
 shift
+
 :setupArgs
 if ""%1""=="""" goto doneStart
 if ""%1""==""-noclasspath"" goto clearclasspath
@@ -46,6 +50,12 @@
 rem This label provides a place for the argument list loop to break out
 rem and for NT handling to skip to.
 
+:synapseSample
+shift
+set _SYNAPSE_XML=-Dsynapse.xml=%SYNAPSE_HOME%\synapse_repository\conf\sample\synapse_sample_%1.xml
+shift
+goto setupArgs
+
 :doneStart
 rem find SYNAPSE_HOME if it does not exist due to either an invalid value passed
 rem by the user or the %0 problem on Windows 9x
@@ -74,7 +84,7 @@
 
 :runSynapse
 @echo on
-"%_JAVACMD%" -Daxis2.xml=%SYNAPSE_HOME%\synapse_repository\conf\axis2.xml -Djava.ext.dirs=%SYNAPSE_HOME%\lib;%EXT_DIRS%;%SYNAPSE_HOME% -cp %SYNAPSE_HOME%\lib org.apache.axis2.transport.http.SimpleHTTPServer %SYNAPSE_CMD_LINE_ARGS%
+"%_JAVACMD%" %_SYNAPSE_XML% -Daxis2.xml=%SYNAPSE_HOME%\synapse_repository\conf\axis2.xml -Djava.ext.dirs=%SYNAPSE_HOME%\lib;%EXT_DIRS%;%SYNAPSE_HOME% -cp %SYNAPSE_HOME%\lib org.apache.axis2.transport.http.SimpleHTTPServer %SYNAPSE_CMD_LINE_ARGS%
 goto end
 
 :end

Modified: incubator/synapse/trunk/java/etc/project.properties
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/etc/project.properties?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/etc/project.properties (original)
+++ incubator/synapse/trunk/java/etc/project.properties Tue May 16 07:15:40 2006
@@ -2,12 +2,12 @@
 #                Dependency Repositories
 # -------------------------------------------------------------------
 maven.repo.remote=\
-http://www.ibiblio.org/maven,\
-http://cvs.apache.org/repository/,\
-http://www.apache.org/dist/java-repository/,\
-http://www.openejb.org/maven,\
-http://dist.codehaus.org/,\
-http://mirrors.sunsite.dk/maven/,\
+http://www.ibiblio.org/maven,\
+http://cvs.apache.org/repository/,\
+http://www.apache.org/dist/java-repository/,\
+http://www.openejb.org/maven,\
+http://dist.codehaus.org/,\
+http://mirrors.sunsite.dk/maven/,\
 http://jibx.sourceforge.net/maven/
 
 # -------------------------------------------------------------------
@@ -23,11 +23,11 @@
 #                JUnit
 # -------------------------------------------------------------------
 # explicit setting of Sax parser as below is a hack to avoid Junit from loading its own parsers ignoring maven.test.excludeXmlApis
-maven.junit.jvmargs=-Djava.awt.headless=true -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
-maven.junit.fork=true
+maven.junit.jvmargs=-Djava.awt.headless=true
+maven.junit.fork=yes 
+maven.test.excludeXmlApis=yes
 #maven.junit.dir=${basedir}/modules/core
 
-
 # -------------------------------------------------------------------
 #                Compile
 # -------------------------------------------------------------------
@@ -63,12 +63,14 @@
 stax.impl.version=asl-2.9.3
 stax.api.version=1.0
 xalan.version=2.7.0
-xerces.version=2.7.1
+xerces.version=2.8.0
 xmlunit.version=1.0
 annogen.version=0.1.0
 geronimo.spec.jms.version=1.1-rc4
 backport_util_concurrent.version=2.1
 spring.version=1.2.6
+
+xml_apis.version=1.3.03
 
 
 # -------------------------------------------------------------------

Modified: incubator/synapse/trunk/java/etc/project.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/etc/project.xml?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/etc/project.xml (original)
+++ incubator/synapse/trunk/java/etc/project.xml Tue May 16 07:15:40 2006
@@ -204,6 +204,24 @@
                 <module>true</module>
             </properties>
         </dependency>
+
+        <dependency>
+            <groupId>xerces</groupId>
+            <artifactId>xercesImpl</artifactId>
+            <version>${xerces.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>xml-apis</groupId>
+            <artifactId>xml-apis</artifactId>
+            <version>${xml_apis.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+
         <dependency>
             <groupId>annogen</groupId>
             <artifactId>annogen</artifactId>

Modified: incubator/synapse/trunk/java/modules/core/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/maven.xml?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/maven.xml (original)
+++ incubator/synapse/trunk/java/modules/core/maven.xml Tue May 16 07:15:40 2006
@@ -50,10 +50,17 @@
         <mkdir dir="target/synapse-repository/modules"/>
         <copy file="../../repository/modules/addressing-${addressing.version}.mar"
               tofile="target/synapse-repository/modules/addressing-${addressing.version}.mar"/>
+        <!--
         <copy file="../../repository/conf/axis2.xml"
               tofile="target/synapse-repository/conf/axis2.xml"/>
         <copy file="../../repository/conf/synapse.xml"
               tofile="target/synapse-repository/conf/synapse.xml"/>
+              -->
+        <copy todir="target/synapse-repository/conf">
+            <fileset dir="../../repository/conf">
+                <include name="**"/>
+            </fileset>
+        </copy>
 
         <echo message="-----------Creating Testing Repository - Fault Handling ----------"/>
         <mkdir dir="target/synapse-repository-fault"/>

Modified: incubator/synapse/trunk/java/modules/core/project.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/project.xml?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/project.xml (original)
+++ incubator/synapse/trunk/java/modules/core/project.xml Tue May 16 07:15:40 2006
@@ -23,10 +23,10 @@
             <includes>
                 <include>**/*Test.java</include>
             </includes>
-            <excludes>
+            <!--<excludes>
                 <exclude>**/*ValidateMediatorTest.java</exclude>
                 <exclude>**/*TransformMediatorTest.java</exclude>
-            </excludes>
+            </excludes>-->
             <resources>
                 <resource>
                     <directory>test-resources</directory>

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Constants.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Constants.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Constants.java Tue May 16 07:15:40 2006
@@ -26,6 +26,8 @@
 
     String CLASSMEDIATOR = "classmediator";
 
+    String CORRELATE = "correlate/";
+
     QName MEDIATE_OPERATION_NAME = new QName("mediate");
 
     String MEDIATOR_RESPONSE_PROPERTY = "synapse.mediator.response";
@@ -42,6 +44,8 @@
     String SYNAPSE_CONFIG = "synapse.config";
 
     String SYNAPSE_ENV = "synapse.env";
+
+    String SYNAPSE_XML = "synapse.xml";
 
     String ADD_ADDRESSING = "synapse.send.useaddressing";
 

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/MessageContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/MessageContext.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/MessageContext.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/MessageContext.java Tue May 16 07:15:40 2006
@@ -23,6 +23,9 @@
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.RelatesTo;
 
+import java.util.Iterator;
+import java.util.Set;
+
 
 /**
  * The Synapse Message Context is available to all mediators through which it flows. It
@@ -73,6 +76,12 @@
      * @param value value to be saved
      */
     public void setProperty(String key, Object value);
+
+    /**
+     * Returns the Set of keys over the properties on this message context
+     * @return a Set of keys over message properties
+     */
+    public Set getPropertyKeySet();
 
     /**
      * Get the SOAP envelope of this message

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Util.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Util.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Util.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Util.java Tue May 16 07:15:40 2006
@@ -18,6 +18,8 @@
 import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.axiom.om.impl.llom.OMElementImpl;
 import org.apache.axiom.om.impl.llom.OMTextImpl;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.logging.Log;
 import org.apache.synapse.mediators.GetPropertyFunction;
@@ -87,6 +89,48 @@
         } catch (JaxenException je) {
             String msg = "Evaluation of the XPath expression " + xpath.toString() + " resulted in an error";
             log.error(msg, je);
+            throw new SynapseException(msg, je);
+        }
+    }
+
+    /**
+     * Return the namespace with the given prefix, using the given element
+     * @param prefix the prefix looked up
+     * @param elem the source element to use
+     * @return the namespace which maps to the prefix or null
+     */
+    public static String getNameSpaceWithPrefix(String prefix, OMElement elem) {
+        if (prefix == null || elem == null) {
+            log.warn("Searching for null NS prefix and/or using null OMElement");
+            return null;
+        }
+
+        Iterator iter = elem.getAllDeclaredNamespaces();
+        while (iter.hasNext()) {
+            OMNamespace ns = (OMNamespace) iter.next();
+            if (prefix.equals(ns.getPrefix())) {
+                return ns.getName();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Add xmlns NS declarations of element 'elem' into XPath expression
+     * @param xpath
+     * @param elem
+     * @param log
+     */
+    public static void addNameSpaces(AXIOMXPath xpath, OMElement elem, Log log) {
+        try {
+            Iterator it = elem.getAllDeclaredNamespaces();
+            while (it.hasNext()) {
+                OMNamespace n = (OMNamespace) it.next();
+                xpath.addNamespace(n.getPrefix(), n.getName());
+            }
+        } catch (JaxenException je) {
+            String msg = "Error adding declared name spaces of " + elem + " to the XPath : " + xpath;
+            log.error(msg);
             throw new SynapseException(msg, je);
         }
     }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Endpoint.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Endpoint.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Endpoint.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Endpoint.java Tue May 16 07:15:40 2006
@@ -26,8 +26,12 @@
  */
 public class Endpoint {
 
+    /** The name of this endpoint instance */
     private String name = null;
+    /** The simple address this endpoint resolves to - if explicitly specified */
     private URL address = null;
+    /** The name of the actual endpoint to which this instance refers to */
+    private String ref = null;
 
     /**
      * Return the name of the endpoint
@@ -59,5 +63,21 @@
      */
     public void setAddress(URL address) {
         this.address = address;
+    }
+
+    /**
+     * Get the name of the Endpoint to which this instance refers to
+     * @return the name of the referenced endpoint
+     */
+    public String getRef() {
+        return ref;
+    }
+
+    /**
+     * Set the name of an Endpoint as the referenced endpoint of this instance
+     * @param ref the name of the Endpoint referenced
+     */
+    public void setRef(String ref) {
+        this.ref = ref;
     }
 }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/AbstractMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/AbstractMediatorFactory.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/AbstractMediatorFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/AbstractMediatorFactory.java Tue May 16 07:15:40 2006
@@ -21,6 +21,7 @@
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
 import org.jaxen.JaxenException;
 
 import java.util.Iterator;
@@ -29,17 +30,4 @@
  * Is the abstract superclass of MediatorFactory's
  */
 public abstract class AbstractMediatorFactory implements MediatorFactory {
-    public void addNameSpaces(OMElement elem, AXIOMXPath xp, Log log) {
-        try {
-            Iterator it = elem.getAllDeclaredNamespaces();
-            while (it.hasNext()) {
-                OMNamespace n = (OMNamespace) it.next();
-                xp.addNamespace(n.getPrefix(), n.getName());
-            }
-        } catch (JaxenException je) {
-            String msg = "Error adding declared name spaces of " + elem + " to the XPath : " + xp;
-            log.error(msg);
-            throw new SynapseException(msg, je);
-        }
-    }
 }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/FaultMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/FaultMediatorFactory.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/FaultMediatorFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/FaultMediatorFactory.java Tue May 16 07:15:40 2006
@@ -21,6 +21,7 @@
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.transform.FaultMediator;
 import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.xpath.AXIOMXPath;
@@ -80,10 +81,24 @@
             OMAttribute expression = code.getAttribute(ATT_EXPR_Q);
 
             if (value != null) {
-                faultMediator.setFaultCodeValue(QName.valueOf(value.getAttributeValue()));
+                String strValue = value.getAttributeValue();
+                String prefix, name;
+                if (strValue.indexOf(":") != -1) {
+                    prefix = strValue.substring(0, strValue.indexOf(":"));
+                    name = strValue.substring(strValue.indexOf(":")+1);
+                } else {
+                    String msg = "A QName is expected for fault code as prefix:name";
+                    log.error(msg);
+                    throw new SynapseException(msg);
+                }
+                faultMediator.setFaultCodeValue(
+                    new QName(Util.getNameSpaceWithPrefix(prefix, code), name));
+                
             } else if (expression != null) {
                 try {
-                    faultMediator.setFaultCodeExpr(new AXIOMXPath(expression.getAttributeValue()));
+                    AXIOMXPath xp = new AXIOMXPath(expression.getAttributeValue());
+                    Util.addNameSpaces(xp, code, log);
+                    faultMediator.setFaultCodeExpr(xp);
                 } catch (JaxenException je) {
                     String msg = "Invalid fault code expression : " + je.getMessage();
                     log.error(msg);
@@ -103,14 +118,17 @@
 
         OMElement reason = elem.getFirstChildWithName(REASON_Q);
         if (reason != null) {
-            OMAttribute value = code.getAttribute(ATT_VALUE_Q);
-            OMAttribute expression = code.getAttribute(ATT_EXPR_Q);
+            OMAttribute value = reason.getAttribute(ATT_VALUE_Q);
+            OMAttribute expression = reason.getAttribute(ATT_EXPR_Q);
 
             if (value != null) {
                 faultMediator.setFaultReasonValue(value.getAttributeValue());
             } else if (expression != null) {
                 try {
-                    faultMediator.setFaultReasonExpr(new AXIOMXPath(expression.getAttributeValue()));
+                    AXIOMXPath xp = new AXIOMXPath(expression.getAttributeValue());
+                    Util.addNameSpaces(xp, reason, log);
+                    faultMediator.setFaultReasonExpr(xp);
+
                 } catch (JaxenException je) {
                     String msg = "Invalid fault reason expression : " + je.getMessage();
                     log.error(msg);

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/FilterMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/FilterMediatorFactory.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/FilterMediatorFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/FilterMediatorFactory.java Tue May 16 07:15:40 2006
@@ -17,6 +17,7 @@
 
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
 import org.apache.synapse.mediators.filters.FilterMediator;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMAttribute;
@@ -67,7 +68,7 @@
                     throw new SynapseException(msg);
                 }
             }
-            addNameSpaces(elem, filter.getXpath(), log);
+            Util.addNameSpaces(filter.getXpath(), elem, log);
 
         } else if (attSource != null && attRegex != null) {
 
@@ -94,7 +95,7 @@
                     throw new SynapseException(msg);
                 }
             }
-            addNameSpaces(elem, filter.getSource(), log);
+            Util.addNameSpaces(filter.getSource(), elem, log);
 
         } else {
             String msg = "An xpath or (source, regex) attributes are required for a filter";

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/HeaderMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/HeaderMediatorFactory.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/HeaderMediatorFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/HeaderMediatorFactory.java Tue May 16 07:15:40 2006
@@ -18,6 +18,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
 import org.apache.synapse.config.xml.Constants;
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.transform.HeaderMediator;
@@ -76,7 +77,9 @@
 
         } else if (exprn != null && exprn.getAttributeValue() != null) {
             try {
-                headerMediator.setExpression(new AXIOMXPath(exprn.getAttributeValue()));
+                AXIOMXPath xp = new AXIOMXPath(exprn.getAttributeValue());
+                Util.addNameSpaces(xp, elem, log);
+                headerMediator.setExpression(xp);
             } catch (JaxenException je) {
                 String msg = "Invalid XPath expression : " + exprn.getAttributeValue();
                 log.error(msg);

Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/InMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/InMediatorFactory.java?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/InMediatorFactory.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/InMediatorFactory.java Tue May 16 07:15:40 2006
@@ -0,0 +1,45 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.config.xml;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.filters.InMediator;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Creates an In mediator instance
+ *
+ * <in>
+ *    mediator+
+ * </in>
+ */
+public class InMediatorFactory extends AbstractListMediatorFactory {
+
+    private static final QName IN_Q = new QName(Constants.SYNAPSE_NAMESPACE, "in");
+
+    public Mediator createMediator(OMElement elem) {
+        InMediator filter = new InMediator();
+        super.addChildren(elem, filter);
+        return filter;
+    }
+
+    public QName getTagQName() {
+        return IN_Q;
+    }
+
+}

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/LogMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/LogMediatorFactory.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/LogMediatorFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/LogMediatorFactory.java Tue May 16 07:15:40 2006
@@ -60,13 +60,14 @@
         // Set the high level set of properties to be logged (i.e. log level)
         OMAttribute level = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "level"));
         if (level != null) {
-            if (SIMPLE.equals(level)) {
+            String levelstr = level.getAttributeValue();
+            if (SIMPLE.equals(levelstr)) {
                 logMediator.setLogLevel(LogMediator.SIMPLE);
-            } else if (HEADERS.equals(level)) {
+            } else if (HEADERS.equals(levelstr)) {
                 logMediator.setLogLevel(LogMediator.HEADERS);
-            } else if (FULL.equals(level)) {
+            } else if (FULL.equals(levelstr)) {
                 logMediator.setLogLevel(LogMediator.FULL);
-            } else if (CUSTOM.equals(level)) {
+            } else if (CUSTOM.equals(levelstr)) {
                 logMediator.setLogLevel(LogMediator.CUSTOM);
             }
         }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/MediatorFactoryFinder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/MediatorFactoryFinder.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/MediatorFactoryFinder.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/MediatorFactoryFinder.java Tue May 16 07:15:40 2006
@@ -60,7 +60,9 @@
         PropertyMediatorFactory.class,
         SwitchMediatorFactory.class,
         SwitchCaseMediatorFactory.class,
-        SwitchCaseDefaultMediatorFactory.class
+        SwitchCaseDefaultMediatorFactory.class,
+        InMediatorFactory.class,
+        OutMediatorFactory.class
       };
 
     private static MediatorFactoryFinder instance = null;

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/MediatorPropertyFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/MediatorPropertyFactory.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/MediatorPropertyFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/MediatorPropertyFactory.java Tue May 16 07:15:40 2006
@@ -20,6 +20,7 @@
 import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.synapse.mediators.MediatorProperty;
 import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jaxen.JaxenException;
@@ -83,7 +84,9 @@
 
                 } else {
                     try {
-                        prop.setExpression(new AXIOMXPath(attExpr.getAttributeValue()));
+                        AXIOMXPath xp = new AXIOMXPath(attExpr.getAttributeValue());
+                        Util.addNameSpaces(xp, propEle, log);
+                        prop.setExpression(xp);
 
                     } catch (JaxenException e) {
                         String msg = "Invalid XPapth expression : " + attExpr.getAttributeValue();

Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/OutMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/OutMediatorFactory.java?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/OutMediatorFactory.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/OutMediatorFactory.java Tue May 16 07:15:40 2006
@@ -0,0 +1,45 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.config.xml;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.filters.OutMediator;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Creates an Out mediator instance
+ *
+ * <out>
+ *    mediator+
+ * </out>
+ */
+public class OutMediatorFactory extends AbstractListMediatorFactory {
+
+    private static final QName IN_Q = new QName(Constants.SYNAPSE_NAMESPACE, "out");
+
+    public Mediator createMediator(OMElement elem) {
+        OutMediator filter = new OutMediator();
+        super.addChildren(elem, filter);
+        return filter;
+    }
+
+    public QName getTagQName() {
+        return IN_Q;
+    }
+
+}

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/PropertyMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/PropertyMediatorFactory.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/PropertyMediatorFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/PropertyMediatorFactory.java Tue May 16 07:15:40 2006
@@ -18,6 +18,7 @@
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.builtin.PropertyMediator;
 import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.xpath.AXIOMXPath;
@@ -60,7 +61,10 @@
             propMediator.setValue(value.getAttributeValue());
         } else {
             try {
-                propMediator.setExpression(new AXIOMXPath(expression.getAttributeValue()));
+                AXIOMXPath xp = new AXIOMXPath(expression.getAttributeValue());
+                Util.addNameSpaces(xp, elem, log);
+                propMediator.setExpression(xp);
+
             } catch (JaxenException e) {
                 String msg = "Invalid XPath expression for attribute 'expression' : " + expression.getAttributeValue();
                 log.error(msg);

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SendMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SendMediatorFactory.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SendMediatorFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SendMediatorFactory.java Tue May 16 07:15:40 2006
@@ -21,7 +21,16 @@
 
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.builtin.SendMediator;
+import org.apache.synapse.config.Endpoint;
+import org.apache.synapse.SynapseException;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Iterator;
+import java.net.URL;
+import java.net.MalformedURLException;
 
 /**
  * The Send mediator factory parses a Send element and creates an instance of the mediator
@@ -57,10 +66,45 @@
  */
 public class SendMediatorFactory extends AbstractMediatorFactory {
 
+    private static final Log log = LogFactory.getLog(SendMediatorFactory.class);
+
     private static final QName SEND_Q = new QName(Constants.SYNAPSE_NAMESPACE, "send");
 
-    public Mediator createMediator(OMElement el) {
+    private static final QName ATT_REF_Q = new QName(Constants.NULL_NAMESPACE, "ref");
+    private static final QName ATT_ADDRESS_Q = new QName(Constants.NULL_NAMESPACE, "address");
+
+    public Mediator createMediator(OMElement elem) {
+
         SendMediator sm =  new SendMediator();
+
+        Iterator iter = elem.getChildrenWithName(new QName(Constants.SYNAPSE_NAMESPACE, "endpoint"));
+        while (iter.hasNext()) {
+
+            OMElement endptElem = (OMElement) iter.next();
+            OMAttribute ref = endptElem.getAttribute(ATT_REF_Q);
+            OMAttribute address = endptElem.getAttribute(ATT_ADDRESS_Q);
+
+            Endpoint endpt = new Endpoint();
+            if (ref != null) {
+                endpt.setRef(ref.getAttributeValue());
+            } else if (address != null) {
+                try {
+                    endpt.setAddress(new URL(address.getAttributeValue()));
+                } catch (MalformedURLException e) {
+                    String msg = "Invalid endpoint address : " + address.getAttributeValue();
+                    log.error(msg, e);
+                    throw new SynapseException(msg, e);
+                }
+            } else {
+                String msg = "An endpoint used within a send mediator definition must contain a " +
+                    "'ref' (reference) or 'address' (absolute URL) attribute";
+                log.error(msg);
+                throw new SynapseException(msg);
+            }
+
+            sm.addEndpoint(endpt);
+        }
+
         return sm;
     }
 

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SwitchMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SwitchMediatorFactory.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SwitchMediatorFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SwitchMediatorFactory.java Tue May 16 07:15:40 2006
@@ -18,9 +18,14 @@
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.filters.SwitchMediator;
 import org.apache.synapse.mediators.filters.SwitchCaseMediator;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.jaxen.JaxenException;
 
 import javax.xml.namespace.QName;
 import java.util.Iterator;
@@ -48,6 +53,25 @@
     public Mediator createMediator(OMElement elem) {
 
         SwitchMediator switchMediator = new SwitchMediator();
+
+        OMAttribute source = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "source"));
+        if (source == null) {
+            String msg = "A 'source' XPath attribute is required for a switch mediator";
+            log.error(msg);
+            throw new SynapseException(msg);
+        } else {
+            try {
+                AXIOMXPath sourceXPath = new AXIOMXPath(source.getAttributeValue());
+                Util.addNameSpaces(sourceXPath, elem, log);
+                switchMediator.setSource(sourceXPath);
+
+            } catch (JaxenException e) {
+                String msg = "Invalid XPath for attribute 'source' : " + source.getAttributeValue();
+                log.error(msg);
+                throw new SynapseException(msg);
+            }
+        }
+
         Iterator iter = elem.getChildrenWithName(CASE_Q);
         while (iter.hasNext()) {
             switchMediator.addCase((SwitchCaseMediator)

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java Tue May 16 07:15:40 2006
@@ -62,30 +62,25 @@
         }
         root.build();
 
-        // digest defined Sequences
         OMContainer definitions = root.getFirstChildWithName(Constants.DEFINITIONS_ELT);
         if (definitions != null) {
+
+            // digest defined Sequences
             Iterator iter = definitions.getChildrenWithName(Constants.SEQUENCE_ELT);
             while (iter.hasNext()) {
                 OMElement elt = (OMElement) iter.next();
                 defineSequence(elt);
             }
-        }
 
-        // digest defined Endpoints
-        OMContainer endpoints = root.getFirstChildWithName(Constants.ENDPOINT_ELT);
-        if (endpoints != null) {
-            Iterator iter = endpoints.getChildrenWithName(Constants.ENDPOINT_ELT);
+            // digest defined Endpoints
+            iter = definitions.getChildrenWithName(Constants.ENDPOINT_ELT);
             while (iter.hasNext()) {
                 OMElement elt = (OMElement) iter.next();
                 defineEndpoint(elt);
             }
-        }
 
-        // digest defined Global properties
-        OMContainer properties = root.getFirstChildWithName(Constants.PROPERTY_ELT);
-        if (properties != null) {
-            Iterator iter = properties.getChildrenWithName(Constants.PROPERTY_ELT);
+            // digest defined Global properties
+            iter = definitions.getChildrenWithName(Constants.PROPERTY_ELT);
             while (iter.hasNext()) {
                 OMElement elt = (OMElement) iter.next();
                 defineProperty(elt);
@@ -159,6 +154,7 @@
             if (address != null) {
                 try {
                     endpoint.setAddress(new URL(address.getAttributeValue()));
+                    config.addNamedEndpoint(endpoint.getName(), endpoint);
                 } catch (MalformedURLException e) {
                     String msg = "Invalid URL specified for 'address' : " + address.getAttributeValue();
                     log.error(msg, e);

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/TransformMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/TransformMediatorFactory.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/TransformMediatorFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/TransformMediatorFactory.java Tue May 16 07:15:40 2006
@@ -19,6 +19,7 @@
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
 import org.apache.synapse.mediators.transform.TransformMediator;
 import org.apache.synapse.api.Mediator;
 import org.apache.commons.logging.Log;
@@ -79,14 +80,18 @@
 
         if (attSource != null) {
             try {
-                transformMediator.setSource(new AXIOMXPath(attSource.getAttributeValue()));
+                AXIOMXPath xp = new AXIOMXPath(attSource.getAttributeValue());
+                Util.addNameSpaces(xp, elem, log);
+                transformMediator.setSource(xp);
+
             } catch (JaxenException e) {
                 String msg = "Invalid XPath specified for the source attribute : " + attSource.getAttributeValue();
                 log.error(msg);
                 throw new SynapseException(msg);
             }
-
         }
+
+        transformMediator.addAllProperties(MediatorPropertyFactory.getMediatorProperties(elem));
 
         return transformMediator;
     }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/ValidateMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/ValidateMediatorFactory.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/ValidateMediatorFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/ValidateMediatorFactory.java Tue May 16 07:15:40 2006
@@ -18,6 +18,7 @@
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.mediators.builtin.ValidateMediator;
 import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.xpath.AXIOMXPath;
@@ -59,7 +60,7 @@
             try {
                 AXIOMXPath xp = new AXIOMXPath(attSource.getAttributeValue());
                 validateMediator.setSource(xp);
-                addNameSpaces(elem, xp, log);
+                Util.addNameSpaces(xp, elem, log);
 
             } catch (JaxenException e) {
                 String msg = "Invalid XPath expression specified for attribute 'source'";

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContext.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContext.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContext.java Tue May 16 07:15:40 2006
@@ -26,6 +26,7 @@
 
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Set;
 
 public class Axis2MessageContext implements MessageContext {
 
@@ -69,6 +70,10 @@
 
     public void setProperty(String key, Object value) {
         properties.put(key, value);
+    }
+
+    public Set getPropertyKeySet() {
+        return properties.keySet();
     }
 
     //--------------------

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContextFinder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContextFinder.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContextFinder.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContextFinder.java Tue May 16 07:15:40 2006
@@ -74,12 +74,21 @@
 
         log.debug("Synapse Config not available. Creating...");
         AxisConfiguration ac = mc.getConfigurationContext().getAxisConfiguration();
-        Parameter param = ac.getParameter(SYNAPSE_CONFIGURATION);
-        if (param == null) {
-            throw new SynapseException(
-                "Axis2 configuration does not specify a '" + SYNAPSE_CONFIGURATION + "' parameter");
+
+        InputStream is = null;
+        // Has a system property synapse.xml overwritten the synapse config location?
+        if (System.getProperty(SYNAPSE_XML) == null) {
+            Parameter param = ac.getParameter(SYNAPSE_CONFIGURATION);
+            if (param == null) {
+                throw new SynapseException(
+                    "Axis2 configuration does not specify a '" + SYNAPSE_CONFIGURATION + "' parameter");
+            }
+            log.debug("Loading configuration from : " + ((String) param.getValue()));
+            is = mc.getAxisService().getClassLoader().getResourceAsStream(((String) param.getValue()).trim());
+        } else {
+            log.debug("Loading configuration from : " + System.getProperty(SYNAPSE_XML));
+            is = mc.getAxisService().getClassLoader().getResourceAsStream(System.getProperty(SYNAPSE_XML));
         }
-        InputStream is = mc.getAxisService().getClassLoader().getResourceAsStream(((String) param.getValue()).trim());
 
         SynapseConfigurationBuilder cfgBuilder = new SynapseConfigurationBuilder();
         cfgBuilder.setConfiguration(is);

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2Sender.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2Sender.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2Sender.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2Sender.java Tue May 16 07:15:40 2006
@@ -18,38 +18,39 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.synapse.Constants;
 import org.apache.synapse.SynapseException;
 
+import java.util.Set;
+import java.util.Iterator;
+
 /**
  * This class helps the Axis2SynapseEnvironment implement the send method
  */
 public class Axis2Sender {
 
-    public static void sendOn(org.apache.synapse.MessageContext synapseMessageContext) {
+    public static void sendOn(org.apache.synapse.MessageContext synapseInMessageContext) {
 
         try {
-            MessageContext axis2MessageContext = ((Axis2MessageContext) synapseMessageContext).getAxis2MessageContext();
+            MessageContext axis2MessageContext = ((Axis2MessageContext) synapseInMessageContext).getAxis2MessageContext();
             // At any time any QOS is disengaged. It's engaged iff, a flag is
             // set in execution chain. ex: addressing will be engage in outpath iff ADDRESSING_PROCESSED is set.
 
-            if (synapseMessageContext.getProperty(Constants.ENGAGE_ADDRESSING_IN_MESSAGE) != null) {
+            if (synapseInMessageContext.getProperty(Constants.ENGAGE_ADDRESSING_IN_MESSAGE) != null) {
                 axis2MessageContext.setProperty(Constants.ENGAGE_ADDRESSING_IN_MESSAGE, Boolean.TRUE);
             }
 
             //Now handle the outbound message with addressing
-            if (synapseMessageContext.getProperty(Constants.ENGAGE_ADDRESSING_OUT_BOUND_MESSAGE) != null) {
+            if (synapseInMessageContext.getProperty(Constants.ENGAGE_ADDRESSING_OUT_BOUND_MESSAGE) != null) {
                 axis2MessageContext.setProperty(Constants.ENGAGE_ADDRESSING_OUT_BOUND_MESSAGE, Boolean.TRUE);
             }
 
             MessageContext axisOutMsgContext = Axis2FlexibleMEPClient.send(axis2MessageContext);
 
             // run all rules on response
-            synapseMessageContext.setResponse(true);
+            synapseInMessageContext.setResponse(true);
             axisOutMsgContext.setServerSide(true);
-
             axisOutMsgContext.setProperty(
                 MessageContext.TRANSPORT_OUT,
                 axis2MessageContext.getProperty(MessageContext.TRANSPORT_OUT));
@@ -57,11 +58,29 @@
             axisOutMsgContext.setTransportIn(
                 axis2MessageContext.getTransportIn());
 
-            synapseMessageContext.getEnvironment().injectMessage(
+            // create the synapse message context for the response
+            org.apache.synapse.MessageContext synapseOutMessageContext =
                 new Axis2MessageContext(
                     axisOutMsgContext,
-                    synapseMessageContext.getConfiguration(),
-                    synapseMessageContext.getEnvironment()));
+                    synapseInMessageContext.getConfiguration(),
+                    synapseInMessageContext.getEnvironment());
+
+            // now set properties to co-relate to the request i.e. copy over
+            // correlate/* messgae properties from original message to response received
+            Iterator iter = synapseInMessageContext.getPropertyKeySet().iterator();
+            while (iter.hasNext()) {
+                Object key = iter.next();
+                if (key instanceof String && ((String)key).startsWith(Constants.CORRELATE)) {
+                    synapseOutMessageContext.setProperty(
+                        (String) key,
+                        synapseInMessageContext.getProperty((String) key)
+                    );
+                }
+            }
+
+
+            // send the response message through the synapse mediation flow
+            synapseInMessageContext.getEnvironment().injectMessage(synapseOutMessageContext);
 
         } catch (Exception e) {
             e.printStackTrace();

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java Tue May 16 07:15:40 2006
@@ -20,6 +20,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.MessageContext;
 import org.apache.synapse.core.SynapseEnvironment;
+import org.apache.axis2.engine.AxisConfiguration;
 
 /**
  * <p> This is the Axis2 implementation of the MessageContext
@@ -27,13 +28,30 @@
 public class Axis2SynapseEnvironment implements SynapseEnvironment {
 
     private ClassLoader cl = null;
+    /** If synapse is initialized by the SynapseAxis2Interceptor, the Axis2
+     * class loaders were not initialized properly at init time. Hence in such
+     * a case, the axisCfg would be set to refer to the Axis configuration
+     * from which the correct and properly initialized classloader could be picked
+     * up at runtime. This would be used only if the explicit classloader referrenced
+     * by "cl" is null (i.e. has not been set) and the axisCfg is available.
+     */
+    private AxisConfiguration axisCfg = null;
     private static final Log log = LogFactory.getLog(Axis2SynapseEnvironment.class);
 
+    public Axis2SynapseEnvironment() {
+        super();
+    }
+
     public Axis2SynapseEnvironment(ClassLoader cl) {
         super();
         this.cl = cl;
     }
 
+    public Axis2SynapseEnvironment(AxisConfiguration axisCfg) {
+        super();
+        this.axisCfg = axisCfg;
+    }
+
     public void injectMessage(MessageContext synCtx) {
         synCtx.setEnvironment(this);
         synCtx.getConfiguration().getMainMediator().mediate(synCtx);
@@ -47,7 +65,12 @@
     }
 
     public ClassLoader getClassLoader() {
-        return cl;
+        if (cl != null) {
+            return cl;
+        } else if (axisCfg != null) {
+            axisCfg.getServiceClassLoader();
+        }
+        return null;
     }
 
     public void setClassLoader(ClassLoader cl) {

Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseAxis2Interceptor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseAxis2Interceptor.java?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseAxis2Interceptor.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseAxis2Interceptor.java Tue May 16 07:15:40 2006
@@ -0,0 +1,147 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.core.axis2;
+
+import org.apache.axis2.engine.AxisObserver;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEvent;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.AxisFault;
+import org.apache.axiom.om.OMElement;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.Constants;
+import org.apache.synapse.config.xml.SynapseConfigurationBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.ArrayList;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+/**
+ * The Synapse Axis2 interceptor will be invoked by Axis2 upon Axis initialization.
+ * This allows the Synapse engine to be initialized at Axis2 startup, and store the
+ * initial Synapse configuration into the AxisConfiguration for subsequent lookup.
+ */
+public class SynapseAxis2Interceptor implements AxisObserver, Constants {
+
+    private static final Log log = LogFactory.getLog(SynapseAxis2Interceptor.class);
+
+    /**
+     * This is where Synapse is initialized at Axis2 startup
+     * @param axisCfg the Axis2 Configuration
+     */
+    public void init(AxisConfiguration axisCfg) {
+
+        log.info("Initializing Synapse...");
+
+        String synapseXmlLocation = null;
+        // Has a system property synapse.xml overwritten the synapse config location?
+        if (System.getProperty(SYNAPSE_XML) != null) {
+            log.info("Loading configuration from XML file specified by the system property '" + SYNAPSE_XML +"'");
+            synapseXmlLocation = System.getProperty(SYNAPSE_XML);
+
+        } else {
+            // get the synapse configuration XML file parameter
+            Parameter param = axisCfg.getParameter(SYNAPSE_CONFIGURATION);
+            if (param == null) {
+                handleException("Axis2 configuration does not specify the '" + SYNAPSE_CONFIGURATION + "' parameter");
+            } else {
+                synapseXmlLocation = ((String) param.getValue()).trim();
+            }
+        }
+
+        // The axis classloaders such as axisCfg.getServiceClassLoader(), axisCfg.getModuleClassLoader(),
+        // axisCfg.getSystemClassLoader() are not yet initialized at this point, hence load the synapse.xml
+        // from a FileInputStream as does Axis!
+        InputStream is = null;
+        try {
+            is = new FileInputStream(synapseXmlLocation);
+        } catch (FileNotFoundException fnf) {
+            handleException("Cannot load Synapse configuration from : " + synapseXmlLocation, fnf);
+        }
+
+        // build the Synapse configuration parsing the XMl config file
+        SynapseConfigurationBuilder cfgBuilder = null;
+        try {
+            cfgBuilder = new SynapseConfigurationBuilder();
+            cfgBuilder.setConfiguration(is);
+        } catch (Exception e) {
+            handleException("Could not initialize Synapse : " + e.getMessage(), e);
+        }
+        log.info("Loaded Synapse configuration from : " + synapseXmlLocation);
+
+        Parameter synapseCtxParam = new Parameter(SYNAPSE_CONFIG, null);
+        synapseCtxParam.setValue(cfgBuilder.getConfig());
+
+        Parameter synapseEnvParam = new Parameter(SYNAPSE_ENV, null);
+        // Note.. will the classloader mentioned below be overwritten subsequently by Axis?
+        synapseEnvParam.setValue(new Axis2SynapseEnvironment(axisCfg));
+
+        try {
+            axisCfg.addParameter(synapseCtxParam);
+            axisCfg.addParameter(synapseEnvParam);
+
+        } catch (AxisFault e) {
+            handleException(
+                "Could not set parameters '" + SYNAPSE_CONFIG + "' and/or '" + SYNAPSE_ENV +
+                "'to the Axis2 configuration : " + e.getMessage(), e);
+        }
+
+        log.info("Synapse initialized...");
+    }
+
+    private void handleException(String msg) {
+        log.error(msg);
+        throw new SynapseException(msg);
+    }
+
+    private void handleException(String msg, Exception e) {
+        log.error(msg, e);
+        throw new SynapseException(msg, e);
+    }
+
+    //---------------------------------------------------------------------------------------
+    public void serviceUpdate(AxisEvent axisEvent, AxisService axisService) {
+    }
+
+    public void moduleUpdate(AxisEvent axisEvent, AxisModule axisModule) {
+    }
+
+    public void addParameter(Parameter parameter) throws AxisFault {
+    }
+
+    public void removeParameter(Parameter parameter) throws AxisFault {
+    }
+
+    public void deserializeParameters(OMElement elem) throws AxisFault {
+    }
+
+    public Parameter getParameter(String string) {
+        return null;
+    }
+
+    public ArrayList getParameters() {
+        return null;
+    }
+
+    public boolean isParameterLocked(String string) {
+        return false;
+    }
+}

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseDispatcher.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseDispatcher.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseDispatcher.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseDispatcher.java Tue May 16 07:15:40 2006
@@ -22,14 +22,18 @@
 import org.apache.axis2.description.HandlerDescription;
 import org.apache.axis2.engine.AbstractDispatcher;
 import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
 
 /**
- * This sends every message to the SynapseMessageReceiver so that it can pass them to Synapse
+ * This is the Axis2 Dispatcher which is registered with the Axis2 engine. It dispatches
+ * each and every message received to the SynapseMessageReceiver for processing.
  */
 public class SynapseDispatcher extends AbstractDispatcher {
-    // FOR EVERY REQUEST - ALWAYS DISPATH TO THE SYNAPSE SERVICE
+
+    private static final Log log = LogFactory.getLog(SynapseDispatcher.class);
 
     private static final long serialVersionUID = -6970206989111592645L;
 
@@ -41,7 +45,6 @@
         QName qn = new QName("http://synapse.apache.org", "SynapseDispatcher");
         HandlerDescription hd = new HandlerDescription(qn);
         super.init(hd);
-
     }
 
     public AxisService findService(MessageContext mc) throws AxisFault {
@@ -50,11 +53,8 @@
         return as;
     }
 
-    public AxisOperation findOperation(AxisService svc, MessageContext mc)
-        throws AxisFault {
-
+    public AxisOperation findOperation(AxisService svc, MessageContext mc) throws AxisFault {
         AxisOperation ao = svc.getOperation(MEDIATE_OPERATION_NAME);
         return ao;
     }
-
 }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/GetPropertyFunction.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/GetPropertyFunction.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/GetPropertyFunction.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/GetPropertyFunction.java Tue May 16 07:15:40 2006
@@ -21,6 +21,7 @@
 import org.jaxen.Navigator;
 import org.jaxen.function.StringFunction;
 import org.apache.synapse.MessageContext;
+import org.apache.synapse.HeaderType;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -59,7 +60,25 @@
             while (iter.hasNext()) {
                 String key = StringFunction.evaluate(iter.next(), navigator);
                 // ignore if more than one argument has been specified
-                return synCtx.getProperty(key);                
+                Object result = synCtx.getProperty(key);
+
+                if (result != null) {
+                    return result;
+                } else {
+                    if (HeaderType.STR_TO.equals(key) && synCtx.getTo() != null) {
+                        return synCtx.getTo().getAddress();
+                    } else if (HeaderType.STR_FROM.equals(key) && synCtx.getFrom() != null) {
+                        return synCtx.getFrom().getAddress();
+                    } else if (HeaderType.STR_ACTION.equals(key) && synCtx.getWSAAction() != null) {
+                        return synCtx.getWSAAction();
+                    } else if (HeaderType.STR_FAULT.equals(key) && synCtx.getFaultTo() != null) {
+                        return synCtx.getFaultTo().getAddress();
+                    } else if (HeaderType.STR_REPLY_TO.equals(key) && synCtx.getReplyTo() != null) {
+                        return synCtx.getReplyTo().getAddress();
+                    } else {
+                        return null;
+                    }
+                }
             }
         }
         return null;

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/LogMediator.java Tue May 16 07:15:40 2006
@@ -84,6 +84,8 @@
         StringBuffer sb = new StringBuffer();
         if (synCtx.getTo() != null)
             sb.append("To: " + synCtx.getTo().getAddress());
+        else
+            sb.append("To: ");
         if (synCtx.getFrom() != null)
             sb.append(SEP + "From: " + synCtx.getFrom().getAddress());
         if (synCtx.getWSAAction() != null)

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java Tue May 16 07:15:40 2006
@@ -17,20 +17,31 @@
 package org.apache.synapse.mediators.builtin;
 
 import org.apache.synapse.MessageContext;
+import org.apache.synapse.config.Endpoint;
 import org.apache.synapse.mediators.AbstractMediator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.axis2.addressing.EndpointReference;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * The Send mediator sends the message using the following semantics.
  * <p/>
  * This is a leaf mediator (i.e. further processing halts after this mediator completes)
  * <p/>
- * TODO support endpoints, loadbalancing and failover
+ * TODO support loadbalancing and failover
  */
 public class SendMediator extends AbstractMediator {
 
     private static final Log log = LogFactory.getLog(SendMediator.class);
+
+    /** The list of endpoints to which the message should be sent to. If none
+     * are specified, the message is sent where its implicitly stated in the
+     * current message */
+    private List endpoints = new ArrayList();
+
     /**
      * This is a leaf mediator. i.e. processing stops once send is invoked,
      * as it always returns false
@@ -40,10 +51,55 @@
      */
     public boolean mediate(MessageContext synCtx) {
         log.debug(getType() + " mediate()");
-        log.debug("Sending To: " + (synCtx.getTo() != null ?
-            synCtx.getTo().getAddress() : "null"));
-        log.debug("Body : \n" + synCtx.getEnvelope());
-        synCtx.getEnvironment().send(synCtx);
+
+        // TODO this may be really strange but true.. unless you call the below, sometimes it
+        // results in an unbound URI exception for no credible reason - needs more investigation
+        // seems like a woodstox issue. Use hack for now
+        synCtx.getEnvelope().build();
+
+        // if no endpoints are defined, send where implicitly stated
+        if (endpoints.isEmpty()) {
+            log.debug("Sending To: " + (synCtx.getTo() != null ?
+                synCtx.getTo().getAddress() : "null"));
+            log.debug("SOAPAction: " + (synCtx.getWSAAction() != null ?
+                synCtx.getWSAAction() : "null"));
+            log.debug("Body : \n" + synCtx.getEnvelope());
+            synCtx.getEnvironment().send(synCtx);
+
+        } else if (endpoints.size() == 1) {
+            Endpoint singleEndpoint = (Endpoint) endpoints.get(0);
+            String eprAddress = null;
+            if (singleEndpoint.getAddress() != null) {
+                eprAddress = singleEndpoint.getAddress().toString();
+            } else {
+                singleEndpoint = synCtx.getConfiguration().getNamedEndpoint(
+                    singleEndpoint.getRef());
+                eprAddress = singleEndpoint.getAddress().toString();
+            }
+
+            synCtx.setTo(new EndpointReference(eprAddress));
+            log.debug("Sending To: " + (synCtx.getTo() != null ?
+                synCtx.getTo().getAddress() : "null"));
+            log.debug("SOAPAction: " + (synCtx.getWSAAction() != null ?
+                synCtx.getWSAAction() : "null"));
+            log.debug("Body : \n" + synCtx.getEnvelope());
+
+            synCtx.getEnvironment().send(synCtx);
+
+        } else {
+            String msg = "The send mediator currently supports only one endpoint";
+            log.error(msg);
+            throw new UnsupportedOperationException(msg);
+        }
         return false;
+    }
+
+    /**
+     * Add the given Endpoint as an endpoint for this Send mediator instance
+     * @param e the Endpoint to be added
+     * @return true if the endpoint list was updated
+     */
+    public boolean addEndpoint(Endpoint e) {
+        return endpoints.add(e);
     }
 }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/ValidateMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/ValidateMediator.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/ValidateMediator.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/ValidateMediator.java Tue May 16 07:15:40 2006
@@ -15,30 +15,37 @@
 */
 package org.apache.synapse.mediators.builtin;
 
-import org.apache.synapse.mediators.AbstractListMediator;
-import org.apache.synapse.MessageContext;
-import org.apache.synapse.SynapseException;
-import org.apache.axiom.om.xpath.AXIOMXPath;
-import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.mediators.AbstractListMediator;
+import org.jaxen.JaxenException;
+import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.DefaultHandler;
-import org.jaxen.JaxenException;
+import org.xml.sax.helpers.XMLReaderFactory;
 
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.stream.XMLStreamWriter;
+import javax.xml.XMLConstants;
 import javax.xml.stream.XMLOutputFactory;
-import java.io.ByteArrayOutputStream;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.util.List;
-import java.util.Iterator;
+import java.util.StringTokenizer;
 
 /**
  * Validate a message or an element against a schema
@@ -47,16 +54,29 @@
 
     private static final Log log = LogFactory.getLog(ValidateMediator.class);
 
+    /** A space or comma delimitered list of schemas to validate the source element against */
     private String schemaUrl = null;
+    /**
+     * An XPath expression to be evaluated against the message to find the element to be validated.
+     * If this is not specified, the validation will occur against the first child element of the SOAP body
+     */
     private AXIOMXPath source = null;
 
-    private static final String SCHEMA_LOCATION_NO_NS =
-        "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";
-    private static final String SCHEMA_LOCATION_NS =
-        "http://apache.org/xml/properties/schema/external-schemaLocation";
-    private static final String FULL_CHECKING = "http://apache.org/xml/features/validation/schema-full-checking";
-    private static final String SCHEMA_VALIDATION = "http://apache.org/xml/features/validation/schema";
-    private static final String VALIDATION = "http://xml.org/sax/features/validation";
+    /**
+     * Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking).
+     */
+    private static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
+
+    /**
+     * Honour all schema locations feature id (http://apache.org/xml/features/honour-all-schemaLocations).
+     */
+    private static final String HONOUR_ALL_SCHEMA_LOCATIONS_ID = "http://apache.org/xml/features/honour-all-schemaLocations";
+
+    /**
+     * Default schema language (http://www.w3.org/2001/XMLSchema).
+     */
+    private static final String DEFAULT_SCHEMA_LANGUAGE = XMLConstants.W3C_XML_SCHEMA_NS_URI;
+
 
     public String getSchemaUrl() {
         return schemaUrl;
@@ -74,14 +94,22 @@
         this.source = source;
     }
 
+    /**
+     * Return the node to be validated. If a source XPath is not specified, this will
+     * default to the first child of the SOAP body
+     * @param synCtx the message context
+     * @return the OMNode against which validation should be performed
+     */
     private OMNode getValidateSource(MessageContext synCtx) {
 
         if (source == null) {
             try {
-                source = new AXIOMXPath("//SOAP-ENV:Body");
+                source = new AXIOMXPath("//SOAP-ENV:Body/child::*");
                 source.addNamespace("SOAP-ENV", synCtx.isSOAP11() ?
                     SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI : SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-            } catch (JaxenException e) {}
+            } catch (JaxenException e) {
+                // this should not cause a runtime exception!
+            }
         }
 
         try {
@@ -106,22 +134,14 @@
     public boolean mediate(MessageContext synCtx) {
 
         ByteArrayInputStream baisFromSource = null;
-        StringBuffer nsLocations = new StringBuffer();
 
         try {
             // create a byte array output stream and serialize the source node into it
             ByteArrayOutputStream baosForSource = new ByteArrayOutputStream();
             XMLStreamWriter xsWriterForSource = XMLOutputFactory.newInstance().createXMLStreamWriter(baosForSource);
 
-            // save the list of defined namespaces for validation against the schema
+            // serialize the validation target and get an input stream into it
             OMNode sourceNode = getValidateSource(synCtx);
-            if (sourceNode instanceof OMElement) {
-                Iterator iter = ((OMElement) sourceNode).getAllDeclaredNamespaces();
-                while (iter.hasNext()) {
-                    OMNamespace omNS = (OMNamespace) iter.next();
-                    nsLocations.append(omNS.getName() + " " + getSchemaUrl());
-                }
-            }
             sourceNode.serialize(xsWriterForSource);
             baisFromSource = new ByteArrayInputStream(baosForSource.toByteArray());
 
@@ -132,22 +152,48 @@
         }
 
         try {
-            SAXParserFactory spFactory = SAXParserFactory.newInstance();
-            spFactory.setNamespaceAware(true);
-            spFactory.setValidating(true);
-            SAXParser parser = spFactory.newSAXParser();
-
-            parser.setProperty(VALIDATION, Boolean.TRUE);
-            parser.setProperty(SCHEMA_VALIDATION, Boolean.TRUE);
-            parser.setProperty(FULL_CHECKING, Boolean.TRUE);
-            parser.setProperty(SCHEMA_LOCATION_NS, nsLocations.toString());
-            parser.setProperty(SCHEMA_LOCATION_NO_NS, getSchemaUrl());
+            // this is our custom validation handler
+            SynapseValidator handler = new SynapseValidator();
+
+            // Create SchemaFactory and configure
+            SchemaFactory factory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE);
+            factory.setErrorHandler(handler);
+            factory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
+            factory.setFeature(HONOUR_ALL_SCHEMA_LOCATIONS_ID, true);
+
+            // Build Schema from schemaUrl
+            Schema schema = null;
+            if (schemaUrl != null) {
+                StringTokenizer st = new StringTokenizer(schemaUrl, " ,");
+                int sourceCount = st.countTokens();
+
+                if (sourceCount == 0) {
+                    schema = factory.newSchema();
+                } else {
+                    StreamSource[] sources = new StreamSource[sourceCount];
+                    for (int j = 0; j < sourceCount; ++j) {
+                        sources[j] = new StreamSource(st.nextToken());
+                    }
+                    schema = factory.newSchema(sources);
+                }
+            } else {
+                schema = factory.newSchema();
+            }
 
-            Validator handler = new Validator();
-            parser.parse(baisFromSource, handler);
+            // Setup validator and input source.
+            Validator validator = schema.newValidator();
+            validator.setErrorHandler(handler);
+            validator.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
+            validator.setFeature(HONOUR_ALL_SCHEMA_LOCATIONS_ID, true);
+
+            XMLReader reader = XMLReaderFactory.createXMLReader();
+            SAXSource source = new SAXSource(reader, new InputSource(baisFromSource));
+            validator.validate(source);
 
             if (handler.isValidationError()) {
-                log.debug("Validation failed :" + handler.getSaxParseException().getMessage());
+                log.debug("Validation of element : " + source + " failed against : " + schemaUrl +
+                    " Message : " + handler.getSaxParseException().getMessage() + " Executing 'on-fail' sequence");
+                log.debug("Failed message envelope : " + synCtx.getEnvelope());
                 // super.mediate() invokes the "on-fail" sequence of mediators
                 return super.mediate(synCtx);
             }
@@ -165,7 +211,7 @@
     /**
      * This class handles validation errors to be used for error reporting
      */
-    private class Validator extends DefaultHandler {
+    private class SynapseValidator extends DefaultHandler {
 
         private boolean validationError = false;
         private SAXParseException saxParseException = null;

Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/InMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/InMediator.java?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/InMediator.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/InMediator.java Tue May 16 07:15:40 2006
@@ -0,0 +1,57 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.mediators.filters;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.mediators.AbstractListMediator;
+
+/**
+ * The In Mediator acts only on "incoming" messages into synapse. This is
+ * performed by looking at the result of MessageContext#isResponse()
+ *
+ * @see org.apache.synapse.MessageContext#isResponse()
+ */
+public class InMediator extends AbstractListMediator implements org.apache.synapse.api.FilterMediator {
+
+    private static final Log log = LogFactory.getLog(InMediator.class);
+
+    /**
+     * Executes the list of sub/child mediators, if the filter condition is satisfied
+     *
+     * @param synCtx the current message
+     * @return true if filter condition fails. else returns as per List mediator semantics
+     */
+    public boolean mediate(MessageContext synCtx) {
+        log.debug(getType() + " mediate()");
+        if (test(synCtx)) {
+            return super.mediate(synCtx);
+        } else {
+            return true;
+        }
+    }
+
+    /**
+     * Apply mediation only on request messages
+     *
+     * @param synCtx the message context
+     * @return MessageContext#isResponse()
+     */
+    public boolean test(MessageContext synCtx) {
+        return !synCtx.isResponse();
+    }
+}

Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/OutMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/OutMediator.java?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/OutMediator.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/OutMediator.java Tue May 16 07:15:40 2006
@@ -0,0 +1,57 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.mediators.filters;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.mediators.AbstractListMediator;
+
+/**
+ * The Out Mediator acts only on "outgoing" messages from synapse. This is
+ * performed by looking at the result of MessageContext#isResponse()
+ *
+ * @see org.apache.synapse.MessageContext#isResponse()
+ */
+public class OutMediator extends AbstractListMediator implements org.apache.synapse.api.FilterMediator {
+
+    private static final Log log = LogFactory.getLog(OutMediator.class);
+
+    /**
+     * Executes the list of sub/child mediators, if the filter condition is satisfied
+     *
+     * @param synCtx the current message
+     * @return true if filter condition fails. else returns as per List mediator semantics
+     */
+    public boolean mediate(MessageContext synCtx) {
+        log.debug(getType() + " mediate()");
+        if (test(synCtx)) {
+            return super.mediate(synCtx);
+        } else {
+            return true;
+        }
+    }
+
+    /**
+     * Apply mediation only on response messages
+     *
+     * @param synCtx the message context
+     * @return MessageContext#isResponse()
+     */
+    public boolean test(MessageContext synCtx) {
+        return synCtx.isResponse();
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org