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.
|
private java.util.Stack<BlockDefinition> |
blocks
Tracks block definitions with the top of the stack as the innermost
scope.
|
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.List<Finalizable> |
deferredExtFinalizables
Finalizable s which need deferred registration. |
private java.util.IdentityHashMap<LazyUndoable,java.lang.Object> |
deferredUndoables
Undoable s which need deferred registration. |
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.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.Set<P2JQuery> |
offEndQueries
A set 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 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.util.List<Resettable> |
resettables
Registered
Resettable s 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 java.util.List<Scopeable> |
scopeList
Registry of all objects needing start and end scope callbacks.
|
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.
|
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 |
autoRemove(java.util.Map<java.lang.Object,java.lang.Boolean> map)
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 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 |
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 iterate 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 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
private final java.util.List<Scopeable> scopeList
private final java.util.Map<java.lang.Object,java.lang.Boolean> masterCommit
private final java.util.Map<java.lang.Object,java.lang.Boolean> masterFinish
private final java.util.List<BatchListener> batchListeners
private 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
private java.util.Stack<BlockDefinition> blocks
private java.util.List<Finalizable> deferredExtFinalizables
Finalizable
s which need deferred registration.private java.util.IdentityHashMap<LazyUndoable,java.lang.Object> deferredUndoables
Undoable
s 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.List<Resettable> resettables
Resettable
s which should be reset at
specific points of block processing.private java.util.Set<P2JQuery> offEndQueries
QueryOffEndException
triggered by these
queries can end a FOR or FOR EACH block, even if the END-KEY action
is overridden.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 volatile boolean abortProcessing
private boolean headless
private Scopeable procScopeable
ProcedureManager
's scopeable instance, to avoid resolving
context-local data.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
Commitable
s and Scopeable
s have been notified
of the state change.java.lang.RuntimeException
TransactionManager.deferError(java.lang.String, java.lang.Throwable)
private int depth()
private void notifyMasterRetry()
private void notifyMasterFinish(boolean iterate)
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 autoRemoveMasterCommit()
private void autoRemove(java.util.Map<java.lang.Object,java.lang.Boolean> map)
true
. The key is a Commitable
or Finalizable
target, the value is its registered
auto-remove setting.map
- Map of registered targets and their auto-remove settings.public java.lang.String toString()
toString
in class java.lang.Object
private boolean processUndoables()
true
if a transaction has been started and the current block's
transaction level is not TransactionManager.NO_TRANSACTION
.