org.apache.commons.vfs.provider.ftp
Class FTPClientWrapper

java.lang.Object
  extended by org.apache.commons.vfs.provider.ftp.FTPClientWrapper
All Implemented Interfaces:
FtpClient

 class FTPClientWrapper
extends java.lang.Object
implements FtpClient

A wrapper to the FTPClient to allow automatic reconnect on connection loss.
I decided to not to use eg. noop() to determine the state of the connection to avoid unnecesary server round-trips.


Field Summary
private  FileSystemOptions fileSystemOptions
           
private  org.apache.commons.net.ftp.FTPClient ftpClient
           
private  GenericFileName root
           
 
Constructor Summary
FTPClientWrapper(GenericFileName root, FileSystemOptions fileSystemOptions)
           
 
Method Summary
 boolean abort()
           
 java.io.OutputStream appendFileStream(java.lang.String relPath)
           
 boolean completePendingCommand()
           
private  org.apache.commons.net.ftp.FTPClient createClient()
           
 boolean deleteFile(java.lang.String relPath)
           
 void disconnect()
           
 FileSystemOptions getFileSystemOptions()
           
private  org.apache.commons.net.ftp.FTPClient getFtpClient()
           
 java.lang.String getReplyString()
           
 GenericFileName getRoot()
           
 boolean isConnected()
           
 org.apache.commons.net.ftp.FTPFile[] listFiles(java.lang.String relPath)
           
 boolean makeDirectory(java.lang.String relPath)
           
 boolean removeDirectory(java.lang.String relPath)
           
 boolean rename(java.lang.String oldName, java.lang.String newName)
           
 java.io.InputStream retrieveFileStream(java.lang.String relPath)
           
 java.io.InputStream retrieveFileStream(java.lang.String relPath, long restartOffset)
           
 java.io.OutputStream storeFileStream(java.lang.String relPath)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

private final GenericFileName root

fileSystemOptions

private final FileSystemOptions fileSystemOptions

ftpClient

private org.apache.commons.net.ftp.FTPClient ftpClient
Constructor Detail

FTPClientWrapper

FTPClientWrapper(GenericFileName root,
                 FileSystemOptions fileSystemOptions)
           throws FileSystemException
Throws:
FileSystemException
Method Detail

getRoot

public GenericFileName getRoot()

getFileSystemOptions

public FileSystemOptions getFileSystemOptions()

createClient

private org.apache.commons.net.ftp.FTPClient createClient()
                                                   throws FileSystemException
Throws:
FileSystemException

getFtpClient

private org.apache.commons.net.ftp.FTPClient getFtpClient()
                                                   throws FileSystemException
Throws:
FileSystemException

isConnected

public boolean isConnected()
                    throws FileSystemException
Specified by:
isConnected in interface FtpClient
Throws:
FileSystemException

disconnect

public void disconnect()
                throws java.io.IOException
Specified by:
disconnect in interface FtpClient
Throws:
java.io.IOException

listFiles

public org.apache.commons.net.ftp.FTPFile[] listFiles(java.lang.String relPath)
                                               throws java.io.IOException
Specified by:
listFiles in interface FtpClient
Throws:
java.io.IOException

removeDirectory

public boolean removeDirectory(java.lang.String relPath)
                        throws java.io.IOException
Specified by:
removeDirectory in interface FtpClient
Throws:
java.io.IOException

deleteFile

public boolean deleteFile(java.lang.String relPath)
                   throws java.io.IOException
Specified by:
deleteFile in interface FtpClient
Throws:
java.io.IOException

rename

public boolean rename(java.lang.String oldName,
                      java.lang.String newName)
               throws java.io.IOException
Specified by:
rename in interface FtpClient
Throws:
java.io.IOException

makeDirectory

public boolean makeDirectory(java.lang.String relPath)
                      throws java.io.IOException
Specified by:
makeDirectory in interface FtpClient
Throws:
java.io.IOException

completePendingCommand

public boolean completePendingCommand()
                               throws java.io.IOException
Specified by:
completePendingCommand in interface FtpClient
Throws:
java.io.IOException

retrieveFileStream

public java.io.InputStream retrieveFileStream(java.lang.String relPath)
                                       throws java.io.IOException
Specified by:
retrieveFileStream in interface FtpClient
Throws:
java.io.IOException

retrieveFileStream

public java.io.InputStream retrieveFileStream(java.lang.String relPath,
                                              long restartOffset)
                                       throws java.io.IOException
Specified by:
retrieveFileStream in interface FtpClient
Throws:
java.io.IOException

appendFileStream

public java.io.OutputStream appendFileStream(java.lang.String relPath)
                                      throws java.io.IOException
Specified by:
appendFileStream in interface FtpClient
Throws:
java.io.IOException

storeFileStream

public java.io.OutputStream storeFileStream(java.lang.String relPath)
                                     throws java.io.IOException
Specified by:
storeFileStream in interface FtpClient
Throws:
java.io.IOException

abort

public boolean abort()
              throws java.io.IOException
Specified by:
abort in interface FtpClient
Throws:
java.io.IOException

getReplyString

public java.lang.String getReplyString()
                                throws java.io.IOException
Specified by:
getReplyString in interface FtpClient
Throws:
java.io.IOException