GigaSpaces XAP 7.0 API

com.gigaspaces.security.fs
Class LocalFileService

java.lang.Object
  extended by com.gigaspaces.security.fs.LocalFileService
All Implemented Interfaces:
FileService

public class LocalFileService
extends Object
implements 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
static String FILE_PATH_DEFAULT_VAL
          The default value of the file-path is non was specified
static String FILE_PATH_PROPERTY_KEY
          The property key identifying the security file
 
Fields inherited from interface com.gigaspaces.security.fs.FileService
FILE_SERVICE_CLASS_PROPERTY_KEY
 
Constructor Summary
LocalFileService()
           
 
Method Summary
 boolean fileExists()
          Checks the existence of the file
 void init(Properties properties)
          Initialize the FileService implementation with the properties supplied to the SecurityManager.
 long lastModified()
          The last time the file was modified.
 byte[] readFromFile()
          Reads from a file, returning a byte array representation of the contents.
 void writeToFile(byte[] bytes)
          Write to a file a byte array representation of the contents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_PATH_PROPERTY_KEY

public static final String FILE_PATH_PROPERTY_KEY
The property key identifying the security file

See Also:
Constant Field Values

FILE_PATH_DEFAULT_VAL

public static final String FILE_PATH_DEFAULT_VAL
The default value of the file-path is non was specified

See Also:
Constant Field Values
Constructor Detail

LocalFileService

public LocalFileService()
Method Detail

init

public void init(Properties properties)
          throws IOException
Description copied from interface: FileService
Initialize the FileService implementation with the properties supplied to the SecurityManager.

Specified by:
init in interface FileService
Throws:
IOException

fileExists

public boolean fileExists()
Description copied from interface: FileService
Checks the existence of the file

Specified by:
fileExists in interface FileService
Returns:
true if and only if the file exists; false otherwise.

readFromFile

public byte[] readFromFile()
                    throws IOException
Description copied from interface: FileService
Reads from a file, returning a byte array representation of the contents.

Specified by:
readFromFile in interface FileService
Returns:
a file as a byte array.
Throws:
IOException - If any exception occurred while reading from a file.

writeToFile

public void writeToFile(byte[] bytes)
                 throws IOException
Description copied from interface: FileService
Write to a file a byte array representation of the contents.

Specified by:
writeToFile in interface FileService
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: FileService
The 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. -1 should be returned to force a refresh. Same value should be returned to avoid a refresh.

Specified by:
lastModified in interface FileService
Returns:
A long value representing the time the file was last modified.

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.