You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/08/13 22:30:09 UTC

svn commit: r232521 - in /webservices/axis/trunk/java/modules: core/src/org/apache/axis2/transport/http/ integration/src/org/apache/axis2/soap12testing/server/ integration/test/org/apache/axis2/integration/

Author: dims
Date: Sat Aug 13 13:30:05 2005
New Revision: 232521

URL: http://svn.apache.org/viewcvs?rev=232521&view=rev
Log:
server.SimpleHttpServer already has threads, don't do threads in our SimpleHTTPServer


Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
    webservices/axis/trunk/java/modules/integration/src/org/apache/axis2/soap12testing/server/SimpleServer.java
    webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java?rev=232521&r1=232520&r2=232521&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java Sat Aug 13 13:30:05 2005
@@ -38,7 +38,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 extends TransportListener implements Runnable {
+public class SimpleHTTPServer extends TransportListener {
     /**
      * Field log
      */
@@ -91,6 +91,18 @@
     }
 
     /**
+     * Checks if this HTTP server instance is running.
+     *
+     * @return  true/false
+     */
+    public boolean isRunning() {
+        if(embedded == null) {
+            return false;
+        }
+        return embedded.isRunning();
+    }
+
+    /**
      * stop the server if not already told to.
      *
      * @throws Throwable
@@ -101,30 +113,12 @@
     }
 
     /**
-     * Accept requests from a given TCP port and send them through the
-     * Axis engine for processing.
-     */
-    public void run() {
-        try {
-            embedded = new SimpleHttpServer(port);
-            embedded.setRequestHandler(new HTTPWorker(configurationContext));
-            embedded.run();
-        } catch (IOException e) {
-            log.error(e);
-            throw new RuntimeException(e);
-        }
-        log.info("Simple Axis Server Quit");
-    }
-
-    /**
      * Start this server as a NON-daemon.
      */
     public void start() throws AxisFault {
         try {
             embedded = new SimpleHttpServer(port);
             embedded.setRequestHandler(new HTTPWorker(configurationContext));
-            Thread newThread = new Thread(embedded);
-            newThread.start();
         } catch (IOException e) {
             log.error(e);
             throw new AxisFault(e);
@@ -169,15 +163,13 @@
                 + args[1]
                 + " using the repository "
                 + new File(args[0]).getAbsolutePath());
-        Thread thread = new Thread(receiver);
-        thread.setDaemon(true);
         try {
             System.out.println(
                     "[Axis2] Using the Repository " +
                     new File(args[0]).getAbsolutePath());
             System.out.println(
                     "[Axis2] Starting the SimpleHTTPServer on port " + args[1]);
-            thread.start();
+            receiver.start();
             System.out.println("[Axis2] SimpleHTTPServer started");
             System.in.read();
         } finally {

Modified: webservices/axis/trunk/java/modules/integration/src/org/apache/axis2/soap12testing/server/SimpleServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/src/org/apache/axis2/soap12testing/server/SimpleServer.java?rev=232521&r1=232520&r2=232521&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/integration/src/org/apache/axis2/soap12testing/server/SimpleServer.java (original)
+++ webservices/axis/trunk/java/modules/integration/src/org/apache/axis2/soap12testing/server/SimpleServer.java Sat Aug 13 13:30:05 2005
@@ -39,12 +39,10 @@
         try {
             File file = new File(MessageComparator.TEST_MAIN_DIR+ "target/Repository");
             if(!file.exists()){
-                throw new AxisFault(file.getAbsolutePath() + " File does not exisits");
+                throw new AxisFault(file.getAbsolutePath() + " File does not exist");
             }
-            SimpleHTTPServer reciver = new SimpleHTTPServer(file.getAbsolutePath(), port);
-            Thread thread = new Thread(reciver);
-            thread.setDaemon(true);
-            thread.start();
+            SimpleHTTPServer receiver = new SimpleHTTPServer(file.getAbsolutePath(), port);
+            receiver.start();
         } catch (Exception e) {
             log.info(e.getMessage());
 //            e.printStackTrace();

Modified: webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java?rev=232521&r1=232520&r2=232521&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java (original)
+++ webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java Sat Aug 13 13:30:05 2005
@@ -64,11 +64,9 @@
                     file.getAbsolutePath());
 
             receiver = new SimpleHTTPServer(er, Constants.TESTING_PORT);
-            Thread thread = new Thread(receiver);
-            thread.setDaemon(true);
 
             try {
-                thread.start();
+                receiver.start();
                 System.out.print(
                         "Server started on port " + Constants.TESTING_PORT +
                         ".....");
@@ -89,6 +87,12 @@
     public static synchronized void stop() {
         if (count == 1) {
             receiver.stop();
+            while(receiver.isRunning()){
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e1) {
+                }
+            }
             count = 0;
             System.out.print("Server stopped .....");
         } else {