You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2011/02/22 12:13:05 UTC

svn commit: r1073298 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/ftp/FTPClient.java

Author: sebb
Date: Tue Feb 22 11:13:05 2011
New Revision: 1073298

URL: http://svn.apache.org/viewvc?rev=1073298&view=rev
Log:
NET-358 Implement copy Listener in FTPClient file operations

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java

Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1073298&r1=1073297&r2=1073298&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml (original)
+++ commons/proper/net/trunk/src/changes/changes.xml Tue Feb 22 11:13:05 2011
@@ -53,6 +53,9 @@ The <action> type attribute can be add,u
 
     <body>
         <release version="TBA" date="TBA" description="TBA"
+            <action issue="NET-358" dev="sebb" type="add">
+            Implement copy Listener in FTPClient file operations
+            </action>
             <action issue="NET-359" dev="sebb" type="fix">
             CopyStreamAdapter unconditionally resets the CopyStreamEvent source and is inefficient
             </action>

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=1073298&r1=1073297&r2=1073298&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java Tue Feb 22 11:13:05 2011
@@ -36,6 +36,7 @@ import org.apache.commons.net.ftp.parser
 import org.apache.commons.net.ftp.parser.ParserInitializationException;
 import org.apache.commons.net.io.CopyStreamEvent;
 import org.apache.commons.net.io.CopyStreamException;
+import org.apache.commons.net.io.CopyStreamListener;
 import org.apache.commons.net.io.FromNetASCIIInputStream;
 import org.apache.commons.net.io.ToNetASCIIOutputStream;
 import org.apache.commons.net.io.Util;
@@ -296,6 +297,9 @@ implements Configurable
 
     private FTPClientConfig __configuration;
 
+    // Listener used by store/retrieve methods
+    private CopyStreamListener __copyStreamListener;
+
     /** Pattern for PASV mode responses */
     private static final String __parms = "\\d{1,3},\\d{1,3},\\d{1,3},\\d{1,3},\\d{1,3},\\d{1,3}";
     private static final java.util.regex.Pattern __parms_pat;
@@ -434,7 +438,7 @@ implements Configurable
         try
         {
             Util.copyStream(local, output, getBufferSize(),
-                    CopyStreamEvent.UNKNOWN_STREAM_SIZE, null,
+                    CopyStreamEvent.UNKNOWN_STREAM_SIZE, __copyStreamListener,
                     false);
         }
         catch (IOException e)
@@ -1450,7 +1454,7 @@ implements Configurable
         try
         {
             Util.copyStream(input, local, getBufferSize(),
-                    CopyStreamEvent.UNKNOWN_STREAM_SIZE, null,
+                    CopyStreamEvent.UNKNOWN_STREAM_SIZE, __copyStreamListener,
                     false);
         }
         catch (IOException e)
@@ -2743,6 +2747,24 @@ implements Configurable
         this.__useEPSVwithIPv4 = selected;
     }
 
+    /**
+     * Set the listener to be used when performing store/retrieve operations.
+     * The default value (if not set) is {@code null}.
+     * 
+     * @param listener to be used, may be {@code null} to disable
+     */
+    public void setCopyStreamListener(CopyStreamListener listener){
+        __copyStreamListener = listener;
+    }
+    
+    /**
+     * Obtain the currently active listener.
+     * 
+     * @return the listener, may be {@code null}
+     */
+    public CopyStreamListener getCopyStreamListener(){
+        return __copyStreamListener;
+    }
 }
 
 /* Emacs configuration