Package fr.dyade.aaa.util
Class NullTransaction
- java.lang.Object
-
- fr.dyade.aaa.util.BaseTransaction
-
- fr.dyade.aaa.util.NullTransaction
-
- All Implemented Interfaces:
NullTransactionMBean,Transaction,TransactionMBean
public final class NullTransaction extends BaseTransaction implements NullTransactionMBean
-
-
Field Summary
Fields Modifier and Type Field Description private intcommitCountNumber of commit operation since starting up.protected intphaseprotected longstartTime-
Fields inherited from class fr.dyade.aaa.util.BaseTransaction
DEBUG, logmon
-
-
Constructor Summary
Constructors Constructor Description NullTransaction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringbackup(String path)Backups the content of Transaction module.voidbegin()Start a transaction validation, the validation phase needs 3 phases: begin, commit and release.voidclose()Close the transaction module.voidcommit(boolean release)Commit the current transaction.booleancontainsOperations()Indicates whether some operations have been done in this transaction.voidcreate(Serializable obj, String name)Register the state of a newly created object in the current transaction.voidcreate(Serializable obj, String dirName, String name)Register the state of a newly created object in the current transaction.voidcreateByteArray(byte[] buf, String name)Register a new byte array in the current transaction.voidcreateByteArray(byte[] buf, String dirName, String name)Register a new byte array in the current transaction.voiddelete(String name)Deletes the specified object.voiddelete(String dirName, String name)Deletes the specified object.intgetCommitCount()Returns the number of commit operation since starting up.FilegetDir()String[]getList(String prefix)Returns an array of strings naming the objects in the component started by this prefix.intgetOperationCount()Returns the number of operations to be committed.StringgetPersistenceDir()Returns the path of persistence directory.intgetPhase()Returns the transaction state.StringgetPhaseInfo()Returns a string representation of the transaction state.longgetStartTime()Returns the starting time.voidinit(String path)Initializes the atomic storage component.booleanisPersistent()Tests if the Transaction component is persistent.Objectload(String name)Load the specified object.Objectload(String dirName, String name)Load the specified object.voidloadAll(String prefix, Map map)Fills the map with all objects of the component whose name begins with the prefix.byte[]loadByteArray(String name)Load the specified byte array.byte[]loadByteArray(String dirName, String name)Load the specified byte array.voidrelease()Release the mutual exclusion.voidsave(Serializable obj, String name)Register the modified state of an object in the current transaction.voidsave(Serializable obj, String dirName, String name)Register the modified state of an object in the current transaction.voidsave(Serializable obj, String dirName, String name, boolean first)Register the state of an object in the current transaction.voidsaveByteArray(byte[] buf, String name)Register a modified byte array in the current transaction.voidsaveByteArray(byte[] buf, String dirName, String name)Register a modified byte array in the current transaction.voidsaveByteArray(byte[] buf, String dirName, String name, boolean copy, boolean first)Register a modified byte array in the current transaction.protected voidsetPhase(int newPhase)voidstop()Stops the transaction module.booleanuseLoadAll()Returns true if this Transaction implementation implements an optimized loadAll method.-
Methods inherited from class fr.dyade.aaa.util.BaseTransaction
dumpObjectList, freeze, getBoolean, getInteger, getInteger, getObject, getObjectList, getProperty, getProperty, loadProperties, saveProperties
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface fr.dyade.aaa.util.TransactionMBean
dumpObjectList, getObject, getObjectList
-
-
-
-
Method Detail
-
getStartTime
public long getStartTime()
Returns the starting time.- Specified by:
getStartTimein interfaceTransactionMBean- Returns:
- The starting time.
-
getPhase
public final int getPhase()
Description copied from interface:TransactionMBeanReturns the transaction state.- Specified by:
getPhasein interfaceTransaction- Specified by:
getPhasein interfaceTransactionMBean- Returns:
- the transaction state.
-
getPhaseInfo
public final String getPhaseInfo()
Description copied from interface:TransactionMBeanReturns a string representation of the transaction state.- Specified by:
getPhaseInfoin interfaceTransaction- Specified by:
getPhaseInfoin interfaceTransactionMBean- Returns:
- the string representation of the transaction state.
-
setPhase
protected final void setPhase(int newPhase)
-
getCommitCount
public final int getCommitCount()
Returns the number of commit operation since starting up.- Specified by:
getCommitCountin interfaceTransaction- Specified by:
getCommitCountin interfaceTransactionMBean- Returns:
- The number of commit operation.
-
isPersistent
public boolean isPersistent()
Tests if the Transaction component is persistent.- Specified by:
isPersistentin interfaceTransaction- Specified by:
isPersistentin interfaceTransactionMBean- Returns:
- false.
-
init
public void init(String path) throws IOException
Description copied from interface:TransactionInitializes the atomic storage component.- Specified by:
initin interfaceTransaction- Parameters:
path- the path of storage directory.- Throws:
IOException- an error occurs.
-
getDir
public File getDir()
-
getPersistenceDir
public String getPersistenceDir()
Returns the path of persistence directory.- Returns:
- null.
-
begin
public final void begin() throws IOExceptionDescription copied from interface:TransactionStart a transaction validation, the validation phase needs 3 phases: begin, commit and release. The begin ensure the mutual exclusion of the current transaction.- Specified by:
beginin interfaceTransaction- Throws:
IOException- an error occurs.
-
getList
public String[] getList(String prefix)
Description copied from interface:TransactionReturns an array of strings naming the objects in the component started by this prefix.- Specified by:
getListin interfaceTransaction- Parameters:
prefix- the prefix of searched objects.- Returns:
- an array of strings naming the objects in the component started by this prefix.
-
useLoadAll
public boolean useLoadAll()
Description copied from interface:TransactionMBeanReturns true if this Transaction implementation implements an optimized loadAll method.- Specified by:
useLoadAllin interfaceTransaction- Specified by:
useLoadAllin interfaceTransactionMBean- Returns:
- true if this Transaction implementation implements an optimized loadAll method.
-
loadAll
public void loadAll(String prefix, Map map)
Description copied from interface:TransactionFills the map with all objects of the component whose name begins with the prefix. Each loaded object is registered in the map with its persistent name as key.- Specified by:
loadAllin interfaceTransaction- Parameters:
prefix- The prefix of searched objects.map- The map of corresponding objects.
-
create
public final void create(Serializable obj, String name) throws IOException
Description copied from interface:TransactionRegister the state of a newly created object in the current transaction.- Specified by:
createin interfaceTransaction- Parameters:
obj- the object to store.name- the name of the object.- Throws:
IOException- an error occurs.
-
create
public final void create(Serializable obj, String dirName, String name) throws IOException
Description copied from interface:TransactionRegister the state of a newly created object in the current transaction.- Specified by:
createin interfaceTransaction- Parameters:
obj- the object to store.dirName- the directory name of the object.name- the name of the object.- Throws:
IOException- an error occurs.
-
save
public final void save(Serializable obj, String name) throws IOException
Description copied from interface:TransactionRegister the modified state of an object in the current transaction.- Specified by:
savein interfaceTransaction- Parameters:
obj- the object to store.name- the name of the object.- Throws:
IOException- an error occurs.
-
save
public final void save(Serializable obj, String dirName, String name) throws IOException
Description copied from interface:TransactionRegister the modified state of an object in the current transaction.- Specified by:
savein interfaceTransaction- Parameters:
obj- the object to store.dirName- the directory name of the object.name- the name of the object.- Throws:
IOException- an error occurs.
-
save
public void save(Serializable obj, String dirName, String name, boolean first) throws IOException
Description copied from interface:TransactionRegister the state of an object in the current transaction.- Specified by:
savein interfaceTransaction- Parameters:
obj- the object to store.dirName- the directory name of the object.name- the name of the object.first- the object is a new one.- Throws:
IOException- an error occurs.
-
createByteArray
public final void createByteArray(byte[] buf, String name) throws IOExceptionDescription copied from interface:TransactionRegister a new byte array in the current transaction.- Specified by:
createByteArrayin interfaceTransaction- Parameters:
buf- the byte array to store.name- the name of the object.- Throws:
IOException- an error occurs.
-
createByteArray
public final void createByteArray(byte[] buf, String dirName, String name) throws IOExceptionDescription copied from interface:TransactionRegister a new byte array in the current transaction.- Specified by:
createByteArrayin interfaceTransaction- Parameters:
buf- the byte array to store.dirName- the directory name of the object.name- the name of the object.- Throws:
IOException- an error occurs.
-
saveByteArray
public final void saveByteArray(byte[] buf, String name) throws IOExceptionDescription copied from interface:TransactionRegister a modified byte array in the current transaction.- Specified by:
saveByteArrayin interfaceTransaction- Parameters:
buf- the byte array to store.name- the name of the object.- Throws:
IOException- an error occurs.
-
saveByteArray
public final void saveByteArray(byte[] buf, String dirName, String name) throws IOExceptionDescription copied from interface:TransactionRegister a modified byte array in the current transaction.- Specified by:
saveByteArrayin interfaceTransaction- Parameters:
buf- the byte array to store.dirName- the directory name of the object.name- the name of the object.- Throws:
IOException- an error occurs.
-
saveByteArray
public void saveByteArray(byte[] buf, String dirName, String name, boolean copy, boolean first) throws IOExceptionDescription copied from interface:TransactionRegister a modified byte array in the current transaction.- Specified by:
saveByteArrayin interfaceTransaction- Parameters:
buf- the byte array to store.dirName- the directory name of the object.name- the name of the object.copy- the byte array can be modified, copy it.first- the object is a new one.- Throws:
IOException- an error occurs.
-
load
public final Object load(String name) throws IOException, ClassNotFoundException
Description copied from interface:TransactionLoad the specified object.- Specified by:
loadin interfaceTransaction- Parameters:
name- the name of the object.- Returns:
- the loaded object.
- Throws:
IOException- an error occurs.ClassNotFoundException- an error occurs.
-
load
public final Object load(String dirName, String name) throws IOException, ClassNotFoundException
Description copied from interface:TransactionLoad the specified object.- Specified by:
loadin interfaceTransaction- Parameters:
dirName- the directory name of the object.name- the name of the object.- Returns:
- the loaded object.
- Throws:
IOException- an error occurs.ClassNotFoundException- an error occurs.
-
loadByteArray
public final byte[] loadByteArray(String name) throws IOException
Description copied from interface:TransactionLoad the specified byte array.- Specified by:
loadByteArrayin interfaceTransaction- Parameters:
name- the name of the object.- Returns:
- the loaded byte array.
- Throws:
IOException- an error occurs.
-
loadByteArray
public byte[] loadByteArray(String dirName, String name) throws IOException
Description copied from interface:TransactionLoad the specified byte array.- Specified by:
loadByteArrayin interfaceTransaction- Parameters:
dirName- the directory name of the object.name- the name of the object.- Returns:
- the loaded byte array.
- Throws:
IOException- an error occurs.
-
delete
public final void delete(String name)
Description copied from interface:TransactionDeletes the specified object.- Specified by:
deletein interfaceTransaction- Parameters:
name- the name of the object.
-
delete
public void delete(String dirName, String name)
Description copied from interface:TransactionDeletes the specified object.- Specified by:
deletein interfaceTransaction- Parameters:
dirName- the directory name of the object.name- the name of the object.
-
commit
public void commit(boolean release) throws IOExceptionDescription copied from interface:TransactionCommit the current transaction.- Specified by:
commitin interfaceTransaction- Parameters:
release- if true releases the transaction at the end of the commit.- Throws:
IOException- an error occurs.
-
release
public void release() throws IOExceptionDescription copied from interface:TransactionRelease the mutual exclusion.- Specified by:
releasein interfaceTransaction- Throws:
IOException- an error occurs.
-
stop
public final void stop()
Description copied from interface:TransactionStops the transaction module. It waits all transactions termination, then the module is kept in a FREE 'ready to use' state.- Specified by:
stopin interfaceTransaction
-
close
public final void close()
Description copied from interface:TransactionClose the transaction module. It waits all transactions termination, the module will be initialized anew before reusing it.- Specified by:
closein interfaceTransaction
-
containsOperations
public boolean containsOperations()
Indicates whether some operations have been done in this transaction.- Specified by:
containsOperationsin interfaceTransaction- Returns:
- true if some operations are waiting for commit in this transaction.
-
getOperationCount
public int getOperationCount()
Returns the number of operations to be committed.- Specified by:
getOperationCountin interfaceTransaction- Returns:
- the number of operations to be committed.
-
backup
public String backup(String path) throws Exception
Backups the content of Transaction module. Produces a generic Backup/Restore file containing all living objects. Currently not implemented, throws an UnsupportedOperationException.- Specified by:
backupin interfaceTransaction- Specified by:
backupin interfaceTransactionMBean- Parameters:
path- Directory path to store the backup.- Returns:
- the name of created backup file.
- Throws:
Exception- An error occurs during backup.
-
-