class TxWrapper extends java.lang.Object implements Commitable, Finalizable
Commitable and Finalizable events of an
application transaction. It creates a database transaction to correspond with the application
transaction, and as it receives events from the TransactionManager, it delegates related
responsibilities to various components of the persistence framework.| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
TxWrapper.AggresiveFlushWrapper
A proxy for a
Commitable that suppressed the commits and rollbacks. |
(package private) static class |
TxWrapper.TxWrapperHelper
Helper instance to access the
TxWrapper.WorkArea state without context-local lookups. |
private static class |
TxWrapper.WorkArea
Manages transaction-related state where buffers are involved.
|
| Modifier and Type | Field and Description |
|---|---|
private boolean |
autoRollback
Roll back the transaction when block finishes, if not previously acted upon
|
private static ContextLocal<TxWrapper.WorkArea> |
context
Stores context local instances of this class
|
private Database |
database
Backing database
|
private DirtyShareContext |
dirtyContext
Dirty share context
|
private boolean |
initialTx
true for an initial transaction only until the first commit or rollback |
private static CentralLogger |
LOG
Logger
|
private Persistence.Context |
persistenceCtx
Persistence context, for access to database session and transaction
|
private SavepointManager |
savepointManager
Savepoint manager (can be
null |
private TxWrapper.WorkArea |
wa
The
TxWrapper.WorkArea instance. |
| Constructor and Description |
|---|
TxWrapper(TxWrapper.WorkArea wa,
Database database)
The sole constructor.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
activate()
Activates the transaction.
|
private void |
begin()
Starts the actual transaction at persistence level.
|
void |
commit(boolean transaction)
Implementation of
Commitable interface: saves any temporary state to the persistent form or
storage that is associated with this class. |
void |
deleted()
Implementation of
Finalizable interface: provides a notification that the external program
in which the object is registered is being deleted and the object's reference may be lost after this
method is called. |
(package private) void |
deregisterGlobalSavepointHooks()
Deregisters the finalizable for savepoint manager from the global block, if any.
|
private void |
end()
Shuts down the transaction at persistence level and performs key management.
|
void |
finished()
Implementation of
Finalizable interface: Provides a notification that the scope in which the
object is registered is ending and the object's reference may or may not be lost after this method
is called. |
static TxWrapper.TxWrapperHelper |
getHelper(BufferManager bm)
Get the helper to access the
Commitable and Resettable state required to maintain
transaction-related state where buffers are involved. |
(package private) boolean |
isActive()
Checks whether this
TxWrapper is active. |
void |
iterate()
Implementation of
Finalizable interface: provides a notification that the block whose scope
in which the object is registered is about to iterate and attempt another pass. |
private java.lang.String |
message(Persistence persistence,
java.lang.String text)
Compose a message suitable for logging.
|
(package private) void |
registerSavepointHooks(boolean fullTx,
int blockDepth)
Registers the commitable and finalizable for savepoint manager, if any.
|
void |
retry()
Implementation of
Finalizable interface: provides a notification that the block whose scope
in which the object is registered is about to retry the same iteration (all loop control data is
unchanged). |
void |
rollback(boolean transaction)
Implementation of
Commitable interface: notifies that a rollback has just occurred (all state
maintained through the Undoable interface has been already rolled back). |
java.lang.String |
toString()
Convert the current object to its string representation to be used during debugging.
|
void |
validate(boolean transaction,
boolean aggressiveFlush)
Implementation of
Commitable interface: Notifies that a block is about to be normally exited
or normally iterated and that any deferred validation processing should be executed. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitentry, initFailure, weightprivate static final CentralLogger LOG
private static final ContextLocal<TxWrapper.WorkArea> context
private final Database database
private final DirtyShareContext dirtyContext
private final SavepointManager savepointManager
nullprivate Persistence.Context persistenceCtx
private boolean autoRollback
private boolean initialTx
true for an initial transaction only until the first commit or rollbackprivate TxWrapper.WorkArea wa
TxWrapper.WorkArea instance.TxWrapper(TxWrapper.WorkArea wa, Database database)
wa - The TxWrapper.WorkArea instance.database - The Database where the transaction takes place.public static TxWrapper.TxWrapperHelper getHelper(BufferManager bm)
Commitable and Resettable state required to maintain
transaction-related state where buffers are involved.bm - The BufferManager instance.TxWrapper.TxWrapperHelper instance.public void iterate()
Finalizable interface: provides a notification that the block whose scope
in which the object is registered is about to iterate and attempt another pass. This provides an
opportunity to preserve state from the previous pass and make preparations for the coming pass.iterate in interface Finalizablepublic void retry()
Finalizable interface: provides a notification that the block whose scope
in which the object is registered is about to retry the same iteration (all loop control data is
unchanged). This provides an opportunity to clear or reset state from the previous pass.retry in interface Finalizablepublic void finished()
Finalizable interface: Provides a notification that the scope in which the
object is registered is ending and the object's reference may or may not be lost after this method
is called. This provides a natural and standard mechanism to clean-up any resources that may need
to be closed explicitly such as operating system files or sockets.finished in interface Finalizablepublic void deleted()
Finalizable interface: provides a notification that the external program
in which the object is registered is being deleted and the object's reference may be lost after this
method is called.deleted in interface Finalizablepublic void commit(boolean transaction)
Commitable interface: saves any temporary state to the persistent form or
storage that is associated with this class.commit in interface Commitabletransaction - true if this is a full transaction and false if this is only a
sub-transaction (a nested scope with transaction support).public void rollback(boolean transaction)
Commitable interface: notifies that a rollback has just occurred (all state
maintained through the Undoable interface has been already rolled back). This notification
can be used to implement cleanup of any custom state that needs to be maintained in this case. It can
also be used to implement a rollback that is completely independent of the Undoable
(externally driven) interface.rollback in interface Commitabletransaction - true if this is a full transaction and false if this is only a
sub-transaction (a nested scope with transaction support).public void validate(boolean transaction,
boolean aggressiveFlush)
Commitable interface: Notifies that a block is about to be normally exited
or normally iterated and that any deferred validation processing should be executed.
This particular implementation is a NOP.
validate in interface Commitabletransaction - Ignored.aggressiveFlush - Ignored.void registerSavepointHooks(boolean fullTx,
int blockDepth)
fullTx - true if this is a full-transaction.blockDepth - zero-based depth of target block, starting from the outermost block. 0 indicates
the global block.void deregisterGlobalSavepointHooks()
void activate()
boolean isActive()
TxWrapper is active.true only if TxWrapper was activated.public java.lang.String toString()
toString in class java.lang.Objectprivate void begin()
private void end()
private java.lang.String message(Persistence persistence, java.lang.String text)
persistence - Persistence object which will provide context info.text - Custom message text.