incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r511618 - /incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpServer.java
Date Sun, 25 Feb 2007 21:19:13 GMT
Author: ngn
Date: Sun Feb 25 13:19:13 2007
New Revision: 511618

URL: http://svn.apache.org/viewvc?view=rev&rev=511618
Log:
Fixed isStopped() so that it reports the correct status (FTPSERVER-68)
Fixed suspend() and resume() so that they suspend/resume the listeners (FTPSERVER-72)

Modified:
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpServer.java

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpServer.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpServer.java?view=diff&rev=511618&r1=511617&r2=511618
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpServer.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpServer.java Sun Feb 25
13:19:13 2007
@@ -34,14 +34,15 @@
 
     private static final Logger LOG = LoggerFactory.getLogger(FtpServer.class);
     
-    private Thread runner;
-
+    
     private FtpServerContext serverContext = new DefaultFtpServerContext();
 
     private boolean suspended;
 
+    private boolean started = false;
+
     /**
-     * Default constructor.
+     * Creates a server with the default configuration
      * @throws Exception 
      */
     public FtpServer() throws Exception {
@@ -63,6 +64,8 @@
         for (int i = 0; i<listeners.length; i++) {
             listeners[i].start(serverContext);
         }
+
+        started = true;
         
         System.out.println("Server ready :: Apache FTP Server");
         LOG.info("------- Apache FTP Server started ------");
@@ -87,19 +90,26 @@
             serverContext = null;
         }
 
+        started = false;
     }
 
     /**
      * Get the server status.
      */
     public boolean isStopped() {
-        return runner == null;
+        return !started;
     }
 
     /**
      * Suspend further requests
      */
     public void suspend() {
+        // stop all listeners
+        Listener[] listeners = serverContext.getListeners(); 
+        for (int i = 0; i<listeners.length; i++) {
+            listeners[i].suspend();
+        }
+        
         suspended = true;
     }
 
@@ -107,6 +117,11 @@
      * Resume the server handler
      */
     public void resume() {
+        Listener[] listeners = serverContext.getListeners(); 
+        for (int i = 0; i<listeners.length; i++) {
+            listeners[i].resume();
+        }
+        
         suspended = false;
     }
 



Mime
View raw message