private static class TransactionManager.WorkArea
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private boolean |
abortProcessing
Flag indicating the processing should be terminated.
|
private java.util.List<BatchListener> |
batchListeners
Map of BatchListeners to get batch start and stop notifications.
|
(package private) Stack<BlockDefinition> |
blocks
Tracks block definitions with the top of the stack as the innermost
scope.
|
BufferManager |
bm
The buffer manager instance, active only on server-side.
|
private java.util.Set<BaseDataType[]> |
deferredDynExt
Set of undoable dynamic extent vars, to be registered with the invoked procedure.
|
private java.lang.Throwable |
deferredError
Throwable caught during commit/rollback processing but deferred.
|
private java.util.ArrayList<Finalizable> |
deferredExtFinalizables
Finalizables which need deferred registration. |
private java.util.IdentityHashMap<LazyUndoable,java.lang.Object> |
deferredUndoables
Undoables which need deferred registration. |
ErrorManager.ErrorHelper |
em
Helper to use the ErrorManager without any context local lookups.
|
private BlockDefinition |
globalBlock
Defines a single global scope which is not kept in the stack.
|
private boolean |
headless
Flag that disables calls to the client side.
|
private boolean |
ignoreError
Defines if an error condition should be ignored until reaching the
caller of a top-level block.
|
private java.lang.Boolean |
interactive
Flag indicating if this is a user-interactive session.
|
LogicalTerminal |
lt
The logical terminal instance, active only on server-side.
|
private java.util.Map<java.lang.Object,java.lang.Boolean> |
masterCommit
Map of Commitables to get a commit notification after all other commits occur in a full transaction;
keys are the listeners, values are flags indicating whether listeners are auto-removed.
|
private java.util.Map<java.lang.Object,java.lang.Boolean> |
masterFinish
Map of Finalizables to get a finish notification after all other finish notifications occur in a full
transaction; keys are the listeners, values are flags indicating whether listeners are auto-removed.
|
private boolean |
nested
Enables/disables nested error support at runtime.
|
private ConditionException |
nestedError
Exception caught during processing another error.
|
private java.lang.Object |
nowIterating
Collection or map currently being iterated.
|
private java.util.ArrayDeque<java.util.Set<QueryOffEndListener>> |
offEndListeners
A stack of registered query off-end listeners, which interrupt the
FOR or FOR EACH block when a
QueryOffEndException is
caught (the user defined END-KEY action is ignored and will perform
a UNDO, LEAVE). |
private java.util.ArrayDeque<java.util.Set<P2JQuery>> |
offEndQueries
A stack of sets of queries registered during FOR or FOR EACH block initialization.
|
private boolean |
offEndRegistration
Flag indicating that the block executes its
Block.init()
method. |
private int |
op
Current operation.
|
private Scopeable[] |
pendingScopeables
The set of pending scopeables to be registered for the next block.
|
ProcedureManager.ProcedureHelper |
pm
Helper to use the ProcedureManager without any context local lookups.
|
private boolean |
processingQuit
Flag to denote if the exit is due to a quit condition.
|
private Scopeable |
procScopeable
The cached
ProcedureManager's scopeable instance, to avoid resolving
context-local data. |
private java.util.Map<java.lang.Object,java.util.IdentityHashMap<LazyUndoable,java.lang.Object>> |
procUndoables
Map of undoables defined in persistent procedures.
|
private java.lang.Boolean |
remote
Cached value of the
AppServerManager.isRemote() state. |
private java.util.ArrayList<Resettable> |
resettables
Registered
Resettables which should be reset at
specific points of block processing. |
private int |
retryScope
Defines the scope at which a pending retry will occur.
|
private boolean |
rollbackPending
Flag to denote if a rollback is pending.
|
private java.lang.Throwable |
rollbackPendingCause
Cause (if available) of pending rollback.
|
private int |
rollbackScope
Defines the scope at which rollback will occur.
|
private boolean |
savedOffEndRegistration
Value of
offEndRegistration flag saved for the period of off-end query registration pause. |
static java.lang.String |
spec
Sprintf format specification for string representation.
|
private java.util.List<StopConditionVetoHandler> |
stopHandlers
Registered STOP condition handlers
|
private java.util.IdentityHashMap<LazyUndoable,java.lang.Object> |
trackedUndoables
The map of undoables which are defined in a new instantiated external program, ran
persistent.
|
private boolean |
trackUndoables
Flag indicating if undoables need to be tracked at ext program instantiation, thus to
be registered with a persistent procedure.
|
(package private) int |
transLevel
Stack level of the full transaction if one is currently active.
|
private int |
txNestingLevel
The number of blocks with full or sub-transaction level, in the current stack.
|
| Modifier | Constructor and Description |
|---|---|
private |
WorkArea() |
| Modifier and Type | Method and Description |
|---|---|
private void |
autoRemoveAndDelete(java.util.Map<java.lang.Object,java.lang.Boolean> map,
boolean delete)
Iterate through the given map entries and remove all those whose values are
true. |
private void |
autoRemoveMasterCommit()
Iterate through registered, master Commitables and deregister those marked for auto-remove.
|
private void |
autoRemoveMasterFinish()
Iterate through registered, master Finalizables and deregister those marked for auto-remove.
|
private void |
autoRemoveMasterFinish(boolean delete)
Iterate through registered, master Finalizables and deregister those marked for auto-remove.
|
private boolean |
canRemoveFromMap(java.util.Map<java.lang.Object,java.lang.Boolean> map,
java.lang.String name)
Test whether the
map is NOT being iterated so elements stored there can be removed. |
private int |
depth()
Report scope depth.
|
private int |
getRollbackScope()
Returns the level specifying the rollback scope that is pending.
|
private void |
handleDeferredError()
Handle a pending, deferred error, represented by an exception thrown
by a commit or rollback notification callback on a registered
Commitable, and caught within TransactionManager.processCommit(com.goldencode.p2j.util.TransactionManager.WorkArea, com.goldencode.p2j.util.BlockDefinition) or TransactionManager.processRollback(com.goldencode.p2j.util.TransactionManager.WorkArea, com.goldencode.p2j.util.BlockDefinition), respectively. |
private void |
honorStopCondition()
Tests the interrupted status of the current thread using
Thread.interrupted, if true then a
StopConditionException will be thrown. |
private boolean |
isFullTransaction()
Reports if the current scope defines the outermost transaction block
(which is the scope at which final commit processing must occur).
|
private boolean |
isInteractive()
Check if the current session is interactive (i.e.
|
private boolean |
isRemote()
Check if this session is an appserver session or not.
|
private boolean |
isRollbackPending()
Reports if there is a rollback operation pending.
|
private boolean |
isTransaction()
Reports if there is a current transaction which is active.
|
private boolean |
isTransactionBlock()
Reports if there is a current transaction which is active.
|
private void |
notifyMasterCommit(boolean rollback)
Notify all master Commitables of a rollback or commit event.
|
private void |
notifyMasterFinish(boolean iterate)
Notify all master Finalizables of an iteration or finished event.
|
private void |
notifyMasterRetry()
Notify all master Finalizables of a retry event.
|
private boolean |
processUndoables()
Check if undoable can be processed by the current block.
|
private boolean |
processUndoables(BlockDefinition blk)
Check if undoable can be processed by the current block.
|
private boolean |
processUndoables(boolean currentBlock)
Check if undoable can be processed.
|
private void |
processValidate()
Worker that notifies all objects in the commit list that they must
commit (persist any state).
|
private void |
processValidateImpl()
Worker that notifies all objects in the commit list that they must
commit (persist any state).
|
private void |
setTransactionLevel(int level)
Starts a new top-level transaction (requires that there is no current
transaction which is active).
|
java.lang.String |
toString()
Render this work area's data as a human readable string.
|
public static final java.lang.String spec
public ProcedureManager.ProcedureHelper pm
public ErrorManager.ErrorHelper em
public BufferManager bm
public LogicalTerminal lt
private Scopeable[] pendingScopeables
private java.util.Map<java.lang.Object,java.lang.Boolean> masterCommit
private java.util.Map<java.lang.Object,java.lang.Boolean> masterFinish
private final java.util.List<BatchListener> batchListeners
int transLevel
private int txNestingLevel
private int rollbackScope
private boolean rollbackPending
private java.lang.Throwable rollbackPendingCause
private boolean processingQuit
private int retryScope
private boolean ignoreError
private java.lang.Throwable deferredError
private boolean nested
private ConditionException nestedError
private BlockDefinition globalBlock
Stack<BlockDefinition> blocks
private java.util.ArrayList<Finalizable> deferredExtFinalizables
Finalizables which need deferred registration.private java.util.IdentityHashMap<LazyUndoable,java.lang.Object> deferredUndoables
Undoables which need deferred registration.private java.util.Set<BaseDataType[]> deferredDynExt
private java.util.Map<java.lang.Object,java.util.IdentityHashMap<LazyUndoable,java.lang.Object>> procUndoables
private boolean trackUndoables
private java.util.IdentityHashMap<LazyUndoable,java.lang.Object> trackedUndoables
private java.lang.Object nowIterating
private int op
private java.util.List<StopConditionVetoHandler> stopHandlers
private java.util.ArrayDeque<java.util.Set<QueryOffEndListener>> offEndListeners
QueryOffEndException is
caught (the user defined END-KEY action is ignored and will perform
a UNDO, LEAVE).private java.util.ArrayList<Resettable> resettables
Resettables which should be reset at
specific points of block processing.private java.util.ArrayDeque<java.util.Set<P2JQuery>> offEndQueries
QueryOffEndException triggered by the queries from a given set can end a FOR or FOR EACH
block, even if the END-KEY action is overridden. The sets are organized in the stack because
in the init() section of a block not only off-end query registration can happen, but also
buffer flush and call of database triggers which may have their own FOR or FOR EACH blocks.private boolean offEndRegistration
Block.init()
method. Only variants of FOR or FOR EACH blocks will set the flag to
true. During block initialization, all created queries
will be collected in the offEndQueries set.private boolean savedOffEndRegistration
offEndRegistration flag saved for the period of off-end query registration pause.private volatile boolean abortProcessing
private boolean headless
private Scopeable procScopeable
ProcedureManager's scopeable instance, to avoid resolving
context-local data.private java.lang.Boolean remote
AppServerManager.isRemote() state.private java.lang.Boolean interactive
private void processValidate()
throws ErrorConditionException
On the last iteration of a loop or block which ends in success (in
which the flow of control reaches the natural end of the block), both
will be called in succession. However, other forms of exit which are
still considered successful (i.e. return and break which are not the
result of condition processing) will only execute popScope
and iterate will be bypassed.
It is important to note that the list of commitables in blk is
iterated in reverse order from that in which they are registered with
the TransactionManager. This is done to ensure that
database transactions (which are registered before their corresponding
buffers) are always committed after all buffers are committed.
ErrorConditionException - If validation fails.private void processValidateImpl()
On the last iteration of a loop or block which ends in success (in
which the flow of control reaches the natural end of the block), both
will be called in succession. However, other forms of exit which are
still considered successful (i.e. return and break which are not the
result of condition processing) will only execute popScope
and iterate will be bypassed.
It is important to note that the list of commitables in blk is
iterated in reverse order from that in which they are registered with
the TransactionManager. This is done to ensure that
database transactions (which are registered before their corresponding
buffers) are always committed after all buffers are committed.
ErrorConditionException - If validation fails.private boolean isInteractive()
private boolean isRemote()
remote state.private boolean isFullTransaction()
true if the current scope defines the top-level
transaction.private boolean isTransaction()
true if a transaction is active.private boolean isRollbackPending()
true if a rollback has been requested but not
yet processed.private boolean isTransactionBlock()
true if a transaction is active.private void setTransactionLevel(int level)
level - Stack level of the scope that is to be specified as the top
level scope.private void honorStopCondition()
throws StopConditionException,
SilentUnwindException
Thread.interrupted, if true then a
StopConditionException will be thrown. The interrupted status
will be true if a call to Thread.interrupt
was previously made.
The thread's interrupted status is cleared by this method before the
StopConditionException is thrown.
StopConditionException - If the current thread's was previously interrupted.SilentUnwindException - If the connection ended prematurely end the current thread
needs to stop.private int getRollbackScope()
private void handleDeferredError()
throws java.lang.RuntimeException
Commitable, and caught within TransactionManager.processCommit(com.goldencode.p2j.util.TransactionManager.WorkArea, com.goldencode.p2j.util.BlockDefinition) or TransactionManager.processRollback(com.goldencode.p2j.util.TransactionManager.WorkArea, com.goldencode.p2j.util.BlockDefinition), respectively. If there is currently no deferred
error, this method returns immediately. Otherwise, a debug message
is logged, the deferred error is reset to null, and the
stored exception is thrown. It is intended that this method is called
at the end of iterate or pop scope processing, after all registered
Commitables and Scopeables have been notified
of the state change.java.lang.RuntimeExceptionTransactionManager.deferError(java.lang.String, java.lang.Throwable)private int depth()
private void notifyMasterRetry()
private void notifyMasterFinish(boolean iterate)
After each notification, the corresponding Finalizable is removed, if it was registered as
auto-removable. Listeners are notified in the order in which they were registered.
iterate - true to notify of an iterate event; false to notify of a finished event.private void notifyMasterCommit(boolean rollback)
autoRemove
is true. Listeners are notified in the order in which
they were registered.rollback - true to notify of a rollback event;
false to notify of a commit event.private void autoRemoveMasterFinish()
private void autoRemoveMasterFinish(boolean delete)
Finalizable.deleted() based on the parameter
value given.delete - If the deleted() method of the Finalizable should be called.private void autoRemoveMasterCommit()
private boolean canRemoveFromMap(java.util.Map<java.lang.Object,java.lang.Boolean> map,
java.lang.String name)
map is NOT being iterated so elements stored there can be removed.map - The map to be tested.name - The name/type of the elements contained in the map. Only for debugging.true if the map can be altered by removing elements or false when a remove
operation will cause a ConcurrentModificationException.private void autoRemoveAndDelete(java.util.Map<java.lang.Object,java.lang.Boolean> map,
boolean delete)
true.
The key is a Commitable or Finalizable target, the value is its registered
auto-remove setting. For a Finalizable target, it also calls the
Finalizable.deleted() method.map - Map of registered targets and their auto-remove settings.delete - Should be true when the map contains Finalizable targets and in this case
the deleted() method of the Finalizable will be called.public java.lang.String toString()
toString in class java.lang.Objectprivate boolean processUndoables(boolean currentBlock)
currentBlock - true to check only for the current block;
false to check only if a transaction has been started.true if undoable can be processed.private boolean processUndoables()
true if a transaction has been started and the current block's
transaction level is not TransactionManager.NO_TRANSACTION.private boolean processUndoables(BlockDefinition blk)
blk - The target block.true if a transaction has been started and the current block's
transaction level is not TransactionManager.NO_TRANSACTION.