Class AbstractFtpSessionFactory<T extends org.apache.commons.net.ftp.FTPClient>

java.lang.Object
org.springframework.integration.ftp.session.AbstractFtpSessionFactory<T>
Type Parameters:
T - The FTPClient type
All Implemented Interfaces:
SessionFactory<org.apache.commons.net.ftp.FTPFile>
Direct Known Subclasses:
DefaultFtpSessionFactory, DefaultFtpsSessionFactory, FtpHttpProxySessionFactory

public abstract class AbstractFtpSessionFactory<T extends org.apache.commons.net.ftp.FTPClient> extends Object implements SessionFactory<org.apache.commons.net.ftp.FTPFile>
Base class for FTP SessionFactory implementations.
Since:
2.0
Author:
Iwein Fuld, Mark Fisher, Oleg Zhurakousky, Sharang Gupta
  • Field Details

    • logger

      protected final org.apache.commons.logging.Log logger
  • Constructor Details

    • AbstractFtpSessionFactory

      public AbstractFtpSessionFactory()
  • Method Details

    • setFileType

      public void setFileType(int fileType)
      File types defined by FTP constants:
      • FTP.ASCII_FILE_TYPE
      • FTP.EBCDIC_FILE_TYPE
      • FTP.BINARY_FILE_TYPE (DEFAULT)
      • FTP.LOCAL_FILE_TYPE
      .
      Parameters:
      fileType - The file type.
    • setControlEncoding

      public void setControlEncoding(String controlEncoding)
    • setConfig

      public void setConfig(org.apache.commons.net.ftp.FTPClientConfig config)
    • setBufferSize

      public void setBufferSize(int bufferSize)
    • setHost

      public void setHost(String host)
    • setPort

      public void setPort(int port)
    • setUsername

      public void setUsername(String user)
    • setPassword

      public void setPassword(String pass)
    • setClientMode

      public void setClientMode(int clientMode)
      ACTIVE_LOCAL_DATA_CONNECTION_MODE = 0
      A constant indicating the FTP session is expecting all transfers to occur between the client (local) and server and that the server should connect to the client's data port to initiate a data transfer. This is the default data connection mode when and FTPClient instance is created. PASSIVE_LOCAL_DATA_CONNECTION_MODE = 2
      A constant indicating the FTP session is expecting all transfers to occur between the client (local) and server and that the server is in passive mode, requiring the client to connect to the server's data port to initiate a transfer.
      Parameters:
      clientMode - The client mode.
    • setConnectTimeout

      public void setConnectTimeout(int connectTimeout)
      Set the connect timeout for the socket.
      Parameters:
      connectTimeout - the timeout
    • setDefaultTimeout

      public void setDefaultTimeout(int defaultTimeout)
      Set the (socket option) timeout on the command socket.
      Parameters:
      defaultTimeout - the timeout.
    • setDataTimeout

      public void setDataTimeout(int dataTimeout)
      Set the (socket option) timeout on the data connection.
      Parameters:
      dataTimeout - the timeout.
    • setProxy

      public void setProxy(Proxy proxy)
      Set the proxy to connect to the server through. The proxy is used for the control connection and for the data connections, therefore this setter also switches the clientMode to the FTPClient.PASSIVE_LOCAL_DATA_CONNECTION_MODE: the server cannot connect back to the client through a proxy. If the clientMode is changed afterwards to another mode, the getSession() fails. A Proxy.Type.SOCKS proxy is used as is. A Proxy.Type.HTTP proxy is used with the HTTP CONNECT tunneling of the JVM; the credentials for such a proxy, if any, have to be provided through a Authenticator. See the FtpHttpProxySessionFactory for an HTTP proxy with credentials.
      Parameters:
      proxy - the proxy.
      Since:
      7.2
      See Also:
      • SocketClient.setProxy(Proxy)
    • getSession

      public FtpSession getSession()
      Specified by:
      getSession in interface SessionFactory<T extends org.apache.commons.net.ftp.FTPClient>
    • createClientInstance

      protected abstract T createClientInstance()
    • postProcessClientAfterConnect

      protected void postProcessClientAfterConnect(T t) throws IOException
      Will handle additional initialization after client.connect() method was invoked, but before any action on the client has been taken.
      Parameters:
      t - The client.
      Throws:
      IOException - Any IOException
    • postProcessClientBeforeConnect

      protected void postProcessClientBeforeConnect(T client) throws IOException
      Will handle additional initialization before client.connect() method was invoked.
      Parameters:
      client - The client.
      Throws:
      IOException - Any IOException.