camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r952103 - in /camel/trunk/components/camel-ftp/src: main/java/org/apache/camel/component/file/remote/ test/java/org/apache/camel/component/file/remote/
Date Mon, 07 Jun 2010 05:14:21 GMT
Author: davsclaus
Date: Mon Jun  7 05:14:20 2010
New Revision: 952103

URL: http://svn.apache.org/viewvc?rev=952103&view=rev
Log:
CAMEL-2774: Setting ftpClient.soTimeout now supported.

Added:
    camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeoutTest.java
      - copied, changed from r952085, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java
Modified:
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java?rev=952103&r1=952102&r2=952103&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
Mon Jun  7 05:14:20 2010
@@ -36,6 +36,7 @@ public class FtpEndpoint<T extends FTPFi
     protected FTPClientConfig ftpClientConfig;
     protected Map<String, Object> ftpClientParameters;
     protected Map<String, Object> ftpClientConfigParameters;
+    protected int soTimeout;
 
     public FtpEndpoint() {
     }
@@ -76,6 +77,11 @@ public class FtpEndpoint<T extends FTPFi
         }
 
         if (ftpClientParameters != null) {
+            // setting soTimeout has to be done later on FTPClient (after it has connected)
+            Object timeout = ftpClientParameters.remove("soTimeout");
+            if (timeout != null) {
+                soTimeout = getCamelContext().getTypeConverter().convertTo(int.class, timeout);
+            }
             IntrospectionSupport.setProperties(client, ftpClientParameters);
         }
         
@@ -125,4 +131,15 @@ public class FtpEndpoint<T extends FTPFi
     void setFtpClientConfigParameters(Map<String, Object> ftpClientConfigParameters)
{
         this.ftpClientConfigParameters = ftpClientConfigParameters;
     }
+
+    public int getSoTimeout() {
+        return soTimeout;
+    }
+
+    /**
+     * Sets the soTimeout option to be used by FTPClient.
+     */
+    public void setSoTimeout(int soTimeout) {
+        this.soTimeout = soTimeout;
+    }
 }

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java?rev=952103&r1=952102&r2=952103&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
Mon Jun  7 05:14:20 2010
@@ -130,6 +130,19 @@ public class FtpOperations implements Re
             client.enterLocalPassiveMode();
         }
 
+        // must set soTimeout after connect
+        if (endpoint instanceof FtpEndpoint) {
+            FtpEndpoint ftpEndpoint = (FtpEndpoint) endpoint;
+            if (ftpEndpoint.getSoTimeout() > 0) {
+                log.trace("Using SoTimeout=" + ftpEndpoint.getSoTimeout());
+                try {
+                    client.setSoTimeout(ftpEndpoint.getSoTimeout());
+                } catch (IOException e) {
+                    throw new GenericFileOperationFailedException(client.getReplyCode(),
client.getReplyString(), e.getMessage(), e);
+                }
+            }
+        }
+
         try {
             boolean login;
             if (username != null) {

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java?rev=952103&r1=952102&r2=952103&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
Mon Jun  7 05:14:20 2010
@@ -121,6 +121,11 @@ public class FtpsEndpoint extends FtpEnd
         }
 
         if (ftpClientParameters != null) {
+            // setting soTimeout has to be done later on FTPClient (after it has connected)
+            Object timeout = ftpClientParameters.remove("soTimeout");
+            if (timeout != null) {
+                soTimeout = getCamelContext().getTypeConverter().convertTo(int.class, timeout);
+            }
             IntrospectionSupport.setProperties(client, ftpClientParameters);
         }
 

Copied: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeoutTest.java
(from r952085, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeoutTest.java?p2=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeoutTest.java&p1=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java&r1=952085&r2=952103&rev=952103&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java
(original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeoutTest.java
Mon Jun  7 05:14:20 2010
@@ -27,10 +27,10 @@ import org.junit.Test;
 /**
  * @version $Revision$
  */
-public class FromFtpClientDataTimeoutTest extends FtpServerTestSupport {
+public class FromFtpClientSoTimeoutTest extends FtpServerTestSupport {
 
     private String getFtpUrl() {
-        return "ftp://admin@localhost:" + getPort() + "/timeout/?password=admin&ftpClient.dataTimeout=5000";
+        return "ftp://admin@localhost:" + getPort() + "/timeout/?password=admin&ftpClient.soTimeout=5000";
     }
 
     @Override
@@ -39,12 +39,12 @@ public class FromFtpClientDataTimeoutTes
         super.setUp();
         prepareFtpServer();
     }
-    
+
     @Test
     public void testTimeout() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
-        
+
         mock.assertIsSatisfied();
     }
 



Mime
View raw message