Package org.frankframework.filesystem
Class AbstractFileSystemListener<F,FS extends IBasicFileSystem<F>>
java.lang.Object
org.frankframework.filesystem.AbstractFileSystemListener<F,FS>
- All Implemented Interfaces:
FrankElement
,HasApplicationContext
,HasName
,HasPhysicalDestination
,IConfigurable
,IHasProcessState<F>
,IListener<F>
,IProvidesMessageBrowsers<F>
,IPullingListener<F>
,IScopeProvider
,NameAware
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
AbstractMailListener
,DirectoryListener
,ExchangeMailListener
,FtpFileSystemListener
,Samba2Listener
,SftpFileSystemListener
public abstract class AbstractFileSystemListener<F,FS extends IBasicFileSystem<F>>
extends Object
implements IPullingListener<F>, HasPhysicalDestination, IProvidesMessageBrowsers<F>
listener
that looks in a FileSystem
for files.
When a file is found, it is moved to an in-process folder, so that it isn't found more than once.
The information specified by
messageType
is then passed to the pipeline.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static enum
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterMessageProcessed
(PipeLineResult processResult, RawMessageWrapper<F> rawMessage, PipeLineSession pipeLineSession) Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.changeProcessState
(RawMessageWrapper<F> message, ProcessState toState, String reason) Change the processState of the message to the specified state, if that state is supported.protected boolean
checkForExistenceOfFolder
(String attributeName, String folderName) void
closeThread
(Map<String, Object> threadContext) Finalizes a message receiving thread.void
Configure this component.protected abstract FS
extractMessage
(RawMessageWrapper<F> rawMessage, Map<String, Object> context) Returns the filename, or the contentsextractMessageProperties
(F rawMessage, String originalFilename) getMessageBrowser
(ProcessState state) returns abrowser
of messages that are in ProcessState 'state', and are stored in a storage managed by the listener itself (as opposed to a storage configured as a messageLog or errorStorage in the configuration).getRawMessage
(Map<String, Object> threadContext) Retrieves messages from queue or other channel, but does no processing on it.getStateFolder
(ProcessState state) Provides the set of ProcessStates used by this listener.Prepares a thread for receiving messages.void
setCharset
(String charset) Charset to be used for extracting the contentsvoid
setCreateFolders
(boolean createFolders) If set totrue
, the folders to look for files and to move files to when being processed and after being processed are created if they are specified and do not existvoid
setDelete
(boolean b) If settrue
, the file processed will be deleted after being processed, and not storedvoid
setDisableMessageBrowsers
(boolean disableMessageBrowsers) If settrue
, no browsers for process folders are generatedvoid
setErrorFolder
(String errorFolder) Folder where files are stored after being processed, in case the exit-state was not equal tosuccess
void
setExcludeWildcard
(String excludeWildcard) Filter of files to be excluded when looking in inputFolder.void
setFileTimeSensitive
(boolean b) Iftrue
, the file modification time is used in addition to the filename to determine if a file has been seen previously.void
setHoldFolder
(String holdFolder) Folder where messages from the error folder can be put on Hold, temporarilyvoid
setInProcessFolder
(String inProcessFolder) Folder where files are stored while being processedvoid
setInputFolder
(String inputFolder) Folder that is scanned for files.void
setLogFolder
(String logFolder) Folder where a copy of every file that is received is storedvoid
setMessageIdPropertyKey
(String messageIdPropertyKey) Key of Property to use as messageId.protected void
Determines the contents of the message that is sent to the pipeline.void
setMinStableTime
(long minStableTime) Minimal age of file in milliseconds, to avoid receiving a file while it is still being writtenvoid
Name of the listenervoid
setNumberOfBackups
(int i) Number of copies held of a file with the same name.void
setOutputFormat
(DocumentFormat outputFormat) OutputFormat of message for messageType=infovoid
setOverwrite
(boolean overwrite) If settrue
, the destination file will be deleted if it already existsvoid
setProcessedFolder
(String processedFolder) Folder where files are stored after being processedvoid
setStoreMetadataInSessionKey
(String storeMetadataInSessionKey) Deprecated.void
setWildcard
(String wildcard) Filter of files to look for in inputFolder e.g. '*.inp'.void
start()
Prepares the listener for receiving messages.void
stop()
Close all resources used for listening.Provides the set of ProcessStates that a message in the specified state can be moved to, e.g. from a MessageBrowser for that state.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
Methods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoader
-
Field Details
-
log
protected org.apache.logging.log4j.Logger log -
ORIGINAL_FILENAME_KEY
- See Also:
-
FILENAME_KEY
- See Also:
-
FILEPATH_KEY
- See Also:
-
-
Constructor Details
-
AbstractFileSystemListener
public AbstractFileSystemListener()
-
-
Method Details
-
createFileSystem
-
configure
Description copied from interface:IConfigurable
Configure this component.configure()
is called once at startup of the framework in the configure method of the owner of thisIConfigurable
. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure()
, to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configure
in interfaceIConfigurable
- Throws:
ConfigurationException
- in case it was not able to configure the component.
-
knownProcessStates
Description copied from interface:IHasProcessState
Provides the set of ProcessStates used by this listener.- Specified by:
knownProcessStates
in interfaceIHasProcessState<F>
-
targetProcessStates
Description copied from interface:IHasProcessState
Provides the set of ProcessStates that a message in the specified state can be moved to, e.g. from a MessageBrowser for that state.- Specified by:
targetProcessStates
in interfaceIHasProcessState<F>
-
start
public void start()Description copied from interface:IListener
Prepares the listener for receiving messages.start()
is called once each time the listener is started. -
checkForExistenceOfFolder
protected boolean checkForExistenceOfFolder(String attributeName, String folderName) throws FileSystemException - Throws:
FileSystemException
-
stop
public void stop()Description copied from interface:IListener
Close all resources used for listening. Called once each time the listener is stopped. -
openThread
Description copied from interface:IPullingListener
Prepares a thread for receiving messages. Called once for each thread that will listen for messages.- Specified by:
openThread
in interfaceIPullingListener<F>
- Returns:
- the threadContext for this thread. The threadContext is a Map in which
thread-specific data can be stored. May not be
null
, must be a mutable map type.
-
closeThread
Description copied from interface:IPullingListener
Finalizes a message receiving thread. Called once for each thread that listens for messages, just beforeIListener.stop()
is called.- Specified by:
closeThread
in interfaceIPullingListener<F>
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationName
in interfaceHasPhysicalDestination
-
getDomain
- Specified by:
getDomain
in interfaceHasPhysicalDestination
-
getRawMessage
public RawMessageWrapper<F> getRawMessage(@Nonnull Map<String, Object> threadContext) throws ListenerExceptionDescription copied from interface:IPullingListener
Retrieves messages from queue or other channel, but does no processing on it. Multiple objects may try to call this method at the same time, from different threads. Implementations of this method should therefore be thread-safe, orsynchronized
.Any thread-specific properties should be stored in and retrieved from the threadContext.
- Specified by:
getRawMessage
in interfaceIPullingListener<F>
- Throws:
ListenerException
-
afterMessageProcessed
public void afterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<F> rawMessage, PipeLineSession pipeLineSession) throws ListenerException Description copied from interface:IListener
Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.- Specified by:
afterMessageProcessed
in interfaceIListener<F>
- Throws:
ListenerException
-
extractMessage
public Message extractMessage(@Nonnull RawMessageWrapper<F> rawMessage, @Nonnull Map<String, Object> context) throws ListenerExceptionReturns the filename, or the contents- Specified by:
extractMessage
in interfaceIListener<F>
- Parameters:
rawMessage
- TheRawMessageWrapper
from which to extract theMessage
.context
- Context to populate. Either aPipeLineSession
or aMap
threadContext depending on caller.- Returns:
- input
Message
for adapter. - Throws:
ListenerException
-
extractMessageProperties
@Nonnull public Map<String,Object> extractMessageProperties(@Nonnull F rawMessage, @Nullable String originalFilename) throws ListenerException - Throws:
ListenerException
-
changeProcessState
public RawMessageWrapper<F> changeProcessState(RawMessageWrapper<F> message, ProcessState toState, String reason) throws ListenerException Description copied from interface:IHasProcessState
Change the processState of the message to the specified state, if that state is supported. If it is not supported, nothing changes, andfalse
is returned.- Specified by:
changeProcessState
in interfaceIHasProcessState<F>
- Returns:
- the moved message, or null if no message was moved.
- Throws:
ListenerException
-
getStateFolder
-
getMessageBrowser
Description copied from interface:IProvidesMessageBrowsers
returns abrowser
of messages that are in ProcessState 'state', and are stored in a storage managed by the listener itself (as opposed to a storage configured as a messageLog or errorStorage in the configuration).- Specified by:
getMessageBrowser
in interfaceIProvidesMessageBrowsers<F>
-
setName
Name of the listener -
setInputFolder
Folder that is scanned for files. If not set, the root is scanned -
setInProcessFolder
Folder where files are stored while being processed -
setProcessedFolder
Folder where files are stored after being processed -
setErrorFolder
Folder where files are stored after being processed, in case the exit-state was not equal tosuccess
-
setHoldFolder
Folder where messages from the error folder can be put on Hold, temporarily -
setLogFolder
Folder where a copy of every file that is received is stored -
setCreateFolders
public void setCreateFolders(boolean createFolders) If set totrue
, the folders to look for files and to move files to when being processed and after being processed are created if they are specified and do not exist- Default value
- false
-
setDelete
public void setDelete(boolean b) If settrue
, the file processed will be deleted after being processed, and not stored- Default value
- false
-
setNumberOfBackups
public void setNumberOfBackups(int i) Number of copies held of a file with the same name. Backup files have a dot and a number suffixed to their name. If set to 0, no backups will be kept.- Default value
- 0
-
setOverwrite
public void setOverwrite(boolean overwrite) If settrue
, the destination file will be deleted if it already exists- Default value
- false
-
setFileTimeSensitive
public void setFileTimeSensitive(boolean b) Iftrue
, the file modification time is used in addition to the filename to determine if a file has been seen previously.
This setting is only supported for filesystem listeners that implementIWritableFileSystem
.- Default value
- false
-
setMinStableTime
public void setMinStableTime(long minStableTime) Minimal age of file in milliseconds, to avoid receiving a file while it is still being written- Default value
- 1000
-
setMessageIdPropertyKey
Key of Property to use as messageId. If not set, the filename of the file as it was received in the inputFolder is used as the messageId- Default value
- for MailFileSystems: Message-ID
-
setDisableMessageBrowsers
public void setDisableMessageBrowsers(boolean disableMessageBrowsers) If settrue
, no browsers for process folders are generated- Default value
- false
-
setWildcard
Filter of files to look for in inputFolder e.g. '*.inp'. -
setExcludeWildcard
Filter of files to be excluded when looking in inputFolder. -
setStoreMetadataInSessionKey
Deprecated.If set, an XML with all message properties is provided under this key. Also stored in the "originalMessage" metadata. -
setCharset
Charset to be used for extracting the contents -
setMessageType
Determines the contents of the message that is sent to the pipeline. The value of the attribute matching the searchKey is returned when usingATTRIBUTE
- Default value
- PATH
-
setOutputFormat
OutputFormat of message for messageType=info- Default value
- XML
-