Class AbstractPathAction
java.lang.Object
org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
org.apache.logging.log4j.core.appender.rolling.action.AbstractPathAction
- Direct Known Subclasses:
DeleteAction
,PosixViewAttributeAction
Abstract action for processing files that are accepted by the specified PathFilters.
-
Field Summary
Fields inherited from class org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
LOGGER
-
Constructor Summary
ModifierConstructorDescriptionprotected
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. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract FileVisitor<Path>
createFileVisitor
(Path visitorBaseDir, List<PathCondition> conditions) Creates a newFileVisitor<Path>
to pass to theFiles.walkFileTree(Path, Set, int, FileVisitor)
method when theexecute()
method is invoked.boolean
execute()
Performs action.boolean
execute
(FileVisitor<Path> visitor) Returns the base path from where to start scanning for files to delete.Returns the base path as it was specified in the configuration.int
Returns the maximum number of directory levels to visit.Returns whether to follow symbolic links or not.Returns the list of PathCondition objects.boolean
Returns whether to follow symbolic links or not.toString()
Methods inherited from class org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
close, isComplete, isInterrupted, reportException, run
-
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
Description copied from class:AbstractAction
Performs action.- Specified by:
execute
in interfaceAction
- Specified by:
execute
in classAbstractAction
- Returns:
- true if successful.
- Throws:
IOException
- if IO error.
-
execute
- Throws:
IOException
-
createFileVisitor
protected abstract FileVisitor<Path> createFileVisitor(Path visitorBaseDir, List<PathCondition> conditions) Creates a newFileVisitor<Path>
to pass to theFiles.walkFileTree(Path, Set, int, FileVisitor)
method when theexecute()
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 processconditions
- filters that determine if a file should be processed- Returns:
- a new
FileVisitor<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
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
-
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
Returns the list of PathCondition objects.- Returns:
- the pathFilters
-
toString
-