Class AbstractInboundFileSynchronizingMessageSource<F>
java.lang.Object
org.springframework.integration.util.AbstractExpressionEvaluator
org.springframework.integration.endpoint.AbstractMessageSource<T>
org.springframework.integration.endpoint.AbstractFetchLimitingMessageSource<File>
org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource<F>
- Type Parameters:
F
- the target system file type.
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,Lifecycle
,MessageSource<File>
,IntegrationPattern
,NamedComponent
,IntegrationInboundManagement
,IntegrationManagement
,ManageableLifecycle
,MessageSourceManagement
- Direct Known Subclasses:
FtpInboundFileSynchronizingMessageSource
,SftpInboundFileSynchronizingMessageSource
,SmbInboundFileSynchronizingMessageSource
public abstract class AbstractInboundFileSynchronizingMessageSource<F>
extends AbstractFetchLimitingMessageSource<File>
implements ManageableLifecycle
Factors out the common logic between the FTP and SFTP adapters. Designed to
be extensible to handle adapters whose task it is to synchronize a remote
file system with a local file system (NB: this does *NOT* handle pushing
files TO the remote file system that exist uniquely in the local file system.
It only handles pulling from the remote file system - as you would expect
from an 'inbound' adapter).
The base class supports configuration of whether the remote file system and local file system's directories should be created on start (what 'creating a directory' means to the specific adapter is of course implementation specific).
This class is to be used as a pair with an implementation of
AbstractInboundFileSynchronizer
. The synchronizer must
handle the work of actually connecting to the remote file system and
delivering new File
s.
- Author:
- Josh Long, Oleg Zhurakousky, Gary Russell, Artem Bilan, Venil Noronha
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
-
Constructor Summary
ConstructorDescriptionAbstractInboundFileSynchronizingMessageSource
(AbstractInboundFileSynchronizer<F> synchronizer, Comparator<File> comparator) -
Method Summary
Modifier and TypeMethodDescriptiondoReceive
(int maxFetchSize) Polls from the file source.Return the underlying synchronizer.boolean
protected void
onInit()
void
setAutoCreateLocalDirectory
(boolean autoCreateLocalDirectory) void
setLocalDirectory
(File localDirectory) void
setLocalFilter
(FileListFilter<File> localFileListFilter) AFileListFilter
used to determine which files will generate messages after they have been synchronized.void
setScanner
(DirectoryScanner scanner) Switch the localFileReadingMessageSource
to use a customDirectoryScanner
.void
setUseWatchService
(boolean useWatchService) Switch the localFileReadingMessageSource
to use its internalFileReadingMessageSource.WatchServiceDirectoryScanner
.void
start()
void
stop()
Methods inherited from class org.springframework.integration.endpoint.AbstractFetchLimitingMessageSource
doReceive, getMaxFetchSize, setMaxFetchSize
Methods inherited from class org.springframework.integration.endpoint.AbstractMessageSource
buildMessage, destroy, getBeanName, getComponentName, getManagedName, getManagedType, getOverrides, isLoggingEnabled, receive, registerMetricsCaptor, setBeanName, setHeaderExpressions, setLoggingEnabled, setManagedName, setManagedType
Methods inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
afterPropertiesSet, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getBeanFactory, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, setBeanFactory, setConversionService, setSimpleEvaluationContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs, isObserved, registerObservationRegistry
Methods inherited from interface org.springframework.integration.core.MessageSource
getIntegrationPatternType
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getComponentType
-
Constructor Details
-
AbstractInboundFileSynchronizingMessageSource
public AbstractInboundFileSynchronizingMessageSource(AbstractInboundFileSynchronizer<F> synchronizer) -
AbstractInboundFileSynchronizingMessageSource
public AbstractInboundFileSynchronizingMessageSource(AbstractInboundFileSynchronizer<F> synchronizer, Comparator<File> comparator)
-
-
Method Details
-
setAutoCreateLocalDirectory
public void setAutoCreateLocalDirectory(boolean autoCreateLocalDirectory) -
setLocalDirectory
-
setLocalFilter
AFileListFilter
used to determine which files will generate messages after they have been synchronized. It will be combined with a filter that will prevent accessing files that are in the process of being synchronized (files having theAbstractInboundFileSynchronizer.getTemporaryFileSuffix()
).The default is an
FileSystemPersistentAcceptOnceFileListFilter
which filters duplicate file names (processed during the current execution).- Parameters:
localFileListFilter
- The local file list filter.
-
setUseWatchService
public void setUseWatchService(boolean useWatchService) Switch the localFileReadingMessageSource
to use its internalFileReadingMessageSource.WatchServiceDirectoryScanner
.- Parameters:
useWatchService
- theboolean
flag to switch toFileReadingMessageSource.WatchServiceDirectoryScanner
ontrue
.- Since:
- 5.0
-
setScanner
Switch the localFileReadingMessageSource
to use a customDirectoryScanner
.- Parameters:
scanner
- theDirectoryScanner
to use.- Since:
- 5.0
-
getSynchronizer
Return the underlying synchronizer.- Returns:
- the synchronizer.
- Since:
- 5.0.7
-
onInit
protected void onInit()- Overrides:
onInit
in classAbstractExpressionEvaluator
-
start
public void start()- Specified by:
start
in interfaceLifecycle
- Specified by:
start
in interfaceManageableLifecycle
-
stop
public void stop()- Specified by:
stop
in interfaceLifecycle
- Specified by:
stop
in interfaceManageableLifecycle
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceLifecycle
- Specified by:
isRunning
in interfaceManageableLifecycle
-
doReceive
Polls from the file source. If the result is not null, it will be returned. If the result is null, it attempts to sync up with the remote directory to populate the file source. At most, maxFetchSize files will be fetched. Then, it polls the file source again and returns the result, whether or not it is null.- Specified by:
doReceive
in classAbstractFetchLimitingMessageSource<File>
- Parameters:
maxFetchSize
- the maximum files to fetch.- Returns:
- The value returned.
-