F
- the Type that represents a remote file.public abstract class AbstractInboundFileSynchronizer<F> extends Object implements InboundFileSynchronizer, BeanFactoryAware, BeanNameAware, InitializingBean, Closeable
The implementation should run through any configured
FileListFilter
s to
ensure the file entry is acceptable.
Modifier and Type | Field and Description |
---|---|
protected static ExpressionParser |
EXPRESSION_PARSER |
protected Log |
logger |
Constructor and Description |
---|
AbstractInboundFileSynchronizer(SessionFactory<F> sessionFactory)
Create a synchronizer with the
SessionFactory used to acquire Session instances. |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
close() |
protected boolean |
copyFileToLocalDirectory(String remoteDirectoryPath,
EvaluationContext localFileEvaluationContext,
F remoteFile,
File localDirectory,
Session<F> session) |
protected void |
doInit()
Subclasses can override to perform initialization - called from
InitializingBean.afterPropertiesSet() . |
protected void |
doSetFilter(FileListFilter<F> filterToSet) |
protected void |
doSetRemoteDirectoryExpression(Expression expression) |
protected List<F> |
filterFiles(F[] files) |
protected Comparator<F> |
getComparator() |
protected abstract String |
getFilename(F file) |
protected abstract long |
getModified(F file) |
String |
getRemoteFileMetadata(File localFile)
Obtain a metadata for remote file associated with the provided local file.
|
protected String |
getTemporaryFileSuffix() |
protected abstract boolean |
isFile(F file) |
protected abstract String |
protocol()
Return the protocol this synchronizer works with.
|
void |
removeRemoteFileMetadata(File localFile)
Remove a metadata for remote file associated with the provided local file.
|
protected void |
rollbackFromFileToListEnd(List<F> filteredFiles,
F file) |
void |
setBeanFactory(BeanFactory beanFactory) |
void |
setBeanName(String name) |
void |
setComparator(Comparator<F> comparator)
Set a comparator to sort the retrieved list of
F (the Type that represents
the remote file) prior to applying filters and max fetch size. |
void |
setDeleteRemoteFiles(boolean deleteRemoteFiles)
Set to true to enable deletion of remote files after successful transfer.
|
void |
setFilter(FileListFilter<F> filter)
Set the filter to be applied to the remote files before transferring.
|
void |
setLocalFilenameGeneratorExpression(Expression localFilenameGeneratorExpression)
Set an expression used to determine the local file name.
|
void |
setLocalFilenameGeneratorExpressionString(String localFilenameGeneratorExpression)
Set an expression used to determine the local file name.
|
void |
setMetadataStorePrefix(String metadataStorePrefix)
Specify a prefix for keys in metadata store do not clash with other keys in the shared store.
|
void |
setPreserveTimestamp(boolean preserveTimestamp)
Set to true to enable the preservation of the remote file timestamp when
transferring.
|
void |
setRemoteDirectory(String remoteDirectory)
Specify the full path to the remote directory.
|
void |
setRemoteDirectoryExpression(Expression remoteDirectoryExpression)
Specify an expression that evaluates to the full path to the remote directory.
|
void |
setRemoteDirectoryExpressionString(String remoteDirectoryExpression)
Specify an expression that evaluates to the full path to the remote directory.
|
void |
setRemoteFileMetadataStore(MetadataStore remoteFileMetadataStore)
Configure a
MetadataStore to hold a remote file info (host, port, remote directory)
to transfer downstream in message headers when local file is pulled. |
void |
setRemoteFileSeparator(String remoteFileSeparator) |
void |
setTemporaryFileSuffix(String temporaryFileSuffix)
Set a temporary file suffix to be used while transferring files.
|
void |
synchronizeToLocalDirectory(File localDirectory)
Synchronize all available files to the local directory;
|
void |
synchronizeToLocalDirectory(File localDirectory,
int maxFetchSize)
Synchronize up to maxFetchSize files to the local directory;
|
protected static final ExpressionParser EXPRESSION_PARSER
protected final Log logger
public AbstractInboundFileSynchronizer(SessionFactory<F> sessionFactory)
SessionFactory
used to acquire Session
instances.sessionFactory
- The session factory.@Nullable protected Comparator<F> getComparator()
public void setComparator(@Nullable Comparator<F> comparator)
F
(the Type that represents
the remote file) prior to applying filters and max fetch size.comparator
- the comparator.public void setRemoteFileSeparator(String remoteFileSeparator)
remoteFileSeparator
- the remote file separator.RemoteFileTemplate.setRemoteFileSeparator(String)
public void setLocalFilenameGeneratorExpression(Expression localFilenameGeneratorExpression)
localFilenameGeneratorExpression
- the expression.public void setLocalFilenameGeneratorExpressionString(String localFilenameGeneratorExpression)
localFilenameGeneratorExpression
- the expression.setRemoteDirectoryExpression(Expression)
public void setTemporaryFileSuffix(String temporaryFileSuffix)
temporaryFileSuffix
- the file suffix.public void setRemoteDirectory(String remoteDirectory)
remoteDirectory
- The remote directory.public void setRemoteDirectoryExpression(Expression remoteDirectoryExpression)
remoteDirectoryExpression
- The remote directory expression.public void setRemoteDirectoryExpressionString(String remoteDirectoryExpression)
remoteDirectoryExpression
- The remote directory expression.setRemoteDirectoryExpression(Expression)
protected final void doSetRemoteDirectoryExpression(Expression expression)
public void setFilter(@Nullable FileListFilter<F> filter)
filter
- the file list filter.protected final void doSetFilter(@Nullable FileListFilter<F> filterToSet)
public void setDeleteRemoteFiles(boolean deleteRemoteFiles)
deleteRemoteFiles
- true to delete.public void setPreserveTimestamp(boolean preserveTimestamp)
preserveTimestamp
- true to preserve.public void setRemoteFileMetadataStore(MetadataStore remoteFileMetadataStore)
MetadataStore
to hold a remote file info (host, port, remote directory)
to transfer downstream in message headers when local file is pulled.remoteFileMetadataStore
- the MetadataStore
to use.public void setMetadataStorePrefix(String metadataStorePrefix)
metadataStorePrefix
- the prefix to use.setRemoteFileMetadataStore(MetadataStore)
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory
in interface BeanFactoryAware
BeansException
public void setBeanName(String name)
setBeanName
in interface BeanNameAware
public final void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
protected void doInit()
InitializingBean.afterPropertiesSet()
.protected String getTemporaryFileSuffix()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void synchronizeToLocalDirectory(File localDirectory)
InboundFileSynchronizer
synchronizeToLocalDirectory
in interface InboundFileSynchronizer
localDirectory
- the directory.public void synchronizeToLocalDirectory(File localDirectory, int maxFetchSize)
InboundFileSynchronizer
synchronizeToLocalDirectory
in interface InboundFileSynchronizer
localDirectory
- the directory.maxFetchSize
- the maximum files to fetch.protected boolean copyFileToLocalDirectory(String remoteDirectoryPath, @Nullable EvaluationContext localFileEvaluationContext, F remoteFile, File localDirectory, Session<F> session) throws IOException
IOException
@Nullable public String getRemoteFileMetadata(File localFile)
localFile
- the local file to retrieve metadata for.protocol://host:port/remoteDirectory#remoteFileName
public void removeRemoteFileMetadata(File localFile)
localFile
- the local file to remove metadata for.protected abstract boolean isFile(F file)
protected abstract long getModified(F file)
protected abstract String protocol()