Package com.gigaspaces.security.fs
Class LocalFileService
java.lang.Object
com.gigaspaces.security.fs.LocalFileService
- All Implemented Interfaces:
FileService
A
FileService responsible for reading and writing to a file on the local file-system. The
file path can be specified by providing a FILE_PATH_PROPERTY_KEY property, or defaults
to FILE_PATH_DEFAULT_VAL if none was specified. The file-path property
can be either a direct path to a file, or resource in the classpath.
- Since:
- 7.0.1
- Author:
- Moran Avigdor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default value of the file-path is non was specifiedstatic final StringThe property key identifying the security fileFields inherited from interface com.gigaspaces.security.fs.FileService
FILE_SERVICE_CLASS_PROPERTY_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks the existence of the filevoidinit(Properties properties) Initialize theFileServiceimplementation with the properties supplied to theSecurityManager.longThe last time the file was modified.byte[]Reads from a file, returning a byte array representation of the contents.voidwriteToFile(byte[] bytes) Write to a file a byte array representation of the contents.
-
Field Details
-
FILE_PATH_PROPERTY_KEY
The property key identifying the security file- See Also:
-
FILE_PATH_DEFAULT_VAL
The default value of the file-path is non was specified- See Also:
-
-
Constructor Details
-
LocalFileService
public LocalFileService()
-
-
Method Details
-
init
Description copied from interface:FileServiceInitialize theFileServiceimplementation with the properties supplied to theSecurityManager.- Specified by:
initin interfaceFileService- Throws:
IOException
-
fileExists
public boolean fileExists()Description copied from interface:FileServiceChecks the existence of the file- Specified by:
fileExistsin interfaceFileService- Returns:
trueif and only if the file exists;falseotherwise.
-
readFromFile
Description copied from interface:FileServiceReads from a file, returning a byte array representation of the contents.- Specified by:
readFromFilein interfaceFileService- Returns:
- a file as a byte array.
- Throws:
IOException- If any exception occurred while reading from a file.
-
writeToFile
Description copied from interface:FileServiceWrite to a file a byte array representation of the contents.- Specified by:
writeToFilein interfaceFileService- Parameters:
bytes- contents as a byte array.- Throws:
IOException- If any exception occurred while writing to a file.
-
lastModified
public long lastModified()Description copied from interface:FileServiceThe last time the file was modified. This serves as an indication for refreshing internal cache of the file contents. By comparing the last saved modification time and the current modification time.-1should be returned to force a refresh. Same value should be returned to avoid a refresh.- Specified by:
lastModifiedin interfaceFileService- Returns:
- A
longvalue representing the time the file was last modified.
-