axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hemap...@apache.org
Subject svn commit: r164000 - in /webservices/axis/trunk/java/modules: core/src/org/apache/axis/clientapi/ core/src/org/apache/axis/transport/http/ samples/test/org/apache/axis/engine/ samples/test/org/apache/axis/integration/
Date Thu, 21 Apr 2005 04:31:34 GMT
Author: hemapani
Date: Wed Apr 20 21:31:32 2005
New Revision: 164000

URL: http://svn.apache.org/viewcvs?rev=164000&view=rev
Log:
fix the org.apache.axis.engine.EchoRawXMLTest

Added:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/ListenerManager.java
Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLTest.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java?rev=164000&r1=163999&r2=164000&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java Wed Apr
20 21:31:32 2005
@@ -15,6 +15,7 @@
 import org.apache.axis.addressing.om.MessageInformationHeadersCollection;
 import org.apache.axis.context.EngineContext;
 import org.apache.axis.context.MessageContext;
+import org.apache.axis.context.ServiceContext;
 import org.apache.axis.description.AxisGlobal;
 import org.apache.axis.description.AxisService;
 import org.apache.axis.description.AxisTransportIn;
@@ -44,13 +45,14 @@
 
     private EngineContext engineContext;
 
-    private String Listenertransport;
+    private EndpointReference replyTo;
+    private String Listenertransport = Constants.TRANSPORT_HTTP;
 
-    private boolean useSeparateListener;
+    private boolean useSeparateListener = false;
+    private String callbackServiceName;
 
     private CallbackReceiver callbackReceiver;
-    
-    
+
     public Call() throws AxisFault {
         try {
             //find the deployment mechanism , create
@@ -82,8 +84,6 @@
             this.engineContext = new EngineContext(registry);
             messageInfoHeaders = new MessageInformationHeadersCollection();
             init();
-        } catch (AxisFault e) {
-            throw new AxisFault(e.getMessage(), e);
         } catch (ClassNotFoundException e) {
             throw new AxisFault(e.getMessage(), e);
         } catch (InstantiationException e) {
@@ -113,13 +113,12 @@
         }
     }
 
-
     public Call(EngineContext engineContext) {
         this.properties = new HashMap();
         this.engineContext = engineContext;
     }
 
-    public void sendReceiveAsync(SOAPEnvelope env, Callback callback) throws AxisFault {
+    public void sendReceiveAsync(SOAPEnvelope env, final Callback callback) throws AxisFault
{
         EngineConfiguration registry = engineContext.getEngineConfig();
         if (Constants.TRANSPORT_MAIL.equals(transport)) {
             throw new AxisFault("This invocation support only for bi-directional transport");
@@ -127,17 +126,53 @@
         try {
             MessageSender sender = new MessageSender(engineContext);
 
-            AxisTransportIn transportIn = registry.getTransportIn(new QName(transport));
-            AxisTransportOut transportOut = registry.getTransportOut(new QName(transport));
+            final AxisTransportIn transportIn = registry.getTransportIn(new QName(transport));
+            final AxisTransportOut transportOut = registry.getTransportOut(new QName(transport));
 
-            MessageContext msgctx =
+            final MessageContext msgctx =
                 new MessageContext(engineContext, null, null, transportIn, transportOut);
             msgctx.setEnvelope(env);
+
+            if (useSeparateListener) {
+                msgctx.getMessageInformationHeaders().setMessageId(String.valueOf(System.currentTimeMillis()));
+                callbackReceiver.addCallback(msgctx.getMessageID(), callback);
+            }
+
             msgctx.setMessageInformationHeaders(messageInfoHeaders);
 
             sender.send(msgctx);
-            
-            callbackReceiver.addCallback(msgctx.getMessageID(),callback);
+            if (useSeparateListener) {
+                
+                
+                //TODO start the server
+            } else {
+                Runnable newThread = new Runnable() {
+                    public void run() {
+                        try {
+                            MessageContext response =
+                                new MessageContext(
+                                    engineContext,
+                                    msgctx.getProperties(),
+                                    msgctx.getSessionContext(),
+                                    msgctx.getTransportIn(),
+                                    transportOut);
+                            response.setServerSide(false);
+
+                            TransportReceiver receiver = response.getTransportIn().getReciever();
+                            receiver.invoke(response);
+                            SOAPEnvelope resenvelope = response.getEnvelope();
+                            AsyncResult asyncResult = new AsyncResult();
+                            asyncResult.setResult(resenvelope);
+                            callback.onComplete(asyncResult);
+                        } catch (AxisFault e) {
+                            callback.reportError(e);
+                        }
+
+                    }
+                };
+                (new Thread(newThread)).start();
+            }
+
         } catch (OMException e) {
             throw AxisFault.makeFault(e);
         } catch (IOException e) {
@@ -218,9 +253,19 @@
     private void init() throws AxisFault {
         messageInfoHeaders = new MessageInformationHeadersCollection();
         AxisService callbackService = new AxisService();
-        callbackService.setName(new QName(CallbackReceiver.SERVIC_NAME));
+        callbackServiceName = CallbackReceiver.SERVIC_NAME + System.currentTimeMillis();
+        callbackService.setName(new QName(callbackServiceName));
         callbackReceiver = new CallbackReceiver();
         callbackService.setMessageReceiver(callbackReceiver);
+
+        ListenerManager.makeSureStarted();
+
+        ListenerManager.getEngineContext().addService(new ServiceContext(callbackService));
+
+    }
+
+    public void close() {
+        ListenerManager.stopAServer();
     }
 
     /**

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/ListenerManager.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/ListenerManager.java?rev=164000&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/ListenerManager.java
(added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/ListenerManager.java
Wed Apr 20 21:31:32 2005
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ *
+ *  Runtime state of the engine
+ */
+package org.apache.axis.clientapi;
+
+import java.net.ServerSocket;
+
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.context.EngineContext;
+import org.apache.axis.description.AxisGlobal;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.engine.EngineConfigurationImpl;
+import org.apache.axis.transport.http.SimpleHTTPServer;
+
+public class ListenerManager {
+    private static EngineContext engineContext;
+    private static boolean started = false;
+    private static int numberOfserver = 0;
+    private static SimpleHTTPServer simpleHttpServer;
+    private static ServerSocket scoket;
+
+    public static void makeSureStarted() throws AxisFault {
+        synchronized (ListenerManager.class) {
+            try {
+                if (started == false) {
+                    engineContext =
+                        new EngineContext(new EngineConfigurationImpl(new AxisGlobal()));
+                    scoket = new ServerSocket(6060);
+                    simpleHttpServer = new SimpleHTTPServer(engineContext, scoket);
+                    simpleHttpServer.start();
+                    started = true;
+                    numberOfserver++;
+                }
+            } catch (Exception e) {
+                throw new AxisFault(e.getMessage(), e);
+            }
+
+        }
+
+    }
+    /**
+     * @return
+     */
+    public static EngineContext getEngineContext() {
+        return engineContext;
+    }
+
+    public static void stopAServer() {
+        numberOfserver--;
+        if (numberOfserver == 0) {
+            simpleHttpServer.stop();
+        }
+    }
+    
+    public EndpointReference replyToEPR(String serviceName){
+        return new EndpointReference(AddressingConstants.WSA_REPLY_TO,"http://127.0.0.1:"+scoket.getLocalPort()+"/axis/services/"+serviceName);
+    }
+}

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java?rev=164000&r1=163999&r2=164000&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java
Wed Apr 20 21:31:32 2005
@@ -30,7 +30,6 @@
 import org.apache.axis.context.MessageContext;
 import org.apache.axis.description.AxisTransportOut;
 import org.apache.axis.engine.AxisFault;
-import org.apache.axis.engine.EngineConfiguration;
 import org.apache.axis.engine.EngineRegistryFactory;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -44,7 +43,7 @@
  * not use multiple instances of this class in the same JVM/classloader unless
  * you want bad things to happen at shutdown.
  */
-public class SimpleHTTPServer implements Runnable {
+public class SimpleHTTPServer implements Runnable{
     /**
      * Field log
      */
@@ -76,8 +75,9 @@
      *
      * @param reg
      */
-    public SimpleHTTPServer(EngineContext reg) {
+    public SimpleHTTPServer(EngineContext reg,ServerSocket serverSoc) {
         this.engineReg = reg;
+        this.serverSocket = serverSoc;
     }
 
     /**
@@ -86,8 +86,9 @@
      * @param dir
      * @throws AxisFault
      */
-    public SimpleHTTPServer(String dir) throws AxisFault {
+    public SimpleHTTPServer(String dir,ServerSocket serverSoc) throws AxisFault {
         try {
+            this.serverSocket = serverSoc;
             Class erClass = Class.forName(
                     "org.apache.axis.deployment.EngineRegistryFactoryImpl");
             EngineRegistryFactory erfac =
@@ -196,7 +197,8 @@
      * @throws Exception
      */
     public void start() throws Exception {
-        run();
+        Thread newThread = new Thread(this);
+        newThread.start();
     }
 
     /**
@@ -258,9 +260,10 @@
         if (args.length != 2) {
             System.out.println("SimpeHttpReciver repositoryLocation port");
         }
-        SimpleHTTPServer reciver = new SimpleHTTPServer(args[0]);
         ServerSocket serverSoc = null;
         serverSoc = new ServerSocket(Integer.parseInt(args[1]));
+        SimpleHTTPServer reciver = new SimpleHTTPServer(args[0],serverSoc);
+        
         reciver.setServerSocket(serverSoc);
         Thread thread = new Thread(reciver);
         thread.setDaemon(true);

Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLTest.java?rev=164000&r1=163999&r2=164000&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLTest.java
(original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLTest.java
Wed Apr 20 21:31:32 2005
@@ -115,7 +115,7 @@
         org.apache.axis.clientapi.Call call = new org.apache.axis.clientapi.Call();
         EndpointReference targetEPR = new EndpointReference(AddressingConstants.WSA_TO, "http://127.0.0.1:"
+ UtilServer.TESTING_PORT + "/axis/services/EchoXMLService");
         call.setTo(targetEPR);
-        call.setListenerTransport("http", true);
+        call.setListenerTransport("http", false);
 
         Callback callback = new Callback() {
             public void onComplete(AsyncResult result) {

Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java?rev=164000&r1=163999&r2=164000&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java
(original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java
Wed Apr 20 21:31:32 2005
@@ -57,11 +57,11 @@
                 throw new AxisFault("Thread interuptted", e1);
             }
 
-            reciver = new SimpleHTTPServer(er);
+            
 
             ServerSocket serverSoc = null;
             serverSoc = new ServerSocket(Constants.TESTING_PORT);
-            reciver.setServerSocket(serverSoc);
+            reciver = new SimpleHTTPServer(er,serverSoc);
             Thread thread = new Thread(reciver);
             thread.setDaemon(true);
 



Mime
View raw message