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
@DestinationType(FILE_SYSTEM)
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 interfacestatic enum -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterMessageProcessed(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 booleancheckForExistenceOfFolder(String attributeName, String folderName) voidcloseThread(Map<String, Object> threadContext) Finalizes a message receiving thread.voidConfigure this component.protected abstract FSextractMessage(RawMessageWrapper<F> rawMessage, Map<String, Object> context) Returns the filename, or the contentsextractMessageProperties(F rawMessage, String originalFilename) getMessageBrowser(ProcessState state) returns abrowserof 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.voidsetCharset(String charset) Charset to be used for extracting the contentsvoidsetCreateFolders(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 existvoidsetDelete(boolean b) If settrue, the file processed will be deleted after being processed, and not storedvoidsetDisableMessageBrowsers(boolean disableMessageBrowsers) If settrue, no browsers for process folders are generatedvoidsetErrorFolder(String errorFolder) Folder where files are stored after being processed, in case the exit-state was not equal tosuccessvoidsetExcludeWildcard(String excludeWildcard) Filter of files to be excluded when looking in inputFolder.voidsetFileTimeSensitive(boolean b) Iftrue, the file modification time is used in addition to the filename to determine if a file has been seen previously.voidsetHoldFolder(String holdFolder) Folder where messages from the error folder can be put on Hold, temporarilyvoidsetInProcessFolder(String inProcessFolder) Folder where files are stored while being processedvoidsetInputFolder(String inputFolder) Folder that is scanned for files.voidsetLogFolder(String logFolder) Folder where a copy of every file that is received is storedvoidsetMessageIdPropertyKey(String messageIdPropertyKey) Key of Property to use as messageId.protected voidDetermines the contents of the message that is sent to the pipeline.voidsetMinStableTime(long minStableTime) Minimal age of file in milliseconds, to avoid receiving a file while it is still being writtenvoidName of the listenervoidsetNumberOfBackups(int i) Number of copies held of a file with the same name.voidsetOutputFormat(DocumentFormat outputFormat) OutputFormat of message for messageType=infovoidsetOverwrite(boolean overwrite) If settrue, the destination file will be deleted if it already existsvoidsetProcessedFolder(String processedFolder) Folder where files are stored after being processedvoidsetStoreMetadataInSessionKey(String storeMetadataInSessionKey) Deprecated.voidsetWildcard(String wildcard) Filter of files to look for in inputFolder e.g. '*.inp'.voidstart()Prepares the listener for receiving messages.voidstop()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, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoader
-
Field Details
-
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:IConfigurableConfigure 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:
configurein interfaceIConfigurable- Throws:
ConfigurationException- in case it was not able to configure the component.
-
knownProcessStates
Description copied from interface:IHasProcessStateProvides the set of ProcessStates used by this listener.- Specified by:
knownProcessStatesin interfaceIHasProcessState<F>
-
targetProcessStates
Description copied from interface:IHasProcessStateProvides 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:
targetProcessStatesin interfaceIHasProcessState<F>
-
start
public void start()Description copied from interface:IListenerPrepares 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:IListenerClose all resources used for listening. Called once each time the listener is stopped. -
openThread
Description copied from interface:IPullingListenerPrepares a thread for receiving messages. Called once for each thread that will listen for messages.- Specified by:
openThreadin 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:IPullingListenerFinalizes a message receiving thread. Called once for each thread that listens for messages, just beforeIListener.stop()is called.- Specified by:
closeThreadin interfaceIPullingListener<F>
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationNamein interfaceHasPhysicalDestination
-
getRawMessage
public RawMessageWrapper<F> getRawMessage(@Nonnull Map<String, Object> threadContext) throws ListenerExceptionDescription copied from interface:IPullingListenerRetrieves 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:
getRawMessagein interfaceIPullingListener<F>- Throws:
ListenerException
-
afterMessageProcessed
public void afterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<F> rawMessage, PipeLineSession pipeLineSession) throws ListenerException Description copied from interface:IListenerCalled to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.- Specified by:
afterMessageProcessedin 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:
extractMessagein interfaceIListener<F>- Parameters:
rawMessage- TheRawMessageWrapperfrom which to extract theMessage.context- Context to populate. Either aPipeLineSessionor aMapthreadContext depending on caller.- Returns:
- input
Messagefor 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:IHasProcessStateChange the processState of the message to the specified state, if that state is supported. If it is not supported, nothing changes, andfalseis returned.- Specified by:
changeProcessStatein interfaceIHasProcessState<F>- Returns:
- the moved message, or null if no message was moved.
- Throws:
ListenerException
-
getStateFolder
-
getMessageBrowser
Description copied from interface:IProvidesMessageBrowsersreturns abrowserof 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:
getMessageBrowserin 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
-