Interface FTPClientFactory

All Known Implementing Classes:
FTPClientFactoryImpl

public interface FTPClientFactory
Factory and pool for FTPClient.

You must make sure that the client is either recycled with recycleClient(URL, FTPClient) or destroyed with destroyClient(URL, FTPClient) using a try-finally block.

Alternatively, one may abandon a client with abandonClient(URL, FTPClient) with the benefit of not having to wait for any pending reply by the FTP server.

Author:
poirigui
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    abandonClient(URL url, org.apache.commons.net.ftp.FTPClient client)
    Abandon an FTP client.
    void
    destroyClient(URL url, org.apache.commons.net.ftp.FTPClient client)
    Destroy an FTP client that is known to be no-longer valid.
    org.apache.commons.net.ftp.FTPClient
    Create an FTP client for the given URL.
    Open an input stream for the given FTP URL.
    void
    recycleClient(URL url, org.apache.commons.net.ftp.FTPClient client)
    Recycle the FTP client so that it might be reused in the future.
  • Method Details

    • getFtpClient

      org.apache.commons.net.ftp.FTPClient getFtpClient(URL url) throws IOException
      Create an FTP client for the given URL.

      Once you're done with the client, you should consider recycling it with recycleClient(URL, FTPClient). However, if you do so, make sure that all pending commands have completed with FTPClient.completePendingCommand().

      Throws:
      IOException
    • recycleClient

      void recycleClient(URL url, org.apache.commons.net.ftp.FTPClient client)
      Recycle the FTP client so that it might be reused in the future.
    • destroyClient

      void destroyClient(URL url, org.apache.commons.net.ftp.FTPClient client)
      Destroy an FTP client that is known to be no-longer valid.
    • abandonClient

      void abandonClient(URL url, org.apache.commons.net.ftp.FTPClient client)
      Abandon an FTP client.

      Unlike destroyClient(URL, FTPClient), no attempt will be made to gracefully logout.

    • openStream

      InputStream openStream(URL url) throws IOException
      Open an input stream for the given FTP URL.

      The FTP client will be recycled once the stream is closed.

      Throws:
      IOException