public abstract class TransactionManager
extends java.lang.Object
TransactionManager is an abstract class which supports executing a transactional method
TransactionManager.TransactionalMethod
, TransactionManager.NonVoidTransactionalMethod
in the context of a transaction.
The manager is responsible for interacting with the appropriate underlying transaction.
The manager may be asked to execute nested transactional methods. In this case only the outermost transactional method can cause a begin and commit on the underlying transaction.
Any transactional method which throws an exception will cause the underlying transaction to be immediately rolled-back. This will leave the TransactionManager in a rollback-only state. When in this state, the manager will not execute any new transactional method. The state is cleared once all of its existing transactional method have been rolled-back.
The TransactionManager is not-thread safe. The current TransactionManager can be retrieved using the
#getCurrentTransactionManager()
method, which returns a TransactionManager scoped to the
current PortalRequestScope
scope.
Modifier and Type | Class and Description |
---|---|
static interface |
TransactionManager.NonVoidTransactionalMethod<R> |
static interface |
TransactionManager.TransactionalMethod |
static interface |
TransactionManager.TransactionToken |
Constructor and Description |
---|
TransactionManager() |
Modifier and Type | Method and Description |
---|---|
abstract TransactionManager.TransactionToken |
beginTransaction()
Indicates to the TransactionManager that the caller is starting a new transaction.
|
abstract void |
commitTransaction(TransactionManager.TransactionToken token)
Requests that the TransactionManager commits the caller's transaction identified
by the given token.
|
abstract <R> R |
execute(TransactionManager.NonVoidTransactionalMethod<R> tm)
Executes a non void transactional method, which is a method
that returns a value.
|
abstract void |
execute(TransactionManager.TransactionalMethod tm)
Executes a void transactional method.
|
static TransactionManager |
getCurrent()
The current transaction manager.
|
abstract boolean |
isActive()
The TransactionManager is active if there is at least one transactional method that
has started executing but not yet committed or rolled-back.
|
abstract void |
rollbackAllTransactions()
Reinitializes the TransactionManager, by rolling back the underlying transaction
if it is active, and returning the manager toa state where it can begin or
execute a new caller transaction.
|
abstract void |
rollbackTransaction(TransactionManager.TransactionToken token)
Requests that the TransactionManager rolls back the caller transaction
identified by the given token.
|
public static TransactionManager getCurrent()
public abstract boolean isActive() throws TransactionException
TransactionException
public abstract void execute(TransactionManager.TransactionalMethod tm) throws oracle.webcenter.portal.BasePortalRuntimeException
Executes a void transactional method.
Portal runtime errors raised by the transactional method are directly propagated. Any other exception is wrapped in a TransactionException which is then thrown. The original exception is available as the cause of the TransactionException.
tm
- a TransactionalMethod to execute.oracle.webcenter.portal.BasePortalRuntimeException
- if any exception occurs.public abstract <R> R execute(TransactionManager.NonVoidTransactionalMethod<R> tm) throws oracle.webcenter.portal.BasePortalRuntimeException
Executes a non void transactional method, which is a method that returns a value.
Portal runtime errors raised by the transactional method are directly propagated. Any other exception is wrapped in a TransactionException which is then thrown. The original exception is available as the cause of the TransactionException.
tm
- a NonVoidTransactionalMethod to execute.TransactionException
- if any exception occurs.oracle.webcenter.portal.BasePortalRuntimeException
public abstract TransactionManager.TransactionToken beginTransaction() throws TransactionException
TransactionException
- if any exception occurs.public abstract void commitTransaction(TransactionManager.TransactionToken token) throws TransactionException
token
- a TransactionToken identifying which transaction to commit.TransactionException
- if the token does not identify the most
recently begun caller transaction, or if any other exception occurs.public abstract void rollbackTransaction(TransactionManager.TransactionToken token) throws TransactionException
token
- a TransactionToken identifying which transaction to rollback.TransactionException
- if teh token is not a valid TransactionToken or
any other exception occurs.public abstract void rollbackAllTransactions() throws TransactionException
TransactionException
- if any exception occurs rolling back and re-initializing
the TransactionManager.