Class FileTransferConnection
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisConnection,ComponentLifecycle,ComponentLifecycleExtension,StateManagedComponent
- Direct Known Subclasses:
FileTransferConnectionUsingPassword,StandardSftpConnection
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final TimeIntervalprotected static final intThe default size of the cache if a size isn't specified (16)Fields inherited from class com.adaptris.core.AdaptrisConnectionImp
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleanValidate the URL Protocol when a URL is used.booleanbooleanprotected voidClose the underlying connection.Connect to the host.protected abstract FileTransferClientcreate(String host, int port, FileTransferConnection.UserInfo ui) Create an instance of theFileTransferClientfor use with the producer or consumer.protected abstract FileTransferConnection.UserInfoabstract intvoidDisconnect the FTP client.protected longbooleanThe additional debug flag.Returns the default user name.getDirectoryRoot(String hostUrl) Returns the directory root for the passed host URL.Get the force relative path flag.Get the max number of entries in the cache.protected voidInitialise the underlying connection.intvoidGet additional logging output where available.voidSet whether or not connections created are held open for future use.voidsetCacheExpiration(TimeInterval expiration) voidOverride the default port.voidSet the user name.voidForce the path to be relative when using getDirectoryRoot(String).voidsetMaxClientCache(Integer maxSize) Set the max number of entries in the cache.voidSet whether the target server is a windows machine that returns backslash separated filenames when doing NLIST on a directory rather than the normal forward slashes.boolean<T extends FileTransferConnection>
TMethods inherited from class com.adaptris.core.NoOpConnection
prepareConnection, startConnection, stopConnectionMethods inherited from class com.adaptris.core.AdaptrisConnectionImp
addExceptionListener, addMessageConsumer, addMessageProducer, changeState, cloneForTesting, close, connectionErrorHandler, getConnectionErrorHandler, getUniqueId, getWorkersFirstOnShutdown, init, prepare, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveConnection, retrieveExceptionListeners, retrieveMessageConsumers, retrieveMessageProducers, setConnectionErrorHandler, setUniqueId, setWorkersFirstOnShutdown, start, stop, workersFirstOnShutdown
-
Field Details
-
DEFAULT_MAX_CACHE_SIZE
protected static final int DEFAULT_MAX_CACHE_SIZEThe default size of the cache if a size isn't specified (16) -
DEFAULT_EXPIRATION
-
-
Constructor Details
-
FileTransferConnection
public FileTransferConnection()
-
-
Method Details
-
setForceRelativePath
Force the path to be relative when using getDirectoryRoot(String).This is useful in the situation where the server in question does not have the user in a ftp jail
- Parameters:
b- true to prefix a.to the path.- See Also:
-
getForceRelativePath
Get the force relative path flag.- Returns:
- true or false.
- See Also:
-
forceRelativePath
public boolean forceRelativePath() -
getDefaultUserName
Returns the default user name.
- Returns:
- the default user name
-
setDefaultUserName
Set the user name.- Parameters:
s- the username.
-
getDefaultControlPort
- Returns:
- Returns the defaultControlPort.
-
defaultControlPort
public abstract int defaultControlPort() -
setDefaultControlPort
Override the default port.- Parameters:
i- The defaultControlPort to set.
-
setAdditionalDebug
Get additional logging output where available.- Parameters:
b- true to get additional logging.
-
getAdditionalDebug
The additional debug flag.- Returns:
- true or false (default false)
- See Also:
-
additionalDebug
public boolean additionalDebug() -
getWindowsWorkAround
- Returns:
- the windowsWorkAround
- See Also:
-
setWindowsWorkAround
Set whether the target server is a windows machine that returns backslash separated filenames when doing NLIST on a directory rather than the normal forward slashes.- Parameters:
b- the windowsWorkAround to set
-
windowsWorkaround
public boolean windowsWorkaround() -
getCacheConnection
- Returns:
- whether connection is held open after use
-
setCacheConnection
Set whether or not connections created are held open for future use.This feature is primarily intended to mitigate the connection cost when using FtpConsumer with a frequent poll interval.If multiple components end up using the same FileTransferClient instance from the cache (perhaps you have multiple FtpConsumer instances configured in the same channel) then you will likely end up with non-optimal performance due to thread synchronisation.
It is generally recommended that you configure the associated FtpConsumer and FtpProducer instances using the URL form of the destination if you intend to use the caching feature; this allows you to make sure that each component has its own unique FileTransferClient instance associated with it.
- Parameters:
b- true to enable, default false.- See Also:
-
cacheConnection
public boolean cacheConnection() -
initConnection
Description copied from class:AdaptrisConnectionImpInitialise the underlying connection.- Overrides:
initConnectionin classNoOpConnection- Throws:
CoreException- wrapping any exception.- See Also:
-
closeConnection
protected void closeConnection()Description copied from class:AdaptrisConnectionImpClose the underlying connection.- Overrides:
closeConnectionin classNoOpConnection- See Also:
-
connect
public FileTransferClient connect(String hostUrl) throws FileTransferException, IOException, PasswordException Connect to the host.- Parameters:
hostUrl- the host to connect to which can be in the form of an url or simply just the hostname in which case the default credentials and port numbers are used.- Returns:
- an FtpClient that is ready to use.
- Throws:
FileTransferExceptionIOExceptionPasswordException
-
getMaxClientCacheSize
Get the max number of entries in the cache.- Returns:
- the maximum number of entries.
-
setMaxClientCache
Set the max number of entries in the cache.Entries will be removed on a least recently accessed basis.
- Parameters:
maxSize- the maximum number of entries, default is 16- See Also:
-
maxClientCacheSize
public int maxClientCacheSize() -
getCacheExpiration
-
setCacheExpiration
-
withCacheExpiration
-
expirationMillis
protected long expirationMillis() -
acceptProtocol
Validate the URL Protocol when a URL is used.- Parameters:
s- the URL Protocol- Returns:
- true if the URL protocol is acceptable to the concrete imp.
-
create
protected abstract FileTransferClient create(String host, int port, FileTransferConnection.UserInfo ui) throws IOException, FileTransferException, PasswordException Create an instance of theFileTransferClientfor use with the producer or consumer.- Parameters:
host- the remote host.port- the port to connect toui- a local UserInfo containing username and password- Returns:
- a
FileTransferClientobject - Throws:
IOException- wrapping a general comms error.FileTransferException- if a protocol specific exception occurred.PasswordException
-
getDirectoryRoot
Returns the directory root for the passed host URL.
- Parameters:
hostUrl- the host URL- Returns:
- the directory root for the passed host URL
-
disconnect
Disconnect the FTP client.- Parameters:
ftp- the ftp client implementation
-
createUserInfo
- Throws:
FileTransferException
-