You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2006/08/24 11:22:25 UTC

svn commit: r434353 [1/2] - in /incubator/synapse/trunk/java: ./ bin/ modules/core/ modules/core/conf/ modules/core/src/org/apache/synapse/ modules/core/src/org/apache/synapse/config/xml/ modules/core/src/org/apache/synapse/core/axis2/ modules/core/src...

Author: asankha
Date: Thu Aug 24 02:22:19 2006
New Revision: 434353

URL: http://svn.apache.org/viewvc?rev=434353&view=rev
Log:
Add a non blocking http transport implementation based on AsyncWeb/MINA
Fix Send mediator for RM

Added:
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/SynapseHTTPServer.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/AsyncCallback.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java
    incubator/synapse/trunk/java/modules/nhttp/
    incubator/synapse/trunk/java/modules/nhttp/maven.xml
    incubator/synapse/trunk/java/modules/nhttp/project.properties
    incubator/synapse/trunk/java/modules/nhttp/project.xml
    incubator/synapse/trunk/java/modules/nhttp/src/
    incubator/synapse/trunk/java/modules/nhttp/src/META-INF/
    incubator/synapse/trunk/java/modules/nhttp/src/META-INF/NOTICE.txt
    incubator/synapse/trunk/java/modules/nhttp/src/org/
    incubator/synapse/trunk/java/modules/nhttp/src/org/apache/
    incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/
    incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/
    incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/
    incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/AsyncHTTPListener.java
    incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/AsyncHTTPSender.java
    incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/Axis2AsyncWebProcessor.java
    incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpServiceHandler.java
Modified:
    incubator/synapse/trunk/java/bin/synapse.bat
    incubator/synapse/trunk/java/bin/synapse.sh
    incubator/synapse/trunk/java/maven.xml
    incubator/synapse/trunk/java/modules/core/conf/log4j.properties
    incubator/synapse/trunk/java/modules/core/project.xml
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/EndpointFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/AnonymousServiceFactory.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.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/Axis2Sender.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/DynamicAxisOperation.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
    incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
    incubator/synapse/trunk/java/modules/core/test-resources/axis2/conf/axis2.xml
    incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/n2n/SynapseCommodityServiceTest.java
    incubator/synapse/trunk/java/modules/samples/src/samples/userguide/ProxyStockQuoteClient.java
    incubator/synapse/trunk/java/project.properties
    incubator/synapse/trunk/java/project.xml
    incubator/synapse/trunk/java/repository/conf/axis2.xml

Modified: incubator/synapse/trunk/java/bin/synapse.bat
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/bin/synapse.bat?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/bin/synapse.bat (original)
+++ incubator/synapse/trunk/java/bin/synapse.bat Thu Aug 24 02:22:19 2006
@@ -96,7 +96,7 @@
 
 @echo on
 cd %SYNAPSE_HOME%
-"%_JAVACMD%" %_SYNAPSE_XML% -Daxis2.xml=%SYNAPSE_HOME%\synapse_repository\conf\axis2.xml -Djava.endorsed.dirs=%SYNAPSE_ENDORSED% -cp %SYNAPSE_CLASS_PATH% org.apache.axis2.transport.http.SimpleHTTPServer %SYNAPSE_CMD_LINE_ARGS%
+"%_JAVACMD%" %_SYNAPSE_XML% -Daxis2.xml=%SYNAPSE_HOME%\synapse_repository\conf\axis2.xml -Djava.endorsed.dirs=%SYNAPSE_ENDORSED% -cp %SYNAPSE_CLASS_PATH% org.apache.synapse.SynapseHTTPServer %SYNAPSE_CMD_LINE_ARGS%
 goto end
 
 :end

Modified: incubator/synapse/trunk/java/bin/synapse.sh
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/bin/synapse.sh?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/bin/synapse.sh (original)
+++ incubator/synapse/trunk/java/bin/synapse.sh Thu Aug 24 02:22:19 2006
@@ -99,4 +99,4 @@
 echo "Using JAVA_HOME:       $JAVA_HOME"
 echo "Using SYNAPSE_XML:     $SYNAPSE_XML"
 
-$JAVA_HOME/bin/java $SYNAPSE_XML -Daxis2.xml=$SYNAPSE_HOME/synapse_repository/conf/axis2.xml -Djava.endorsed.dirs=$SYNAPSE_ENDORSED -classpath $SYNAPSE_CLASSPATH org.apache.axis2.transport.http.SimpleHTTPServer $SYNAPSE_HOME/synapse_repository -p8080
+$JAVA_HOME/bin/java $SYNAPSE_XML -Daxis2.xml=$SYNAPSE_HOME/synapse_repository/conf/axis2.xml -Djava.endorsed.dirs=$SYNAPSE_ENDORSED -classpath $SYNAPSE_CLASSPATH org.apache.synapse.SynapseHTTPServer $SYNAPSE_HOME/synapse_repository -p8080

Modified: incubator/synapse/trunk/java/maven.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/maven.xml?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/maven.xml (original)
+++ incubator/synapse/trunk/java/maven.xml Thu Aug 24 02:22:19 2006
@@ -48,6 +48,7 @@
     <j:set var="src.dist.dir" value="target/dist-src/synapse-src"/>
     <j:set var="mediators.dist.dir" value="target/dist-mediators/synapse"/>
     <j:set var="extensions.dist.dir" value="target/dist-extensions/synapse"/>
+    <j:set var="nhttp.dist.dir" value="target/dist-nhttp/synapse"/>
 
     <tstamp>
         <format property="release_date" pattern="MMMM d, yyyy" locale="en"/>
@@ -346,7 +347,7 @@
         <ant:mkdir dir="${target/lib}/endorsed"/>
     </goal>
 
-    <goal name="release" prereqs="dist-src,dist-bin,dist-extensions"/>
+    <goal name="release" prereqs="dist-src,dist-bin,dist-extensions,dist-nhttp"/>
 
     <!-- ================================================================ -->
     <!--- Create the Distro -->
@@ -451,7 +452,7 @@
             	<ant:exclude name="**/synapse-${pom.currentVersion}.mar"/>
             </ant:fileset>
         </ant:copy>
-
+        
         <ant:copy todir="${bin.dist.dir}/samples" flatten="false">
             <ant:fileset dir="modules/samples/target/dist-bin/synapse/samples"/>
         </ant:copy>
@@ -768,6 +769,36 @@
 
         <ant:delete dir="target/temp"/>
         <ant:delete dir="target/dist-extensions"/>
+
+    </goal>
+
+    <!-- ================================================================ -->
+    <!--- Create the Async HTTP Distribution -->
+    <!-- ================================================================ -->
+
+    <goal name="dist-nhttp" >
+        <ant:echo>+----------------------------------------------</ant:echo>
+        <ant:echo>| Creating: Synapse nhttp Distribution</ant:echo>
+        <ant:echo>+----------------------------------------------</ant:echo>
+        <!-- todo fill up the  distribution-->
+        <ant:mkdir dir="target/temp/"/>
+
+        <ant:copy todir="${nhttp.dist.dir}/nhttp" flatten="false">
+            <ant:fileset dir="modules/nhttp/target/dist"/>
+        </ant:copy>
+
+        <ant:copy todir="target/temp/">
+            <ant:fileset dir="target/dist-nhttp/">
+                <include name="**"/>
+            </ant:fileset>
+        </ant:copy>
+
+
+        <ant:zip file="${dist.dir}/${dist.name}-nhttp-${pom.currentVersion}-bin.zip"
+                 basedir="target/temp"/>
+
+        <ant:delete dir="target/temp"/>
+        <ant:delete dir="target/dist-nhttp"/>
 
     </goal>
 </project>

Modified: incubator/synapse/trunk/java/modules/core/conf/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/conf/log4j.properties?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/conf/log4j.properties (original)
+++ incubator/synapse/trunk/java/modules/core/conf/log4j.properties Thu Aug 24 02:22:19 2006
@@ -3,6 +3,7 @@
 # Set the level to DEBUG if you want to log all SlideExceptions (some of them aren't errors)
 #log4j.category.org.apache.axis2=INFO
 log4j.category.org.apache.synapse=DEBUG
+log4j.category.org.apache.axis2.transport.nhttp=DEBUG
 
 
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender

Modified: incubator/synapse/trunk/java/modules/core/project.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/project.xml?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/project.xml (original)
+++ incubator/synapse/trunk/java/modules/core/project.xml Thu Aug 24 02:22:19 2006
@@ -22,6 +22,14 @@
         </dependency>
     </dependencies>
     
+    <dependencies>
+        <dependency>
+            <groupId>synapse</groupId>
+            <artifactId>synapse-nhttp</artifactId>
+            <version>${synapse.version}</version>
+        </dependency>        
+    </dependencies>
+    
     <build>
         <nagEmailAddress>synapse-dev@ws.apache.org</nagEmailAddress>
         <sourceDirectory>src</sourceDirectory>

Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/SynapseHTTPServer.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/SynapseHTTPServer.java?rev=434353&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/SynapseHTTPServer.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/SynapseHTTPServer.java Thu Aug 24 02:22:19 2006
@@ -0,0 +1,88 @@
+/*
+* 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;
+
+import org.apache.axis2.util.OptionsParser;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.description.TransportInDescription;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.util.Iterator;
+
+/**
+ * Starts all transports as specified on the axis2.xml
+ */
+public class SynapseHTTPServer {
+
+    public static void printUsage() {
+        System.out.println("Usage: SynapseHTTPServer [options] <repository>");
+        System.out.println(" Opts: -? this message");
+        System.out.println();
+        System.out.println("       -p port to listen on (default is 8080)");
+        System.exit(1);
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        int port = 8080;
+        OptionsParser optionsParser = new OptionsParser(args);
+        args = optionsParser.getRemainingArgs();
+
+        // first check if we should print usage
+        if ((optionsParser.isFlagSet('?') > 0) || (optionsParser.isFlagSet('h') > 0) ||
+                args == null || args.length == 0 || args.length > 2) {
+            printUsage();
+        }
+        String paramPort = optionsParser.isValueSet('p');
+        if (paramPort != null) {
+            port = Integer.parseInt(paramPort);
+        }
+        args = optionsParser.getRemainingArgs();
+
+        System.out.println("[SynapseHTTPServer] Starting on port " + port + "...");
+        System.out.println("[SynapseHTTPServer] Using the Axis2 Repository "
+                + new File(args[0]).getAbsolutePath());
+
+        try {
+            ConfigurationContext configctx = ConfigurationContextFactory.
+                createConfigurationContextFromFileSystem(args[0], null);
+
+            ListenerManager listenerManager = configctx.getListenerManager();
+            if (listenerManager == null) {
+                listenerManager = new ListenerManager();
+                listenerManager.init(configctx);
+            }
+
+            Iterator iter = configctx.getAxisConfiguration().
+                getTransportsIn().keySet().iterator();
+            while (iter.hasNext()) {
+                QName trp = (QName) iter.next();
+                TransportInDescription trsIn = (TransportInDescription)
+                    configctx.getAxisConfiguration().getTransportsIn().get(trp);
+                listenerManager.addListener(trsIn, false);
+            }
+            System.out.println("[SynapseHTTPServer] Started");
+
+        } catch (Throwable t) {
+            t.printStackTrace();
+            System.out.println("[SynapseHTTPServer] Startup failed...");
+        }
+    }
+
+}

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/EndpointFactory.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/EndpointFactory.java?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/EndpointFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/EndpointFactory.java Thu Aug 24 02:22:19 2006
@@ -83,17 +83,17 @@
             }
 
             OMElement wsAddr = elem.getFirstChildWithName(
-                new QName(Constants.NULL_NAMESPACE, "enableAddressing"));
+                new QName(Constants.SYNAPSE_NAMESPACE, "enableAddressing"));
             if (wsAddr != null) {
                 endpoint.setAddressingOn(true);
             }
             OMElement wsSec = elem.getFirstChildWithName(
-                new QName(Constants.NULL_NAMESPACE, "enableSec"));
+                new QName(Constants.SYNAPSE_NAMESPACE, "enableSec"));
             if (wsSec != null) {
                 endpoint.setSecurityOn(true);
             }
             OMElement wsRm = elem.getFirstChildWithName(
-                new QName(Constants.NULL_NAMESPACE, "enableRM"));
+                new QName(Constants.SYNAPSE_NAMESPACE, "enableRM"));
             if (wsRm != null) {
                 endpoint.setReliableMessagingOn(true);
             }
@@ -107,7 +107,7 @@
                 RampartSecurityBuilder.getSecurityParameter(elem, Constants.INFLOW_SECURITY));
 
             // if WS-RM is enabled, set it as requested
-            endpoint.setReliableMessagingOn(OutflowRMPolicyBuilder.isRMEnabled(elem));
+            //endpoint.setReliableMessagingOn(OutflowRMPolicyBuilder.isRMEnabled(elem));
             endpoint.setWsRMPolicy(OutflowRMPolicyBuilder.getRMPolicy(elem));
 
             return endpoint;

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/AnonymousServiceFactory.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/AnonymousServiceFactory.java?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/AnonymousServiceFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/AnonymousServiceFactory.java Thu Aug 24 02:22:19 2006
@@ -16,8 +16,8 @@
 package org.apache.synapse.core.axis2;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.util.CallbackReceiver;
 import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.OutInAxisOperation;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -34,29 +34,40 @@
 
     private static final Log log = LogFactory.getLog(AnonymousServiceFactory.class);
 
-    private static final String NO_ADDRESSING   = "__NO_ADDRESSING__";
-    private static final String ADDRESSING_ONLY = "__ADDRESSING_ONLY__";
-    private static final String RM_ONLY         = "__RM_ONLY__";
-    private static final String SEC_ONLY        = "__SEC_ONLY__";
-    private static final String RM_AND_SEC      = "__RM_AND_SEC__";
+    private static final String NONE            = "__NONE__";
+    private static final String ADDR_ONLY       = "__ADDR_ONLY__";
+    private static final String RM_AND_ADDR     = "__RM_AND_ADDR__";
+    private static final String SEC_AND_ADDR    = "__SEC_AND_ADDR__";
+    private static final String RM_SEC_AND_ADDR = "__RM_SEC_AND_ADDR__";
 
-    public static final String OPERATION_OUT_IN  = "__OPERATION_OUT_IN__";
+    public static final String DYNAMIC_OPERATION  = "__DYNAMIC_OPERATION__";
 
+    private static final SynapseCallbackReceiver synapseCallback = new SynapseCallbackReceiver();
+
+    /**
+     * Creates an AxisService for the requested QoS for sending out messages
+     * Callers must guarantee that if wsRMon or wsSecOn is required, that wsAddrOn is also set
+     * @param axisCfg Axis2 configuration
+     * @param wsAddrOn
+     * @param wsRMOn
+     * @param wsSecOn
+     * @return An Axis service for the requested QoS
+     */
     public static AxisService getAnonymousService(AxisConfiguration axisCfg,
         boolean wsAddrOn, boolean wsRMOn, boolean wsSecOn) {
 
         String servicekey = null;
         if (!wsAddrOn) {
-            servicekey = NO_ADDRESSING;
+            servicekey = NONE;
         } else {
             if (!wsSecOn && !wsRMOn) {
-                servicekey = ADDRESSING_ONLY;
+                servicekey = ADDR_ONLY;
             } else if (wsRMOn && !wsSecOn) {
-                servicekey = RM_ONLY;
+                servicekey = RM_AND_ADDR;
             } else if (wsSecOn && !wsRMOn) {
-                servicekey = SEC_ONLY;
+                servicekey = SEC_AND_ADDR;
             } else {
-                servicekey = RM_AND_SEC;
+                servicekey = RM_SEC_AND_ADDR;
             }
         }
 
@@ -95,11 +106,6 @@
         throw new SynapseException(msg, e);
     }
 
-    private static void handleException(String msg) {
-        log.error(msg);
-        throw new SynapseException(msg);
-    }
-
     /**
      * Create a new Anonymous Axis service for OUT-IN as default MEP
      * @param axisCfg the Axis2 configuration
@@ -109,13 +115,15 @@
         AxisConfiguration axisCfg, String serviceKey) {
 
         try {
-            OutInAxisOperation outInOperation =
-                new OutInAxisOperation(new QName(OPERATION_OUT_IN));
+            DynamicAxisOperation dynamicOperation =
+                new DynamicAxisOperation(new QName(DYNAMIC_OPERATION));
+            dynamicOperation.setMessageReceiver(synapseCallback);
             AxisService axisAnonymousService  = new AxisService(serviceKey);
-            axisAnonymousService.addOperation(outInOperation);
+            axisAnonymousService.addOperation(dynamicOperation);
             axisCfg.addService(axisAnonymousService);
-            axisCfg.getPhasesInfo().setOperationPhases(outInOperation);
+            axisCfg.getPhasesInfo().setOperationPhases(dynamicOperation);
             return axisAnonymousService;
+
         } catch (AxisFault e) {
             handleException(
                 "Error occured while creating an anonymous service for QoS : " +

Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/AsyncCallback.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/AsyncCallback.java?rev=434353&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/AsyncCallback.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/AsyncCallback.java Thu Aug 24 02:22:19 2006
@@ -0,0 +1,102 @@
+/*
+* 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.client.async.Callback;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.context.MessageContext;
+import org.apache.synapse.Constants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Iterator;
+
+public class AsyncCallback extends Callback {
+
+    private static final Log log = LogFactory.getLog(AsyncCallback.class);
+
+    org.apache.synapse.MessageContext synapseOutMsgCtx = null;
+
+    public AsyncCallback(org.apache.synapse.MessageContext synapseOutMsgCtx) {
+        this.synapseOutMsgCtx = synapseOutMsgCtx;
+    }
+
+    public void onComplete(AsyncResult result) {
+
+        log.debug("Synapse received an Async response to a callback");
+        MessageContext response = result.getResponseMessageContext();
+
+        MessageContext axisOutMsgCtx =
+            ((Axis2MessageContext)synapseOutMsgCtx).getAxis2MessageContext();
+
+        // set properties on response
+        response.setServerSide(true);
+        response.setProperty(Constants.ISRESPONSE_PROPERTY, Boolean.TRUE);
+        response.setProperty(MessageContext.TRANSPORT_OUT,
+            axisOutMsgCtx.getProperty(MessageContext.TRANSPORT_OUT));
+        response.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
+            axisOutMsgCtx.getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO));
+        response.setProperty(
+                org.apache.synapse.Constants.PROCESSED_MUST_UNDERSTAND,
+                axisOutMsgCtx.getProperty(
+                        org.apache.synapse.Constants.PROCESSED_MUST_UNDERSTAND));
+        response.setTransportIn(axisOutMsgCtx.getTransportIn());
+        response.setTransportOut(axisOutMsgCtx.getTransportOut());
+
+        // If request is REST assume that the response is REST too
+        response.setDoingREST(axisOutMsgCtx.isDoingREST());
+
+        // create the synapse message context for the response
+        Axis2MessageContext synapseInMessageContext =
+            new Axis2MessageContext(
+                response,
+                synapseOutMsgCtx.getConfiguration(),
+                synapseOutMsgCtx.getEnvironment());
+
+        synapseInMessageContext.setResponse(true);
+        synapseInMessageContext.setTo(null);
+
+        // now set properties to co-relate to the request i.e. copy over
+        // correlate/* messgae properties from original message to response received
+        Iterator iter = synapseOutMsgCtx.getPropertyKeySet().iterator();
+
+        while (iter.hasNext()) {
+            Object key = iter.next();
+
+            if (key instanceof String &&
+                ((String) key).startsWith(Constants.CORRELATE)) {
+
+                synapseInMessageContext.setProperty(
+                        (String) key,
+                        synapseOutMsgCtx.getProperty((String) key)
+                );
+            }
+        }
+
+        // send the response message through the synapse mediation flow
+        synapseOutMsgCtx.getEnvironment().
+            injectMessage(synapseInMessageContext);
+    }
+
+    public void onError(Exception e) {
+        // this will never be called as our custom SynapseCallbackReceiver will push
+        // faults as well through the onComplete()
+    }
+
+    public void setSynapseOutMshCtx(org.apache.synapse.MessageContext synapseOutMsgCtx) {
+        this.synapseOutMsgCtx = synapseOutMsgCtx;
+    }
+}

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java Thu Aug 24 02:22:19 2006
@@ -21,8 +21,10 @@
 import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.OperationClient;
 import org.apache.axis2.client.Options;
+import org.apache.axis2.client.async.Callback;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.ServiceContext;
@@ -60,7 +62,7 @@
      * @param outflowSecurityParameter
      * @param wsRMEnabled
      * @param wsRMPolicy
-     * @param axisMsgCtx
+     * @param synapseOutMessageContext
      * @return The Axis2 reponse message context
      */
     public static MessageContext send(
@@ -70,11 +72,20 @@
         Parameter inflowSecurityParameter,
         boolean wsRMEnabled,
         Policy wsRMPolicy,
-        MessageContext axisMsgCtx) throws AxisFault {
+        org.apache.synapse.MessageContext synapseOutMessageContext) throws AxisFault {
 
-        TransportOutDescription savedTransportOut = axisMsgCtx.getTransportOut();
+        MessageContext axisOutMsgCtx =
+            ((Axis2MessageContext) synapseOutMessageContext).getAxis2MessageContext();
 
-        ConfigurationContext axisCfgCtx = axisMsgCtx.getConfigurationContext();
+        Object addDisabled = axisOutMsgCtx.getProperty(
+            AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES);
+        if (wsAddressingEnabled && addDisabled != null && Boolean.TRUE.equals(addDisabled)) {
+            axisOutMsgCtx.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.FALSE);
+        }
+
+        TransportOutDescription savedTransportOut = axisOutMsgCtx.getTransportOut();
+
+        ConfigurationContext axisCfgCtx = axisOutMsgCtx.getConfigurationContext();
         AxisConfiguration axisCfg       = axisCfgCtx.getAxisConfiguration();
 
         AxisService anoymousService =
@@ -84,25 +95,33 @@
             axisCfgCtx, (AxisServiceGroup) anoymousService.getParent());
         ServiceContext serviceCtx = sgc.getServiceContext(anoymousService);
 
-        if (axisMsgCtx.getMessageID() != null) {
-            axisMsgCtx.setMessageID(String.valueOf("uuid:" + UUIDGenerator.getUUID()));
+        if (axisOutMsgCtx.getMessageID() != null) {
+            axisOutMsgCtx.setMessageID(String.valueOf("uuid:" + UUIDGenerator.getUUID()));
         }
 
-        axisMsgCtx.setConfigurationContext(serviceCtx.getConfigurationContext());
+        axisOutMsgCtx.setConfigurationContext(serviceCtx.getConfigurationContext());
+        axisOutMsgCtx.setServerSide(false); // this will become a client
 
         // set SOAP envelope on the message context, removing WS-A headers
-        axisMsgCtx.setEnvelope(removeAddressingHeaders(axisMsgCtx));
+        axisOutMsgCtx.setEnvelope(removeAddressingHeaders(axisOutMsgCtx));
 
-        // get a reference to the OUT-IN operation of the Anonymous Axis2 service
+        // get a reference to the DYNAMIC operation of the Anonymous Axis2 service
         AxisOperation axisAnonymousOperation = anoymousService.getOperation(
-            new QName(AnonymousServiceFactory.OPERATION_OUT_IN));
+            new QName(AnonymousServiceFactory.DYNAMIC_OPERATION));
 
         Options clientOptions = new Options();
+        clientOptions.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTP);
 
         // if RM is requested, and if a WS-RM policy is specified, use it
-        if (wsRMEnabled && wsRMPolicy != null) {
-            axisAnonymousOperation.getPolicyInclude().
-                addPolicyElement(PolicyInclude.OPERATION_POLICY, wsRMPolicy);
+        if (wsRMEnabled) {
+            if (wsRMPolicy != null) {
+                axisAnonymousOperation.getPolicyInclude().
+                    addPolicyElement(PolicyInclude.OPERATION_POLICY, wsRMPolicy);
+            }
+            clientOptions.setUseSeparateListener(true);
+
+            // always send each and every message in a new sequence and terminate sequence
+            clientOptions.setProperty("Sandesha2LastMessage", "true");
         }
 
         // if security is enabled,
@@ -124,30 +143,41 @@
 
         OperationClient mepClient = axisAnonymousOperation.createClient(
             serviceCtx, clientOptions);
-        mepClient.addMessageContext(axisMsgCtx);
-        mepClient.execute(true);
-
-        MessageContext response = mepClient.getMessageContext(
-            WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+        mepClient.addMessageContext(axisOutMsgCtx);
 
-        // set properties on response
-        response.setServerSide(true);
-        response.setProperty(Constants.ISRESPONSE_PROPERTY, Boolean.TRUE);
-        response.setProperty(MessageContext.TRANSPORT_OUT,
-            axisMsgCtx.getProperty(MessageContext.TRANSPORT_OUT));
-        response.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
-            axisMsgCtx.getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO));
-        response.setProperty(
-                org.apache.synapse.Constants.PROCESSED_MUST_UNDERSTAND,
-                axisMsgCtx.getProperty(
-                        org.apache.synapse.Constants.PROCESSED_MUST_UNDERSTAND));
-        response.setTransportIn(axisMsgCtx.getTransportIn());
-        response.setTransportOut(savedTransportOut);
+        if (clientOptions.isUseSeparateListener()) {
+            mepClient.setCallback(new AsyncCallback(synapseOutMessageContext));
+            axisOutMsgCtx.getOperationContext().setProperty(
+                org.apache.axis2.Constants.RESPONSE_WRITTEN, "SKIP");
+            mepClient.execute(false);
+            return null;
+
+        } else {
+
+            mepClient.execute(true);
+
+            MessageContext response = mepClient.getMessageContext(
+                WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+
+            // set properties on response
+            response.setServerSide(true);
+            response.setProperty(Constants.ISRESPONSE_PROPERTY, Boolean.TRUE);
+            response.setProperty(MessageContext.TRANSPORT_OUT,
+                axisOutMsgCtx.getProperty(MessageContext.TRANSPORT_OUT));
+            response.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
+                axisOutMsgCtx.getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO));
+            response.setProperty(
+                    org.apache.synapse.Constants.PROCESSED_MUST_UNDERSTAND,
+                    axisOutMsgCtx.getProperty(
+                            org.apache.synapse.Constants.PROCESSED_MUST_UNDERSTAND));
+            response.setTransportIn(axisOutMsgCtx.getTransportIn());
+            response.setTransportOut(savedTransportOut);
 
-        // If request is REST assume that the response is REST too
-        response.setDoingREST(axisMsgCtx.isDoingREST());
+            // If request is REST assume that the response is REST too
+            response.setDoingREST(axisOutMsgCtx.isDoingREST());
 
-        return response;
+            return response;
+        }
     }
 
     /**

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContext.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContext.java?rev=434353&r1=434352&r2=434353&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 Thu Aug 24 02:22:19 2006
@@ -222,6 +222,22 @@
             response = resp.booleanValue();
     }
 
+    public void setPaused(boolean value) {
+        axis2MessageContext.setPaused(value);
+    }
+
+    public boolean isPaused() {
+        return axis2MessageContext.isPaused();
+    }
+
+    public boolean isServerSide() {
+        return axis2MessageContext.isServerSide();
+    }
+
+    public void setServerSide(boolean value) {
+        axis2MessageContext.setServerSide(value);
+    }
+
     /**
      * Evaluates the given XPath expression against the SOAPEnvelope of the
      * current message and returns a String representation of the result

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2Sender.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2Sender.java?rev=434353&r1=434352&r2=434353&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 Thu Aug 24 02:22:19 2006
@@ -70,41 +70,43 @@
                         Constants.OUTFLOW_RM_POLICY),
 
                     // The Axis2 Message context of the Synapse MC
-                    ((Axis2MessageContext) synapseInMessageContext).
-                        getAxis2MessageContext());
+                    synapseInMessageContext);
 
-            //set the response Envelop as a property in Original axisMsgCtx
-            synapseInMessageContext.setProperty(org.apache.synapse.Constants.RESPONSE_SOAP_ENVELOPE,
-                                                axisOutMsgContext.getEnvelope());
-
-            // create the synapse message context for the response
-            org.apache.synapse.MessageContext synapseOutMessageContext =
-                new Axis2MessageContext(
-                    axisOutMsgContext,
-                    synapseInMessageContext.getConfiguration(),
-                    synapseInMessageContext.getEnvironment());
-            synapseOutMessageContext.setResponse(true);
-
-            // 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)
-                    );
+            if (axisOutMsgContext != null) {
+                //set the response Envelop as a property in Original axisMsgCtx
+                synapseInMessageContext.setProperty(
+                    org.apache.synapse.Constants.RESPONSE_SOAP_ENVELOPE,
+                    axisOutMsgContext.getEnvelope());
+
+                // create the synapse message context for the response
+                org.apache.synapse.MessageContext synapseOutMessageContext =
+                    new Axis2MessageContext(
+                        axisOutMsgContext,
+                        synapseInMessageContext.getConfiguration(),
+                        synapseInMessageContext.getEnvironment());
+                synapseOutMessageContext.setResponse(true);
+
+                // 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);
+                // send the response message through the synapse mediation flow
+                synapseInMessageContext.getEnvironment().
+                    injectMessage(synapseOutMessageContext);
+            }
 
         } catch (Exception e) {
             handleException("Unexpected error during Sending message onwards", e);

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/DynamicAxisOperation.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/DynamicAxisOperation.java?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/DynamicAxisOperation.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/DynamicAxisOperation.java Thu Aug 24 02:22:19 2006
@@ -18,10 +18,15 @@
 
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.util.UUIDGenerator;
+import org.apache.axis2.util.CallbackReceiver;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.OperationClient;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.client.async.AsyncResult;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
@@ -30,14 +35,21 @@
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.synapse.SynapseException;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFault;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.om.OMElement;
 
 import javax.xml.namespace.QName;
 import java.util.HashMap;
+import java.util.Map;
+import java.util.Iterator;
 
 /**
  * DynamicAxisOperation which switch dynamically between MEPs
  */
-public class DynamicAxisOperation extends InOutAxisOperation {
+public class DynamicAxisOperation extends OutInAxisOperation {
+
     public DynamicAxisOperation() {
         super();
     }
@@ -46,127 +58,373 @@
         super(name);
     }
 
-    public void addMessageContext(MessageContext msgContext,
-                                  OperationContext opContext) throws AxisFault {
-        HashMap mep = opContext.getMessageContexts();
-        MessageContext immsgContext = (MessageContext) mep
-            .get(MESSAGE_LABEL_IN_VALUE);
-        MessageContext outmsgContext = (MessageContext) mep
-            .get(MESSAGE_LABEL_OUT_VALUE);
-
-        if ((immsgContext != null) && (outmsgContext != null)) {
-            throw new AxisFault(
-                "Invalid message addition , operation context completed");
-        }
-
-        if (outmsgContext == null) {
-            mep.put(MESSAGE_LABEL_OUT_VALUE, msgContext);
-        } else {
-            mep.put(MESSAGE_LABEL_IN_VALUE, msgContext);
-            opContext.setComplete(true);
-        }
-    }
-
-
     public OperationClient createClient(ServiceContext sc, Options options) {
         return new DynamicOperationClient(this, sc, options);
     }
 
-}
+    class DynamicOperationClient implements OperationClient {
 
-class DynamicOperationClient implements OperationClient {
-    private DynamicAxisOperation axisOp;
-    private ServiceContext sc;
-    private OperationContext oc;
-    private Options options;
-
-    public DynamicOperationClient(DynamicAxisOperation axisOp, ServiceContext sc, Options options) {
-        this.options = options;
-        this.axisOp = axisOp;
-        this.sc = sc;
-        this.oc = new OperationContext(axisOp, sc);
-        this.oc.setParent(this.sc);
-    }
+        private AxisOperation axisOp;
+        protected ServiceContext sc;
+        protected Options options;
+        protected OperationContext oc;
+        protected Callback callback;
+
+        /*
+         * indicates whether the MEP execution has completed (and hence ready for
+         * resetting)
+         */
+        boolean completed;
+
+        DynamicOperationClient(OutInAxisOperation axisOp, ServiceContext sc,
+                                 Options options) {
+            this.axisOp = axisOp;
+            this.sc = sc;
+            this.options = options;
+            this.completed = false;
+            this.oc = new OperationContext(axisOp);
+            this.oc.setParent(this.sc);
+        }
 
-    public void setOptions(Options options) {
-        // Not supported
-    }
+        /**
+         * Sets the options that should be used for this particular client. This
+         * resets the entire set of options to use the new options - so you'd lose
+         * any option cascading that may have been set up.
+         *
+         * @param options the options
+         */
+        public void setOptions(Options options) {
+            this.options = options;
+        }
 
-    public Options getOptions() {
-        throw new SynapseException("Not Supported");
-    }
+        /**
+         * Returns the options used by this client. If you want to set a single
+         * option, then the right way is to call getOptions() and set specific
+         * options.
+         *
+         * @return Returns the options, which will never be null.
+         */
+        public Options getOptions() {
+            return options;
+        }
 
-    public void addMessageContext(MessageContext mc) throws AxisFault {
-        mc.setServiceContext(sc);
-        axisOp.registerOperationContext(mc, oc);
-    }
+        /**
+         * Adds message context to operation context , so that it will handle the
+         * logic correctly if the OperationContext is null then new one will be
+         * created , and Operation Context will become null when some one calls reset().
+         *
+         * @param mc
+         * @throws AxisFault
+         */
+        public void addMessageContext(MessageContext mc) throws AxisFault {
+            mc.setServiceContext(sc);
+            if (mc.getMessageID() == null) {
+                setMessageID(mc);
+            }
+            axisOp.registerOperationContext(mc, oc);
+        }
 
-    public MessageContext getMessageContext(String messageLabel) throws AxisFault {
-        return oc.getMessageContext(messageLabel);
-    }
+        /**
+         * Returns the message context for a given message label.
+         *
+         * @param messageLabel :
+         *                     label of the message and that can be either "Out" or "In" and
+         *                     nothing else
+         * @return Returns MessageContext.
+         * @throws AxisFault
+         */
+        public MessageContext getMessageContext(String messageLabel)
+                throws AxisFault {
+            return oc.getMessageContext(messageLabel);
+        }
 
-    public void setCallback(Callback callback) {
-        // Not supported
-    }
+        public void setCallback(Callback callback) {
+            this.callback = callback;
+        }
+
+        /**
+         * Create a message ID for the given message context if needed. If user gives an option with
+         * MessageID then just copy that into MessageContext , and with that there can be mutiple
+         * message with same MessageID unless user call setOption for each invocation.
+         * <p/>
+         * If user want to give message ID then the better way is to set the message ID in the option and
+         * call setOption for each invocation then the right thing will happen.
+         * <p/>
+         * If user does not give a message ID then the new one will be created and set that into Message
+         * Context.
+         *
+         * @param mc the message context whose id is to be set
+         */
+        private void setMessageID(MessageContext mc) {
+            // now its the time to put the parameters set by the user in to the
+            // correct places and to the
+            // if there is no message id still, set a new one.
+            String messageId = options.getMessageId();
+            if (messageId == null || "".equals(messageId)) {
+                messageId = UUIDGenerator.getUUID();
+            }
+            mc.setMessageID(messageId);
+        }
 
-    public void execute(boolean block) throws AxisFault {
-        if (block) {
+
+        /**
+         * Executes the MEP. What this does depends on the specific MEP client. The
+         * basic idea is to have the MEP client execute and do something with the
+         * messages that have been added to it so far. For example, if its an Out-In
+         * MEP, then if the Out message has been set, then executing the client asks
+         * it to send the message and get the In message, possibly using a different
+         * thread.
+         *
+         * @param block Indicates whether execution should block or return ASAP. What
+         *              block means is of course a function of the specific MEP
+         *              client. IGNORED BY THIS MEP CLIENT.
+         * @throws AxisFault if something goes wrong during the execution of the MEP.
+         */
+        public void execute(boolean block) throws AxisFault {
+            if (completed) {
+                throw new AxisFault(Messages.getMessage("mepiscomplted"));
+            }
             ConfigurationContext cc = sc.getConfigurationContext();
 
             // copy interesting info from options to message context.
             MessageContext mc = oc
-                .getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+                    .getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
             if (mc == null) {
-                throw new AxisFault(
-                    "Out message context is null ,"
-                        + " please set the out message context before calling this method");
+                throw new AxisFault(Messages.getMessage("outmsgctxnull"));
             }
 
-            EndpointReference toEPR = mc.getTo();
+            mc.setOptions(options);
 
-            TransportOutDescription transportOut = ClientUtils.inferOutTransport(cc
-                .getAxisConfiguration(), toEPR, mc);
+            // do Target Resolution
+            cc.getAxisConfiguration().getTargetResolverChain().resolveTarget(mc);
+
+            // if the transport to use for sending is not specified, try to find it
+            // from the URL
+            TransportOutDescription transportOut = options.getTransportOut();
+            if (transportOut == null) {
+                EndpointReference toEPR = (options.getTo() != null) ? options
+                        .getTo() : mc.getTo();
+                transportOut = ClientUtils.inferOutTransport(cc
+                        .getAxisConfiguration(), toEPR, mc);
+            }
             mc.setTransportOut(transportOut);
 
-            /*
-            Options need to Infer TransportInDescription
-            */
-            if (mc.getTransportIn() == null) {
-                TransportInDescription transportIn = options.getTransportIn();
-                if (transportIn == null) {
-                    mc.setTransportIn(ClientUtils.inferInTransport(cc
+
+            if (options.getTransportIn() == null && mc.getTransportIn() == null) {
+                mc.setTransportIn(ClientUtils.inferInTransport(cc
                         .getAxisConfiguration(), options, mc));
-                } else {
-                    mc.setTransportIn(transportIn);
-                }
+            } else if (mc.getTransportIn() == null) {
+                mc.setTransportIn(options.getTransportIn());
             }
 
             if (mc.getSoapAction() == null || "".equals(mc.getSoapAction())) {
-                Parameter soapaction = axisOp.getParameter(AxisOperation.SOAP_ACTION);
+                String soapaction = axisOp.getSoapAction();
                 if (soapaction != null) {
-                    mc.setSoapAction((String) soapaction.getValue());
+                    mc.setSoapAction(soapaction);
                 }
             }
+            addReferenceParameters(mc);
+            if (options.isUseSeparateListener()) {
+                SynapseCallbackReceiver callbackReceiver = (SynapseCallbackReceiver) axisOp.getMessageReceiver();
+                callbackReceiver.addCallback(mc.getMessageID(), callback);
+                EndpointReference replyToFromTransport = mc.getConfigurationContext().getListenerManager().
+                        getEPRforService(sc.getAxisService().getName(), axisOp.getName().getLocalPart(), mc
+                                .getTransportIn().getName()
+                                .getLocalPart());
 
-            oc.addMessageContext(mc);
-            // ship it out
-            AxisEngine engine = new AxisEngine(cc);
-            engine.send(mc);
+                if (mc.getReplyTo() == null) {
+                    mc.setReplyTo(replyToFromTransport);
+                } else {
+                    mc.getReplyTo().setAddress(replyToFromTransport.getAddress());
+                }
+                //if dont do this , this guy will wait till its gets HTTP 202 in the case
+                //HTTP
+                mc.setProperty(MessageContext.TRANSPORT_NON_BLOCKING, Boolean.TRUE);
+                AxisEngine engine = new AxisEngine(cc);
+                mc.getConfigurationContext().registerOperationContext(mc.getMessageID(), oc);
+                engine.send(mc);
+
+                // Options object reused so soapAction needs to be removed so
+                // that soapAction+wsa:Action on response don't conflict
+                options.setAction("");
+            } else {
+                if (block) {
+                    // Send the SOAP Message and receive a response
+                    MessageContext response = send(mc);
+                    // check for a fault and return the result
+                    if (response != null) {
+                        SOAPEnvelope resEnvelope = response.getEnvelope();
+                        if (resEnvelope.getBody().hasFault()) {
+                            SOAPFault soapFault = resEnvelope.getBody().getFault();
+
+                            //we need to call engine.receiveFault
+                            AxisEngine engine = new AxisEngine(mc.getConfigurationContext());
+                            engine.receiveFault(response);
+                            if (options.isExceptionToBeThrownOnSOAPFault()) {
+                                // does the SOAPFault has a detail element for Excpetion
+
+                                throw new AxisFault(soapFault.getCode(), soapFault.getReason(),
+                                        soapFault.getNode(), soapFault.getRole(), soapFault.getDetail());
+
+                            }
+                        }
+                    }
+                    completed = true;
+                } else {
+                    sc.getConfigurationContext().getThreadPool().execute(
+                            new NonBlockingInvocationWorker(callback, mc));
+                }
+            }
         }
 
-    }
+        private void addReferenceParameters(MessageContext msgctx) {
+            EndpointReference to = msgctx.getTo();
+            if (options.isManageSession()) {
+                EndpointReference tepr = sc.getTargetEPR();
+                if (tepr != null) {
+                    Map map = tepr.getAllReferenceParameters();
+                    if (map != null) {
+                        Iterator valuse = map.values().iterator();
+                        while (valuse.hasNext()) {
+                            Object refparaelement = valuse.next();
+                            if (refparaelement instanceof OMElement) {
+                                to.addReferenceParameter((OMElement) refparaelement);
+                            }
+                        }
+                    }
+                }
+            }
+        }
 
-    public OperationContext getOperationContext() {
-        return oc;
-    }
+        /**
+         * Sends the message using a two way transport and waits for a response
+         *
+         * @param msgctx
+         * @return Returns MessageContext.
+         * @throws AxisFault
+         */
+        protected MessageContext send(MessageContext msgctx) throws AxisFault {
+
+            AxisEngine engine = new AxisEngine(msgctx.getConfigurationContext());
+
+            // create the responseMessageContext
+            MessageContext responseMessageContext = new MessageContext();
+
+            // This is a hack - Needs to change
+            responseMessageContext.setOptions(options);
+
+
+            responseMessageContext.setServerSide(false);
+            responseMessageContext.setMessageID(msgctx.getMessageID());
+            addMessageContext(responseMessageContext);
+
+            //sending the message
+            engine.send(msgctx);
+            responseMessageContext.setDoingREST(msgctx.isDoingREST());
+
+            responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgctx
+                    .getProperty(MessageContext.TRANSPORT_IN));
+            responseMessageContext.setTransportIn(msgctx.getTransportIn());
+            responseMessageContext.setTransportOut(msgctx.getTransportOut());
+
+            // Options object reused above so soapAction needs to be removed so
+            // that soapAction+wsa:Action on response don't conflict
+            responseMessageContext.setSoapAction("");
+
+            if (responseMessageContext.getEnvelope() == null) {
+                // If request is REST we assume the responseMessageContext is REST, so
+                // set the variable
+
+                SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(
+                        responseMessageContext, msgctx.getEnvelope().getNamespace()
+                        .getNamespaceURI());
+                if (resenvelope != null) {
+                    responseMessageContext.setEnvelope(resenvelope);
+                    engine = new AxisEngine(msgctx.getConfigurationContext());
+                    engine.receive(responseMessageContext);
+                    if (responseMessageContext.getReplyTo() != null) {
+                        sc.setTargetEPR(responseMessageContext.getReplyTo());
+                    }
+                } else {
+                    throw new AxisFault(Messages
+                            .getMessage("blockingInvocationExpectsResponse"));
+                }
+            }
+            return responseMessageContext;
+        }
 
-    public void reset() throws AxisFault {
-        // Not supported
-    }
+        /**
+         * Resets the MEP client to a clean status after the MEP has completed. This
+         * is how you can reuse a MEP client. NOTE: this does not reset the options;
+         * only the internal state so the client can be used again.
+         *
+         * @throws AxisFault if reset is called before the MEP client has completed an
+         *                   interaction.
+         */
+        public void reset() throws AxisFault {
+            if (!completed) {
+                throw new AxisFault(Messages.getMessage("cannotreset"));
+            }
+            oc = null;
+            completed = false;
+        }
 
-    public void complete(MessageContext msgCtxt) throws AxisFault {
-        // Not supported
-    }
+        public void complete(MessageContext msgCtxt) throws AxisFault {
+            TransportOutDescription trsout = msgCtxt.getTransportOut();
+            if (trsout != null) {
+                trsout.getSender().cleanup(msgCtxt);
+            }
+        }
+
+        public OperationContext getOperationContext() {
+            return oc;
+        }
+
+        /**
+         * This class is the workhorse for a non-blocking invocation that uses a two
+         * way transport.
+         */
+        private class NonBlockingInvocationWorker implements Runnable {
+            private Callback callback;
+
+            private MessageContext msgctx;
+
+            public NonBlockingInvocationWorker(Callback callback,
+                                               MessageContext msgctx) {
+                this.callback = callback;
+                this.msgctx = msgctx;
+            }
 
+            public void run() {
+                try {
+                    // send the request and wait for reponse
+                    MessageContext response = send(msgctx);
+                    // call the callback
+                    if (response != null) {
+                        SOAPEnvelope resenvelope = response.getEnvelope();
+                        SOAPBody body = resenvelope.getBody();
+                        if (body.hasFault()) {
+                            Exception ex = body.getFault().getException();
+
+                            if (ex != null) {
+                                callback.onError(ex);
+                            } else {
+                                callback.onError(new Exception(body.getFault()
+                                        .getReason().getText()));
+                            }
+                        } else {
+                            AsyncResult asyncResult = new AsyncResult(response);
+
+                            callback.onComplete(asyncResult);
+                        }
+                    }
+
+                    callback.setComplete(true);
+                } catch (Exception e) {
+                    callback.onError(e);
+                }
+            }
+        }
+    }
 
 }

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java Thu Aug 24 02:22:19 2006
@@ -78,7 +78,7 @@
                         endpoint.getInflowSecurity(),
                         endpoint.isReliableMessagingOn(),
                         endpoint.getWsRMPolicy(),
-                        axisInMsgContext);
+                        synCtx);
 
                 axisOutMsgContext.setServerSide(true);
                 axisOutMsgContext.setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_OUT,

Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java?rev=434353&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java Thu Aug 24 02:22:19 2006
@@ -0,0 +1,52 @@
+/*
+* 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.MessageReceiver;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.AxisFault;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+
+public class SynapseCallbackReceiver implements MessageReceiver {
+
+    private Map callbackStore;  // this will be made thread safe
+
+    public SynapseCallbackReceiver() {
+        callbackStore = Collections.synchronizedMap(new HashMap());
+    }
+
+    public void addCallback(String MsgID, Callback callback) {
+        callbackStore.put(MsgID, callback);
+    }
+
+    public void receive(MessageContext messageCtx) throws AxisFault {
+
+        RelatesTo relatesTO = messageCtx.getOptions().getRelatesTo();
+        String messageID    = relatesTO.getValue();
+        Callback callback   = (Callback) callbackStore.get(messageID);
+
+        if (callback != null) {
+            callbackStore.remove(messageID);
+            callback.onComplete(new AsyncResult(messageCtx));
+        }
+    }
+}

Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java?rev=434353&r1=434352&r2=434353&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 Thu Aug 24 02:22:19 2006
@@ -91,6 +91,7 @@
 
             // if RM is turned on
             if (singleEndpoint.isReliableMessagingOn()) {
+                synCtx.setProperty(Constants.OUTFLOW_ADDRESSING_ON, Boolean.TRUE);
                 synCtx.setProperty(Constants.OUTFLOW_RM_ON, Boolean.TRUE);
                 if (singleEndpoint.getWsRMPolicy() != null) {
                     synCtx.setProperty(Constants.OUTFLOW_RM_POLICY,
@@ -100,6 +101,7 @@
 
             // if WS Security is specified
             if (singleEndpoint.isSecurityOn()) {
+                synCtx.setProperty(Constants.OUTFLOW_ADDRESSING_ON, Boolean.TRUE);
                 synCtx.setProperty(Constants.OUTFLOW_SECURITY_ON, Boolean.TRUE);
                 if (singleEndpoint.getOutflowSecurity() != null) {
                     synCtx.setProperty(Constants.OUTFLOW_SEC_PARAMETER,

Modified: incubator/synapse/trunk/java/modules/core/test-resources/axis2/conf/axis2.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/test-resources/axis2/conf/axis2.xml?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test-resources/axis2/conf/axis2.xml (original)
+++ incubator/synapse/trunk/java/modules/core/test-resources/axis2/conf/axis2.xml Thu Aug 24 02:22:19 2006
@@ -1,19 +1,34 @@
-<axisconfig name="AxisJava2.0_Provider_Endpint">
+<axisconfig name="AxisJava2.0">
     <!-- ================================================= -->
     <!-- Parameters -->
     <!-- ================================================= -->
     <parameter name="hotdeployment" locked="false">true</parameter>
     <parameter name="hotupdate" locked="false">false</parameter>
-    <parameter name="enableMTOM" locked="false">true</parameter>
+    <parameter name="enableMTOM" locked="false">false</parameter>
+
+    <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
+    <!--that behaviour.-->
     <parameter name="sendStacktraceDetailsWithFaults" locked="false">true</parameter>
 
-    <!-- Uncomment this to enable REST support -->
-    <!--    <parameter name="enableREST" locked="false">true</parameter>-->
+    <!--If there aren't any information available to find out the fault reason, we set the message of the expcetion-->
+    <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
+    <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
+    <!--is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
+    <parameter name="DrillDownToRootCauseForFaultReason" locked="false">false</parameter>
+
 
+    <parameter name="Sandesha2StorageManager" locked="false">inmemory</parameter>
 
+    <!--This is the user name and password of admin console-->
     <parameter name="userName" locked="false">admin</parameter>
     <parameter name="password" locked="false">axis2</parameter>
 
+    <!-- ==================================================== -->
+    <parameter name="Sandesha2StorageManager" locked="false">inmemory</parameter>
+    <module ref="synapse"/>
+
+    <!-- ==================================================== -->
+
     <!-- ================================================= -->
     <!-- Message Receivers -->
     <!-- ================================================= -->
@@ -30,13 +45,33 @@
     <!-- ================================================= -->
     <!-- Transport Ins -->
     <!-- ================================================= -->
-    <transportReceiver name="http"
+    <transportReceiver name="http" class="org.apache.axis2.transport.nhttp.AsyncHTTPListener"/>
+    <!--<transportReceiver name="http"
                        class="org.apache.axis2.transport.http.SimpleHTTPServer">
-        <parameter name="port" locked="false">6060</parameter>
-        <!--If you want to give your own host address for EPR generation-->
-        <!--uncommet following paramter , and set as you required.-->
-        <!--<parameter name="hostname" locked="false">http://myApp.com/ws</parameter>-->
-    </transportReceiver>
+        <parameter name="port" locked="false">6060</parameter>-->
+    <!-- Here is the complete list of supported parameters (see example settings further below):
+        port: the port to listen on (default 6060)
+        hostname:  if non-null, url prefix used in reply-to endpoint references                                 (default null)
+        originServer:  value of http Server header in outgoing messages                                         (default "Simple-Server/1.1")
+        requestTimeout:  value in millis of time that requests can wait for data                                (default 20000)
+        requestTcpNoDelay:  true to maximize performance and minimize latency                                   (default true)
+                            false to minimize bandwidth consumption by combining segments  
+        requestCoreThreadPoolSize:  number of threads available for request processing (unless queue fills up)  (default 25)
+        requestMaxThreadPoolSize:  number of threads available for request processing if queue fills us         (default 150)
+                                   note that default queue never fills up:  see HttpFactory
+        threadKeepAliveTime:  time to keep threads in excess of core size alive while inactive                  (default 180)
+                              note that no such threads can exist with default unbounded request queue
+        threadKeepAliveTimeUnit:  TimeUnit of value in threadKeepAliveTime (default SECONDS)                    (default SECONDS)
+    -->
+        <!-- <parameter name="hostname"                  locked="false">http://www.myApp.com/ws</parameter> -->
+        <!-- <parameter name="originServer"              locked="false">My-Server/1.1</parameter>           -->
+        <!-- <parameter name="requestTimeout"            locked="false">10000</parameter>                   -->
+        <!-- <parameter name="requestTcpNoDelay"         locked="false">false</parameter>                   -->
+        <!-- <parameter name="requestCoreThreadPoolSize" locked="false">50</parameter>                      -->
+        <!-- <parameter name="RequestMaxThreadPoolSize"  locked="false">100</parameter>                     -->
+        <!-- <parameter name="threadKeepAliveTime"       locked="false">240000</parameter>                  -->
+        <!-- <parameter name="threadKeepAliveTimeUnit"   locked="false">MILLISECONDS</parameter>            -->
+    <!--</transportReceiver>-->
 
     <transportReceiver name="tcp"
                        class="org.apache.axis2.transport.tcp.TCPServer">
@@ -45,6 +80,27 @@
         <!--uncommet following paramter , and set as you required.-->
         <!--<parameter name="hostname" locked="false">tcp://myApp.com/ws</parameter>-->
     </transportReceiver>
+    
+    <!--Uncomment this for JMS after setting up your JMS environment (e.g. ActiveMQ)
+    <transportReceiver name="jms" class="org.apache.axis2.transport.njms.JMSListener">
+        <parameter name="myTopicConnectionFactory" locked="false">        	        	
+        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>        	
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
+        </parameter>
+
+        <parameter name="myQueueConnectionFactory" locked="false">        	        	
+        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>        	
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
+        </parameter>
+
+        <parameter name="default" locked="false">        	        	
+        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>        	
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
+        </parameter>
+    </transportReceiver>-->
 
     <!-- ================================================= -->
     <!-- Transport Outs -->
@@ -55,11 +111,13 @@
     <transportSender name="local"
                      class="org.apache.axis2.transport.local.LocalTransportSender"/>
     <transportSender name="jms"
-                     class="org.apache.axis2.transport.jms.JMSSender"/>
+                     class="org.apache.axis2.transport.njms.JMSSender"/>
+    <!--<transportSender name="http"
+                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">-->
     <transportSender name="http"
-                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+                     class="org.apache.axis2.transport.nhttp.AsyncHTTPSender">
         <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
-        <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+        <!--<parameter name="Transfer-Encoding" locked="false">chunked</parameter>-->
     </transportSender>
     <transportSender name="https"
                      class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
@@ -75,11 +133,11 @@
          <phase name="Transport">
             <handler name="RequestURIBasedDispatcher"
                      class="org.apache.axis2.engine.RequestURIBasedDispatcher">
-                <order phase="Dispatch"/>
+                <order phase="Transport"/>
             </handler>
             <handler name="SOAPActionBasedDispatcher"
                      class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
-                <order phase="Dispatch"/>
+                <order phase="Transport"/>
             </handler>
         </phase>
         <phase name="Security"/>
@@ -100,13 +158,15 @@
             </handler>
         </phase>
         <!--  System pre defined phases       -->
-        <!--   After Postdispatch phase module author or or service author can add any phase he want      -->
+        <phase name="RMPhase"/>
         <phase name="MUPhase"/>
+        <!--   After Postdispatch phase module author or or service author can add any phase he want      -->
         <phase name="OperationInPhase"/>
     </phaseOrder>
     <phaseOrder type="outflow">
         <!--      user can add his own phases to this area  -->
         <phase name="MUPhase"/>
+        <phase name="RMPhase"/>
         <phase name="OperationOutPhase"/>
         <!--system predefined phase-->
         <!--these phase will run irrespective of the service-->
@@ -141,12 +201,14 @@
             </handler>
         </phase>
         <!--      user can add his own phases to this area  -->
+        <phase name="RMPhase"/>
         <phase name="MUPhase"/>
         <phase name="OperationInFaultPhase"/>
     </phaseOrder>
     <phaseOrder type="Outfaultflow">
         <!--      user can add his own phases to this area  -->
         <phase name="MUPhase"/>
+        <phase name="RMPhase"/>
         <phase name="OperationOutFaultPhase"/>
         <phase name="PolicyDetermination"/>
         <phase name="MessageOut"/>

Modified: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/n2n/SynapseCommodityServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/n2n/SynapseCommodityServiceTest.java?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/n2n/SynapseCommodityServiceTest.java (original)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/n2n/SynapseCommodityServiceTest.java Thu Aug 24 02:22:19 2006
@@ -27,7 +27,7 @@
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
-import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.axis2.transport.nhttp.AsyncHTTPListener;
 import org.apache.synapse.Constants;
 import org.apache.synapse.utils.Services;
 
@@ -36,24 +36,27 @@
 
 public class SynapseCommodityServiceTest extends TestCase {
 
-    private SimpleHTTPServer synapseServer = null;
-    private SimpleHTTPServer businessServer = null;
+    private AsyncHTTPListener synapseServer = null;
+    private AsyncHTTPListener businessServer = null;
 
     protected void setUp() throws java.lang.Exception {
         // Initializing Synapse repository
         System.setProperty(Constants.SYNAPSE_XML,
                            "target/testing_repository/conf/synapse.xml");
+        System.setProperty(org.apache.axis2.Constants.AXIS2_CONF,
+                           "target/testing_repository/conf/axis2.xml");
+
         ConfigurationContext synapseConfigCtx = ConfigurationContextFactory
                 .createConfigurationContextFromFileSystem(
                         "target/testing_repository",
                         "target/testing_repository/conf/axis2.xml");
 
-
         // Initializing Bussiness Endpoint
         ConfigurationContext businessConfigCtx = ConfigurationContextFactory
                 .createConfigurationContextFromFileSystem(
                         "target/testing_repository",
                         "target/testing_repository/conf/axis2.xml");
+
         AxisService businessService =
                 AxisService.createService(Services.class.getName(),
                                           businessConfigCtx.getAxisConfiguration(),
@@ -61,25 +64,23 @@
                                           "http://business.org", "http://business.org");
         businessConfigCtx.getAxisConfiguration().addService(businessService);
 
-        synapseServer = new SimpleHTTPServer(synapseConfigCtx, 10000);
-        businessServer = new SimpleHTTPServer(businessConfigCtx, 10001);
+        synapseServer = new AsyncHTTPListener(synapseConfigCtx, 10000);
+        businessServer = new AsyncHTTPListener(businessConfigCtx, 10001);
 
         //starting servers
         synapseServer.start();
         businessServer.start();
-
-
     }
 
     protected void tearDown() throws java.lang.Exception {
         businessServer.stop();
         synapseServer.stop();
-
     }
 
     public void testN2N() throws Exception {
         // Creating the Simple Commodity Client
-        ServiceClient businessClient = new ServiceClient();
+        System.getProperties().remove(org.apache.axis2.Constants.AXIS2_CONF);
+        ServiceClient businessClient = new ServiceClient(null, null);
         Options options = new Options();
         options.setTo(
                 new EndpointReference("http://127.0.0.1:10000/CommodityQuote"));

Added: incubator/synapse/trunk/java/modules/nhttp/maven.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/nhttp/maven.xml?rev=434353&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/nhttp/maven.xml (added)
+++ incubator/synapse/trunk/java/modules/nhttp/maven.xml Thu Aug 24 02:22:19 2006
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="jar"
+         xmlns:j="jelly:core"
+         xmlns:u="jelly:util"
+         xmlns:deploy="deploy"
+         xmlns:ant="jelly:ant"
+         xmlns:maven="jelly:maven"
+         xmlns:define="jelly:define">
+
+    <j:set var="dist.name" value="${pom.artifactId}-${pom.currentVersion}"/>
+    <!--<j:set var="dist.dir" value="target/dist"/>-->
+    <j:set var="nhttp.dir" value="target/nhttp"/>
+
+    <postGoal name="test:compile">
+        <mkdir dir="${nhttp.dir}"/>
+        <attainGoal name="nhttp"/>
+    </postGoal>
+
+    <goal name="nhttp">
+        <mkdir dir="${nhttp.dir}"/>
+        <mkdir dir="target/dist"/>
+        <mkdir dir="${nhttp.dir}/META-INF"/>
+        <ant:copy todir="${nhttp.dir}">
+            <ant:fileset dir="target/classes">
+                <ant:include name="**/**"/>
+            </ant:fileset>
+        </ant:copy>
+        <!--<ant:copy todir="${nhttp.dir}/META-INF">
+            <ant:fileset dir="src/META-INF">
+                <ant:include name="**/**"/>
+            </ant:fileset>
+            <ant:fileset file="../../LICENSE.txt"/>
+        </ant:copy>-->
+        
+        <ant:copy file="../../NOTICE-JAR.txt"
+                  tofile="src/META-INF/NOTICE.txt"/>
+
+        <manifest file="target/MANIFEST.MF">
+            <attribute name="Extension-Name" value="org.apache.synapse"/>
+            <attribute name="Specification-Title" value="${pom.artifactId}"/>
+            <attribute name="Specification-Vendor"
+                       value="Apache Software Foundation"/>
+            <attribute name="Specification-Version"
+                       value="${pom.currentVersion}"/>
+            <attribute name="Implementation-Title" value="Apache Synapse"/>
+            <attribute name="Implementation-Vendor-Id" value="org.apache"/>
+            <attribute name="Implementation-Vendor"
+                       value="Apache Software Foundation"/>
+            <attribute name="Implementation-Version"
+                       value="${pom.currentVersion}"/>
+        </manifest>
+
+        <jar jarfile="target/dist/nhttp.jar"
+             basedir="${nhttp.dir}" manifest="target/MANIFEST.MF">
+            <include name="**/**"/>
+        </jar>
+        <ant:delete dir="${nhttp.dir}"/>
+    </goal>
+</project>

Added: incubator/synapse/trunk/java/modules/nhttp/project.properties
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/nhttp/project.properties?rev=434353&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/nhttp/project.properties (added)
+++ incubator/synapse/trunk/java/modules/nhttp/project.properties Thu Aug 24 02:22:19 2006
@@ -0,0 +1,17 @@
+# -------------------------------------------------------------------
+# Copyright 2001-2004 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.
+# -------------------------------------------------------------------
+
+maven.multiproject.type=jar

Added: incubator/synapse/trunk/java/modules/nhttp/project.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/nhttp/project.xml?rev=434353&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/nhttp/project.xml (added)
+++ incubator/synapse/trunk/java/modules/nhttp/project.xml Thu Aug 24 02:22:19 2006
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+	
+    <pomVersion>3</pomVersion>
+    <extend>../../project.xml</extend>
+
+
+    <name>Apache Synapse - nhttp</name>
+    <id>synapse-nhttp</id>
+    <groupId>synapse</groupId>
+
+    <!-- ============ -->
+    <!-- Dependencies -->
+    <!-- ============ -->
+
+    <dependencies>
+    </dependencies>
+    
+    <build>
+        <nagEmailAddress>synapse-dev@ws.apache.org</nagEmailAddress>
+        <sourceDirectory>src</sourceDirectory>
+        <!--<unitTestSourceDirectory>test</unitTestSourceDirectory>
+        <unitTest>
+            <includes>
+                <include>**/*Test.java</include>
+            </includes>
+            <resources>
+                <resource>
+                    <directory>test-resources</directory>
+                </resource>
+            </resources>
+        </unitTest>
+
+        <resources>
+			<resource>
+				<directory>conf</directory>
+				<includes>
+					<include>**/*.properties</include>
+				</includes>
+			</resource>
+        </resources>-->
+    </build>
+</project>
+

Added: incubator/synapse/trunk/java/modules/nhttp/src/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/nhttp/src/META-INF/NOTICE.txt?rev=434353&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/nhttp/src/META-INF/NOTICE.txt (added)
+++ incubator/synapse/trunk/java/modules/nhttp/src/META-INF/NOTICE.txt Thu Aug 24 02:22:19 2006
@@ -0,0 +1,9 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Synapse distribution.                    ==
+   =========================================================================
+
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).



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