public abstract class FileTransferConnection extends NoOpConnection
Modifier and Type | Class and Description |
---|---|
class |
FileTransferConnection.UserInfo |
Modifier and Type | Field and Description |
---|---|
protected static TimeInterval |
DEFAULT_EXPIRATION |
protected static int |
DEFAULT_MAX_CACHE_SIZE
The default size of the cache if a size isn't specified (16)
|
log
Constructor and Description |
---|
FileTransferConnection() |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
acceptProtocol(java.lang.String s)
Validate the URL Protocol when a URL is used.
|
boolean |
additionalDebug() |
boolean |
cacheConnection() |
protected void |
closeConnection()
Close the underlying connection.
|
FileTransferClient |
connect(java.lang.String hostUrl)
Connect to the host.
|
protected abstract FileTransferClient |
create(java.lang.String host,
int port,
FileTransferConnection.UserInfo ui)
Create an instance of the
FileTransferClient for use with the producer or consumer. |
protected abstract FileTransferConnection.UserInfo |
createUserInfo() |
abstract int |
defaultControlPort() |
void |
disconnect(FileTransferClient ftp)
Disconnect the FTP client.
|
protected long |
expirationMillis() |
boolean |
forceRelativePath() |
java.lang.Boolean |
getAdditionalDebug()
The additional debug flag.
|
java.lang.Boolean |
getCacheConnection() |
TimeInterval |
getCacheExpiration() |
java.lang.Integer |
getDefaultControlPort() |
java.lang.String |
getDefaultUserName()
Returns the default user name.
|
java.lang.String |
getDirectoryRoot(java.lang.String hostUrl)
Returns the directory root for the passed host URL.
|
java.lang.Boolean |
getForceRelativePath()
Get the force relative path flag.
|
java.lang.Integer |
getMaxClientCacheSize()
Get the max number of entries in the cache.
|
java.lang.Boolean |
getWindowsWorkAround() |
protected void |
initConnection()
Initialise the underlying connection.
|
int |
maxClientCacheSize() |
void |
setAdditionalDebug(java.lang.Boolean b)
Get additional logging output where available.
|
void |
setCacheConnection(java.lang.Boolean b)
Set whether or not connections created are held open for future use.
|
void |
setCacheExpiration(TimeInterval expiration) |
void |
setDefaultControlPort(java.lang.Integer i)
Override the default port.
|
void |
setDefaultUserName(java.lang.String s)
Set the user name.
|
void |
setForceRelativePath(java.lang.Boolean b)
Force the path to be relative when using getDirectoryRoot(String).
|
void |
setMaxClientCache(java.lang.Integer maxSize)
Set the max number of entries in the cache.
|
void |
setWindowsWorkAround(java.lang.Boolean b)
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.
|
boolean |
windowsWorkaround() |
<T extends FileTransferConnection> |
withCacheExpiration(TimeInterval i) |
prepareConnection, startConnection, stopConnection
addExceptionListener, addMessageConsumer, addMessageProducer, changeState, cloneForTesting, close, connectionErrorHandler, getConnectionErrorHandler, getLookupName, getUniqueId, getWorkersFirstOnShutdown, init, prepare, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveConnection, retrieveExceptionListeners, retrieveMessageConsumers, retrieveMessageProducers, setConnectionErrorHandler, setLookupName, setUniqueId, setWorkersFirstOnShutdown, start, stop, workersFirstOnShutdown
protected static final int DEFAULT_MAX_CACHE_SIZE
setMaxClientCache(Integer)
,
Constant Field Valuesprotected static final TimeInterval DEFAULT_EXPIRATION
public void setForceRelativePath(java.lang.Boolean b)
This is useful in the situation where the server in question does not have the user in a ftp jail
b
- true to prefix a .
to the path.getDirectoryRoot(String)
public java.lang.Boolean getForceRelativePath()
setForceRelativePath(Boolean)
public boolean forceRelativePath()
public java.lang.String getDefaultUserName()
Returns the default user name.
public void setDefaultUserName(java.lang.String s)
s
- the username.public java.lang.Integer getDefaultControlPort()
public abstract int defaultControlPort()
public void setDefaultControlPort(java.lang.Integer i)
i
- The defaultControlPort to set.public void setAdditionalDebug(java.lang.Boolean b)
b
- true to get additional logging.public java.lang.Boolean getAdditionalDebug()
setAdditionalDebug(Boolean)
public boolean additionalDebug()
public java.lang.Boolean getWindowsWorkAround()
setWindowsWorkAround(Boolean)
public void setWindowsWorkAround(java.lang.Boolean b)
b
- the windowsWorkAround to setpublic boolean windowsWorkaround()
public java.lang.Boolean getCacheConnection()
public void setCacheConnection(java.lang.Boolean b)
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.
b
- true to enable, default false.setMaxClientCache(Integer)
public boolean cacheConnection()
protected void initConnection() throws CoreException
AdaptrisConnectionImp
initConnection
in class NoOpConnection
CoreException
- wrapping any exception.NoOpConnection.initConnection()
protected void closeConnection()
AdaptrisConnectionImp
closeConnection
in class NoOpConnection
AdaptrisConnectionImp.closeConnection()
public FileTransferClient connect(java.lang.String hostUrl) throws FileTransferException, java.io.IOException, PasswordException
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.FileTransferException
java.io.IOException
PasswordException
public java.lang.Integer getMaxClientCacheSize()
public void setMaxClientCache(java.lang.Integer maxSize)
Entries will be removed on a least recently accessed basis.
maxSize
- the maximum number of entries, default is 16setCacheConnection(Boolean)
public int maxClientCacheSize()
public TimeInterval getCacheExpiration()
public void setCacheExpiration(TimeInterval expiration)
public <T extends FileTransferConnection> T withCacheExpiration(TimeInterval i)
protected long expirationMillis()
protected abstract boolean acceptProtocol(java.lang.String s)
s
- the URL Protocolprotected abstract FileTransferClient create(java.lang.String host, int port, FileTransferConnection.UserInfo ui) throws java.io.IOException, FileTransferException, PasswordException
FileTransferClient
for use with the producer or consumer.host
- the remote host.port
- the port to connect toui
- a local UserInfo containing username and passwordFileTransferClient
objectjava.io.IOException
- wrapping a general comms error.FileTransferException
- if a protocol specific exception occurred.PasswordException
public java.lang.String getDirectoryRoot(java.lang.String hostUrl)
Returns the directory root for the passed host URL.
hostUrl
- the host URLpublic void disconnect(FileTransferClient ftp)
ftp
- the ftp client implementationprotected abstract FileTransferConnection.UserInfo createUserInfo() throws FileTransferException
FileTransferException