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.
  • Field Details

  • Constructor Details

    • AbstractFileSystemListener

      public AbstractFileSystemListener()
  • Method Details

    • createFileSystem

      protected abstract FS createFileSystem()
    • configure

      public void configure() throws ConfigurationException
      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 this IConfigurable. 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 the configure(), to improve performance.

      In the case of a container, this will propagate the configure signal to all components that apply.

      Specified by:
      configure in interface IConfigurable
      Throws:
      ConfigurationException - in case it was not able to configure the component.
    • knownProcessStates

      public Set<ProcessState> knownProcessStates()
      Description copied from interface: IHasProcessState
      Provides the set of ProcessStates used by this listener.
      Specified by:
      knownProcessStates in interface IHasProcessState<F>
    • targetProcessStates

      public Map<ProcessState,Set<ProcessState>> 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 interface IHasProcessState<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.
      Specified by:
      start in interface IListener<F>
    • 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.
      Specified by:
      stop in interface IListener<F>
    • openThread

      @Nonnull public Map<String,Object> 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 interface IPullingListener<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

      public void closeThread(@Nonnull Map<String,Object> threadContext)
      Description copied from interface: IPullingListener
      Finalizes a message receiving thread. Called once for each thread that listens for messages, just before IListener.stop() is called.
      Specified by:
      closeThread in interface IPullingListener<F>
    • getPhysicalDestinationName

      public String getPhysicalDestinationName()
      Specified by:
      getPhysicalDestinationName in interface HasPhysicalDestination
    • getDomain

      public String getDomain()
      Specified by:
      getDomain in interface HasPhysicalDestination
    • getRawMessage

      public RawMessageWrapper<F> getRawMessage(@Nonnull Map<String,Object> threadContext) throws ListenerException
      Description 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, or synchronized.

      Any thread-specific properties should be stored in and retrieved from the threadContext.

      Specified by:
      getRawMessage in interface IPullingListener<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 interface IListener<F>
      Throws:
      ListenerException
    • extractMessage

      public Message extractMessage(@Nonnull RawMessageWrapper<F> rawMessage, @Nonnull Map<String,Object> context) throws ListenerException
      Returns the filename, or the contents
      Specified by:
      extractMessage in interface IListener<F>
      Parameters:
      rawMessage - The RawMessageWrapper from which to extract the Message.
      context - Context to populate. Either a PipeLineSession or a Map 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, and false is returned.
      Specified by:
      changeProcessState in interface IHasProcessState<F>
      Returns:
      the moved message, or null if no message was moved.
      Throws:
      ListenerException
    • getStateFolder

      public String getStateFolder(ProcessState state)
    • getMessageBrowser

      public IMessageBrowser<F> getMessageBrowser(ProcessState state)
      Description copied from interface: IProvidesMessageBrowsers
      returns a browser 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 interface IProvidesMessageBrowsers<F>
    • setName

      public void setName(String name)
      Name of the listener
      Specified by:
      setName in interface NameAware
    • setInputFolder

      public void setInputFolder(String inputFolder)
      Folder that is scanned for files. If not set, the root is scanned
    • setInProcessFolder

      public void setInProcessFolder(String inProcessFolder)
      Folder where files are stored while being processed
    • setProcessedFolder

      public void setProcessedFolder(String processedFolder)
      Folder where files are stored after being processed
    • setErrorFolder

      public void setErrorFolder(String errorFolder)
      Folder where files are stored after being processed, in case the exit-state was not equal to success
    • setHoldFolder

      public void setHoldFolder(String holdFolder)
      Folder where messages from the error folder can be put on Hold, temporarily
    • setLogFolder

      public void setLogFolder(String logFolder)
      Folder where a copy of every file that is received is stored
    • setCreateFolders

      public void setCreateFolders(boolean createFolders)
      If set to true, 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 set true, 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 set true, the destination file will be deleted if it already exists
      Default value
      false
    • setFileTimeSensitive

      public void setFileTimeSensitive(boolean b)
      If true, 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 implement IWritableFileSystem.
      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

      public void setMessageIdPropertyKey(String messageIdPropertyKey)
      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 set true, no browsers for process folders are generated
      Default value
      false
    • setWildcard

      public void setWildcard(String wildcard)
      Filter of files to look for in inputFolder e.g. '*.inp'.
    • setExcludeWildcard

      public void setExcludeWildcard(String excludeWildcard)
      Filter of files to be excluded when looking in inputFolder.
    • setStoreMetadataInSessionKey

      @Deprecated(since="9.0") public void setStoreMetadataInSessionKey(String storeMetadataInSessionKey)
      Deprecated.
      If set, an XML with all message properties is provided under this key. Also stored in the "originalMessage" metadata.
    • setCharset

      public void setCharset(String charset)
      Charset to be used for extracting the contents
    • setMessageType

      protected void setMessageType(AbstractFileSystemListener.IMessageType type)
      Determines the contents of the message that is sent to the pipeline. The value of the attribute matching the searchKey is returned when using ATTRIBUTE
      Default value
      PATH
    • setOutputFormat

      public void setOutputFormat(DocumentFormat outputFormat)
      OutputFormat of message for messageType=info
      Default value
      XML