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(File file) |
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() |
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 Pair<String,Object> |
validateStrictConfigFilePermissions(Path path,
LinkOption... options)
Checks if a path has strict permissions
|
public 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(File file)
public ModifiableFileWatcher(Path file)
public ModifiableFileWatcher(Path file, LinkOption... options)
public final boolean exists() throws IOException
IOException
public final long size() throws IOException
IOException
public final FileTime lastModified() throws IOException
IOException
public 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 static Pair<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 LinkOption
s to use to query the file's permissionsPair
first is a message second is
offending object PosixFilePermission
or String
for owner - null
if
no violations detectedIOException
- If failed to retrieve the permissionsSTRICTLY_PROHIBITED_FILE_PERMISSION
Copyright © 2008–2016 The Apache Software Foundation. All rights reserved.