public final class BufferManager extends java.lang.Object implements Scopeable, BatchListener, StopConditionVetoHandler, Resettable
TransactionManager
, the
persistence service layer which manages database resources, and multiple
record buffers opened by client code.
A record buffer registers itself with the buffer manager when client code opens a new buffer scope. If a transaction is active, that buffer is immediately registered with the transaction manager for commit processing. This allows the buffer to synchronize its state with the persistence service when a transaction or subtransaction commit occurs. If a transaction is not active when a new buffer scope is opened, the buffer manager keeps track of the open buffer, and the block scope at which it was opened. When a full transaction subsequently is opened, all buffers with open scopes are batch registered for commit processing.
Also, when a full transaction begins, the buffer manager takes stock of
all databases referred to by open buffer scopes, and begins a new,
database-level transaction for each one. The database transaction's life
cycle is managed by an inner class, BufferManager.DBTxWrapper
.
This inner class registers itself for master commit and finish processing
with the transaction manager, such that it can reflect an application
level commit/rollback back to the underlying database transaction.
Updates made to existing records are tracked for undo purposes by this class. A scoped dictionary of reversible updates by DMO type is managed by the context local instance of this class, for all open buffers in the current client context.
Modifier and Type | Class and Description |
---|---|
private static class |
BufferManager.BatchModeData
Container for batch assign mode information.
|
private class |
BufferManager.DBTxWrapper
A helper class which is created whenever a new database-level
transaction is needed.
|
private class |
BufferManager.PersistentProcScope
Buffer-related data for a certain persistent procedure, surviving after its external
procedure is finished.
|
private static class |
BufferManager.RefCount
Reference count object with a mutable counter value, for tracking buffer references to DMOs
currently in use within a Hibernate session.
|
private static class |
BufferManager.SessionFlusher
Commitable implementation which tries to flush Hibernate session before
any rollback.
|
private static class |
BufferManager.UndoData
Storage mechanism for maps of reversible/undoable actions, keyed by
primary key.
|
Modifier and Type | Field and Description |
---|---|
private ScopedDictionary<java.lang.String,RecordBuffer> |
allBuffers
Scoped dictionary in which all defined record buffers are stored
|
private Finalizable |
batchCleaner
Finalizable which clears batch mode at the appropriate times
|
private java.util.ArrayDeque<BufferManager.BatchModeData> |
batchModeStack
Stack of batch mode data
|
private ChangeBroker |
changeBroker
Change broker
|
private ConnectionManager |
connMgr
Connection manager
|
private static ContextLocal<BufferManager> |
context
Stores context local instances of this class
|
private boolean |
explicitSilentError
Flag indicating whether we are in explicit silent error mode
|
private Scopeable |
fieldScopes
Field assigner for function/procedure parameter assign-backs
|
private static boolean |
initialized
Flag indicating whether class was initialized, i.e.
|
private java.util.Map<Persistable,BufferManager.RefCount> |
inUseRecords
Map of records in use (in a persistence session) by database/buffer
|
private ScopedDictionary<RecordBuffer,java.lang.Boolean> |
loadedBuffers
Scoped dictionary which key set contains all buffers into which a new record was loaded (or
the old record was reloaded) into corresponding scopes.
|
private static java.util.logging.Logger |
LOG
Logger
|
private ScopedList<RecordBuffer> |
openBuffers
Scoped dictionary in which open record buffers are stored
|
private ScopedDictionary<java.lang.String,StaticTempTable> |
openStaticTempTables
Scoped dictionary which contains currently active static temp tables (i.e.
|
private java.util.Map<java.lang.String,RecordBuffer> |
pendingBuffers
The buffers which will be registered on the next scope entry.
|
private java.util.Map<Persistence,java.util.Set<java.io.Serializable>> |
pendingReclaimedKeys
Primary keys pending reclamation
|
private java.util.Map<java.lang.Object,BufferManager.PersistentProcScope> |
persistProcScopes
Map with buffer-related data surviving a persistent proc's external procedure.
|
private java.util.Map<Persistence,BufferManager.DBTxWrapper> |
persistToDbTx
Persistence to DBTxWrapper instance map |
private int |
queryDepth
Number of nested queries being processed
|
private ScopedDictionary<OutputTableHandleCopier,java.lang.Integer> |
thOutputParameters
Scoped dictionary which contains the maps of output copiers for a procedure/function to
their 0-based indexes in the set of all TABLE-HANDLE parameters for the procedure/function
(excluding other types of parameters).
|
private int |
transactionDepth
Block depth at which full application transaction began, or -1 if not in a transaction
|
private ScopedDictionary<BufferType,BufferManager.UndoData> |
undoData
All undoable actions scoped by block and keyed by buffer type
|
private Finalizable |
xactFin
Transaction finalizable to manage transaction state locally (avoid context-local calls)
|
Modifier | Constructor and Description |
---|---|
private |
BufferManager()
Constructor; instances of this class are context-local and must be accessed using the static
get() method. |
Modifier and Type | Method and Description |
---|---|
(package private) java.util.Iterator<RecordBuffer> |
activeBuffers(Persistence persistence)
Get an iterator on all open buffers which contain non-
null
current records for the given persistence object, within the current
client context. |
(package private) java.util.Iterator<RecordBuffer> |
activeBuffers(Persistence persistence,
boolean includeTransient)
Get an iterator on all open buffers which contain non-
null
current records for the given persistence object, within the current
client context. |
(package private) void |
addDirtyBatchBuffer(RecordBuffer buffer)
If we currently are in batch assignment mode, add the given record
buffer to the set of buffers requiring validation at the end of the
batch.
|
(package private) void |
addPendingReclaimedKeys(Persistence persistence,
java.util.List<java.io.Serializable> keys)
Add potentially unused keys to be reclaimed after the end of the current transaction or
as buffer scopes are closed after a transaction.
|
(package private) void |
addReversible(RecordBuffer buffer,
java.io.Serializable key,
Reversible item)
Add a
Reversible object to the reversibles set. |
(package private) void |
addReversible(RecordBuffer buffer,
java.io.Serializable key,
Reversible item,
boolean chain)
Add a
Reversible object to the reversibles set. |
(package private) void |
addToAllBuffersArray(int blockDepth,
RecordBuffer buffer)
Add the target buffer to the set of all buffers at the specified block depth.
|
void |
batchNotify(boolean start)
Provides a notification that a batch is starting or ending.
|
(package private) void |
bufferActiveInTransaction(RecordBuffer buffer,
boolean beginTx)
Given a record buffer with an open scope operating within an application
level transaction, possibly create a new database transaction wrapper
object and optionally begin a database level transaction in the buffer's
backing database.
|
(package private) void |
checkNestedQuery()
Check whether the current query depth is non-zero, indicating that we are processing a
query within the context of another query.
|
static void |
cleanupPending()
Cleanup of pending resources.
|
(package private) int |
decrementDMOUseCount(Persistable dmo)
Decrement the context local use count for the specific instance of the
given record.
|
(package private) void |
deregisterDynamicBuffer(RecordBuffer buffer)
Deregister the given, dynamic record buffer by removing it from the buffer manager's
tracking.
|
(package private) java.util.Set<RecordBuffer> |
endBatchAssignMode()
End batch assignment mode if we are currently in batch assignment mode
and we are in the same scope at which batch assignment mode was
started.
|
(package private) boolean |
evictDMOIfUnused(Persistence persistence,
Persistence.Context local,
Persistable dmo)
Evict the given DMO from the current Hibernate session if it is not
referenced by any buffer or other resource.
|
(package private) java.lang.String |
generateUniqueBufferName(java.lang.String legacyBufferName)
Generate unique (across the session) name (DMO alias) for a dynamic buffer.
|
static BufferManager |
get()
Retrieve the context-local instance of this class, instantiating it
first if necessary.
|
int |
getCurrentScope()
Query the scope level which currently is open.
|
(package private) int |
getDMOUseCount(Persistable dmo)
Return the context local use count for the specific instance of the given record.
|
int |
getFullTransactionBlock()
Get the zero-based block depth (counting from the outermost scope) at which the current,
full, application-level transaction (if any) began.
|
(package private) java.util.Set<Reversible> |
getReversibles(RecordBuffer buffer,
int depth,
boolean create)
Retrieve the set of reversible action objects for a given block scope.
|
(package private) java.util.Map<java.io.Serializable,java.util.List<Reversible>> |
getReversiblesMap(RecordBuffer buffer,
int depth,
boolean create)
Retrieve a map of reversible action objects for a given block scope.
|
(package private) StaticTempTable |
getStaticTempTable(java.lang.String name)
Get definition for the active static temp table with the given name.
|
(package private) int |
getStaticTempTableDepth(java.lang.String name)
Get the depth of the scope at which the static temp table was opened.
|
(package private) java.util.Map<java.io.Serializable,Reversible> |
getUndoables(RecordBuffer buffer,
int depth,
boolean create)
Retrieve the map of DMO IDs to reversible update objects for a given
block scope.
|
(package private) int |
incrementDMOUseCount(Persistable dmo)
Increment the context local use count for the specific instance of the
given record.
|
(package private) static void |
initialize()
Register with the
TransactionManager a factory object which creates instances of this
class, so that they can be registered to receive notifications of
runtime scope start and finish events. |
(package private) boolean |
isBatchAssignMode()
Indicate whether we currently are in batch assignment mode.
|
boolean |
isFullTransaction()
Check whether the current block marks (and is within) the boundary of an application-level
full transaction.
|
boolean |
isTransaction()
Check whether the current block is within an application-level transaction.
|
boolean |
isTransactionAt(int level)
Check whether the block at the specified block depth is within an application-level
transaction.
|
(package private) RecordBuffer |
lookupBuffer(java.lang.String alias)
Find the record buffer associated with the given alias, which is the
variable name with which the buffer was defined.
|
private java.lang.String |
message(Persistence persistence,
java.lang.String text)
Compose a message suitable for logging.
|
(package private) void |
notifyRecordWasLoaded(RecordBuffer recordBuffer)
Notify the buffer manager that a new record was loaded (or the old
record was reloaded) into the specified record buffer.
|
(package private) int |
openScope(RecordBuffer buffer,
boolean nestedOpen)
Called by
RecordBuffer when a new buffer scope is opened to
register the open scope with the buffer manager, so that the buffer
can receive block scope start and stop notifications, and be registered
for commit processing when a full transaction is begun. |
(package private) void |
openScopeAt(int blockDepth,
RecordBuffer buffer)
Called by
TemporaryBuffer when a new dynamic buffer scope is opened to register the
open scope with the buffer manager, so that the buffer can receive block scope start and
stop notifications, and be registered for commit processing when a full transaction is
begun. |
boolean |
postponeTableHandleDelete(TempTable tempTable)
Marks the table for postponed delete, if it is possible.
|
(package private) void |
reclaimPendingKeys(Persistence persistence,
java.util.Set<java.io.Serializable> released)
Reclaim unused keys collected during the transaction which just ended or from the buffer
scope which just closed.
|
(package private) void |
registerBuffer(RecordBuffer buffer)
Register a newly defined record buffer in the current scope.
|
(package private) void |
registerBufferUndoable(RecordBuffer buffer,
Undoable undoTarget)
Register an undoable which is responsible for setting the buffer's
proper current record after all reversibles are processed.
|
(package private) void |
registerOutputTableHandleCopier(OutputTableHandleCopier copier)
Register the output table copier.
|
(package private) void |
registerPending(RecordBuffer buffer)
Register as pending the newly defined record buffer.
|
(package private) StaticTempTable |
registerStaticTempTable(Temporary defaultBuffer,
boolean global)
Register static temp table when its scope is opened.
|
(package private) void |
removeAllReversibles(TemporaryBuffer buffer)
Remove all
Reversible objects associated with the given buffer from their
respective scoped dictionaries. |
void |
resetState(boolean clearOnly)
Releases the buffers into which a new record was loaded (or the old
record was reloaded) into the current or deeper scopes, or only clears
the list of buffers pending to be released.
|
void |
scopeDeleted()
Provides notification that the external procedure scope has been deleted.
|
void |
scopeFinished()
Process a notification that a scope is about to be exited.
|
void |
scopeStart()
Process a notification that a new block scope has been entered.
|
(package private) void |
setImplicitSilentError(boolean enableImplicit)
Enable or disable silent error mode.
|
(package private) void |
startBatchAssignMode()
Begin batch assignment mode.
|
(package private) void |
unregisterOutputTableHandleCopier(OutputTableHandleCopier copier)
Unregister the output table copier in the current scope.
|
boolean |
vetoStop(StopConditionException exc)
Check the specified exception and determine whether we want to allow it
to be honored by the
TransactionManager , or whether we want to
veto the STOP at this scope. |
private static final java.util.logging.Logger LOG
private static final ContextLocal<BufferManager> context
private static boolean initialized
initialize()
was calledprivate final Finalizable xactFin
private final Finalizable batchCleaner
private final ChangeBroker changeBroker
private final Scopeable fieldScopes
private final java.util.Map<java.lang.String,RecordBuffer> pendingBuffers
private final ScopedDictionary<java.lang.String,RecordBuffer> allBuffers
private final ScopedDictionary<RecordBuffer,java.lang.Boolean> loadedBuffers
private final ScopedList<RecordBuffer> openBuffers
private final ScopedDictionary<java.lang.String,StaticTempTable> openStaticTempTables
private final ScopedDictionary<OutputTableHandleCopier,java.lang.Integer> thOutputParameters
private final java.util.Map<Persistable,BufferManager.RefCount> inUseRecords
private final java.util.Map<Persistence,BufferManager.DBTxWrapper> persistToDbTx
Persistence
to DBTxWrapper
instance mapprivate final ScopedDictionary<BufferType,BufferManager.UndoData> undoData
private final java.util.ArrayDeque<BufferManager.BatchModeData> batchModeStack
private final java.util.Map<java.lang.Object,BufferManager.PersistentProcScope> persistProcScopes
private final java.util.Map<Persistence,java.util.Set<java.io.Serializable>> pendingReclaimedKeys
private int transactionDepth
private ConnectionManager connMgr
private int queryDepth
private boolean explicitSilentError
private BufferManager()
get()
method.public static BufferManager get()
java.lang.IllegalStateException
- when BufferManager
is not activated, i.e. initialize()
is not called.public static void cleanupPending()
static void initialize()
TransactionManager
a factory object which creates instances of this
class, so that they can be registered to receive notifications of
runtime scope start and finish events.
This method should be invoked once during the server bootstrap phase.
public int getCurrentScope()
public boolean vetoStop(StopConditionException exc)
TransactionManager
, or whether we want to
veto the STOP at this scope.
This implementation is interested only in STOP conditions which have
been generated by database connection errors. STOP processing at the
current scope is vetoed iff the exception is an instance of DatabaseConnectionException
AND either of the following criteria are
met:
Otherwise, normal STOP processing is allowed to continue.
vetoStop
in interface StopConditionVetoHandler
exc
- The exception to be checked.true
if STOP should be vetoed;
false
if the STOP should be allowed.public void scopeStart()
scopeStart
in interface Scopeable
ErrorConditionException
- if there is an error flushing pending changes to the database
as we open a new database transaction.public void scopeFinished()
scopeFinished
in interface Scopeable
public void scopeDeleted()
If we are deleting a persistent procedure, clean all its data from the global scope for the
following dictionaries: loadedBuffers
, openBuffers
, allBuffers
,
openStaticTempTables
.
scopeDeleted
in interface Scopeable
public void batchNotify(boolean start)
start
.batchNotify
in interface BatchListener
start
- true
if this is the start of a batch, otherwise
false
.RecordBuffer.startBatch()
,
RecordBuffer.endBatch()
public void resetState(boolean clearOnly)
resetState
in interface Resettable
clearOnly
- If true
then clear the list of buffers pending to be
released, otherwise perform release of these buffers and clear
the list after that.public boolean postponeTableHandleDelete(TempTable tempTable)
tempTable
- Temporary table to be marked for postponed delete.true
if the table was postponed for deletion. false
if
this can't be done.public boolean isTransaction()
true
if we are in a transaction, else false
.public boolean isTransactionAt(int level)
level
- Zero-based block depth (counting from the outermost scope).true
if we are in a transaction, else false
.public boolean isFullTransaction()
true
if we are at (and within) a full transaction boundary, else false
.public int getFullTransactionBlock()
void registerBufferUndoable(RecordBuffer buffer, Undoable undoTarget)
buffer
- Record buffer for which a change is being tracked for undo
purposes. It is assumed the buffer has been initialized.undoTarget
- The undoable responsible with setting the buffer back to its
proper record.void registerBuffer(RecordBuffer buffer)
buffer
- Buffer to be registered.void registerPending(RecordBuffer buffer)
pendingBuffers
will be registered with
that scope. Buffers are deregistered implicitly when the scope in which
they were registered ends.buffer
- Buffer pending to be registered.void deregisterDynamicBuffer(RecordBuffer buffer)
buffer
- Dynamic record buffer to be removed.void startBatchAssignMode()
java.lang.IllegalStateException
- if batch mode is already active in the current block or was started but never
ended in a previous block.RecordBuffer.startBatch()
,
RecordBuffer.endBatch()
,
RecordBuffer.cleanupBatchMode(com.goldencode.p2j.persist.BufferManager)
java.util.Set<RecordBuffer> endBatchAssignMode()
null
, indicating
either we are not in batch mode, or we are not in the proper
scope to end it, or the buffers already have been processed, or
the program is ending and we are in cleanup mode.RecordBuffer.startBatch()
,
RecordBuffer.endBatch()
,
RecordBuffer.cleanupBatchMode(com.goldencode.p2j.persist.BufferManager)
boolean isBatchAssignMode()
true
if in batch assignment mode, else
false
.startBatchAssignMode()
,
endBatchAssignMode()
void addDirtyBatchBuffer(RecordBuffer buffer)
buffer
- Buffer to be added to the set of dirty batch mode buffers.startBatchAssignMode()
,
endBatchAssignMode()
void setImplicitSilentError(boolean enableImplicit)
This method supports temporary error suppression during the processing of query substitution parameters during construction/initialization of a query.
This method MUST be invoked in balanced brackets which first enable and then disable
implicit silent error mode. Brackets may be nested, but they must be balanced, such that
at the end of all nested calls, queryDepth
must be 0
and
explicitSilentError
must be false
.
enableImplicit
- true
to enable silent error mode; false
to disable.void checkNestedQuery()
void addPendingReclaimedKeys(Persistence persistence, java.util.List<java.io.Serializable> keys)
persistence
- Persistence helper object for a particular database.keys
- Keys to be reclaimed.void reclaimPendingKeys(Persistence persistence, java.util.Set<java.io.Serializable> released)
persistence
- Persistence helper object for a particular database.released
- Keys actually released, due to the corresponding locks on them being released
(as opposed to downgraded).java.util.Set<Reversible> getReversibles(RecordBuffer buffer, int depth, boolean create)
If create
is true
and no set is found for the
given alias at the given scope, a set is created for the requested
scope. Otherwise, the existing set or null
will be
returned. If newly created, a set is stored in the scoped dictionary
for future lookups.
buffer
- Record buffer for which a change is being tracked for undo
purposes. It is assumed the buffer has been initialized.depth
- Depth from the top of the block scope stack at which to
retrieve the map. 0 indicates the current scope, 1 the
closest enclosing scope, and so on. -1 indicates the global
scope.create
- If true
and no set exists in the requested scope,
a new set is created and is stored for future lookups; if
false
, no new set is created.null
.Reversible
,
ReversibleCreate and ReversibleDelete inner classes
java.util.Map<java.io.Serializable,java.util.List<Reversible>> getReversiblesMap(RecordBuffer buffer, int depth, boolean create)
If create
is true
and no map is found for the
given alias at the given scope, a map is created for the requested
scope. Otherwise, the existing map or null
will be
returned. If newly created, a map is stored in the scoped dictionary
for future lookups.
buffer
- Record buffer for which a change is being tracked for undo
purposes. It is assumed the buffer has been initialized.depth
- Depth from the top of the block scope stack at which to
retrieve the map. 0 indicates the current scope, 1 the
closest enclosing scope, and so on. -1 indicates the global
scope.create
- If true
and no map exists in the requested scope,
a new map is created and is stored for future lookups; if
false
, no new map is created.null
.Reversible
,
ReversibleCreate and ReversibleDelete inner classes
void addReversible(RecordBuffer buffer, java.io.Serializable key, Reversible item)
Reversible
object to the reversibles set. This method also
ensures that a subsequent chain of reversibles will be kept, in a
separate map, by DMO ID. As reversible actions for 2 DMO's can mix, this
map will allow access to the reversibles for a certain DMO, in the
proper order.buffer
- Record buffer with which changes are associated.key
- The DMO ID used by this reversible.item
- Object which will perform the re-application of changes.void addReversible(RecordBuffer buffer, java.io.Serializable key, Reversible item, boolean chain)
Reversible
object to the reversibles set. When the
chain
parameter is true, this method ensures that a
subsequent chain of reversibles will be kept, in a separate map, by DMO
ID. As reversible actions for 2 DMO's can mix, this map will allow
access to the reversibles for a certain DMO, in proper order.buffer
- Record buffer with which changes are associated.key
- The DMO ID used by this reversible.item
- Object which will perform the re-application of changes.chain
- When true, it will add the reversible to the per-DMO map,
to enable access to all reversibles registered for a DMO.java.util.Map<java.io.Serializable,Reversible> getUndoables(RecordBuffer buffer, int depth, boolean create)
If create
is true
and no map is found for the
given alias at the given scope, a map is created for the requested
scope. Otherwise, the existing map or null
will be
returned. If newly created, a map is stored in the scoped dictionary
for future lookups.
buffer
- Record buffer for which a change is being tracked for undo
purposes. It is assumed the buffer has been initialized.depth
- Depth from the top of the block scope stack at which to
retrieve the map. 0 indicates the current scope, 1 the
closest enclosing scope, and so on. -1 indicates the global
scope.create
- If true
and no map exists in the requested scope,
a new map is created and is stored for future lookups; if
false
, no new map is created.null
.ReversibleUpdate inner class
void removeAllReversibles(TemporaryBuffer buffer)
Reversible
objects associated with the given buffer from their
respective scoped dictionaries.buffer
- Buffer associated with the Reversible
s to be removed.int openScope(RecordBuffer buffer, boolean nestedOpen)
RecordBuffer
when a new buffer scope is opened to
register the open scope with the buffer manager, so that the buffer
can receive block scope start and stop notifications, and be registered
for commit processing when a full transaction is begun.buffer
- Buffer for which a new scope is being opened.nestedOpen
- true
if this buffer is already open.StaticTempTable registerStaticTempTable(Temporary defaultBuffer, boolean global)
defaultBuffer
- Default buffer for the target temp table.global
- Indicates if it is a global temp table (declared as SHARED GLOBAL).void registerOutputTableHandleCopier(OutputTableHandleCopier copier)
copier
- Copier to register.void unregisterOutputTableHandleCopier(OutputTableHandleCopier copier)
copier
- Copier to unregister.StaticTempTable getStaticTempTable(java.lang.String name)
name
- Legacy name of the target static temp table.null
if
there is no active table with the given name.int getStaticTempTableDepth(java.lang.String name)
name
- Legacy name of the target static temp table.-1
is returned.void addToAllBuffersArray(int blockDepth, RecordBuffer buffer)
blockDepth
- Zero-based depth of the block (starting from the outermost block) at which the
buffer was opened.buffer
- Buffer to add.void openScopeAt(int blockDepth, RecordBuffer buffer)
TemporaryBuffer
when a new dynamic buffer scope is opened to register the
open scope with the buffer manager, so that the buffer can receive block scope start and
stop notifications, and be registered for commit processing when a full transaction is
begun.blockDepth
- Zero-based depth of the block (starting from the outermost block) at which the
buffer scope is opened.buffer
- Buffer for which a new scope is being opened.void bufferActiveInTransaction(RecordBuffer buffer, boolean beginTx)
buffer
- Record buffer with an open buffer scope.beginTx
- Indicates whether to begin a new database transaction, in
addition to creating a transaction wrapper. This parameter is
ignored if a transaction wrapper already exists.RecordBuffer lookupBuffer(java.lang.String alias)
alias
- Buffer variable name in business logic.null
if not found.java.util.Iterator<RecordBuffer> activeBuffers(Persistence persistence)
null
current records for the given persistence object, within the current
client context. Auto-commit record buffers associated with a pending,
reversible rollback are not included in the iteration. Records that
represent copies of DMOs from other sessions, obtained from a DirtyShareContext
, are likewise excluded.persistence
- Persistence object which manages sessions. Only record
buffers associated with this persistence object are returned.java.util.Iterator<RecordBuffer> activeBuffers(Persistence persistence, boolean includeTransient)
null
current records for the given persistence object, within the current
client context. Auto-commit record buffers associated with a pending,
reversible rollback are not included in the iteration. Records that
represent copies of DMOs from other sessions, obtained from a DirtyShareContext
, are likewise excluded.persistence
- Persistence object which manages sessions. Only record
buffers associated with this persistence object are returned.includeTransient
- true
to include transient records in the result set.int incrementDMOUseCount(Persistable dmo)
decrementDMOUseCount(com.goldencode.p2j.persist.Persistable)
to
implement an aggressive DMO eviction policy. Records are evicted from
the current persistence session when their use counts reach zero.
Use counts must be maintained because multiple buffers may hold the same instance of a record. A record must not be evicted while any buffer still needs it.
dmo
- DMO instance whose reference count is to be incremented.dmo
after incrementing.int getDMOUseCount(Persistable dmo)
decrementDMOUseCount(com.goldencode.p2j.persist.Persistable)
and incrementDMOUseCount(com.goldencode.p2j.persist.Persistable)
to
maintain an evidence of the buffers referencing the dmo. Records are evicted from the
current persistence session when their use counts reach zero.
The actual count of buffers referencing the dmo is used to emulate the P4GL behavior when
rereadnolock
is specified. When this parameter is active, the dmo is refreshed
from database no matter how many buffers refer the dmo, otherwise only refresh the dmo if
it is referred by only one buffer.
dmo
- DMO instance whose reference count is to be returned.dmo
.int decrementDMOUseCount(Persistable dmo) throws PersistenceException
incrementDMOUseCount(com.goldencode.p2j.persist.Persistable)
to
implement an aggressive DMO eviction policy. Records are evicted from
the current persistence session when their use counts reach zero.
Use counts must be maintained because multiple buffers may hold the same instance of a record. A record must not be evicted while any buffer still needs it.
dmo
- DMO instance whose reference count is to be decremented.dmo
after decrementing, or -1 if use
count could not be found (possible in rare cases of interrupted
thread on session exit).PersistenceException
- if an error occurs detaching dmo
from the
persistence session.boolean evictDMOIfUnused(Persistence persistence, Persistence.Context local, Persistable dmo) throws PersistenceException
persistence
- Persistence object which manages sessions.local
- Current user persistence context.dmo
- DMO instance whose reference count is to be decremented.true
if the DMO was evicted; false
if it was referenced by other resources.PersistenceException
- if an error occurs detaching dmo
from the
persistence session.void notifyRecordWasLoaded(RecordBuffer recordBuffer)
recordBuffer
- The record buffer in which a record was loaded (or the old record
was reloaded).java.lang.String generateUniqueBufferName(java.lang.String legacyBufferName)
__{unique number}
postfix. This guarantees that the name will not contain
invalid characters and will be unique.legacyBufferName
- Legacy name of the buffer.private java.lang.String message(Persistence persistence, java.lang.String text)
persistence
- Persistence object which will provide context info.text
- Custom message text.