org.modeshape.jcr.cache.document
Class TransactionalWorkspaceCache
java.lang.Object
org.modeshape.jcr.cache.document.WorkspaceCache
org.modeshape.jcr.cache.document.TransactionalWorkspaceCache
- All Implemented Interfaces:
- ChangeSetListener, DocumentCache, NodeCache
public class TransactionalWorkspaceCache
- extends WorkspaceCache
A special WorkspaceCache implementation that should be used by sessions running within user transactions.
Normally, each RepositoryCache
instance has for each workspace a single WorkspaceCache instance shared by all sessions.
However, in the event that a session is running within a user transaction, it is possible for the session (or other sessions
that are also participating in the same user transaction) to persist node changes in the document store but to not commit the
transaction. This means that no other transactions should see these persisted-but-not-committed node representations. Thus,
these sessions running within a user transaction cannot share the common WorkspaceCache instance, lest any node representations
persisted-but-not-committed be loaded into the WorkspaceCache (leaking transaction-scoped data outside of the transaction) or
the shared WorkspaceCache instance has already-cached pre-modified representations of the persisted-but-not-committed nodes
(transaction-scoped changes are not visible to the transaction).
Therefore, such sessions running within user transactions need a transactionally-scoped WorkspaceCache instance. Because the
ModeShape infrastructure is not set up to handle lots of WorkspaceCache instances, we only want one instance that is actually
caching nodes. Therefore, the WorkspaceCache returned from this method will never cache any nodes and will always re-read the
nodes from the document store.
Method Summary |
void |
changed(ChangeSet changes)
Signal that changes have been made to the persisted data. |
void |
changedWithinTransaction(ChangeSet changes)
Signal that this transaction-specific workspace cache needs to reflect recent changes that have been persisted but not yet
committed. |
void |
clear()
Clears all changes in the cache. |
void |
notify(ChangeSet changeSet)
|
Methods inherited from class org.modeshape.jcr.cache.document.WorkspaceCache |
checkNotClosed, getAllNodeKeys, getAllNodeKeysAtAndBelow, getChildReference, getNode, getNode, getProcessKey, getRepositoryKey, getRootKey, getWorkspaceKey, getWorkspaceName, isEmpty, setMinimumStringLengthForBinaryStorage, signalClosed, signalClosing, signalDeleted, toString, unwrap, workspaceCache |
TransactionalWorkspaceCache
protected TransactionalWorkspaceCache(WorkspaceCache sharedWorkspaceCache,
TransactionalWorkspaceCaches cacheManager,
Transaction txn)
changed
public void changed(ChangeSet changes)
- Description copied from class:
WorkspaceCache
- Signal that changes have been made to the persisted data. Related information in the cache is cleared, and this workspace's
listener is notified of the changes.
- Overrides:
changed
in class WorkspaceCache
- Parameters:
changes
- the changes to be made; may not be null
changedWithinTransaction
public void changedWithinTransaction(ChangeSet changes)
- Signal that this transaction-specific workspace cache needs to reflect recent changes that have been persisted but not yet
committed. Generally, the transactional workspace cache will clear any cached nodes that were included in the change set
- Parameters:
changes
- the changes that were persisted but not yet committed- See Also:
SynchronizedTransactions.updateCache(WorkspaceCache, ChangeSet, org.modeshape.jcr.txn.Transactions.Transaction)
clear
public void clear()
- Description copied from interface:
NodeCache
- Clears all changes in the cache.
- Specified by:
clear
in interface NodeCache
- Overrides:
clear
in class WorkspaceCache
notify
public void notify(ChangeSet changeSet)
- Specified by:
notify
in interface ChangeSetListener
- Overrides:
notify
in class WorkspaceCache
Copyright © 2008-2013 JBoss, a division of Red Hat. All Rights Reserved.