synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sami...@apache.org
Subject svn commit: r405630 - in /incubator/synapse/trunk/java/modules: core/src/org/apache/synapse/ core/src/org/apache/synapse/config/ core/src/org/apache/synapse/config/xml/ core/src/org/apache/synapse/core/axis2/ core/src/org/apache/synapse/mediators/built...
Date Wed, 10 May 2006 04:27:17 GMT
Author: saminda
Date: Tue May  9 21:27:13 2006
New Revision: 405630

URL: http://svn.apache.org/viewcvs?rev=405630&view=rev
Log:
applying patch sent by asankha to remove SynapseMessage

Added:
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Endpoint.java
    incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/
    incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java
    incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/DropMediatorTest.java
    incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/FaultMediatorTest.java
    incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/HeaderMediatorTest.java
Removed:
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/SynapseMessage.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseMessage.java
    incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessage.java
Modified:
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/HeaderType.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/SynapseMessageContext.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Util.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/SynapseConfiguration.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/core/axis2/Axis2Sender.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseContextFinder.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/Axis2SynapseMessageContext.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.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/filters/FilterMediator.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/HeaderMediator.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/TestSynapseMessageContext.java
    incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestUtils.java
    incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/TransformMediatorTest.java
    incubator/synapse/trunk/java/modules/samples/src/sampleMediators/InjectRedirect.java
    incubator/synapse/trunk/java/modules/samples/src/sampleMediators/Logger.java

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/HeaderType.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/HeaderType.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/HeaderType.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/HeaderType.java Tue May  9 21:27:13 2006
@@ -17,7 +17,8 @@
 package org.apache.synapse;
 
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * This is a convenience class used to manipulate common headers. The convenience string names this defines could be
@@ -28,61 +29,75 @@
  */
 public class HeaderType {
 
+    private static final Log log = LogFactory.getLog(HeaderType.class);
+
     private final static int TO = 1, FROM = 2, FAULT = 3, ACTION = 4, REPLYTO = 5;
 
     /** Refers the To header */
-    public final static String STRTO = "To";
+    public final static String STR_TO = "To";
     /** Refers the From header */
-    public final static String STRFROM = "From";
+    public final static String STR_FROM = "From";
     /** Refers the FaultTo header */
-    public final static String STRFAULT = "FaultTo";
+    public final static String STR_FAULT = "FaultTo";
     /** Refers the Action header */
-    public final static String STRACTION = "Action";
+    public final static String STR_ACTION = "Action";
     /** Refers the ReplyTo header */
-    public final static String STRREPLYTO = "ReplyTo";
+    public final static String STR_REPLY_TO = "ReplyTo";
 
+    /** The header type being internally reffered to */
     private int headerType = 0;
 
+    /**
+     * Sets the internal header type depending on the header identification string passed in
+     * @param header a string denoting a SOAP header
+     */
     public void setHeaderType(String header) {
-        if (header.equalsIgnoreCase(STRTO))
+        if (header.equalsIgnoreCase(STR_TO))
             headerType = TO;
-        else if (header.equalsIgnoreCase(STRFROM))
+        else if (header.equalsIgnoreCase(STR_FROM))
             headerType = FROM;
-        else if (header.equalsIgnoreCase(STRFAULT))
+        else if (header.equalsIgnoreCase(STR_FAULT))
             headerType = FAULT;
-        else if (header.equalsIgnoreCase(STRACTION))
+        else if (header.equalsIgnoreCase(STR_ACTION))
             headerType = ACTION;
-        else if (header.equalsIgnoreCase(STRREPLYTO))
+        else if (header.equalsIgnoreCase(STR_REPLY_TO))
             headerType = REPLYTO;
-        else
-            throw new SynapseException("Unknown header type : " + header);
+        else {
+            String msg = "Unknown header type : " + header;
+            log.error(msg);
+            throw new SynapseException(msg);
+        }
     }
 
-    public String getHeader(SynapseMessage sm) {
+    /**
+     * Gets the value of this header from the given Synapse message
+     * @param synCtx the message where lookup should be performed
+     * @return the string value of the header
+     */
+    public String getHeader(SynapseMessageContext synCtx) {
         switch (headerType) {
             case TO: {
-                if (sm.getTo() != null)
-                    return sm.getTo().getAddress();
-
+                if (synCtx.getTo() != null)
+                    return synCtx.getTo().getAddress();
             }
             case FROM: {
-                if (sm.getFrom() != null)
-                    return sm.getFrom().getAddress();
+                if (synCtx.getFrom() != null)
+                    return synCtx.getFrom().getAddress();
                 break;
             }
             case FAULT: {
-                if (sm.getFaultTo() != null)
-                    return sm.getFaultTo().getAddress();
+                if (synCtx.getFaultTo() != null)
+                    return synCtx.getFaultTo().getAddress();
                 break;
             }
             case ACTION: {
-                if (sm.getWSAAction() != null)
-                    return sm.getWSAAction();
+                if (synCtx.getWSAAction() != null)
+                    return synCtx.getWSAAction();
                 break;
             }
             case REPLYTO: {
-                if (sm.getReplyTo() != null)
-                    return sm.getReplyTo().getAddress();
+                if (synCtx.getReplyTo() != null)
+                    return synCtx.getReplyTo().getAddress();
                 break;
             }
         }
@@ -91,42 +106,62 @@
     }
 
     /**
-     * Removed the header indicated by this header type from the given message
-     * @param synMsg the current message from which the header should be removed
+     * Removed the header indicated by this header type from the given message. i.e. sets it as null
+     * @param synCtx the current message from which the header should be removed (set null)
      */
-    public void removeHeader(SynapseMessage synMsg) {
-        //TODO This is not yet implemented - revisit later
-        System.err.println("Unimplemented functionality - Needs to be fixed");
+    public void removeHeader(SynapseMessageContext synCtx) {
+        switch (headerType) {
+            case TO: {
+                synCtx.setTo(null);
+                break;
+            }
+            case FROM: {
+                synCtx.setFrom(null);
+                break;
+            }
+            case REPLYTO: {
+                synCtx.setReplyTo(null);
+                break;
+            }
+            case ACTION: {
+                synCtx.setWSAAction(null);
+                break;
+            }
+            default: {
+                String msg = "Unknown header type : " + headerType;
+                log.error(msg);
+                throw new SynapseException("Invalid header type");
+            }
+        }
     }
 
     /**
      * Sets the given value into the message's indicated header
-     * @param synMsg the current message on which to set the header
+     * @param synCtx the current message on which to set the header
      * @param value the value to be set
      */
-    public void setHeader(SynapseMessage synMsg, String value) {
+    public void setHeader(SynapseMessageContext synCtx, String value) {
         switch (headerType) {
-            case 0: {
-                throw new SynapseException(
-                    "headerType=0 in setHeader. Assume called setHeader before setHeaderType");
-            }
-
             case TO: {
-
-                synMsg.setTo(new EndpointReference(value));
+                synCtx.setTo(new EndpointReference(value));
                 break;
             }
             case FROM: {
-                synMsg.setFrom(new EndpointReference(value));
+                synCtx.setFrom(new EndpointReference(value));
                 break;
             }
             case REPLYTO: {
-                synMsg.setReplyTo(new EndpointReference(value));
+                synCtx.setReplyTo(new EndpointReference(value));
                 break;
             }
             case ACTION: {
-                synMsg.setWSAAction(value);
+                synCtx.setWSAAction(value);
                 break;
+            }
+            default: {
+                String msg = "Unknown header type : " + headerType;
+                log.error(msg);
+                throw new SynapseException(msg);
             }
         }
     }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/SynapseMessageContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/SynapseMessageContext.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/SynapseMessageContext.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/SynapseMessageContext.java Tue May  9 21:27:13 2006
@@ -18,14 +18,18 @@
 
 import org.apache.synapse.config.SynapseConfiguration;
 import org.apache.synapse.core.SynapseEnvironment;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.RelatesTo;
 
 
 /**
- * The Synapse Context is available to mediators through the SynapseMessage. It
+ * The Synapse Message Context is available to all mediators through which it flows. It
  * allows one to call to the underlying SynapseEnvironment (i.e. the SOAP engine
- * - such as Axis2 - where required. It also allows one to access the current
+ * - such as Axis2) where required. It also allows one to access the current
  * SynapseConfiguration. Additionally it holds per message properties (i.e. local
- * properties valid for the lifetime of the message)
+ * properties valid for the lifetime of the message), and the current SOAPEnvelope
  */
 public interface SynapseMessageContext {
 
@@ -57,18 +61,6 @@
     public void setSynapseEnvironment(SynapseEnvironment se);
 
     /**
-     * Sets the associated Synapse message
-     * @param sm the synapse message associated with this context
-     */
-    public void setSynapseMessage(SynapseMessage sm);
-
-    /**
-     * Return the associated SynapseMessage
-     * @return the associated Synapse message
-     */
-    public SynapseMessage getSynapseMessage();
-
-    /**
      * Get the value of a custom (local) property set on the message instance
      * @param key key to look up property
      * @return value for the given key
@@ -81,5 +73,135 @@
      * @param value value to be saved
      */
     public void setProperty(String key, Object value);
+
+    /**
+     * Get the SOAP envelope of this message
+     * @return the SOAP envelope of the message
+     */
+    public SOAPEnvelope getEnvelope();
+
+    /**
+     * Sets the given envelope as the current SOAPEnvelope for this message
+     * @param envelope the envelope to be set
+     * @throws org.apache.axis2.AxisFault on exception
+     */
+    public void setEnvelope(SOAPEnvelope envelope) throws AxisFault;
+
+    // --- SOAP Message related methods ------
+    public EndpointReference getFaultTo();
+
+    public void setFaultTo(EndpointReference reference);
+
+    public EndpointReference getFrom();
+
+    public void setFrom(EndpointReference reference);
+
+    public String getMessageID();
+
+    public void setMessageID(String string);
+
+    public RelatesTo getRelatesTo();
+
+    public void setRelatesTo(RelatesTo[] reference);
+
+    public EndpointReference getReplyTo();
+
+    public void setReplyTo(EndpointReference reference);
+
+    public EndpointReference getTo();
+
+    public void setTo(EndpointReference reference);
+
+    /**
+     * Sets the WSAAction
+     * @param actionURI the WSAAction
+     */
+    public void setWSAAction(String actionURI);
+
+    /**
+     * Returns the WSAAction
+     * @return the WSAAction
+     */
+    public String getWSAAction();
+
+    /**
+     * Returns the SOAPAction of the message
+     * @return the SOAPAction
+     */
+    public String getSoapAction();
+
+    /**
+     * Set the SOAPAction
+     * @param string the SOAP Action
+     */
+    public void setSoapAction(String string);
+
+    /**
+     * Set the message if
+     * @param messageID
+     */
+    public void setMessageId(String messageID);
+
+    /**
+     * Gets the message id
+     * @return the message id
+     */
+    public String getMessageId();
+
+    /**
+     * If this message using MTOM?
+     * @return true if using MTOM
+     */
+    public boolean isDoingMTOM();
+
+    /**
+     * Marks as using MTOM
+     * @param b true to mark as using MTOM
+     */
+    public void setDoingMTOM(boolean b);
+
+    /**
+     * Is this message over REST?
+     * @return true if over REST
+     */
+    public boolean isDoingREST();
+
+    /**
+     * Marks this message as over REST
+     * @param b true to mark as REST
+     */
+    public void setDoingREST(boolean b);
+
+    /**
+     * Is this message a SOAP 1.1 message?
+     * @return true if this is a SOAP 1.1 message
+     */
+    public boolean isSOAP11();
+
+    /**
+     * Mark this message as a response or not.
+     * @see org.apache.synapse.SynapseMessageContext#isResponse()
+     * @param b true to set this as a response
+     */
+    public void setResponse(boolean b);
+
+    /**
+     * Is this message a response to a synchronous message sent out through Synapse?
+     * @return true if this message is a response message
+     */
+    public boolean isResponse();
+
+    /**
+     * Marks this message as a fault response
+     * @see org.apache.synapse.SynapseMessageContext#isFaultResponse()
+     * @param b true to mark this as a fault response
+     */
+    public void setFaultResponse(boolean b);
+
+    /**
+     * Is this message a response to a fault message?
+     * @return true if this is a response to a fault message
+     */
+    public boolean isFaultResponse();
 
 }

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=405630&r1=405629&r2=405630&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  9 21:27:13 2006
@@ -66,7 +66,7 @@
         }
 
         try {
-            Object result = xpath.evaluate(synCtx.getSynapseMessage().getEnvelope());
+            Object result = xpath.evaluate(synCtx.getEnvelope());
             StringBuffer textValue = new StringBuffer();
 
             if (result instanceof List) {

Added: 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=405630&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Endpoint.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Endpoint.java Tue May  9 21:27:13 2006
@@ -0,0 +1,63 @@
+/*
+* 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;
+
+import java.net.URL;
+
+/**
+ * An endpoint can be used to give a logical name to an endpoint address, and possibly reused.
+ * If the address is not just a simple URL, then extensibility elements may be used to indicate
+ * the address. (i.e. an endpoint always will "resolve" into an absolute endpoint address.
+ *
+ * In future registry lookups etc may be used to resolve a named endpoint into its absolute address
+ */
+public class Endpoint {
+
+    private String name = null;
+    private URL address = null;
+
+    /**
+     * Return the name of the endpoint
+     * @return the name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Set the name of this named endpoint
+     * @param name the name to be set
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * This should return the absolute EPR address referenced by the named endpoint. This may be possibly computed.
+     * @return an absolute address to be used to reference the named endpoint
+     */
+    public URL getAddress() {
+        return address;
+    }
+
+    /**
+     * Set an absolute URL as the address for this named endpoint
+     * @param address the absolute address to be used
+     */
+    public void setAddress(URL address) {
+        this.address = address;
+    }
+}

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/SynapseConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/SynapseConfiguration.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/SynapseConfiguration.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/SynapseConfiguration.java Tue May  9 21:27:13 2006
@@ -20,35 +20,95 @@
 import java.util.HashMap;
 import java.util.Map;
 
+/**
+ * The SynapseConfiguration holds the global configuration for a Synapse
+ * instance. It:
+ *  - contains the model of the definitions & rules to execute
+ *	- contains named global properties and their values
+ *  - contains named endpoint definitions
+ */
 public class SynapseConfiguration {
-
+    /** Holds named sequences of mediators for reuse */
     private Map namedSequences = new HashMap();
+
+    /** Holds named endpoints (which results into absolute EPRs) for reuse */
     private Map namedEndpoints = new HashMap();
+
+    /** Holds global (system-wide) properties that apply to the synapse instance and every message */
     private Map globalProps = new HashMap();
 
+    /** This is the "main" (or default) synapse mediator which mediates each and every message */
     private Mediator mainMediator = null;
 
+    /**
+     * Add a named mediator into this configuration
+     * @param name the name for the sequence
+     * @param m the mediator to be reffered to by the name
+     */
     public void addNamedMediator(String name, Mediator m) {
         namedSequences.put(name, m);
     }
 
+    /**
+     * Return the mediator named with the given name
+     * @param name the name being looked up
+     * @return the mediator referenced by the name
+     */
     public Mediator getNamedMediator(String name) {
         return (Mediator) namedSequences.get(name);
     }
 
+    /**
+     * Return the "main" (or default) mediator of synapse. The main mediator mediates each and every
+     * message flowing through the system. In an XML based configuration, this is specified within the
+     * <rules> section of the configuration
+     * @return the main mediator to be used
+     */
     public Mediator getMainMediator() {
         return mainMediator;
     }
 
+    /**
+     * Sets the main mediator for this instance
+     * @param mainMediator the mediator to be used as the main mediator
+     */
     public void setMainMediator(Mediator mainMediator) {
         this.mainMediator = mainMediator;
     }
 
+    /**
+     * Add a global (system-wide) property. These properties must be string literals
+     * @param name the name of the property
+     * @param value its string value
+     */
     public void addProperty(String name, String value) {
         globalProps.put(name, value);
     }
 
+    /**
+     * Get the value of the named property
+     * @param name key of the property being looked up
+     * @return its value
+     */
     public String getProperty(String name) {
         return (String) globalProps.get(name);
+    }
+
+    /**
+     * Define a named endpoint with the given name
+     * @param name the name of the endpoint
+     * @param endpoint the endpoint definition
+     */
+    public void addNamedEndpoint(String name, Endpoint endpoint) {
+        namedEndpoints.put(name, endpoint);
+    }
+
+    /**
+     * Get the definition of a named endpoint
+     * @param name the name being looked up
+     * @return the endpoint definition which will resolve into an absolute address
+     */
+    public Endpoint getNamedEndpoint(String name) {
+        return (Endpoint) namedEndpoints.get(name);
     }
 }

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=405630&r1=405629&r2=405630&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  9 21:27:13 2006
@@ -21,6 +21,7 @@
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.synapse.config.Endpoint;
 import org.apache.synapse.mediators.base.SequenceMediator;
 import org.apache.synapse.mediators.base.SynapseMediator;
 import org.apache.commons.logging.Log;
@@ -31,6 +32,8 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.util.Iterator;
+import java.net.URL;
+import java.net.MalformedURLException;
 
 
 /**
@@ -75,7 +78,7 @@
             Iterator iter = endpoints.getChildrenWithName(Constants.ENDPOINT_ELT);
             while (iter.hasNext()) {
                 OMElement elt = (OMElement) iter.next();
-                //defineEndpoint(synCfg, elt); //TODO process Endpoints
+                defineEndpoint(elt);
             }
         }
 
@@ -130,6 +133,39 @@
     private void defineSequence(OMElement ele) {
         SequenceMediator seq = (SequenceMediator) MediatorFactoryFinder.getInstance().getMediator(ele);
         config.addNamedMediator(seq.getName(), seq);
+    }
+
+    /**
+     * Create an endpoint definition digesting an XML fragment
+     *
+     * <endpoint name="string" [address="url"]>
+     *    .. extensibility ..
+     * </endpoint>
+     * @param ele the <endpoint> element
+     */
+    private void defineEndpoint(OMElement ele) {
+
+        OMAttribute name = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
+        if (name == null) {
+            String msg = "The 'name' attribute is required for a named endpoint definition";
+            log.error(msg);
+            throw new SynapseException(msg);
+
+        } else {
+            Endpoint endpoint = new Endpoint();
+            endpoint.setName(name.getAttributeValue());
+
+            OMAttribute address = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "address"));
+            if (address != null) {
+                try {
+                    endpoint.setAddress(new URL(address.getAttributeValue()));
+                } catch (MalformedURLException e) {
+                    String msg = "Invalid URL specified for 'address' : " + address.getAttributeValue();
+                    log.error(msg, e);
+                    throw new SynapseException(msg, e);
+                }
+            }
+        }
     }
 
 }

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=405630&r1=405629&r2=405630&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  9 21:27:13 2006
@@ -34,7 +34,7 @@
 
         try {
 
-            MessageContext messageContext = ((Axis2SynapseMessage) smc.getSynapseMessage()).getMessageContext();
+            MessageContext messageContext = ((Axis2SynapseMessageContext) smc).getMessageContext();
             // 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
@@ -60,7 +60,7 @@
 
             // run all rules on response
 
-            smc.getSynapseMessage().setResponse(true);//
+            smc.setResponse(true);//
 
             outMsgContext.setServerSide(true);
 
@@ -71,7 +71,7 @@
 
             outMsgContext.setTransportIn(ti);
 
-            smc.setSynapseMessage(new Axis2SynapseMessage(outMsgContext, smc));
+            smc = new Axis2SynapseMessageContext(outMsgContext);
             smc.getSynapseEnvironment().injectMessage(smc);
 
         } catch (Exception e) {
@@ -81,7 +81,7 @@
     }
 
     public static void sendBack(SynapseMessageContext smc) {
-        MessageContext messageContext = ((Axis2SynapseMessage) smc.getSynapseMessage()).getMessageContext();
+        MessageContext messageContext = ((Axis2SynapseMessageContext) smc).getMessageContext();
         AxisEngine ae =
             new AxisEngine(messageContext.getConfigurationContext());
         try {

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseContextFinder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseContextFinder.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseContextFinder.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseContextFinder.java Tue May  9 21:27:13 2006
@@ -57,11 +57,10 @@
             throw new SynapseException(msg);
         }
 
-        SynapseMessageContext synCtx = new Axis2SynapseMessageContext();
+        SynapseMessageContext synCtx = new Axis2SynapseMessageContext(mc);
         synCtx.setSynapseEnvironment(synEnv);
         synCtx.setConfiguration(synCfg);
-        synCtx.setSynapseMessage(new Axis2SynapseMessage(mc, synCtx));
-        return synCtx;        
+        return synCtx;
     }
 
     /**

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=405630&r1=405629&r2=405630&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  9 21:27:13 2006
@@ -40,7 +40,7 @@
     }
 
     public void send(SynapseMessageContext synCtx) {
-        if (synCtx.getSynapseMessage().isResponse())
+        if (synCtx.isResponse())
             Axis2Sender.sendBack(synCtx);
         else
             Axis2Sender.sendOn(synCtx);

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseMessageContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseMessageContext.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseMessageContext.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseMessageContext.java Tue May  9 21:27:13 2006
@@ -16,9 +16,14 @@
 package org.apache.synapse.core.axis2;
 
 import org.apache.synapse.SynapseMessageContext;
-import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.Constants;
 import org.apache.synapse.core.SynapseEnvironment;
 import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.AxisFault;
+import org.apache.axiom.soap.SOAPEnvelope;
 
 import java.util.Map;
 import java.util.HashMap;
@@ -27,9 +32,15 @@
 
     private SynapseConfiguration cfg = null;
     private SynapseEnvironment   env = null;
-    private SynapseMessage       msg = null;
     private Map properties = new HashMap();
 
+    /** The Axis2 MessageContext reference */
+    private MessageContext mc = null;
+
+    private boolean response = false;
+
+    private boolean faultResponse = false;
+
     public SynapseConfiguration getConfiguration() {
         return cfg;
     }
@@ -46,14 +57,6 @@
         this.env = env;
     }
 
-    public void setSynapseMessage(SynapseMessage msg) {
-        this.msg = msg;
-    }
-
-    public SynapseMessage getSynapseMessage() {
-        return msg;
-    }
-
     public Object getProperty(String key) {
         Object ret = properties.get(key);
         if (ret != null) {
@@ -68,4 +71,138 @@
     public void setProperty(String key, Object value) {
         properties.put(key, value);
     }
+
+    //--------------------
+    public Axis2SynapseMessageContext(MessageContext mc) {
+        setMessageContext(mc);
+    }
+
+    public EndpointReference getFaultTo() {
+        return mc.getFaultTo();
+    }
+
+    public void setFaultTo(EndpointReference reference) {
+        mc.setFaultTo(reference);
+    }
+
+    public EndpointReference getFrom() {
+        return mc.getFrom();
+    }
+
+    public void setFrom(EndpointReference reference) {
+        mc.setFrom(reference);
+    }
+
+    public SOAPEnvelope getEnvelope() {
+        return mc.getEnvelope();
+    }
+
+    public void setEnvelope(SOAPEnvelope envelope) throws AxisFault {
+        mc.setEnvelope(envelope);
+    }
+
+    public String getMessageID() {
+        return mc.getMessageID();
+    }
+
+    public void setMessageID(String string) {
+        mc.setMessageID(string);
+    }
+
+    public RelatesTo getRelatesTo() {
+        return mc.getRelatesTo();
+    }
+
+    public void setRelatesTo(RelatesTo[] reference) {
+        mc.setRelationships(reference);
+    }
+
+    public EndpointReference getReplyTo() {
+        return mc.getReplyTo();
+    }
+
+    public void setReplyTo(EndpointReference reference) {
+        mc.setReplyTo(reference);
+    }
+
+    public EndpointReference getTo() {
+        return mc.getTo();
+    }
+
+    public void setTo(EndpointReference reference) {
+        mc.setTo(reference);
+    }
+
+    public void setWSAAction(String actionURI) {
+        mc.setWSAAction(actionURI);
+    }
+
+    public String getWSAAction() {
+        return mc.getWSAAction();
+    }
+
+    public void setMessageId(String messageID) {
+        mc.setWSAMessageId(messageID);
+    }
+
+    public String getMessageId() {
+        return mc.getMessageID();
+    }
+
+    public String getSoapAction() {
+        return mc.getSoapAction();
+    }
+
+    public void setSoapAction(String string) {
+        mc.setSoapAction(string);
+    }
+
+    public boolean isDoingMTOM() {
+        return mc.isDoingMTOM();
+    }
+
+    public void setDoingMTOM(boolean b) {
+        mc.setDoingMTOM(b);
+    }
+
+    public boolean isDoingREST() {
+        return mc.isDoingREST();
+    }
+
+    public void setDoingREST(boolean b) {
+        mc.setDoingREST(b);
+    }
+
+    public boolean isSOAP11() {
+        return mc.isSOAP11();
+    }
+
+    public void setResponse(boolean b) {
+        response = b;
+        mc.setProperty(Constants.ISRESPONSE_PROPERTY, Boolean.valueOf(b));
+    }
+
+    public boolean isResponse() {
+        return response;
+    }
+
+    public void setFaultResponse(boolean b) {
+        this.faultResponse = b;
+    }
+
+    public boolean isFaultResponse() {
+        return this.faultResponse;
+    }
+
+    public MessageContext getMessageContext() {
+        return mc;
+    }
+
+    public void setMessageContext(MessageContext mc) {
+        this.mc = mc;
+        Boolean resp = (Boolean) mc.getProperty(Constants.ISRESPONSE_PROPERTY);
+        if (resp != null)
+            response = resp.booleanValue();
+    }
+
 }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java Tue May  9 21:27:13 2006
@@ -22,7 +22,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.SynapseMessageContext;
-import org.apache.synapse.SynapseMessage;
 
 /**
  * This message receiver should be configured in the Axis2 configuration as the
@@ -43,7 +42,6 @@
         // So it a mediator uses EnvironmentAware, that mediator will be injected with the correct environment
 
         ////////////////////////////////////////////////////////////////////////
-        SynapseMessage smc = new Axis2SynapseMessage(mc, synCtx);
         synCtx.getSynapseEnvironment().injectMessage(synCtx);
 
         ///////////////////////////////////////////////////////////////////////
@@ -51,11 +49,11 @@
         // smc.isResponse =true then the response will be handle with 200 OK
         // else, response will be 202 OK without no http body
         // smc.isFaultRespose = true then the response is a fault with 500 Internal Server Error
-        if (smc.isResponse()) {
+        if (synCtx.isResponse()) {
             mc.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
                 Constants.VALUE_TRUE);
         }
-        if (smc.isFaultResponse()) {
+        if (synCtx.isFaultResponse()) {
             // todo: a good way to inject faultSoapEnv to the Axis2 Transport 
             throw new AxisFault(
                 "Synapse Encounters an Error - Please See Log for More Details");

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/DropMediator.java Tue May  9 21:27:13 2006
@@ -35,10 +35,10 @@
      */
     public boolean mediate(SynapseMessageContext synCtx) {
         log.debug(getType() + " mediate()");
-        if (synCtx.getSynapseMessage().getTo() == null) {
+        if (synCtx.getTo() == null) {
             return false;
         } else {
-            synCtx.getSynapseMessage().setTo(null);
+            synCtx.setTo(null);
             return false;
         }
     }

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=405630&r1=405629&r2=405630&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  9 21:27:13 2006
@@ -17,7 +17,6 @@
 package org.apache.synapse.mediators.builtin;
 
 import org.apache.axiom.soap.SOAPHeader;
-import org.apache.synapse.SynapseMessage;
 import org.apache.synapse.SynapseMessageContext;
 import org.apache.synapse.mediators.AbstractMediator;
 import org.apache.synapse.mediators.MediatorProperty;
@@ -82,28 +81,26 @@
     }
 
     private String getSimpleLogMessage(SynapseMessageContext synCtx) {
-        SynapseMessage synMsg = synCtx.getSynapseMessage();
         StringBuffer sb = new StringBuffer();
-        if (synMsg.getTo() != null)
-            sb.append("To: " + synMsg.getTo().getAddress());
-        if (synMsg.getFrom() != null)
-            sb.append(SEP + "From: " + synMsg.getFrom().getAddress());
-        if (synMsg.getWSAAction() != null)
-            sb.append(SEP + "WSAction: " + synMsg.getWSAAction());
-        if (synMsg.getSoapAction() != null)
-            sb.append(SEP + "SOAPAction: " + synMsg.getSoapAction());
-        if (synMsg.getReplyTo() != null)
-            sb.append(SEP + "ReplyTo: " + synMsg.getReplyTo().getAddress());
-        if (synMsg.getMessageID() != null)
-            sb.append(SEP + "MessageID: " + synMsg.getMessageID());
+        if (synCtx.getTo() != null)
+            sb.append("To: " + synCtx.getTo().getAddress());
+        if (synCtx.getFrom() != null)
+            sb.append(SEP + "From: " + synCtx.getFrom().getAddress());
+        if (synCtx.getWSAAction() != null)
+            sb.append(SEP + "WSAction: " + synCtx.getWSAAction());
+        if (synCtx.getSoapAction() != null)
+            sb.append(SEP + "SOAPAction: " + synCtx.getSoapAction());
+        if (synCtx.getReplyTo() != null)
+            sb.append(SEP + "ReplyTo: " + synCtx.getReplyTo().getAddress());
+        if (synCtx.getMessageID() != null)
+            sb.append(SEP + "MessageID: " + synCtx.getMessageID());
         setCustomProperties(sb, synCtx);
         return sb.toString();
     }
 
     private String getHeadersLogMessage(SynapseMessageContext synCtx) {
-        SynapseMessage synMsg = synCtx.getSynapseMessage();
         StringBuffer sb = new StringBuffer();
-        Iterator iter = synMsg.getEnvelope().getHeader().examineAllHeaderBlocks();
+        Iterator iter = synCtx.getEnvelope().getHeader().examineAllHeaderBlocks();
         while (iter.hasNext()) {
             SOAPHeader header = (SOAPHeader) iter.next();
             sb.append(SEP + header.getLocalName() + " : " + header.getText());
@@ -113,11 +110,10 @@
     }
 
     private String getFullLogMessage(SynapseMessageContext synCtx) {
-        SynapseMessage synMsg = synCtx.getSynapseMessage();
         StringBuffer sb = new StringBuffer();
         sb.append(getSimpleLogMessage(synCtx));
-        if (synMsg.getEnvelope() != null)
-            sb.append(SEP + "Envelope: " + synMsg.getEnvelope());
+        if (synCtx.getEnvelope() != null)
+            sb.append(SEP + "Envelope: " + synCtx.getEnvelope());
         setCustomProperties(sb, synCtx);
         return sb.toString();
     }

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=405630&r1=405629&r2=405630&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  9 21:27:13 2006
@@ -40,9 +40,9 @@
      */
     public boolean mediate(SynapseMessageContext synCtx) {
         log.debug(getType() + " mediate()");
-        log.debug("Sending To: " + (synCtx.getSynapseMessage().getTo() != null ?
-            synCtx.getSynapseMessage().getTo().getAddress() : "null"));
-        log.debug("Body : \n" + synCtx.getSynapseMessage().getEnvelope());
+        log.debug("Sending To: " + (synCtx.getTo() != null ?
+            synCtx.getTo().getAddress() : "null"));
+        log.debug("Body : \n" + synCtx.getEnvelope());
         synCtx.getSynapseEnvironment().send(synCtx);
         return false;
     }

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=405630&r1=405629&r2=405630&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  9 21:27:13 2006
@@ -18,7 +18,6 @@
 import org.apache.synapse.mediators.AbstractListMediator;
 import org.apache.synapse.SynapseMessageContext;
 import org.apache.synapse.SynapseException;
-import org.apache.synapse.SynapseMessage;
 import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMElement;
@@ -75,18 +74,18 @@
         this.source = source;
     }
 
-    private OMNode getValidateSource(SynapseMessage synMsg) {
+    private OMNode getValidateSource(SynapseMessageContext synCtx) {
 
         if (source == null) {
             try {
                 source = new AXIOMXPath("//SOAP-ENV:Body");
-                source.addNamespace("SOAP-ENV", synMsg.isSOAP11() ?
+                source.addNamespace("SOAP-ENV", synCtx.isSOAP11() ?
                     SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI : SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
             } catch (JaxenException e) {}
         }
 
         try {
-            Object o = source.evaluate(synMsg.getEnvelope());
+            Object o = source.evaluate(synCtx.getEnvelope());
             if (o instanceof OMNode) {
                 return (OMNode) o;
             } else if (o instanceof List && !((List) o).isEmpty()) {
@@ -115,7 +114,7 @@
             XMLStreamWriter xsWriterForSource = XMLOutputFactory.newInstance().createXMLStreamWriter(baosForSource);
 
             // save the list of defined namespaces for validation against the schema
-            OMNode sourceNode = getValidateSource(synCtx.getSynapseMessage());
+            OMNode sourceNode = getValidateSource(synCtx);
             if (sourceNode instanceof OMElement) {
                 Iterator iter = ((OMElement) sourceNode).getAllDeclaredNamespaces();
                 while (iter.hasNext()) {

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java Tue May  9 21:27:13 2006
@@ -62,7 +62,7 @@
     public boolean test(SynapseMessageContext synCtx) {
         try {
             if (xpath != null) {
-                return xpath.booleanValueOf(synCtx.getSynapseMessage().getEnvelope());
+                return xpath.booleanValueOf(synCtx.getEnvelope());
 
             } else if (source != null && regex != null) {
                 return regex.matcher(Util.getStringValue(source, synCtx)).matches();

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java Tue May  9 21:27:13 2006
@@ -18,6 +18,7 @@
 
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.*;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.AxisFault;
@@ -25,109 +26,200 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.SynapseMessageContext;
-import org.apache.synapse.SynapseMessage;
 import org.apache.synapse.mediators.AbstractMediator;
 
 import javax.xml.namespace.QName;
+import java.net.URI;
 
 /**
- * This transforms the current message instance into a SOAP Fault message. If the
+ * This transforms the current message instance into a SOAP Fault message. The
+ * SOAP version for the fault message could be explicitly specified. Else if the
  * original message was SOAP 1.1 the fault will also be SOAP 1.1 else, SOAP 1.2
  *
- * TODO this class needs more attention! - revisit later
+ * This class exposes methods to set SOAP 1.1 and 1.2 fault elements and uses
+ * these as required.
  */
 public class FaultMediator extends AbstractMediator {
-    
+
     private static final Log log = LogFactory.getLog(FaultMediator.class);
 
+    /** Make a SOAP 1.1 fault */
     public static final int SOAP11 = 1;
+    /** Make a SOAP 1.2 fault */
     public static final int SOAP12 = 2;
-
+    /** Holds the SOAP version to be used to make the fault, if specified */
     private int soapVersion;
-    private QName code;
-    private String reason;
 
-    //TODO support SOAP 1.2 fault stuff..
-    //Node, Role, detail etc
+    //--------- SOAP 1.1 elements ---------------
+    /** SOAP 1.1 faultcode (Required) */
+    private QName faultcode = null;
+    /** SOAP 1.1 faultstring (Required) */
+    private String faultstring = null;
+    /** SOAP 1.1 faultactor */
+    private URI faultactor = null;
+    /** SOAP 1.1 detail (Kept as String) */
+    private String detail = null;
+
+    //--------- SOAP 1.2 elements ---------------
+    /**
+     * Hold the Code/Value of a SOAP 1.2 fault. (Required) Must be one of the following
+     * DataEncodingUnknown, MustUnderstand, Receiver, Sender, VersionMismatch
+     */
+    private QName codeValue = null;
+    /** Hold the Code/Subcode/Value of the SOAP 1.2 fault */
+    private QName codeSubcodeValue = null;
+    /** Holds the Reason of the SOAP 1.2 fault */
+    private String Reason = null;
+    /** The language attribute for the Reason text */
+    private String ReasonLang = null;
+    /** Hold the node for the SOAP 1.2 fault */
+    private URI Node = null;
+    /** Hold the role for the SOAP 1.2 fault */
+    private URI Role = null;
+    /** SOAP 1.2 detail (Kept as a String) */
+    private String Detail = null;
 
     public boolean mediate(SynapseMessageContext synCtx) {
         log.debug(getType() + " mediate()");
-        SynapseMessage synMsg = synCtx.getSynapseMessage();
-        SOAPEnvelope envelop = synMsg.getEnvelope();
-        SOAPFactory factory;
+        SOAPEnvelope envelop = synCtx.getEnvelope();
 
         switch (soapVersion) {
             case SOAP11:
-                factory = OMAbstractFactory.getSOAP11Factory();
-                break;
+                return makeSOAPFault(synCtx, SOAP11);
             case SOAP12:
-                factory = OMAbstractFactory.getSOAP12Factory();
-                break;
+                return makeSOAPFault(synCtx, SOAP12);
             default : {
                 if (envelop != null) {
-                    if (envelop.getNamespace().getName().equals(
-                        SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
-                        factory = OMAbstractFactory.getSOAP12Factory();
+                    if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelop.getNamespace().getName())) {
+                        return makeSOAPFault(synCtx, SOAP12);
                     } else {
-                        factory = OMAbstractFactory.getSOAP11Factory();
+                        return makeSOAPFault(synCtx, SOAP11);
                     }
                 } else {
-                    factory = OMAbstractFactory.getSOAP11Factory();
+                    return makeSOAPFault(synCtx, SOAP11);
                 }
             }
         }
+    }
+
+    private boolean makeSOAPFault(SynapseMessageContext synCtx, int soapVersion) {
+
+        // get the correct SOAP factory to be used
+        SOAPFactory factory = (
+            soapVersion == SOAP11 ? OMAbstractFactory.getSOAP11Factory() : OMAbstractFactory.getSOAP12Factory());
 
+        // create the SOAP fault document and envelope
         OMDocument soapFaultDocument = factory.createOMDocument();
         SOAPEnvelope faultEnvelope = factory.getDefaultFaultEnvelope();
         soapFaultDocument.addChild(faultEnvelope);
 
-        /*SOAPFaultReason reason = factory.createSOAPFaultReason();
-        reason.setText(getReason());
-
+        // create the fault element
         SOAPFault fault = factory.createSOAPFault();
-        fault.setReason(reason);
 
-        SOAPEnvelope faultEnvelope = factory.getDefaultFaultEnvelope();
-        faultEnvelope.getBody().addFault(fault);*/
+        // populate it
+        setFaultCode(factory, fault, soapVersion);
+        setFaultResaon(factory, fault, soapVersion);
+        setFaultNode(factory, fault, soapVersion);
+        setFaultRole(factory, fault, soapVersion);
+        setFaultDetail(factory, fault, soapVersion);
+
+        // set the fault element
+        faultEnvelope.getBody().setFirstChild(fault);
 
-        // set the fault message to the "faultTo" of the original message if it exists
-        // else to the "replyTo"
-        EndpointReference toEPR = synMsg.getTo();
-        EndpointReference faultToEPR = synMsg.getFaultTo();
+        // set the fault message "to" header to the "faultTo" of the original message if
+        // such a header existed on the original message, else set it to the "replyTo" of the original
+
+        EndpointReference toEPR = synCtx.getTo();
+        EndpointReference faultToEPR = synCtx.getFaultTo();
         if (faultToEPR != null) {
-            synMsg.setTo(faultToEPR);
-            synMsg.setReplyTo(toEPR);
+            synCtx.setTo(faultToEPR);
+            synCtx.setReplyTo(toEPR);
         } else {
-            EndpointReference replyToEPR = synMsg.getReplyTo();
-            synMsg.setTo(replyToEPR);
-            synMsg.setReplyTo(toEPR);
+            EndpointReference replyToEPR = synCtx.getReplyTo();
+            synCtx.setTo(replyToEPR);
+            synCtx.setReplyTo(toEPR);
         }
-        synMsg.setResponse(true);
+        synCtx.setResponse(true);
 
+        // overwrite current message envelope with new fault envelope
         try {
-            synMsg.setEnvelope(faultEnvelope);
+            synCtx.setEnvelope(faultEnvelope);
         } catch (AxisFault af) {
             String msg = "Error replacing SOAP envelope with a fault envelope " + af.getMessage();
             log.error(msg);
             throw new SynapseException(af);
         }
+
         return true;
     }
 
-    public QName getCode() {
-        return code;
+    private void setFaultCode(SOAPFactory factory, SOAPFault fault, int soapVersion) {
+        QName fault_code = (soapVersion == SOAP11 ? faultcode : codeValue);
+        if (fault_code != null) {
+            SOAPFaultCode code = factory.createSOAPFaultCode();
+            SOAPFaultValue value = factory.createSOAPFaultValue(code);
+            value.setText(fault_code);
+            fault.setCode(code);
+
+        } else {
+            handleException(soapVersion == SOAP11 ?
+                "faultcode is required for a SOAP 1.1 fault message" :
+                "Code/Value is required for a SOAP 1.2 fault message"
+            );
+        }
     }
 
-    public void setCode(QName code) {
-        this.code = code;
+    private void setFaultResaon(SOAPFactory factory, SOAPFault fault, int soapVersion) {
+        String reasonString = (soapVersion == SOAP11 ? faultstring : Reason);
+        if (faultstring != null) {
+            SOAPFaultReason reason = factory.createSOAPFaultReason();
+            SOAPFaultText text = factory.createSOAPFaultText();
+            text.setText(reasonString);
+            if (soapVersion == SOAP12 && ReasonLang != null) {
+                text.setLang(ReasonLang);
+            }
+            reason.addSOAPText(text);
+            fault.setReason(reason);
+
+        } else {
+            handleException(soapVersion == SOAP11 ?
+                "faultstring is required for a SOAP 1.1 fault message" :
+                "Reason is required for a SOAP 1.2 fault message"
+            );
+        }
     }
 
-    public String getReason() {
-        return reason;
+    private void setFaultNode(SOAPFactory factory, SOAPFault fault, int soapVersion) {
+        URI fActor = (soapVersion == SOAP11 ? faultactor : Node);
+        if (fActor != null) {
+            SOAPFaultNode faultNode = factory.createSOAPFaultNode();
+            faultNode.setNodeValue(fActor.toString());
+            fault.setNode(faultNode);
+        }
     }
 
-    public void setReason(String reason) {
-        this.reason = reason;
+    private void setFaultRole(SOAPFactory factory, SOAPFault fault, int soapVersion) {
+        if (soapVersion == SOAP12) {
+            if (Role != null) {
+                SOAPFaultRole faultRole = factory.createSOAPFaultRole();
+                faultRole.setRoleValue(Role.toString());
+                fault.setRole(faultRole);
+            }
+        }
+    }
+
+    private void setFaultDetail(SOAPFactory factory, SOAPFault fault, int soapVersion) {
+        String detailText = (soapVersion == SOAP11 ? detail : Detail);
+        if (detailText != null) {
+            SOAPFaultDetail faultDetail = factory.createSOAPFaultDetail();
+            faultDetail.setText(detailText);
+            fault.setDetail(faultDetail);
+        }
+    }
+
+    private void handleException(String msg) {
+        log.error(msg);
+        throw new SynapseException(msg);
     }
 
     public int getSoapVersion() {
@@ -138,5 +230,102 @@
         this.soapVersion = soapVersion;
     }
 
+    // -- SOAP 1.1 getters and setters --
+
+    public QName getFaultcode() {
+        return faultcode;
+    }
+
+    public void setFaultcode(QName faultcode) {
+        this.faultcode = faultcode;
+    }
+
+    public String getFaultstring() {
+        return faultstring;
+    }
+
+    public void setFaultstring(String faultstring) {
+        this.faultstring = faultstring;
+    }
+
+    public URI getFaultactor() {
+        return faultactor;
+    }
+
+    public void setFaultactor(URI faultactor) {
+        this.faultactor = faultactor;
+    }
+
+    public String getDetail() {
+        return detail;
+    }
+
+    public void setDetail(String detail) {
+        this.detail = detail;
+    }
+
+    // -- SOAP 1.2 getters and setters --
+
+    public QName getCodeValue() {
+        return codeValue;
+    }
+
+    public void setCodeValue(QName codeValue) {
+        if (
+            SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX.equals(codeValue.getNamespaceURI()) &&
+
+            (SOAP12Constants.FAULT_CODE_DATA_ENCODING_UNKNOWN.equals(codeValue.getLocalPart()) ||
+            SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND.equals(codeValue.getLocalPart()) ||
+            SOAP12Constants.FAULT_CODE_RECEIVER.equals(codeValue.getLocalPart()) ||
+            SOAP12Constants.FAULT_CODE_SENDER.equals(codeValue.getLocalPart()) ||
+            SOAP12Constants.FAULT_CODE_VERSION_MISMATCH.equals(codeValue.getLocalPart())) ){
 
+            this.codeValue = codeValue;
+
+        } else {
+            String msg = "Invalid Fault code value for a SOAP 1.2 fault : " + codeValue;
+            log.error(msg);
+            throw new SynapseException(msg);
+        }
+    }
+
+    public QName getCodeSubcodeValue() {
+        return codeSubcodeValue;
+    }
+
+    public void setCodeSubcodeValue(QName codeSubcodeValue) {
+        this.codeSubcodeValue = codeSubcodeValue;
+    }
+
+    public String getReason() {
+        return Reason;
+    }
+
+    public void setReason(String reason) {
+        this.Reason = reason;
+    }
+
+    public String getReasonLang() {
+        return ReasonLang;
+    }
+
+    public void setReasonLang(String reasonLang) {
+        this.ReasonLang = reasonLang;
+    }
+
+    public URI getNode() {
+        return Node;
+    }
+
+    public void setNode(URI node) {
+        Node = node;
+    }
+
+    public URI getRole() {
+        return Role;
+    }
+
+    public void setRole(URI role) {
+        Role = role;
+    }
 }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java Tue May  9 21:27:13 2006
@@ -39,11 +39,15 @@
     public static final int ACTION_SET = 0;
     public static final int ACTION_REMOVE = 1;
 
+    /** The name of the header @see HeaderType */
     private String name = null;
+    /** The literal value to be set as the header (if one was specified) */
     private String value = null;
+    /** Set the header (ACTION_SET) or remove it (ACTION_REMOVE). Defaults to ACTION_SET */
     private int action = ACTION_SET;
-
+    /** An expression which should be evaluated, and the result set as the header value */
     private AXIOMXPath expression = null;
+
     private HeaderType headerType = new HeaderType();
 
     /**
@@ -56,12 +60,13 @@
         log.debug(getType() + " mediate()");
 
         if (action == ACTION_SET) {
-            headerType.setHeader(synCtx.getSynapseMessage(),
+            headerType.setHeader(
+                synCtx,
                 (getValue() != null ? getValue() :
                     Util.getStringValue(getExpression(), synCtx)));
 
         } else {
-            headerType.removeHeader(synCtx.getSynapseMessage());
+            headerType.removeHeader(synCtx);
         }
         return true;
     }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java Tue May  9 21:27:13 2006
@@ -9,7 +9,6 @@
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.synapse.SynapseException;
-import org.apache.synapse.SynapseMessage;
 import org.apache.synapse.SynapseMessageContext;
 import org.apache.synapse.mediators.AbstractMediator;
 import org.apache.commons.logging.Log;
@@ -53,7 +52,7 @@
         log.debug(getType() + " mediate()");
 
         if (xsltUrl != null) {
-            performXLST(synCtx.getSynapseMessage());
+            performXLST(synCtx);
             return true;
 
         } else if (xQueryUrl != null) {
@@ -67,7 +66,7 @@
         }
     }
 
-    private void performXLST(SynapseMessage synMsg) {
+    private void performXLST(SynapseMessageContext synCtx) {
         try {
             // create a transformer
             Transformer transformer = TransformerFactory.newInstance().newTransformer(
@@ -77,7 +76,7 @@
             ByteArrayOutputStream baosForSource = new ByteArrayOutputStream();
             XMLStreamWriter xsWriterForSource = XMLOutputFactory.newInstance().createXMLStreamWriter(baosForSource);
 
-            OMNode sourceNode = getTransformSource(synMsg);
+            OMNode sourceNode = getTransformSource(synCtx);
             sourceNode.serialize(xsWriterForSource);
             Source transformSrc = new StreamSource(new ByteArrayInputStream(baosForSource.toByteArray()));
 
@@ -112,18 +111,18 @@
         }
     }
 
-    private OMNode getTransformSource(SynapseMessage synMsg) {
+    private OMNode getTransformSource(SynapseMessageContext synCtx) {
 
         if (source == null) {
             try {
                 source = new AXIOMXPath("//SOAP-ENV:Body");
-                source.addNamespace("SOAP-ENV", synMsg.isSOAP11() ?
+                source.addNamespace("SOAP-ENV", synCtx.isSOAP11() ?
                     SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI : SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
             } catch (JaxenException e) {}
         }
 
         try {
-            Object o = source.evaluate(synMsg.getEnvelope());;
+            Object o = source.evaluate(synCtx.getEnvelope());;
             if (o instanceof OMNode) {
                 return (OMNode) o;
             } else if (o instanceof List && !((List) o).isEmpty()) {

Modified: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessageContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessageContext.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessageContext.java (original)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessageContext.java Tue May  9 21:27:13 2006
@@ -17,6 +17,12 @@
 
 import org.apache.synapse.config.SynapseConfiguration;
 import org.apache.synapse.core.SynapseEnvironment;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.AxisFault;
 
 import java.util.Map;
 import java.util.HashMap;
@@ -25,10 +31,12 @@
 
     private Map properties = new HashMap();
 
-    private SynapseMessage synMsg = null;
-
     private SynapseConfiguration synCfg = null;
 
+    SOAPEnvelope envelope = null;
+
+    private EndpointReference to = null;
+
     public SynapseConfiguration getConfiguration() {
         return synCfg;
     }
@@ -44,17 +52,6 @@
     public void setSynapseEnvironment(SynapseEnvironment se) {
     }
 
-    public void setSynapseMessage(SynapseMessage sm) {
-        synMsg = sm;
-    }
-
-    public SynapseMessage getSynapseMessage() {
-        if (synMsg == null)
-            return new TestSynapseMessage();
-        else
-            return synMsg;
-    }
-
     public Object getProperty(String key) {
         Object ret = properties.get(key);
         if (ret != null) {
@@ -68,4 +65,120 @@
 
     public void setProperty(String key, Object value) {
         properties.put(key, value);
-    }}
+    }
+
+    //---------
+    public SOAPEnvelope getEnvelope() {
+        if (envelope == null)
+            return OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+        else
+            return envelope;
+    }
+
+    public void setEnvelope(SOAPEnvelope envelope) throws AxisFault {
+        this.envelope = envelope;
+    }
+
+    public EndpointReference getFaultTo() {
+        return null;
+    }
+
+    public void setFaultTo(EndpointReference reference) {
+    }
+
+    public EndpointReference getFrom() {
+        return null;
+    }
+
+    public void setFrom(EndpointReference reference) {
+    }
+
+    public String getMessageID() {
+        return null;
+    }
+
+    public void setMessageID(String string) {
+    }
+
+    public RelatesTo getRelatesTo() {
+        return null;
+    }
+
+    public void setRelatesTo(RelatesTo[] reference) {
+    }
+
+    public EndpointReference getReplyTo() {
+        return null;
+    }
+
+    public void setReplyTo(EndpointReference reference) {
+    }
+
+    public EndpointReference getTo() {
+        return to;
+    }
+
+    public void setTo(EndpointReference reference) {
+        to = reference;
+    }
+
+    public void setWSAAction(String actionURI) {
+    }
+
+    public String getWSAAction() {
+        return null;
+    }
+
+    public String getSoapAction() {
+        return null;
+    }
+
+    public void setSoapAction(String string) {
+    }
+
+    public void setMessageId(String messageID) {
+    }
+
+    public String getMessageId() {
+        return null;
+    }
+
+    public boolean isDoingMTOM() {
+        return false;
+    }
+
+    public void setDoingMTOM(boolean b) {
+    }
+
+    public boolean isDoingREST() {
+        return false;
+    }
+
+    public void setDoingREST(boolean b) {
+    }
+
+    public boolean isSOAP11() {
+        return envelope.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+    }
+
+    public void setResponse(boolean b) {
+    }
+
+    public boolean isResponse() {
+        return false;
+    }
+
+    public void setFaultResponse(boolean b) {
+    }
+
+    public boolean isFaultResponse() {
+        return false;
+    }
+
+    public SynapseMessageContext getSynapseContext() {
+        return null;
+    }
+
+    public void setSynapseContext(SynapseMessageContext env) {
+    }
+}

Modified: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestUtils.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestUtils.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestUtils.java (original)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestUtils.java Tue May  9 21:27:13 2006
@@ -16,7 +16,6 @@
 package org.apache.synapse.mediators;
 
 import org.apache.synapse.TestSynapseMessageContext;
-import org.apache.synapse.TestSynapseMessage;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMDocument;
@@ -32,7 +31,6 @@
 
         // create a test synapse context
         TestSynapseMessageContext synCtx = new TestSynapseMessageContext();
-        TestSynapseMessage synMsg = new TestSynapseMessage();
 
         SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
         OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument();
@@ -45,8 +43,7 @@
         // set a dummy static message
         envelope.getBody().addChild(builder.getDocumentElement());
 
-        synMsg.setEnvelope(envelope);
-        synCtx.setSynapseMessage(synMsg);
+        synCtx.setEnvelope(envelope);
         return synCtx;
     }
 }

Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java?rev=405630&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java Tue May  9 21:27:13 2006
@@ -0,0 +1,64 @@
+/*
+* 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.base;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import org.apache.synapse.mediators.TestMediator;
+import org.apache.synapse.mediators.TestMediateHandler;
+import org.apache.synapse.mediators.TestUtils;
+import org.apache.synapse.SynapseMessageContext;
+
+public class SequenceMediatorTest extends TestCase {
+
+    private StringBuffer result = new StringBuffer();
+
+    public void testSequenceMediator() throws Exception {
+
+        TestMediator t1 = new TestMediator();
+        t1.setHandler(
+            new TestMediateHandler() {
+                public void handle(SynapseMessageContext synCtx) {
+                    result.append("T1.");
+                }
+            });
+        TestMediator t2 = new TestMediator();
+        t2.setHandler(
+            new TestMediateHandler() {
+                public void handle(SynapseMessageContext synCtx) {
+                    result.append("T2.");
+                }
+            });
+        TestMediator t3 = new TestMediator();
+        t3.setHandler(
+            new TestMediateHandler() {
+                public void handle(SynapseMessageContext synCtx) {
+                    result.append("T3");
+                }
+            });
+
+        SequenceMediator seq = new SequenceMediator();
+        seq.addChild(t1);
+        seq.addChild(t2);
+        seq.addChild(t3);
+
+        // invoke transformation, with static enveope
+        SynapseMessageContext synCtx = TestUtils.getTestContext("<empty/>");
+        seq.mediate(synCtx);
+
+        assertTrue("T1.T2.T3".equals(result.toString()));
+    }
+}

Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/DropMediatorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/DropMediatorTest.java?rev=405630&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/DropMediatorTest.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/DropMediatorTest.java Tue May  9 21:27:13 2006
@@ -0,0 +1,35 @@
+/*
+* 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.builtin;
+
+import junit.framework.TestCase;
+import org.apache.synapse.SynapseMessageContext;
+import org.apache.synapse.mediators.TestUtils;
+
+public class DropMediatorTest extends TestCase {
+
+    public void testDropMediator() throws Exception {
+
+        DropMediator drop = new DropMediator();
+
+        // invoke transformation, with static enveope
+        SynapseMessageContext synCtx = TestUtils.getTestContext("<empty/>");
+        boolean returnValue = drop.mediate(synCtx);
+
+        assertTrue(!returnValue);
+        assertTrue(synCtx.getTo() == null);
+    }
+}

Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/FaultMediatorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/FaultMediatorTest.java?rev=405630&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/FaultMediatorTest.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/FaultMediatorTest.java Tue May  9 21:27:13 2006
@@ -0,0 +1,58 @@
+/*
+* 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.transform;
+
+import junit.framework.TestCase;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.mediators.TestUtils;
+import org.apache.synapse.SynapseMessageContext;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFault;
+
+import java.net.URI;
+
+public class FaultMediatorTest extends TestCase {
+
+    private static final QName F_CODE = new QName("http://namespace", "somefaultcode");
+    private static final String F_STRING = "Some fault string";
+    private static final String F_ACTOR_URI = "http://factor";
+    private static final String F_DETAIL = "Some detail text";
+
+    public void testSOAP11Fault() throws Exception {
+
+        FaultMediator faultMediator = new FaultMediator();
+        faultMediator.setSoapVersion(FaultMediator.SOAP11);
+        faultMediator.setFaultcode(F_CODE);
+        faultMediator.setFaultstring(F_STRING);
+        faultMediator.setFaultactor(new URI(F_ACTOR_URI));
+        faultMediator.setDetail(F_DETAIL);
+
+        // invoke transformation, with static enveope
+        SynapseMessageContext synCtx = TestUtils.getTestContext("<empty/>");
+        faultMediator.mediate(synCtx);
+
+        SOAPEnvelope envelope = synCtx.getEnvelope();
+        SOAPFault fault = envelope.getBody().getFault();
+        assertTrue(F_CODE.equals(fault.getCode().getValue().getTextAsQName()));
+        assertTrue(F_STRING.equals(fault.getReason().getFirstSOAPText().getText()));
+        assertTrue(F_ACTOR_URI.equals(fault.getNode().getNodeValue()));
+        assertTrue(F_DETAIL.equals(fault.getDetail().getText()));
+
+        System.out.println(envelope);
+    }
+}

Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/HeaderMediatorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/HeaderMediatorTest.java?rev=405630&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/HeaderMediatorTest.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/HeaderMediatorTest.java Tue May  9 21:27:13 2006
@@ -0,0 +1,67 @@
+/*
+* 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.transform;
+
+import junit.framework.TestCase;
+import org.apache.synapse.SynapseMessageContext;
+import org.apache.synapse.HeaderType;
+import org.apache.synapse.mediators.TestUtils;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+
+public class HeaderMediatorTest extends TestCase {
+
+    private static final String TEST_HEADER = "http://server/path";
+
+    public void testSimpleHeaderSetAndRemove() throws Exception {
+
+        HeaderMediator headerMediator = new HeaderMediator();
+        headerMediator.setName(HeaderType.STR_TO);
+        headerMediator.setValue(TEST_HEADER);
+
+        // invoke transformation, with static enveope
+        SynapseMessageContext synCtx = TestUtils.getTestContext("<empty/>");
+        headerMediator.mediate(synCtx);
+
+        assertTrue(TEST_HEADER.equals(synCtx.getTo().getAddress()));
+
+        // set the header mediator as a remove-header
+        headerMediator.setAction(HeaderMediator.ACTION_REMOVE);
+        headerMediator.mediate(synCtx);
+
+        assertTrue(synCtx.getTo() == null);
+    }
+
+    public void testSimpleHeaderXPathSetAndRemove() throws Exception {
+
+        HeaderMediator headerMediator = new HeaderMediator();
+        headerMediator.setName(HeaderType.STR_TO);
+        headerMediator.setExpression(new AXIOMXPath("concat('http://','server','/path')"));
+
+        // invoke transformation, with static enveope
+        SynapseMessageContext synCtx = TestUtils.getTestContext("<empty/>");
+        headerMediator.mediate(synCtx);
+
+        assertTrue(TEST_HEADER.equals(synCtx.getTo().getAddress()));
+
+        // set the header mediator as a remove-header
+        headerMediator.setAction(HeaderMediator.ACTION_REMOVE);
+        headerMediator.mediate(synCtx);
+
+        assertTrue(synCtx.getTo() == null);
+    }
+
+
+}

Modified: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/TransformMediatorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/TransformMediatorTest.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/TransformMediatorTest.java (original)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/transform/TransformMediatorTest.java Tue May  9 21:27:13 2006
@@ -60,7 +60,7 @@
         transformMediator.mediate(synCtx);
 
         // validate result
-        OMContainer body = synCtx.getSynapseMessage().getEnvelope().getBody();
+        OMContainer body = synCtx.getEnvelope().getBody();
         if (body.getFirstOMChild() instanceof OMElement) {
 
             OMElement getQuoteElem = (OMElement) body.getFirstOMChild();
@@ -95,7 +95,7 @@
         transformMediator.mediate(synCtx);
 
         // validate result
-        OMContainer body = synCtx.getSynapseMessage().getEnvelope().getBody();
+        OMContainer body = synCtx.getEnvelope().getBody();
         if (body.getFirstOMChild() instanceof OMElement) {
 
             OMElement getQuoteElem = (OMElement) body.getFirstOMChild();
@@ -131,7 +131,7 @@
         transformMediator.mediate(synCtx);
 
         // validate result
-        OMContainer body = synCtx.getSynapseMessage().getEnvelope().getBody();
+        OMContainer body = synCtx.getEnvelope().getBody();
         if (body.getFirstOMChild() instanceof OMElement) {
 
             OMElement someOtherElem = (OMElement) body.getFirstOMChild();

Modified: incubator/synapse/trunk/java/modules/samples/src/sampleMediators/InjectRedirect.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/samples/src/sampleMediators/InjectRedirect.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/sampleMediators/InjectRedirect.java (original)
+++ incubator/synapse/trunk/java/modules/samples/src/sampleMediators/InjectRedirect.java Tue May  9 21:27:13 2006
@@ -30,7 +30,7 @@
 
         System.out.println("Redirect.mediate: " + uri);
 
-        mc.getSynapseMessage().setTo(new EndpointReference(uri));
+        mc.setTo(new EndpointReference(uri));
         return true;
     }
 }

Modified: incubator/synapse/trunk/java/modules/samples/src/sampleMediators/Logger.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/samples/src/sampleMediators/Logger.java?rev=405630&r1=405629&r2=405630&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/sampleMediators/Logger.java (original)
+++ incubator/synapse/trunk/java/modules/samples/src/sampleMediators/Logger.java Tue May  9 21:27:13 2006
@@ -16,7 +16,6 @@
 package sampleMediators;
 
 import org.apache.synapse.SynapseMessageContext;
-import org.apache.synapse.SynapseMessage;
 import org.apache.synapse.mediators.AbstractMediator;
 import org.apache.axiom.soap.SOAPEnvelope;
 
@@ -34,18 +33,17 @@
       * @see org.apache.synapse.mediator.Mediator#mediate(org.apache.axis2.context.MessageContext)
       */
     public boolean mediate(SynapseMessageContext mctx) {
-        SynapseMessage mc = mctx.getSynapseMessage();
         System.out.println("Logger.mediate:");
-        if (mc.getTo() != null && mc.getTo().getAddress() != null)
-            System.out.println("Logger.mediate to:" + mc.getTo().getAddress());
+        if (mctx.getTo() != null && mctx.getTo().getAddress() != null)
+            System.out.println("Logger.mediate to:" + mctx.getTo().getAddress());
         else
             System.out.println("Empty To");
-        if (mc.getReplyTo() != null && mc.getReplyTo().getAddress() != null)
+        if (mctx.getReplyTo() != null && mctx.getReplyTo().getAddress() != null)
             System.out.println("Logger.mediate ReplyTo:"
-                    + mc.getReplyTo().getAddress());
+                    + mctx.getReplyTo().getAddress());
         else
             System.out.println("Empty ReplyTo");
-        SOAPEnvelope env = mc.getEnvelope();
+        SOAPEnvelope env = mctx.getEnvelope();
         System.out.println(env.toString());
         System.out.println();
         return true;



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


Mime
View raw message