public class RemoteFileTemplate<F> extends Object implements RemoteFileOperations<F>, InitializingBean, BeanFactoryAware
Modifier and Type | Field and Description |
---|---|
protected SessionFactory<F> |
sessionFactory
the
SessionFactory for acquiring remote file Sessions. |
Constructor and Description |
---|
RemoteFileTemplate(SessionFactory<F> sessionFactory)
Construct a
RemoteFileTemplate with the supplied session factory. |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
String |
append(Message<?> message)
Send a file to a remote server, based on information in a message, appending.
|
String |
append(Message<?> message,
String subDirectory)
Send a file to a remote server, based on information in a message, appending.
|
<T> T |
execute(SessionCallback<F,T> callback)
Execute the callback's doInSession method after obtaining a session.
|
<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 |
exists(String path)
Check if a file exists on the remote server.
|
boolean |
get(Message<?> message,
InputStreamCallback callback)
Retrieve a remote file as an InputStream, based on information in a message.
|
boolean |
get(String remotePath,
InputStreamCallback callback)
Retrieve a remote file as an InputStream.
|
String |
getRemoteFileSeparator() |
SessionFactory<F> |
getSessionFactory() |
String |
getTemporaryFileSuffix() |
boolean |
isUseTemporaryFileName() |
boolean |
remove(String path)
Remove a remote file.
|
void |
rename(String fromPath,
String toPath)
Rename a remote file, creating directories if needed.
|
String |
send(Message<?> message,
FileExistsMode... mode)
Send a file to a remote server, based on information in a message.
|
String |
send(Message<?> message,
String subDirectory,
FileExistsMode... mode)
Send a file to a remote server, based on information in a message.
|
void |
setAutoCreateDirectory(boolean autoCreateDirectory)
Determine whether the remote directory should automatically be created when
sending files to the remote system.
|
void |
setBeanFactory(BeanFactory beanFactory) |
void |
setCharset(String charset)
Set the charset to use when converting String payloads to bytes as the content of the
remote file.
|
void |
setFileNameExpression(Expression fileNameExpression)
Set the file name expression to determine the full path to the remote file when retrieving
a file using the
get(Message, InputStreamCallback) method, with the message
being the root object of the evaluation. |
void |
setFileNameGenerator(FileNameGenerator fileNameGenerator)
Set the file name generator used to generate the remote filename to be used when transferring
files to the remote system.
|
void |
setRemoteDirectoryExpression(Expression remoteDirectoryExpression)
Set the remote directory expression used to determine the remote directory to which
files will be sent.
|
void |
setRemoteFileSeparator(String remoteFileSeparator)
Set the file separator when dealing with remote files; default '/'.
|
void |
setTemporaryFileSuffix(String temporaryFileSuffix)
Set the temporary suffix to use when transferring files to the remote system.
|
void |
setTemporaryRemoteDirectoryExpression(Expression temporaryRemoteDirectoryExpression)
Set a temporary remote directory expression; used when transferring files to the remote
system.
|
void |
setUseTemporaryFileName(boolean useTemporaryFileName)
Set whether a temporary file name is used when sending files to the remote system.
|
protected final SessionFactory<F> sessionFactory
SessionFactory
for acquiring remote file Sessions.public RemoteFileTemplate(SessionFactory<F> sessionFactory)
RemoteFileTemplate
with the supplied session factory.sessionFactory
- the session factory.public SessionFactory<F> getSessionFactory()
SessionFactory
.public void setAutoCreateDirectory(boolean autoCreateDirectory)
autoCreateDirectory
- true to create the directory.public void setRemoteFileSeparator(String remoteFileSeparator)
remoteFileSeparator
- the separator.public final String getRemoteFileSeparator()
public void setRemoteDirectoryExpression(Expression remoteDirectoryExpression)
remoteDirectoryExpression
- the remote directory expression.public void setTemporaryRemoteDirectoryExpression(Expression temporaryRemoteDirectoryExpression)
remoteDirectoryExpression
.temporaryRemoteDirectoryExpression
- the temporary remote directory expression.public void setFileNameExpression(Expression fileNameExpression)
get(Message, InputStreamCallback)
method, with the message
being the root object of the evaluation.fileNameExpression
- the file name expression.public String getTemporaryFileSuffix()
public boolean isUseTemporaryFileName()
public void setUseTemporaryFileName(boolean useTemporaryFileName)
useTemporaryFileName
- true to use a temporary file name.setTemporaryFileSuffix(String)
public void setFileNameGenerator(FileNameGenerator fileNameGenerator)
DefaultFileNameGenerator
.fileNameGenerator
- the file name generator.public void setCharset(String charset)
UTF-8
.charset
- the charset.public void setTemporaryFileSuffix(String temporaryFileSuffix)
temporaryFileSuffix
- the suffixsetUseTemporaryFileName(boolean)
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory
in interface BeanFactoryAware
BeansException
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public String append(Message<?> message)
RemoteFileOperations
append
in interface RemoteFileOperations<F>
message
- The message.public String append(Message<?> message, String subDirectory)
RemoteFileOperations
append
in interface RemoteFileOperations<F>
message
- The message.subDirectory
- The sub directory.public String send(Message<?> message, FileExistsMode... mode)
RemoteFileOperations
send
in interface RemoteFileOperations<F>
message
- The message.mode
- See FileExistsMode
(optional; default REPLACE). A
vararg is used to make the argument optional; only the first will be
used if more than one is provided.public String send(Message<?> message, String subDirectory, FileExistsMode... mode)
RemoteFileOperations
send
in interface RemoteFileOperations<F>
message
- The message.subDirectory
- The sub directory.mode
- See FileExistsMode
(optional; default REPLACE). A
vararg is used to make the argument optional; only the first will be
used if more than one is provided.public boolean exists(String path)
RemoteFileOperations
exists
in interface RemoteFileOperations<F>
path
- The full path to the file.public boolean remove(String path)
RemoteFileOperations
remove
in interface RemoteFileOperations<F>
path
- The full path to the file.public void rename(String fromPath, String toPath)
RemoteFileOperations
rename
in interface RemoteFileOperations<F>
fromPath
- The current path.toPath
- The new path.public boolean get(Message<?> message, InputStreamCallback callback)
RemoteFileOperations
get
in interface RemoteFileOperations<F>
message
- The message which will be evaluated to generate the remote path.callback
- the callback.setFileNameExpression(Expression)
public boolean get(String remotePath, InputStreamCallback callback)
RemoteFileOperations
get
in interface RemoteFileOperations<F>
remotePath
- The remote path to the file.callback
- the callback.public <T> T execute(SessionCallback<F,T> callback)
RemoteFileOperations
execute
in interface RemoteFileOperations<F>
T
- The type returned by
SessionCallback.doInSession(org.springframework.integration.file.remote.session.Session)
.callback
- the SessionCallback.public <T,C> T executeWithClient(ClientCallback<C,T> callback)
RemoteFileOperations
executeWithClient
in interface RemoteFileOperations<F>
T
- The type returned by ClientCallback.doWithClient(Object)
.C
- The type of the underlying client object.callback
- the ClientCallback.