Author: rwinston
Date: Sun Aug 27 03:06:55 2006
New Revision: 437355

URL: http://svn.apache.org/viewvc?rev=437355&view=rev
Log:
NET-36 (experimental)

Modified:
    
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/examples/FTPSExample.java
    
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTP.java
    
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
    jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/xdocs/changes.xml

Modified: 
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/examples/FTPSExample.java
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/examples/FTPSExample.java?rev=437355&r1=437354&r2=437355&view=diff
==============================================================================
--- 
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/examples/FTPSExample.java
 (original)
+++ 
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/examples/FTPSExample.java
 Sun Aug 27 03:06:55 2006
@@ -77,8 +77,7 @@
         local = args[base];
 
         ftps = new FTPSClient();
-        // NOTE this is necessary for FTPSClient connections
-               ftps.setReaderThread(false);
+       
         ftps.addProtocolCommandListener(new PrintCommandListener(new 
PrintWriter(System.out)));
 
         try

Modified: 
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTP.java
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTP.java?rev=437355&r1=437354&r2=437355&view=diff
==============================================================================
--- 
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTP.java
 (original)
+++ 
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTP.java
 Sun Aug 27 03:06:55 2006
@@ -29,16 +29,12 @@
 import org.apache.commons.net.ProtocolCommandListener;
 import org.apache.commons.net.ProtocolCommandSupport;
 import org.apache.commons.net.SocketClient;
-import org.apache.commons.net.telnet.TelnetClient;
 
 /***
  * FTP provides the basic the functionality necessary to implement your
- * own FTP client.  It extends org.apache.commons.net.TelnetClient
- * simply because it saves the writing of extra code to handle the FTP
- * control connection which always remains open during an FTP session and
- * uses the Telnet protocol.  Aggregation would require writing new
- * wrapper methods and wouldn't leverage the functionality already
- * present in org.apache.commons.net.SocketClient.
+ * own FTP client.  It extends org.apache.commons.net.SocketClient since
+ * extending TelnetClient was causing unwanted behavior (like connections
+ * that did not time out properly).
  * <p>
  * To derive the full benefits of the FTP class requires some knowledge
  * of the FTP protocol defined in RFC 959.  However, there is no reason
@@ -88,12 +84,14 @@
  * <p>
  * <p>
  * @author Daniel F. Savarese
+ * @author Joseph Hindsley
  * @see FTPClient
  * @see FTPConnectionClosedException
  * @see org.apache.commons.net.MalformedServerReplyException
+ * @version $Id$
  ***/
 
-public class FTP extends TelnetClient
+public class FTP extends SocketClient
 {
     /*** The default FTP data port (20). ***/
     public static final int DEFAULT_DATA_PORT = 20;
@@ -220,13 +218,13 @@
     public static final String DEFAULT_CONTROL_ENCODING = "ISO-8859-1";
     private static final String __modes = "AEILNTCFRPSBC";
 
-    private StringBuffer __commandBuffer;
+    private StringBuilder __commandBuffer = new StringBuilder();
 
-    int _replyCode;
-    Vector _replyLines;
-    boolean _newReplyString;
-    String _replyString;
-    String _controlEncoding;
+    protected int _replyCode;
+    protected Vector<String> _replyLines;
+    protected boolean _newReplyString;
+    protected String _replyString;
+    protected String _controlEncoding;
 
     /**
      * Wraps SocketClient._input_ to facilitate the writing of text
@@ -259,9 +257,9 @@
      ***/
     public FTP()
     {
+        super();
         setDefaultPort(DEFAULT_PORT);
-        __commandBuffer = new StringBuffer();
-        _replyLines = new Vector();
+        _replyLines = new Vector<String>();
         _newReplyString = false;
         _replyString = null;
         _commandSupport_ = new ProtocolCommandSupport(this);
@@ -328,12 +326,13 @@
             // line.startsWith(code)));
         }
 
-        if (_commandSupport_.getListenerCount() > 0)
+        if (_commandSupport_.getListenerCount() > 0) {
             _commandSupport_.fireReplyReceived(_replyCode, getReplyString());
+        }
 
-        if (_replyCode == FTPReply.SERVICE_NOT_AVAILABLE)
-            throw new FTPConnectionClosedException(
-                "FTP response 421 received.  Server closed connection.");
+        if (_replyCode == FTPReply.SERVICE_NOT_AVAILABLE) {
+            throw new FTPConnectionClosedException("FTP response 421 received. 
 Server closed connection.");
+        }
     }
 
     /**
@@ -344,10 +343,10 @@
     {
         super._connectAction_();
         _controlInput_ =
-            new BufferedReader(new InputStreamReader(getInputStream(),
+            new BufferedReader(new InputStreamReader(_socket_.getInputStream(),
                                                      getControlEncoding()));
         _controlOutput_ =
-            new BufferedWriter(new OutputStreamWriter(getOutputStream(),
+            new BufferedWriter(new 
OutputStreamWriter(_socket_.getOutputStream(),
                                                       getControlEncoding()));
         __getReply();
         // If we received code 120, we have to fetch completion reply.
@@ -636,8 +635,9 @@
         Enumeration en;
         StringBuffer buffer;
 
-        if (!_newReplyString)
+        if (!_newReplyString) {
             return _replyString;
+        }
 
         buffer = new StringBuffer(256);
         en = _replyLines.elements();

Modified: 
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSClient.java?rev=437355&r1=437354&r2=437355&view=diff
==============================================================================
--- 
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
 (original)
+++ 
jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
 Sun Aug 27 03:06:55 2006
@@ -48,7 +48,6 @@
  * <p>
  * <code>
  *  FTPSClient client = new FTPSClient();
- *     client.setReaderThread(false);
  *     client.addProtocolCommandListener(new PrintCommandListener(new 
PrintWriter(System.out)));
  *     client.connect("127.0.0.1");
  *     client.login(username, password);

Modified: jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/xdocs/changes.xml?rev=437355&r1=437354&r2=437355&view=diff
==============================================================================
--- jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/xdocs/changes.xml 
(original)
+++ jakarta/commons/proper/net/branches/JDK_1_5_BRANCH/xdocs/changes.xml Sun 
Aug 27 03:06:55 2006
@@ -27,13 +27,15 @@
                                FTPS (TLS and SSL) is now supported. Thanks to 
Jose Juan Montiel, Paul Ferraro, and Satoshi Ishigami.
                        </action>
                        <action dev="rwinston" type="update">
-                               Commons::Net now uses Maven 2.
+                               Commons::Net now uses Maven 2. The project.xml 
has been replaced with a pom.xml, and the source tree layout
+                               has been changed accordingly.
                        </action>
                        <action dev="rwinston" type="remove">
                                Removed old ftp2 proposal directories.
                        </action>
                        <action dev="rwinston" type="update">
-                               Commons::Net now uses JDK regex functionality, 
saving on an extra [oro] dependency.
+                               Commons::Net now uses JDK regex functionality, 
saving on an extra [oro] dependency. There are now
+                               no external dependencies required.
                        </action>
                        <action dev="rwinston" type="fix">
                                Various syntactic issues (FindBugs issues, JDK 
5.0 generics support)
@@ -56,6 +58,10 @@
                                because it caused final packets to not
                                be sent.
                        </action>
+                       <action dev="rwinston" type="update">
+                               Applied patch from NET-36 which makes FTPClient 
extend SocketClient
+                               instead of TelnetClient.
+                       <action>
                </release>      
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to