|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.objectweb.jotm.impl.core.transaction.CoreTransaction
CoreTransaction is an implementation of a simple transaction
with two phase commit. I.e., it emits events that are implementations of
TransactionalEvent or TwoPhaseCommitEvent.
CoreTransaction also implements Interrogable,
Demarcable, and Suspendable.
CoreTransaction serves as an event source for the events
as follows:
BeforeCompletionEvent
AfterCompletionEvent
BeforePrepareEvent
PrepareEvent
AfterPrepareEvent
BeforeCommitEvent
CommitEvent
AfterCommitEvent
BeforeAbortEvent
AbortEvent
AfterAbortEvent
BeforeOnePhaseCommitEvent
OnePhaseCommitEvent
AfterOnePhaseCommitEvent
Interrogable.STATUS_ACTIVE state.
Important note: It is not possible to register a listener of each individual event in the
list above. This is done for:
TYPE_PREPARE but not to
TYPE_COMMIT, or registration to TYPE_PREPARE
and TYPE_COMMIT but not to TYPE_ONE_PHASE_COMMIT,
so in case of only single TYPE_COMMIT registered listener,
the CommitEvent does not occur).
TYPE_PREPARE and
TYPE_COMMIT listeners
(e.g., to implement the read-only optimization by not to sending
the TYPE_COMMIT event to listeners that voted
PrepareEvent.VOTE_READ_ONLY).
TwoPhaseCommitEvent
TYPE_PREPARE,
TYPE_ONE_PHASE_COMMIT,
TYPE_COMMIT, and
TYPE_ABORT
events individually.
Instead, it is necessary to register a listener that handles the
TwoPhaseCommitEvent.TYPE_TWO_PHASE_COMMIT event which covers all
of these events.TwoPhaseCommitEvent.TYPE_SYNCHRONIZATION event covers
the TransactionalEvent.TYPE_BEFORE_COMPLETION,
TransactionalEvent.TYPE_AFTER_COMPLETION, but it is also
possible to register individual listeners of these events, since this
is not an incorrect behavior.
| Field Summary |
| Fields inherited from interface org.objectweb.jotm.core.transaction.Interrogable |
STATUS_ABORTED, STATUS_ABORTING, STATUS_ACTIVE, STATUS_COMMITTED, STATUS_COMMITTING, STATUS_NO_TRANSACTION |
| Fields inherited from interface org.objectweb.jotm.core.transaction.TwoPhaseCommitInterrogable |
STATUS_PREPARED, STATUS_PREPARING |
| Constructor Summary | |
CoreTransaction(TransactionManager iTm)
|
|
CoreTransaction(TransactionManager iTm,
java.lang.String name)
|
|
| Method Summary | |
void |
abort()
Aborts transaction. |
void |
addListener(int eventType,
EventListener listener)
Adds a new listener. |
void |
begin()
Begins transaction. |
void |
commit()
Commits transaction. |
java.lang.String |
getName()
Get transaction name. |
int |
getStatus()
Get transaction status. |
int |
getTimeout()
Get transaction timeout. |
static CoreTransaction |
getTransaction()
|
java.lang.Object |
getWrapper()
|
void |
removeListener(int eventType,
EventListener listener)
Removes a listener. |
void |
resume()
|
void |
setWrapper(java.lang.Object object)
|
void |
suspend()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public CoreTransaction(TransactionManager iTm)
public CoreTransaction(TransactionManager iTm,
java.lang.String name)
| Method Detail |
public void begin()
throws InvalidStateException
Demarcable
begin in interface DemarcableInvalidStateException - if the transaction is in a state different from
Interrogable.STATUS_NO_TRANSACTION
public void commit()
throws InvalidStateException,
TransactionAbortedException
Demarcable
commit in interface DemarcableTransactionAbortedException - commit of the transaction did
not succeeded and the transaction has been aborted
InvalidStateException - if the transaction is in a state different from
Interrogable.STATUS_ACTIVE
public void abort()
throws InvalidStateException
Demarcable
abort in interface DemarcableInvalidStateException - if the transaction is in a state different from
Interrogable.STATUS_ACTIVEpublic int getTimeout()
Interrogable
getTimeout in interface Interrogablepublic java.lang.String getName()
Interrogable
getName in interface Interrogablepublic void suspend()
suspend in interface Suspendablepublic void resume()
resume in interface Suspendablepublic int getStatus()
Interrogable
getStatus in interface Interrogable
public void addListener(int eventType,
EventListener listener)
BeforeCompletionEvent
AfterCompletionEvent
BeforePrepareEvent
AfterPrepareEvent
BeforeCommitEvent
AfterCommitEvent
BeforeAbortEvent
AfterAbortEvent
TwoPhaseCommitEvent
TwoPhaseCommitEvent.
addListener in interface EventSourceeventType - type of events to be delivered to the listenerlistener - listener that will receive events of the specified type
public void removeListener(int eventType,
EventListener listener)
addListener(int, org.objectweb.jotm.core.events.EventListener).
It is allowed to remove listeners to several events at the same time by passing bitwise or of
those events.
removeListener in interface EventSourceeventType - type of events that are delivered to the listenerlistener - listener that receives events of the specified type
public static CoreTransaction getTransaction()
throws NoTransactionException
NoTransactionExceptionpublic java.lang.Object getWrapper()
public void setWrapper(java.lang.Object object)
object - wrapper object
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||