public class ModifiableFileWatcher extends AbstractLoggingBean
| Modifier and Type | Field and Description |
|---|---|
protected LinkOption[] |
options |
static Set<PosixFilePermission> |
STRICTLY_PROHIBITED_FILE_PERMISSION
The
Set of PosixFilePermission not allowed if strict permissions are enforced on key files |
log| Constructor and Description |
|---|
ModifiableFileWatcher(Path file) |
ModifiableFileWatcher(Path file,
LinkOption... options) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkReloadRequired() |
boolean |
exists() |
Path |
getPath() |
FileTime |
lastModified() |
void |
resetReloadAttributes()
Resets the state attributes used to detect changes to the initial construction values - i.e., file assumed not to
exist and no known size of modify time
|
long |
size() |
PathResource |
toPathResource() |
PathResource |
toPathResource(OpenOption... options) |
String |
toString() |
void |
updateReloadAttributes()
May be called to refresh the state attributes used to detect changes e.g., file existence, size and last-modified
time once re-loading is successfully completed.
|
static AbstractMap.SimpleImmutableEntry<String,Object> |
validateStrictConfigFilePermissions(Path path,
LinkOption... options)
Checks if a path has strict permissions
|
getSimplifiedLoggerpublic static final Set<PosixFilePermission> STRICTLY_PROHIBITED_FILE_PERMISSION
Set of PosixFilePermission not allowed if strict permissions are enforced on key filesprotected final LinkOption[] options
public ModifiableFileWatcher(Path file)
public ModifiableFileWatcher(Path file, LinkOption... options)
public final boolean exists()
throws IOException
IOExceptionpublic final long size()
throws IOException
IOExceptionpublic final FileTime lastModified() throws IOException
IOExceptionpublic boolean checkReloadRequired()
throws IOException
true if the watched file has probably been changedIOException - If failed to query file datapublic void resetReloadAttributes()
public void updateReloadAttributes()
throws IOException
IOException - If failed to access the file (if exists)resetReloadAttributes()public PathResource toPathResource()
public PathResource toPathResource(OpenOption... options)
public static AbstractMap.SimpleImmutableEntry<String,Object> validateStrictConfigFilePermissions(Path path, LinkOption... options) throws IOException
Checks if a path has strict permissions
(For Unix) The path may not have group or others write permissions
The path must be owned by current user.
(For Unix) The path may be owned by root.
path - The Path to be checked - ignored if null or does not existoptions - The LinkOptions to use to query the file's permissionsAbstractMap.SimpleImmutableEntry where key is a loggable message and
value is the offending object - e.g., PosixFilePermission or String for
owner. Return value is null if no violations detectedIOException - If failed to retrieve the permissionsSTRICTLY_PROHIBITED_FILE_PERMISSIONCopyright © 2018–2020 The Apache Software Foundation. All rights reserved.