Class FileMarkHandler

    • Field Detail

      • CONF_IS_CRITICAL

        public static final String CONF_IS_CRITICAL
        Configuration key: Whether the event handler is critical and problems handling the event should abort all handling of the current event.
        See Also:
        Constant Field Values
      • CONF_HANDLE_CONSUMED

        public static final String CONF_HANDLE_CONSUMED
        Configuration key for whether this handler should also handle files of which the corresponding file event has been consumed.
        See Also:
        Constant Field Values
      • HANDLE_CONSUMED

        protected final boolean HANDLE_CONSUMED
        Whether this handler should also handle files of which the corresponding file event has been consumed.
      • CONF_DELETE_FILE

        public static final String CONF_DELETE_FILE
        Configuration key for whether to delete files from file events.
        See Also:
        Constant Field Values
      • DELETE_FILE

        protected final boolean DELETE_FILE
        Whether to delete the files from file events.
      • CONF_RENAME_FILE

        public static final String CONF_RENAME_FILE
        Configuration key for whether to rename files from file events.
        See Also:
        Constant Field Values
      • CONF_TARGET_NAME

        public static final String CONF_TARGET_NAME
        Configuration key for how to set the new name for files from file events. This will only apply if the file should be renamed.
        See Also:
        Constant Field Values
      • RENAME_FILE

        protected final boolean RENAME_FILE
        Whether to rename the files from file events.
      • TARGET_NAME

        protected final String TARGET_NAME
        The name or the pattern of the name the file should be renamed to or the names of the lock files. A '*' wildcard which will be replaced by the current file name.
      • CONF_ADD_FILE

        public static final String CONF_ADD_FILE
        Configuration key for whether to add lock files for files from file events.
        See Also:
        Constant Field Values
      • ADD_FILE

        protected final boolean ADD_FILE
        Whether to add a lock file for files from file events.
      • CONF_MOVE_FILE

        public static final String CONF_MOVE_FILE
        Configuration key for whether to move files from file events.
        See Also:
        Constant Field Values
      • CONF_TARGET_FOLDER

        public static final String CONF_TARGET_FOLDER
        Configuration key for the name of the target folder in case the files of file events should be moved. This will only apply if the files from file events should be moved.
        See Also:
        Constant Field Values
      • MOVE_FILE

        protected final boolean MOVE_FILE
        Whether to move the files from file events.
      • TARGET_FOLDER

        protected final String TARGET_FOLDER
        The name of the target folder in case the files from file events should be moved.
      • CONF_REPLACE_EXISTING

        public static final String CONF_REPLACE_EXISTING
        Configuration key for whether to replace an existing target file or a file in the target folder. This applies to renaming and moving.
        See Also:
        Constant Field Values
      • REPLACE_EXISTING

        protected final boolean REPLACE_EXISTING
        Whether to replace an existing target file or a file in the target folder. This applies to renaming and moving.
      • CONF_MARK_LOCK_FILE

        public static final String CONF_MARK_LOCK_FILE
        Configuration key for whether to mark the lock file or the data file.
        See Also:
        Constant Field Values
      • MARK_LOCK_FILE

        protected final boolean MARK_LOCK_FILE
        Whether the original file or the lock file should be marked.
    • Constructor Detail

      • FileMarkHandler

        public FileMarkHandler​(org.apache.commons.configuration2.Configuration conf,
                               EventManager eventManager,
                               Registry registry)
                        throws ConfigurationException
        Default constructor for a plugin of an EventManager called by a service registry. This constructor just reads the configuration values.
        Parameters:
        conf - The configuration as provided from the registry.
        eventManager - The event manager this event handler is a plugin of.
        registry - The registry of this plugin.
        Throws:
        ConfigurationException - If there are problems with the configuration a ConfigurationException will be thrown.
    • Method Detail

      • handleEvent

        public boolean handleEvent​(Event eve,
                                   boolean consumed)
                            throws EventHandlingException
        Description copied from interface: EventHandler
        This method actually processes an event. What is done depends on the implementation of the event handler. Some restrictions may apply depending on the produced event. Only events will be received for which the event handler is registered. However, to improve robustness, an event handler should check the event before processing. If it cannot handle the provided event, this method should just return.
        Event handling is usually synchronously, that is, this method will only be executed by one thread at a time. If another event of the same type occurs while still handling the previous event, the second event will be suspended until the previous event has been completely handled. There is no need to start a separate thread while handling to improve performance. But it is not forbidden to do so. Handling that takes place in a new thread is not exclusive any more and therefore must not consume the event!
        Parameters:
        eve - The event that occurred and for which this event handler is registered.
        consumed - Whether the event has been consumed by a previous event handler.
        Returns:
        Whether the event has been consumed (that is changed) while handling it. If the event has been consumed before the current handing, it will have to remain consumed (implementations must return true).
        Throws:
        EventHandlingException - If there have been problems handling the event, an EventHandlingException may be thrown. If this is critical, the event handling for the current event will stop. If it is non-critical, other event handlers will also get the event for handling it.
        If event handling fails, the corresponding event handler needs to roll back its changes, especially a consuming event handler.
      • markFile

        protected Triple<Boolean,​File,​Boolean> markFile​(FileEvent eve,
                                                                    boolean consumed)
                                                             throws EventHandlingException
        Extracted from handleEvent(Event, boolean) so that it could be extended with the destination file, i.e. the file the source was renamed or moved to.
        Parameters:
        eve - The event that occurred and for which this event handler is registered.
        consumed - Whether the event has been consumed by a previous event handler.
        Returns:
        Whether the event has been consumed (that is changed) while handling it plus the new file that was created/changed while handling (or null for a deleted file). This new file could be used as input parameter for the instance start event handler. The third element indicates whether the marked file is the lock file.
        Throws:
        EventHandlingException - If there have been problems handling the event, an EventHandlingException may be thrown.