|
Home | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--xl2.transaction.AbstractTransaction | +--xl2.odb.XL2Transaction
A transaction of a single XL2database.
Like thread cooperation using the synchronized keyword, applications must cooperate by successfully locking objects before using them. Any transaction can modify another XL2Transaction's object if no attempt is made to lock the object first!
Locking
New and modified objects get saved to the database via locking. If
an object is not locked, it may be lost.
XL2References automatically lock objects, but for modifications to second
class objects and primitive fields, one must manually lock parent first
class objects.
Threads
Threads must be joined to transactions. This is so XL2References
can "find" their database.
InvalidObjectException
,
LockNotGrantedException
,
XL2TransactionMgr.currentTransaction()
Field Summary | |
static int |
READ
Lock type. |
static int |
WRITE
Lock type. |
Fields inherited from interface xl2.transaction.Transaction |
STATUS_ABORT_FAILED, STATUS_ABORTED, STATUS_ABORTING, STATUS_BEGINNING, STATUS_COMMITTED, STATUS_COMMITTING, STATUS_IN_PROGRESS, STATUS_INSTANTIATED, STATUS_MARKED_ABORT |
Method Summary | |
void |
abort()
Rollback the transaction. |
void |
begin()
Calling begin multiple times on the same transaction, without an intervening call to commit or abort, causes TransactionNotClosedException to be thrown on the second and subsequent calls. |
void |
commit()
Save the transaction state. |
XL2Database |
getDatabase()
The database of the transaction. |
long |
getExpiration()
The time (System.currentTimeMillis) after which the open transaction will be automatically aborted. |
long |
getTimeout()
The length of time after which an open transaction will be automatically aborted. |
static boolean |
isReadLocked(java.lang.Object obj)
Returns true if the object is read locked by one or more transactions. |
boolean |
isReadOnly()
True if the transaction can not write lock objects. |
static boolean |
isWriteLocked(java.lang.Object obj)
Returns true if the object is write locked by any transaction. |
void |
lock(java.lang.Object object,
int mode)
Attempts to lock the object with the given mode. |
void |
readLock(java.lang.Object object)
A convenience function that calls lock(object,XL2Transaction.READ). |
void |
setReadOnly(boolean readonly)
Only to be called when the transaction is closed. |
void |
setTimeout(long millis)
The length of time after which an open transaction will be automatically aborted. |
boolean |
tryLock(java.lang.Object obj,
int mode)
Same as lock(Object,int) except no exception is thrown. |
void |
writeLock(java.lang.Object object)
A convenience function that calls lock(object,XL2Transaction.WRITE). |
Methods inherited from class xl2.transaction.AbstractTransaction |
getStatus, isClosed, isOpen, join, leave, setAbortOnly |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static int READ
public static int WRITE
Method Detail |
public void abort() throws AbortFailedException, TransactionNotOpenException
Transaction
abort
in class AbstractTransaction
xl2.transaction.Transaction
AbortFailedException
- TransactionNotOpenException
- public void begin() throws TransactionNotClosedException
Transaction
begin
in class AbstractTransaction
xl2.transaction.Transaction
TransactionNotClosedException
- public void commit() throws TransactionAbortedException, TransactionNotOpenException
Transaction
commit
in class AbstractTransaction
xl2.transaction.Transaction
AbortedFailedException
- If the transaction attempts to abort and
an exception occurrs.TransactionAbortedException
- If an exeception occurs.TransactionNotOpenException
- Transaction.isOpen()
public XL2Database getDatabase()
public long getExpiration()
public long getTimeout()
public static boolean isReadLocked(java.lang.Object obj)
public boolean isReadOnly()
public static boolean isWriteLocked(java.lang.Object obj)
public void lock(java.lang.Object object, int mode) throws InvalidObjectException, LockNotGrantedException, TransactionNotOpenException
InvalidObjectException
- TransactionNotOpenException
- LockNotGrantedException
- public void readLock(java.lang.Object object)
lock(Object,int)
public void setReadOnly(boolean readonly)
XL2TransactionNotClosedException
- public void setTimeout(long millis)
millis
- <=0 Is an infinite lifetime, and the default.public boolean tryLock(java.lang.Object obj, int mode)
public void writeLock(java.lang.Object object)
lock(Object,int)
|
Home | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |