Package org.jppf.persistence
Class AbstractFilePersistence<I,E extends Exception>
java.lang.Object
org.jppf.persistence.AbstractFilePersistence<I,E>
- Type Parameters:
I- the type of objects to persist.E- the type of exceptions to raise.
- Direct Known Subclasses:
DefaultFilePersistence,FileLoadBalancerPersistence
Abstract common superclass for file-based persistence implementations.
- Since:
- 6.0
- Author:
- Laurent Cohen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA filter that only matches directories. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractFilePersistence(String... paths) Initialize this persistence with the specified path as root directory. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckDirectory(Path dir) Check the specified directory and create it if it doesn't exist.protected abstract ECreate the appropriate type of exception.protected booleandeleteIfEmpty(Path channelPath) Delete the specified directyory if it is empty.protected PathGet the directory of witht he psecified name directly under the root.protected static booleanisSameFile(Path path1, Path path2) Determines whether two paths denote the same file.protected StringGet the full path name for the file or directory denoted by the specified path.toString()
-
Field Details
-
DEFAULT_EXTENSION
Default extension for the persisted objects files.- See Also:
-
TEMP_EXTENSION
Default extension for temporary files.- See Also:
-
rootPath
The root directory for this persistence.
-
-
Constructor Details
-
AbstractFilePersistence
Initialize this persistence with the specified path as root directory.- Parameters:
paths- the root directory for this persistence.
-
-
Method Details
-
pathname
Get the full path name for the file or directory denoted by the specified path.- Parameters:
path- the path for which to get the full name.- Returns:
- the full path name.
-
checkDirectory
Check the specified directory and create it if it doesn't exist.- Parameters:
dir- the directory to check.- Throws:
E- if any error occurs.
-
deleteIfEmpty
Delete the specified directyory if it is empty.- Parameters:
channelPath- directory path to delete.- Returns:
- true if the directory was deleted, false otherwise.
- Throws:
E- if any error occurs.
-
getSubDir
Get the directory of witht he psecified name directly under the root.- Parameters:
name- the name of the directory to lookup.- Returns:
- a
Pathinstance.
-
toString
-
convertException
Create the appropriate type of exception.- Parameters:
e- the actual exception from which to create the new one.- Returns:
- an exception of type E.
-
isSameFile
Determines whether two paths denote the same file.- Parameters:
path1- the first path to check.path2- the second path to check.- Returns:
trueif the two path represent the same file,falseotherwise.- See Also:
-