Package fr.dyade.aaa.util
Interface Transaction
-
- All Known Implementing Classes:
AbstractTransaction,ATransaction,BaseTransaction,DBTransaction,DerbyDBTransaction,JDBCTransaction,JTransaction,NGTransaction,NTransaction,NullTransaction
public interface TransactionThe Transaction interface defines the API of the atomic storage component.
-
-
Method Summary
All Methods Instance Methods Abstract 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.StringdumpObjectList(String prefix)voidfreeze(long timeout)booleangetBoolean(String key)Returnstrueif and only if the corresponding property exists and is equal to the string"true".intgetCommitCount()Returns the number of commit operation since startup.IntegergetInteger(String key)Determines the integer value of the property with the specified name.IntegergetInteger(String key, int value)Determines the integer value of the property with the specified name.String[]getList(String prefix)Returns an array of strings naming the objects in the component started by this prefix.StringgetObject(String dirname, String name)String[]getObjectList(String prefix)intgetOperationCount()Returns the number of operations to be committed.intgetPhase()Returns the transaction state.StringgetPhaseInfo()Returns a string representation of the transaction state.StringgetProperty(String key)Searches for the property with the specified key in the specific Transaction property list.StringgetProperty(String key, String defaultValue)Searches for the property with the specified key in the specific Transaction property list.voidinit(String path)Initializes the atomic storage component.booleanisPersistent()Returns true if the 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.voidstop()Stops the transaction module.booleanuseLoadAll()Returns true if this Transaction implementation implements an optimized loadAll method.
-
-
-
Field Detail
-
INIT
static final int INIT
- See Also:
- Constant Field Values
-
FREE
static final int FREE
- See Also:
- Constant Field Values
-
RUN
static final int RUN
- See Also:
- Constant Field Values
-
COMMIT
static final int COMMIT
- See Also:
- Constant Field Values
-
ROLLBACK
static final int ROLLBACK
- See Also:
- Constant Field Values
-
GARBAGE
static final int GARBAGE
- See Also:
- Constant Field Values
-
FINALIZE
static final int FINALIZE
- See Also:
- Constant Field Values
-
BACKUP
static final int BACKUP
- See Also:
- Constant Field Values
-
PhaseInfo
static final String[] PhaseInfo
-
Kb
static final int Kb
- See Also:
- Constant Field Values
-
Mb
static final int Mb
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
void init(String path) throws IOException
Initializes the atomic storage component.- Parameters:
path- the path of storage directory.- Throws:
IOException- an error occurs.
-
getProperty
String getProperty(String key)
Searches for the property with the specified key in the specific Transaction property list. If the key is not found in this property list, the Configuration property list is then checked. The method returnsnullif the property is not found.- Parameters:
key- the property key.- Returns:
- the value corresponding to the specified key value.
-
getProperty
String getProperty(String key, String defaultValue)
Searches for the property with the specified key in the specific Transaction property list. If the key is not found in this property list, the Configuration property list is then checked. The method returns the default value argument if the property is not found.- Parameters:
key- the property key.defaultValue- a default value.- Returns:
- the value corresponding to the specified key value.
-
getInteger
Integer getInteger(String key)
Determines the integer value of the property with the specified name.- Parameters:
key- property name.- Returns:
- the Integer value of the property.
-
getInteger
Integer getInteger(String key, int value)
Determines the integer value of the property with the specified name.- Parameters:
key- property name.value- a default value.- Returns:
- the Integer value of the property.
-
getBoolean
boolean getBoolean(String key)
Returnstrueif and only if the corresponding property exists and is equal to the string"true".- Parameters:
key- the property name.- Returns:
- the
booleanvalue of the property.
-
getPhase
int getPhase()
Returns the transaction state.- Returns:
- the transaction state.
-
getPhaseInfo
String getPhaseInfo()
Returns a string representation of the transaction state.- Returns:
- the string representation of the transaction state.
-
getCommitCount
int getCommitCount()
Returns the number of commit operation since startup.- Returns:
- The number of commit operation.
-
begin
void begin() throws IOExceptionStart a transaction validation, the validation phase needs 3 phases: begin, commit and release. The begin ensure the mutual exclusion of the current transaction.- Throws:
IOException- an error occurs.
-
getList
String[] getList(String prefix)
Returns an array of strings naming the objects in the component started by this prefix.- Parameters:
prefix- the prefix of searched objects.- Returns:
- an array of strings naming the objects in the component started by this prefix.
-
useLoadAll
boolean useLoadAll()
Returns true if this Transaction implementation implements an optimized loadAll method.- Returns:
- true if this Transaction implementation implements an optimized loadAll method.
-
loadAll
void loadAll(String prefix, Map map)
Fills 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.- Parameters:
prefix- The prefix of searched objects.map- The map of corresponding objects.
-
isPersistent
boolean isPersistent()
Returns true if the component is persistent.- Returns:
- true if the component is persistent.
-
create
void create(Serializable obj, String name) throws IOException
Register the state of a newly created object in the current transaction.- Parameters:
obj- the object to store.name- the name of the object.- Throws:
IOException- an error occurs.
-
create
void create(Serializable obj, String dirName, String name) throws IOException
Register the state of a newly created object in the current transaction.- 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
void save(Serializable obj, String name) throws IOException
Register the modified state of an object in the current transaction.- Parameters:
obj- the object to store.name- the name of the object.- Throws:
IOException- an error occurs.
-
save
void save(Serializable obj, String dirName, String name) throws IOException
Register the modified state of an object in the current transaction.- 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
void save(Serializable obj, String dirName, String name, boolean first) throws IOException
Register the state of an object in the current transaction.- 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
void createByteArray(byte[] buf, String name) throws IOExceptionRegister a new byte array in the current transaction.- Parameters:
buf- the byte array to store.name- the name of the object.- Throws:
IOException- an error occurs.
-
createByteArray
void createByteArray(byte[] buf, String dirName, String name) throws IOExceptionRegister a new byte array in the current transaction.- 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
void saveByteArray(byte[] buf, String name) throws IOExceptionRegister a modified byte array in the current transaction.- Parameters:
buf- the byte array to store.name- the name of the object.- Throws:
IOException- an error occurs.
-
saveByteArray
void saveByteArray(byte[] buf, String dirName, String name) throws IOExceptionRegister a modified byte array in the current transaction.- 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
void saveByteArray(byte[] buf, String dirName, String name, boolean copy, boolean first) throws IOExceptionRegister a modified byte array in the current transaction.- 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
Object load(String name) throws IOException, ClassNotFoundException
Load the specified object.- Parameters:
name- the name of the object.- Returns:
- the loaded object.
- Throws:
IOException- an error occurs.ClassNotFoundException- an error occurs.
-
load
Object load(String dirName, String name) throws IOException, ClassNotFoundException
Load the specified object.- 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
byte[] loadByteArray(String name) throws IOException, ClassNotFoundException
Load the specified byte array.- Parameters:
name- the name of the object.- Returns:
- the loaded byte array.
- Throws:
IOException- an error occurs.ClassNotFoundException- an error occurs.
-
loadByteArray
byte[] loadByteArray(String dirName, String name) throws IOException
Load the specified byte array.- 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
void delete(String name)
Deletes the specified object.- Parameters:
name- the name of the object.
-
delete
void delete(String dirName, String name)
Deletes the specified object.- Parameters:
dirName- the directory name of the object.name- the name of the object.
-
commit
void commit(boolean release) throws IOExceptionCommit the current transaction.- Parameters:
release- if true releases the transaction at the end of the commit.- Throws:
IOException- an error occurs.
-
release
void release() throws IOExceptionRelease the mutual exclusion.- Throws:
IOException- an error occurs.
-
stop
void stop()
Stops the transaction module. It waits all transactions termination, then the module is kept in a FREE 'ready to use' state.
-
close
void close()
Close the transaction module. It waits all transactions termination, the module will be initialized anew before reusing it.
-
containsOperations
boolean containsOperations()
Indicates whether some operations have been done in this transaction.- Returns:
- true if some operations are waiting for commit in this transaction.
-
getOperationCount
int getOperationCount()
Returns the number of operations to be committed.- Returns:
- the number of operations to be committed.
-
backup
String backup(String path) throws Exception
Backups the content of Transaction module. Produces a generic Backup/Restore file containing all living objects.- Parameters:
path- Directory path to store the backup.- Returns:
- the name of created backup file.
- Throws:
Exception- An error occurs during backup.
-
freeze
void freeze(long timeout) throws InterruptedException- Throws:
InterruptedException
-
-