Class FtpRemoteFileTemplate
java.lang.Object
org.springframework.integration.file.remote.RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile>
org.springframework.integration.ftp.session.FtpRemoteFileTemplate
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,InitializingBean
,RemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
FTP version of
RemoteFileTemplate
providing type-safe access to
the underlying FTPClient object.- Since:
- 4.1
- Author:
- Gary Russell, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.file.remote.RemoteFileOperations
RemoteFileOperations.OperationsCallback<F,
T> -
Field Summary
Fields inherited from class org.springframework.integration.file.remote.RemoteFileTemplate
logger, sessionFactory
-
Constructor Summary
ConstructorDescriptionFtpRemoteFileTemplate
(SessionFactory<org.apache.commons.net.ftp.FTPFile> sessionFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> T
doExecuteWithClient
(ClientCallback<org.apache.commons.net.ftp.FTPClient, T> callback) <T,
C> T executeWithClient
(ClientCallback<C, T> callback) Execute the callback's doWithClient method after obtaining a session's client, providing access to low level methods.boolean
This particular FTP implementation is based on theFTPClient.getStatus(String)
by default, but since not all FTP servers properly implement theSTAT
command, the framework internalFtpRemoteFileTemplate
instances are switched to theFTPClient.listNames(String)
for only files operations.void
setExistsMode
(FtpRemoteFileTemplate.ExistsMode existsMode) Specify anFtpRemoteFileTemplate.ExistsMode
forexists(String)
operation.Methods inherited from class org.springframework.integration.file.remote.RemoteFileTemplate
afterPropertiesSet, append, append, execute, get, get, getDirectoryExpressionProcessor, getRemoteFileSeparator, getSession, getSessionFactory, getTemporaryFileSuffix, invoke, isUseTemporaryFileName, list, remove, rename, send, send, setAutoCreateDirectory, setBeanFactory, setCharset, setFileNameExpression, setFileNameGenerator, setRemoteDirectoryExpression, setRemoteFileSeparator, setTemporaryFileSuffix, setTemporaryRemoteDirectoryExpression, setUseTemporaryFileName
-
Constructor Details
-
FtpRemoteFileTemplate
-
-
Method Details
-
executeWithClient
Description copied from interface:RemoteFileOperations
Execute the callback's doWithClient method after obtaining a session's client, providing access to low level methods. Reliably closes the session when the method exits.- Specified by:
executeWithClient
in interfaceRemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
- Overrides:
executeWithClient
in classRemoteFileTemplate<org.apache.commons.net.ftp.FTPFile>
- Type Parameters:
T
- The type returned byClientCallback.doWithClient(Object)
.C
- The type of the underlying client object.- Parameters:
callback
- the ClientCallback.- Returns:
- The result of the callback method.
-
setExistsMode
Specify anFtpRemoteFileTemplate.ExistsMode
forexists(String)
operation. Defaults toFtpRemoteFileTemplate.ExistsMode.STAT
. When used internally by framework components for file operation, switched toFtpRemoteFileTemplate.ExistsMode.NLST
.- Parameters:
existsMode
- theFtpRemoteFileTemplate.ExistsMode
to use.- Since:
- 4.1.9
-
doExecuteWithClient
protected <T> T doExecuteWithClient(ClientCallback<org.apache.commons.net.ftp.FTPClient, T> callback) -
exists
This particular FTP implementation is based on theFTPClient.getStatus(String)
by default, but since not all FTP servers properly implement theSTAT
command, the framework internalFtpRemoteFileTemplate
instances are switched to theFTPClient.listNames(String)
for only files operations.The mode can be switched with the
setExistsMode(ExistsMode)
property.Any custom implementation can be done in an extension of the
FtpRemoteFileTemplate
.- Specified by:
exists
in interfaceRemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
- Overrides:
exists
in classRemoteFileTemplate<org.apache.commons.net.ftp.FTPFile>
- Parameters:
path
- the remote file path to check.- Returns:
- true or false if remote file exists or not.
-