|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfr.dyade.aaa.util.AbstractTransaction
public abstract class AbstractTransaction
The AbstractTransaction class implements the common part of the Transaction Transaction interface. A transaction implementation only needs to define several methods: saveInLog, loadByteArray, delete and commit.
Transaction
Nested Class Summary | |
---|---|
protected class |
AbstractTransaction.Context
|
Field Summary | |
---|---|
protected static byte[] |
OOS_STREAM_HEADER
The OOS_STREAM_HEADER allows to reset an ObjectOutputStream built on top of a ByteArrayOutputStream. |
protected java.lang.ThreadLocal |
perThreadContext
ThreadLocal variable used to get the log to associate state with each thread. |
protected int |
phase
|
Fields inherited from interface fr.dyade.aaa.util.Transaction |
---|
COMMIT, FINALIZE, FREE, GARBAGE, INIT, Kb, Mb, PhaseInfo, ROLLBACK, RUN |
Constructor Summary | |
---|---|
AbstractTransaction()
|
Method Summary | |
---|---|
void |
begin()
Start a transaction validation, the validation phase needs 3 phases: begin, commit and release. |
void |
create(java.io.Serializable obj,
java.lang.String name)
Register the state of a newly created object in the current transaction. |
void |
create(java.io.Serializable obj,
java.lang.String dirName,
java.lang.String name)
Register the state of a newly created object in the current transaction. |
void |
createByteArray(byte[] buf,
java.lang.String name)
Register a new byte array in the current transaction. |
void |
createByteArray(byte[] buf,
java.lang.String dirName,
java.lang.String name)
Register a new byte array in the current transaction. |
void |
delete(java.lang.String name)
Deletes the specified object. |
int |
getPhase()
Returns the transaction state. |
java.lang.String |
getPhaseInfo()
Returns a string representation of the transaction state. |
java.lang.Object |
load(java.lang.String name)
Load the specified object. |
java.lang.Object |
load(java.lang.String dirName,
java.lang.String name)
Load the specified object. |
byte[] |
loadByteArray(java.lang.String name)
Load the specified byte array. |
void |
release()
Release the mutual exclusion. |
void |
save(java.io.Serializable obj,
java.lang.String name)
Register the modified state of an object in the current transaction. |
void |
save(java.io.Serializable obj,
java.lang.String dirName,
java.lang.String name)
Register the modified state of an object in the current transaction. |
void |
save(java.io.Serializable obj,
java.lang.String dirName,
java.lang.String name,
boolean first)
Register the state of an object in the current transaction. |
void |
saveByteArray(byte[] buf,
java.lang.String name)
Register a modified byte array in the current transaction. |
void |
saveByteArray(byte[] buf,
java.lang.String dirName,
java.lang.String name)
Register a modified byte array in the current transaction. |
void |
saveByteArray(byte[] buf,
java.lang.String dirName,
java.lang.String name,
boolean copy,
boolean first)
Register a modified byte array in the current transaction. |
protected abstract void |
saveInLog(byte[] buf,
java.lang.String dirName,
java.lang.String name,
java.util.Hashtable log,
boolean copy,
boolean first)
Register the specified object in transaction log. |
protected abstract void |
setPhase(int newPhase)
Changes the transaction state. |
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.Transaction |
---|
close, commit, delete, getList, init, isPersistent, loadByteArray, stop |
Field Detail |
---|
protected int phase
protected java.lang.ThreadLocal perThreadContext
commit
. On commit, its content is added to current
log (clog, memory + disk), then it is freed.
protected static final byte[] OOS_STREAM_HEADER
Constructor Detail |
---|
public AbstractTransaction()
Method Detail |
---|
public final int getPhase()
getPhase
in interface Transaction
Transaction.getPhase()
public final java.lang.String getPhaseInfo()
getPhaseInfo
in interface Transaction
Transaction.getPhaseInfo()
protected abstract void setPhase(int newPhase) throws java.io.IOException
newPhase
- the new transaction state.
java.io.IOException
public final void begin() throws java.io.IOException
begin
in interface Transaction
java.io.IOException
Transaction.begin()
public final void create(java.io.Serializable obj, java.lang.String name) throws java.io.IOException
create
in interface Transaction
obj
- the object to store.name
- the name of the object.
java.io.IOException
Transaction.create(java.io.Serializable, java.lang.String)
public final void create(java.io.Serializable obj, java.lang.String dirName, java.lang.String name) throws java.io.IOException
create
in interface Transaction
obj
- the object to store.dirName
- the directory name of the object.name
- the name of the object.
java.io.IOException
Transaction.create(java.io.Serializable, java.lang.String, java.lang.String)
public final void save(java.io.Serializable obj, java.lang.String name) throws java.io.IOException
save
in interface Transaction
obj
- the object to store.name
- the name of the object.
java.io.IOException
Transaction.save(java.io.Serializable, java.lang.String)
public final void save(java.io.Serializable obj, java.lang.String dirName, java.lang.String name) throws java.io.IOException
save
in interface Transaction
obj
- the object to store.dirName
- the directory name of the object.name
- the name of the object.
java.io.IOException
Transaction.save(java.io.Serializable, java.lang.String, java.lang.String)
public final void save(java.io.Serializable obj, java.lang.String dirName, java.lang.String name, boolean first) throws java.io.IOException
save
in interface Transaction
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.
java.io.IOException
Transaction.save(java.io.Serializable, java.lang.String, java.lang.String, boolean)
public final void createByteArray(byte[] buf, java.lang.String name) throws java.io.IOException
createByteArray
in interface Transaction
buf
- the byte array to store.name
- the name of the object.
java.io.IOException
Transaction.createByteArray(byte[], java.lang.String)
public final void createByteArray(byte[] buf, java.lang.String dirName, java.lang.String name) throws java.io.IOException
createByteArray
in interface Transaction
buf
- the byte array to store.dirName
- the directory name of the object.name
- the name of the object.
java.io.IOException
Transaction.createByteArray(byte[], java.lang.String, java.lang.String)
public final void saveByteArray(byte[] buf, java.lang.String name) throws java.io.IOException
saveByteArray
in interface Transaction
buf
- the byte array to store.name
- the name of the object.
java.io.IOException
Transaction.saveByteArray(byte[], java.lang.String)
public final void saveByteArray(byte[] buf, java.lang.String dirName, java.lang.String name) throws java.io.IOException
saveByteArray
in interface Transaction
buf
- the byte array to store.dirName
- the directory name of the object.name
- the name of the object.
java.io.IOException
Transaction.saveByteArray(byte[], java.lang.String, java.lang.String)
public final void saveByteArray(byte[] buf, java.lang.String dirName, java.lang.String name, boolean copy, boolean first) throws java.io.IOException
saveByteArray
in interface Transaction
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.
java.io.IOException
Transaction.saveByteArray(byte[], java.lang.String, java.lang.String, boolean, boolean)
protected abstract void saveInLog(byte[] buf, java.lang.String dirName, java.lang.String name, java.util.Hashtable log, boolean copy, boolean first) throws java.io.IOException
buf
- the byte array containing the state of the object.dirName
- the directory name of the object.name
- the name of the object.log
- the log to use.copy
- the byte array can be modified, copy it.first
- the object is a new one.
java.io.IOException
public final java.lang.Object load(java.lang.String name) throws java.io.IOException, java.lang.ClassNotFoundException
load
in interface Transaction
name
- the name of the object.
java.io.IOException
java.lang.ClassNotFoundException
Transaction.load(java.lang.String)
public final java.lang.Object load(java.lang.String dirName, java.lang.String name) throws java.io.IOException, java.lang.ClassNotFoundException
load
in interface Transaction
dirName
- the directory name of the object.name
- the name of the object.
java.io.IOException
java.lang.ClassNotFoundException
Transaction.load(java.lang.String, java.lang.String)
public final byte[] loadByteArray(java.lang.String name) throws java.io.IOException
loadByteArray
in interface Transaction
name
- the name of the object.
java.io.IOException
Transaction.loadByteArray(java.lang.String)
public final void delete(java.lang.String name)
delete
in interface Transaction
name
- the name of the object.Transaction.delete(java.lang.String)
public void release() throws java.io.IOException
release
in interface Transaction
java.io.IOException
Transaction.release()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |