Class AbstractPathAction

java.lang.Object
org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
org.apache.logging.log4j.core.appender.rolling.action.AbstractPathAction
All Implemented Interfaces:
Runnable, Action
Direct Known Subclasses:
DeleteAction, PosixViewAttributeAction

public abstract class AbstractPathAction extends AbstractAction
Abstract action for processing files that are accepted by the specified PathFilters.
  • Constructor Details

    • AbstractPathAction

      protected AbstractPathAction(String basePath, boolean followSymbolicLinks, int maxDepth, PathCondition[] pathFilters, StrSubstitutor subst)
      Creates a new AbstractPathAction that starts scanning for files to process from the specified base path.
      Parameters:
      basePath - base path from where to start scanning for files to process.
      followSymbolicLinks - whether to follow symbolic links. Default is false.
      maxDepth - The maxDepth parameter is the maximum number of levels of directories to visit. A value of 0 means that only the starting file is visited, unless denied by the security manager. A value of MAX_VALUE may be used to indicate that all levels should be visited.
      pathFilters - an array of path filters (if more than one, they all need to accept a path before it is processed).
  • Method Details

    • execute

      public boolean execute() throws IOException
      Description copied from class: AbstractAction
      Performs action.
      Specified by:
      execute in interface Action
      Specified by:
      execute in class AbstractAction
      Returns:
      true if successful.
      Throws:
      IOException - if IO error.
    • execute

      public boolean execute(FileVisitor<Path> visitor) throws IOException
      Throws:
      IOException
    • createFileVisitor

      protected abstract FileVisitor<Path> createFileVisitor(Path visitorBaseDir, List<PathCondition> conditions)
      Creates a new FileVisitor<Path> to pass to the Files.walkFileTree(Path, Set, int, FileVisitor) method when the execute() method is invoked.

      The visitor is responsible for processing the files it encounters that are accepted by all filters.

      Parameters:
      visitorBaseDir - base dir from where to start scanning for files to process
      conditions - filters that determine if a file should be processed
      Returns:
      a new FileVisitor<Path>
    • getBasePath

      public Path getBasePath()
      Returns the base path from where to start scanning for files to delete. Lookups are resolved, so if the configuration was <Delete basePath="${sys:user.home}/abc" /> then this method returns a path to the "abc" file or directory in the user's home directory.
      Returns:
      the base path (all lookups resolved)
    • getBasePathString

      public String getBasePathString()
      Returns the base path as it was specified in the configuration. Lookups are not resolved.
      Returns:
      the base path as it was specified in the configuration
    • getStrSubstitutor

      public StrSubstitutor getStrSubstitutor()
    • getOptions

      public Set<FileVisitOption> getOptions()
      Returns whether to follow symbolic links or not.
      Returns:
      the options
    • isFollowSymbolicLinks

      public boolean isFollowSymbolicLinks()
      Returns whether to follow symbolic links or not.
      Returns:
      whether to follow symbolic links or not
    • getMaxDepth

      public int getMaxDepth()
      Returns the maximum number of directory levels to visit.
      Returns:
      the maxDepth
    • getPathConditions

      public List<PathCondition> getPathConditions()
      Returns the list of PathCondition objects.
      Returns:
      the pathFilters
    • toString

      public String toString()
      Overrides:
      toString in class Object