Class AbstractInboundFileSynchronizer<F>
java.lang.Object
org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer<F>
- Type Parameters:
- F- the Type that represents a remote file.
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Aware,- BeanFactoryAware,- BeanNameAware,- InitializingBean,- InboundFileSynchronizer
- Direct Known Subclasses:
- FtpInboundFileSynchronizer,- SftpInboundFileSynchronizer,- SmbInboundFileSynchronizer
public abstract class AbstractInboundFileSynchronizer<F>
extends Object
implements InboundFileSynchronizer, BeanFactoryAware, BeanNameAware, InitializingBean, Closeable
Base class charged with knowing how to connect to a remote file system,
 scan it for new files and then download the files.
 
 The implementation should run through any configured
 FileListFilters to
 ensure the file entry is acceptable.
- Since:
- 2.0
- Author:
- Josh Long, Mark Fisher, Oleg Zhurakousky, Gary Russell, Artem Bilan
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionAbstractInboundFileSynchronizer(SessionFactory<F> sessionFactory) Create a synchronizer with theSessionFactoryused to acquireSessioninstances.
- 
Method SummaryModifier and TypeMethodDescriptionfinal voidvoidclose()protected booleancopyFileToLocalDirectory(String remoteDirectoryPath, EvaluationContext localFileEvaluationContext, F remoteFile, File localDirectory, Session<F> session) protected voiddoInit()Subclasses can override to perform initialization - called fromInitializingBean.afterPropertiesSet().protected final voiddoSetFilter(FileListFilter<F> filterToSet) protected final voiddoSetRemoteDirectoryExpression(Expression expression) filterFiles(F[] files) protected Comparator<? extends F>protected abstract StringgetFilename(F file) protected abstract longgetModified(F file) getRemoteFileMetadata(File localFile) Obtain a metadata for remote file associated with the provided local file.protected Stringprotected abstract booleanprotected abstract Stringprotocol()Return the protocol this synchronizer works with.voidremoveRemoteFileMetadata(File localFile) Remove a metadata for remote file associated with the provided local file.protected voidrollbackFromFileToListEnd(List<F> filteredFiles, F file) voidsetBeanFactory(BeanFactory beanFactory) voidsetBeanName(String name) voidsetComparator(Comparator<? extends F> comparator) Set a comparator to sort the retrieved list ofF(the Type that represents the remote file) prior to applying filters and max fetch size.voidsetDeleteRemoteFiles(boolean deleteRemoteFiles) Set to true to enable deletion of remote files after successful transfer.voidsetFilter(FileListFilter<F> filter) Set the filter to be applied to the remote files before transferring.voidsetLocalFilenameGeneratorExpression(Expression localFilenameGeneratorExpression) Set an expression used to determine the local file name.voidsetLocalFilenameGeneratorExpressionString(String localFilenameGeneratorExpression) Set an expression used to determine the local file name.voidsetMetadataStorePrefix(String metadataStorePrefix) Specify a prefix for keys in metadata store do not clash with other keys in the shared store.voidsetPreserveTimestamp(boolean preserveTimestamp) Set to true to enable the preservation of the remote file timestamp when transferring.voidsetRemoteDirectory(String remoteDirectory) Specify the full path to the remote directory.voidsetRemoteDirectoryExpression(Expression remoteDirectoryExpression) Specify an expression that evaluates to the full path to the remote directory.voidsetRemoteDirectoryExpressionString(String remoteDirectoryExpression) Specify an expression that evaluates to the full path to the remote directory.voidsetRemoteFileMetadataStore(MetadataStore remoteFileMetadataStore) Configure aMetadataStoreto hold a remote file info (host, port, remote directory) to transfer downstream in message headers when local file is pulled.voidsetRemoteFileSeparator(String remoteFileSeparator) voidsetTemporaryFileSuffix(String temporaryFileSuffix) Set a temporary file suffix to be used while transferring files.voidsynchronizeToLocalDirectory(File localDirectory) Synchronize all available files to the local directory.voidsynchronizeToLocalDirectory(File localDirectory, int maxFetchSize) Synchronize up to maxFetchSize files to the local directory.
- 
Field Details- 
EXPRESSION_PARSER
- 
logger
 
- 
- 
Constructor Details- 
AbstractInboundFileSynchronizerCreate a synchronizer with theSessionFactoryused to acquireSessioninstances.- Parameters:
- sessionFactory- The session factory.
 
 
- 
- 
Method Details- 
getComparator
- 
setComparatorSet a comparator to sort the retrieved list ofF(the Type that represents the remote file) prior to applying filters and max fetch size.- Parameters:
- comparator- the comparator.
- Since:
- 5.1
 
- 
setRemoteFileSeparator- Parameters:
- remoteFileSeparator- the remote file separator.
- See Also:
 
- 
setLocalFilenameGeneratorExpressionSet an expression used to determine the local file name.- Parameters:
- localFilenameGeneratorExpression- the expression.
 
- 
setLocalFilenameGeneratorExpressionStringSet an expression used to determine the local file name.- Parameters:
- localFilenameGeneratorExpression- the expression.
- Since:
- 4.3.13
- See Also:
 
- 
setTemporaryFileSuffixSet a temporary file suffix to be used while transferring files. Default ".writing".- Parameters:
- temporaryFileSuffix- the file suffix.
 
- 
setRemoteDirectorySpecify the full path to the remote directory.- Parameters:
- remoteDirectory- The remote directory.
 
- 
setRemoteDirectoryExpressionSpecify an expression that evaluates to the full path to the remote directory.- Parameters:
- remoteDirectoryExpression- The remote directory expression.
- Since:
- 4.2
 
- 
setRemoteDirectoryExpressionStringSpecify an expression that evaluates to the full path to the remote directory.- Parameters:
- remoteDirectoryExpression- The remote directory expression.
- Since:
- 4.3.13
- See Also:
 
- 
doSetRemoteDirectoryExpression
- 
setFilterSet the filter to be applied to the remote files before transferring.- Parameters:
- filter- the file list filter.
 
- 
doSetFilter
- 
setDeleteRemoteFilespublic void setDeleteRemoteFiles(boolean deleteRemoteFiles) Set to true to enable deletion of remote files after successful transfer.- Parameters:
- deleteRemoteFiles- true to delete.
 
- 
setPreserveTimestamppublic void setPreserveTimestamp(boolean preserveTimestamp) Set to true to enable the preservation of the remote file timestamp when transferring.- Parameters:
- preserveTimestamp- true to preserve.
 
- 
setRemoteFileMetadataStoreConfigure aMetadataStoreto hold a remote file info (host, port, remote directory) to transfer downstream in message headers when local file is pulled.- Parameters:
- remoteFileMetadataStore- the- MetadataStoreto use.
- Since:
- 5.2
 
- 
setMetadataStorePrefixSpecify a prefix for keys in metadata store do not clash with other keys in the shared store.- Parameters:
- metadataStorePrefix- the prefix to use.
- Since:
- 5.2
- See Also:
 
- 
setBeanFactory- Specified by:
- setBeanFactoryin interface- BeanFactoryAware
- Throws:
- BeansException
 
- 
setBeanName- Specified by:
- setBeanNamein interface- BeanNameAware
 
- 
afterPropertiesSetpublic final void afterPropertiesSet()- Specified by:
- afterPropertiesSetin interface- InitializingBean
 
- 
doInitprotected void doInit()Subclasses can override to perform initialization - called fromInitializingBean.afterPropertiesSet().
- 
filterFiles
- 
getTemporaryFileSuffix
- 
close- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Throws:
- IOException
 
- 
synchronizeToLocalDirectoryDescription copied from interface:InboundFileSynchronizerSynchronize all available files to the local directory.- Specified by:
- synchronizeToLocalDirectoryin interface- InboundFileSynchronizer
- Parameters:
- localDirectory- the directory.
 
- 
synchronizeToLocalDirectoryDescription copied from interface:InboundFileSynchronizerSynchronize up to maxFetchSize files to the local directory.- Specified by:
- synchronizeToLocalDirectoryin interface- InboundFileSynchronizer
- Parameters:
- localDirectory- the directory.
- maxFetchSize- the maximum files to fetch.
 
- 
rollbackFromFileToListEnd
- 
copyFileToLocalDirectoryprotected boolean copyFileToLocalDirectory(String remoteDirectoryPath, @Nullable EvaluationContext localFileEvaluationContext, F remoteFile, File localDirectory, Session<F> session) throws IOException - Throws:
- IOException
 
- 
getRemoteFileMetadataObtain a metadata for remote file associated with the provided local file.- Parameters:
- localFile- the local file to retrieve metadata for.
- Returns:
- the metadata for remove file in the URI style:
 protocol://host:port/remoteDirectory#remoteFileName
- Since:
- 5.2
 
- 
removeRemoteFileMetadataRemove a metadata for remote file associated with the provided local file.- Parameters:
- localFile- the local file to remove metadata for.
- Since:
- 5.2
 
- 
isFile
- 
getFilename
- 
getModified
- 
protocolReturn the protocol this synchronizer works with.- Returns:
- the protocol this synchronizer works with.
- Since:
- 5.2
 
 
-