net.sf.joafip.service
Class FilePersistence

java.lang.Object
  extended by net.sf.joafip.service.AbstractFilePersistenceDelegate
      extended by net.sf.joafip.service.FilePersistence
All Implemented Interfaces:
IFilePersistence

@NotStorableClass
public class FilePersistence
extends AbstractFilePersistenceDelegate

manager for file persistence of java object

Author:
luc peuvrier

Field Summary
static int BEST_COMPRESSION
          Compression level for best compression.
static int BEST_SPEED
          Compression level for fastest compression.
static int DEFAULT_COMPRESSION
          Default compression level.
static int NO_COMPRESSION
          Compression level for no compression.
 
Fields inherited from class net.sf.joafip.service.AbstractFilePersistenceDelegate
_log, mutex, store
 
Constructor Summary
FilePersistence(java.io.File path, boolean removeFiles, boolean garbageManagement)
          create a file persistence using proxy for lazy loading
no file cache used, crash safe mode enabled
FilePersistence(java.io.File path, boolean proxyMode, boolean removeFiles, boolean garbageManagement)
          create a file persistence and optionally proxy for lazy loading
no file cache used, crash safe mode enabled
FilePersistence(java.io.File path, boolean proxyMode, boolean removeFiles, int pageSize, int maxPage, boolean garbageManagement, boolean crashSafeMode)
          create a file persistence and optionally proxy for lazy loading
file cache used
FilePersistence(java.io.File path, boolean removeFiles, int pageSize, int maxPage, boolean garbageManagement)
          create a file persistence using proxy for lazy loading
file cache used, crash safe mode enabled
FilePersistence(IHeapDataManager dataManager, boolean proxyMode, boolean removeFiles, boolean garbageManagement)
          create a persistence using a provided data manager and optionaly proxy for lazy loading
FilePersistence(java.lang.String propertiesSetupResourceName, boolean removeFiles)
          create a persistence setup from properties
FilePersistence(java.lang.String pathName, boolean removeFiles, boolean garbageManagement)
          create a file persistence using proxy for lazy loading
no file cache used, crash safe mode enabled
FilePersistence(java.lang.String pathName, boolean proxyMode, boolean removeFiles, boolean garbageManagement)
          create a file persistence and optionally proxy for lazy loading
no file cache used, crash safe mode enabled
FilePersistence(java.lang.String pathName, boolean proxyMode, boolean removeFiles, boolean garbageManagement, boolean crashSafeMode)
          create a file persistence and optionally proxy for lazy loading
no file cache used
FilePersistence(java.lang.String pathName, boolean proxyMode, boolean removeFiles, int pageSize, int maxPage, boolean garbageManagement, boolean crashSafeMode)
          create a file persistence and optionally proxy for lazy loading
file cache used
FilePersistence(java.lang.String pathName, boolean removeFiles, int pageSize, int maxPage, boolean garbageManagement, boolean crashSafeMode)
          create a file persistence using proxy for lazy loading
file cache used
 
Method Summary
protected  void assertNoObjectStored()
          assert there is no object stored
protected  void checkSessionClosed()
           
 void close()
          close ( important to close files )
do not save modification
 DataAccessSession createDataAccessSession()
           
static EnumFileState fileState(java.lang.Exception exception)
          to have the file state give by exception or its primary cause
static java.lang.String getVersion()
           
 boolean isUsed()
          for tests only ( used to check all user thread have ended usage )
static void setIdCount(int idCount)
          for test only
 
Methods inherited from class net.sf.joafip.service.AbstractFilePersistenceDelegate
checkIntegrity, closeStore, copy, disableBackgroundGarbageSweep, enableBackgroundGarbageSweep, freeSize, garbageSweep, getBackupFileName, getChangeFileName, getClassLoader, getNumberOfDataRecord, getNumberOfFreeRecord, getNumberOfGarbageCandidate, getNumberOfModified, getNumberOfToGarbage, getNumberOfVisited, getStorageFileName, numberOfObjectState, openStore, setChangeLogEnabled, setClassLoader, setEnumState, setForceEnhance, setForceEnhance, setGarbageListener, setNoLazyLoad, setNoLazyLoad, setObjectIOForClass, setStore, setStoreNotUseStandardSerialization, setStoreNotUseStandardSerialization, setStoreSerializeAndGZippedInOneRecord, setStoreSerializeAndGZippedInOneRecord, setStoreSerializeAndZippedInOneRecord, setStoreSerializeAndZippedInOneRecord, setStoreSerializeInOneRecord, setStoreSerializeInOneRecord, setSubstitution, setSubstitutionOfJavaUtilCollection, setZipCompressionLevel, storedEnum, storedEnum, storedEnum, storeDoNotSave, storeGetRoot, storeSave, storeSetRoot, totalSize, usedSize, xmlExport, xmlImport
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_COMPRESSION

public static final int NO_COMPRESSION
Compression level for no compression.

See Also:
Constant Field Values

BEST_SPEED

public static final int BEST_SPEED
Compression level for fastest compression.

See Also:
Constant Field Values

BEST_COMPRESSION

public static final int BEST_COMPRESSION
Compression level for best compression.

See Also:
Constant Field Values

DEFAULT_COMPRESSION

public static final int DEFAULT_COMPRESSION
Default compression level.

See Also:
Constant Field Values
Constructor Detail

FilePersistence

public FilePersistence(java.io.File path,
                       boolean removeFiles,
                       boolean garbageManagement)
                throws FilePersistenceException,
                       FilePersistenceInvalidClassException,
                       FilePersistenceNotSerializableException,
                       FilePersistenceClassNotFoundException,
                       FilePersistenceDataCorruptedException
create a file persistence using proxy for lazy loading
no file cache used, crash safe mode enabled

Parameters:
path - directory path where store files
removeFiles - true if remove files before open
garbageManagement - true if manage garbage
Throws:
FilePersistenceException - no file in stable state, file state restored to stable, file persistence is not opened
FilePersistenceNotSerializableException - Some object to be serialized does not follow joafip persistence rules or does not implement the java.io.Serializable interface.
FilePersistenceInvalidClassException - something is wrong with a class used by serialization
FilePersistenceDataCorruptedException - data is inconsistent.
FilePersistenceClassNotFoundException - Class of a serialized object cannot be found.

FilePersistence

public FilePersistence(java.lang.String pathName,
                       boolean removeFiles,
                       boolean garbageManagement)
                throws FilePersistenceException,
                       FilePersistenceInvalidClassException,
                       FilePersistenceNotSerializableException,
                       FilePersistenceClassNotFoundException,
                       FilePersistenceDataCorruptedException
create a file persistence using proxy for lazy loading
no file cache used, crash safe mode enabled

Parameters:
pathName - directory path name where store files
removeFiles - true if remove files before open
garbageManagement - true if manage garbage
Throws:
FilePersistenceException - no file in stable state, file state restored to stable, file persistence is not opened
FilePersistenceNotSerializableException - Some object to be serialized does not follow joafip persistence rules or does not implement the java.io.Serializable interface.
FilePersistenceInvalidClassException - something is wrong with a class used by serialization
FilePersistenceDataCorruptedException - data is inconsistent.
FilePersistenceClassNotFoundException - Class of a serialized object cannot be found.

FilePersistence

public FilePersistence(java.io.File path,
                       boolean proxyMode,
                       boolean removeFiles,
                       boolean garbageManagement)
                throws FilePersistenceException,
                       FilePersistenceInvalidClassException,
                       FilePersistenceNotSerializableException,
                       FilePersistenceClassNotFoundException,
                       FilePersistenceDataCorruptedException
create a file persistence and optionally proxy for lazy loading
no file cache used, crash safe mode enabled

Parameters:
path - directory path where store files
removeFiles - true if remove files before open
proxyMode - true if use proxy for lazy loading
removeFiles - true if remove files before open
garbageManagement - true if manage garbage
Throws:
FilePersistenceException - no file in stable state, file state restored to stable, file persistence is not opened
FilePersistenceNotSerializableException - Some object to be serialized does not follow joafip persistence rules or does not implement the java.io.Serializable interface.
FilePersistenceInvalidClassException - something is wrong with a class used by serialization
FilePersistenceDataCorruptedException - data is inconsistent.
FilePersistenceClassNotFoundException - Class of a serialized object cannot be found.

FilePersistence

public FilePersistence(java.lang.String pathName,
                       boolean proxyMode,
                       boolean removeFiles,
                       boolean garbageManagement)
                throws FilePersistenceException,
                       FilePersistenceInvalidClassException,
                       FilePersistenceNotSerializableException,
                       FilePersistenceClassNotFoundException,
                       FilePersistenceDataCorruptedException
create a file persistence and optionally proxy for lazy loading
no file cache used, crash safe mode enabled

Parameters:
pathName - directory path name where store files
removeFiles - true if remove files before open
proxyMode - true if use proxy for lazy loading
removeFiles - true if remove files before open
garbageManagement - true if manage garbage
Throws:
FilePersistenceException - no file in stable state, file state restored to stable, file persistence is not opened
FilePersistenceNotSerializableException - Some object to be serialized does not follow joafip persistence rules or does not implement the java.io.Serializable interface.
FilePersistenceInvalidClassException - something is wrong with a class used by serialization
FilePersistenceDataCorruptedException - data is inconsistent.
FilePersistenceClassNotFoundException - Class of a serialized object cannot be found.

FilePersistence

public FilePersistence(java.lang.String pathName,
                       boolean proxyMode,
                       boolean removeFiles,
                       boolean garbageManagement,
                       boolean crashSafeMode)
                throws FilePersistenceException,
                       FilePersistenceInvalidClassException,
                       FilePersistenceNotSerializableException,
                       FilePersistenceClassNotFoundException,
                       FilePersistenceDataCorruptedException
create a file persistence and optionally proxy for lazy loading
no file cache used

Parameters:
pathName - directory path name where store files
proxyMode - true if use proxy for lazy loading
removeFiles - true if remove files before open
garbageManagement - true if manage garbage
crashSafeMode - true if crash safe mode enabled
Throws:
FilePersistenceException - no file in stable state, file state restored to stable, file persistence is not opened
FilePersistenceNotSerializableException - Some object to be serialized does not follow joafip persistence rules or does not implement the java.io.Serializable interface.
FilePersistenceInvalidClassException - something is wrong with a class used by serialization
FilePersistenceDataCorruptedException - data is inconsistent.
FilePersistenceClassNotFoundException - Class of a serialized object cannot be found.

FilePersistence

public FilePersistence(java.io.File path,
                       boolean removeFiles,
                       int pageSize,
                       int maxPage,
                       boolean garbageManagement)
                throws FilePersistenceException,
                       FilePersistenceInvalidClassException,
                       FilePersistenceNotSerializableException,
                       FilePersistenceClassNotFoundException,
                       FilePersistenceDataCorruptedException
create a file persistence using proxy for lazy loading
file cache used, crash safe mode enabled

Parameters:
path - directory path where store files
removeFiles - true if remove files before open
pageSize - page size ( number of byte ), must be greater or equals to 1024
maxPage - maximum number of page for read cache
garbageManagement - true if manage garbage
Throws:
FilePersistenceException - no file in stable state, file state restored to stable, file persistence is not opened
FilePersistenceNotSerializableException - Some object to be serialized does not follow joafip persistence rules or does not implement the java.io.Serializable interface.
FilePersistenceInvalidClassException - something is wrong with a class used by serialization
FilePersistenceDataCorruptedException - data is inconsistent.
FilePersistenceClassNotFoundException - Class of a serialized object cannot be found.

FilePersistence

public FilePersistence(java.lang.String pathName,
                       boolean removeFiles,
                       int pageSize,
                       int maxPage,
                       boolean garbageManagement,
                       boolean crashSafeMode)
                throws FilePersistenceException,
                       FilePersistenceInvalidClassException,
                       FilePersistenceNotSerializableException,
                       FilePersistenceClassNotFoundException,
                       FilePersistenceDataCorruptedException
create a file persistence using proxy for lazy loading
file cache used

Parameters:
pathName - directory path name where store files
removeFiles - true if remove files before open
pageSize - page size for read cache ( number of byte ), must be greater or equals to 1024
maxPage - maximum number of page for read cache
garbageManagement - true if manage garbage
crashSafeMode - true if crash safe mode enabled
Throws:
FilePersistenceException - no file in stable state, file state restored to stable, file persistence is not opened
FilePersistenceNotSerializableException - Some object to be serialized does not follow joafip persistence rules or does not implement the java.io.Serializable interface.
FilePersistenceInvalidClassException - something is wrong with a class used by serialization
FilePersistenceDataCorruptedException - data is inconsistent.
FilePersistenceClassNotFoundException - Class of a serialized object cannot be found.

FilePersistence

public FilePersistence(java.io.File path,
                       boolean proxyMode,
                       boolean removeFiles,
                       int pageSize,
                       int maxPage,
                       boolean garbageManagement,
                       boolean crashSafeMode)
                throws FilePersistenceException,
                       FilePersistenceInvalidClassException,
                       FilePersistenceNotSerializableException,
                       FilePersistenceClassNotFoundException,
                       FilePersistenceDataCorruptedException
create a file persistence and optionally proxy for lazy loading
file cache used

Parameters:
path - directory path where store files
proxyMode - true if use proxy for lazy loading
removeFiles - true if remove files before open
pageSize - page size ( number of byte ), must be greater or equals to 1024
maxPage - maximum number of page for read cache
garbageManagement - true if manage garbage
crashSafeMode - true if crash safe mode enabled
Throws:
FilePersistenceException - no file in stable state, file state restored to stable, file persistence is not opened
FilePersistenceNotSerializableException - Some object to be serialized does not follow joafip persistence rules or does not implement the java.io.Serializable interface.
FilePersistenceInvalidClassException - something is wrong with a class used by serialization
FilePersistenceDataCorruptedException - data is inconsistent.
FilePersistenceClassNotFoundException - Class of a serialized object cannot be found.

FilePersistence

public FilePersistence(java.lang.String pathName,
                       boolean proxyMode,
                       boolean removeFiles,
                       int pageSize,
                       int maxPage,
                       boolean garbageManagement,
                       boolean crashSafeMode)
                throws FilePersistenceException,
                       FilePersistenceInvalidClassException,
                       FilePersistenceNotSerializableException,
                       FilePersistenceClassNotFoundException,
                       FilePersistenceDataCorruptedException
create a file persistence and optionally proxy for lazy loading
file cache used

Parameters:
pathName - directory path name where store files
proxyMode - true if use proxy for lazy loading
removeFiles - true if remove files before open
pageSize - page size ( number of byte ), must be greater or equals to 1024
maxPage - maximum number of page for read cache
garbageManagement - true if manage garbage
crashSafeMode - true if crash safe mode enabled
Throws:
FilePersistenceException - no file in stable state, file state restored to stable, file persistence is not opened
FilePersistenceNotSerializableException - Some object to be serialized does not follow joafip persistence rules or does not implement the java.io.Serializable interface.
FilePersistenceInvalidClassException - something is wrong with a class used by serialization
FilePersistenceDataCorruptedException - data is inconsistent.
FilePersistenceClassNotFoundException - Class of a serialized object cannot be found.

FilePersistence

public FilePersistence(IHeapDataManager dataManager,
                       boolean proxyMode,
                       boolean removeFiles,
                       boolean garbageManagement)
                throws FilePersistenceException,
                       FilePersistenceInvalidClassException,
                       FilePersistenceNotSerializableException,
                       FilePersistenceClassNotFoundException,
                       FilePersistenceDataCorruptedException
create a persistence using a provided data manager and optionaly proxy for lazy loading

Parameters:
dataManager - the provided data manager
proxyMode - true if use proxy for lazy loading
removeFiles - true if remove files before open
garbageManagement - true if manage garbage
Throws:
FilePersistenceException
FilePersistenceNotSerializableException - Some object to be serialized does not follow joafip persistence rules or does not implement the java.io.Serializable interface.
FilePersistenceInvalidClassException - something is wrong with a class used by serialization
FilePersistenceDataCorruptedException - data is inconsistent.
FilePersistenceClassNotFoundException - Class of a serialized object cannot be found.

FilePersistence

public FilePersistence(java.lang.String propertiesSetupResourceName,
                       boolean removeFiles)
                throws FilePersistenceException,
                       FilePersistenceInvalidClassException,
                       FilePersistenceNotSerializableException,
                       FilePersistenceClassNotFoundException,
                       FilePersistenceDataCorruptedException
create a persistence setup from properties

Parameters:
propertiesSetupResourceName - properties to use for setup
removeFiles - true if remove files before open
Throws:
FilePersistenceException
FilePersistenceNotSerializableException - Some object to be serialized does not follow joafip persistence rules or does not implement the java.io.Serializable interface.
FilePersistenceInvalidClassException - something is wrong with a class used by serialization
FilePersistenceDataCorruptedException - data is inconsistent.
FilePersistenceClassNotFoundException - Class of a serialized object cannot be found.
Method Detail

getVersion

public static java.lang.String getVersion()
Returns:
version information according to svn revision and location

close

public void close()
           throws FilePersistenceException
Description copied from interface: IFilePersistence
close ( important to close files )
do not save modification

Throws:
FilePersistenceException

createDataAccessSession

public DataAccessSession createDataAccessSession()
                                          throws FilePersistenceException
Returns:
a new created data access session
Throws:
FilePersistenceException

isUsed

@Fortest
public boolean isUsed()
               throws FilePersistenceException
for tests only ( used to check all user thread have ended usage )

Returns:
true if used by at least one data access session
Throws:
FilePersistenceException

checkSessionClosed

protected void checkSessionClosed()
                           throws FilePersistenceException
Specified by:
checkSessionClosed in class AbstractFilePersistenceDelegate
Throws:
FilePersistenceException

fileState

public static EnumFileState fileState(java.lang.Exception exception)
to have the file state give by exception or its primary cause

Parameters:
exception - exception
Returns:
file state for exception

setIdCount

@Fortest
public static void setIdCount(int idCount)
                       throws FilePersistenceException
for test only

Parameters:
idCount -
Throws:
FilePersistenceException

assertNoObjectStored

protected void assertNoObjectStored()
                             throws FilePersistenceException,
                                    FilePersistenceClassNotFoundException,
                                    FilePersistenceInvalidClassException,
                                    FilePersistenceDataCorruptedException,
                                    FilePersistenceNotSerializableException
Description copied from class: AbstractFilePersistenceDelegate
assert there is no object stored

Specified by:
assertNoObjectStored in class AbstractFilePersistenceDelegate
Throws:
FilePersistenceException
FilePersistenceClassNotFoundException
FilePersistenceInvalidClassException
FilePersistenceDataCorruptedException
FilePersistenceNotSerializableException


Copyright © 2007-2009 Luc Peuvrier. All Rights Reserved.