public class XAItemStateManager extends LocalItemStateManager implements InternalXAResource
LocalItemStateManager
that remembers changes on
multiple save() requests and commits them only when an associated transaction
is itself committed.factory, sharedStateMgr
Modifier | Constructor and Description |
---|---|
protected |
XAItemStateManager(SharedItemStateManager sharedStateMgr,
EventStateCollectionFactory factory,
String attributeName,
ItemStateCacheFactory cacheFactory)
Creates a new instance of this class with a custom attribute name.
|
Modifier and Type | Method and Description |
---|---|
void |
afterOperation(TransactionContext tx)
|
void |
associate(TransactionContext tx)
Associate this resource with a transaction.
|
void |
beforeOperation(TransactionContext tx)
|
void |
commit(TransactionContext tx)
Commit transaction.
|
static XAItemStateManager |
createInstance(SharedItemStateManager sharedStateMgr,
EventStateCollectionFactory factory,
String attributeName,
ItemStateCacheFactory cacheFactory)
Creates a new
XAItemStateManager instance and registers it as an ItemStateListener
with the given SharedItemStateManager . |
ChangeLog |
getChangeLog()
Returns the current change log.
|
protected ChangeLog |
getChanges()
Returns the change log that contains the current changes in this local
item state manager.
|
ItemState |
getItemState(ItemId id)
Return an item state, given its item id.
|
NodeReferences |
getNodeReferences(NodeId id)
Return a node references object, given its target id
|
boolean |
hasItemState(ItemId id)
Return a flag indicating whether an item state for a given
item id exists.
|
boolean |
hasNodeReferences(NodeId id)
Return a flag indicating whether a node references object
for a given target id exists.
|
void |
prepare(TransactionContext tx)
Prepare transaction.
|
void |
rollback(TransactionContext tx)
Rollback transaction.
|
void |
setVirtualProvider(VirtualItemStateProvider virtualProvider)
Set optional virtual item state provider.
|
void |
stateModified(ItemState modified)
Called when an
ItemState has successfully
been modified (i.e. |
protected void |
update(ChangeLog changeLog)
End an update operation.
|
addListener, cancel, createInstance, createNew, createNew, destroy, dispose, edit, getNodeIdFactory, getNodeState, getOrCreateLocalState, getPropertyState, inEditMode, nodeAdded, nodeModified, nodeRemoved, nodesReplaced, removeListener, stateCreated, stateDestroyed, stateDiscarded, store, update
protected XAItemStateManager(SharedItemStateManager sharedStateMgr, EventStateCollectionFactory factory, String attributeName, ItemStateCacheFactory cacheFactory)
sharedStateMgr
- shared state managerfactory
- event state collection factoryattributeName
- the attribute name, if null
then a default name is usedpublic static XAItemStateManager createInstance(SharedItemStateManager sharedStateMgr, EventStateCollectionFactory factory, String attributeName, ItemStateCacheFactory cacheFactory)
XAItemStateManager
instance and registers it as an ItemStateListener
with the given SharedItemStateManager
.sharedStateMgr
- the SharedItemStateManager
factory
- the EventStateCollectionFactory
attributeName
- the attribute name, if null
then a default name is usedcacheFactory
- the ItemStateCacheFactory
XAItemStateManager
instancepublic void setVirtualProvider(VirtualItemStateProvider virtualProvider)
public void associate(TransactionContext tx)
associate
in interface InternalXAResource
tx
- transaction context, if null
disassociatepublic void beforeOperation(TransactionContext tx)
InternalXAResource.prepare(org.apache.jackrabbit.data.core.TransactionContext)
, InternalXAResource.commit(org.apache.jackrabbit.data.core.TransactionContext)
or
InternalXAResource.rollback(org.apache.jackrabbit.data.core.TransactionContext)
method is called.beforeOperation
in interface InternalXAResource
tx
- transaction contextpublic void prepare(TransactionContext tx) throws TransactionException
prepare
in interface InternalXAResource
tx
- transaction contextTransactionException
- if an error occurspublic void commit(TransactionContext tx) throws TransactionException
commit
in interface InternalXAResource
tx
- transaction contextTransactionException
- if an error occurspublic void rollback(TransactionContext tx)
rollback
in interface InternalXAResource
tx
- transaction context.public void afterOperation(TransactionContext tx)
InternalXAResource.prepare(org.apache.jackrabbit.data.core.TransactionContext)
, InternalXAResource.commit(org.apache.jackrabbit.data.core.TransactionContext)
or
InternalXAResource.rollback(org.apache.jackrabbit.data.core.TransactionContext)
method has been called.afterOperation
in interface InternalXAResource
tx
- transaction contextpublic ChangeLog getChangeLog()
null
if no
change log was found.protected ChangeLog getChanges()
LocalItemStateManager
getChanges
in class LocalItemStateManager
UnsupportedOperationException
- always.public ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException
If this state manager is committing changes, this method first checks the commitLog ThreadLocal. Else if associated to a transaction check the transactional change log. Fallback is always the call to the base class.
getItemState
in interface ItemStateManager
getItemState
in class LocalItemStateManager
id
- item idNoSuchItemStateException
- if the item does not existItemStateException
- if an error occurspublic boolean hasItemState(ItemId id)
If this state manager is committing changes, this method first checks the commitLog ThreadLocal. Else if associated to a transaction check the transactional change log. Fallback is always the call to the base class.
hasItemState
in interface ItemStateManager
hasItemState
in class LocalItemStateManager
id
- item idtrue
if an item state exists,
otherwise false
public NodeReferences getNodeReferences(NodeId id) throws NoSuchItemStateException, ItemStateException
If this state manager is committing changes, this method first checks the commitLog ThreadLocal. Else if associated to a transaction check the transactional change log. Fallback is always the call to the base class.
getNodeReferences
in interface ItemStateManager
getNodeReferences
in class LocalItemStateManager
id
- target idNoSuchItemStateException
- if the item does not existItemStateException
- if an error occurspublic boolean hasNodeReferences(NodeId id)
If this state manager is committing changes, this method first checks the commitLog ThreadLocal. Else if associated to a transaction check the transactional change log. Fallback is always the call to the base class.
hasNodeReferences
in interface ItemStateManager
hasNodeReferences
in class LocalItemStateManager
id
- target idtrue
if a node reference object exists for the given
id, otherwise false
.protected void update(ChangeLog changeLog) throws ReferentialIntegrityException, StaleItemStateException, ItemStateException
If associated with a transaction, simply merge the changes given to the ones already known (removing items that were first added and then again deleted).
update
in class LocalItemStateManager
changeLog
- change log containing local states and referencesReferentialIntegrityException
- if a new or modified REFERENCE
property refers to a non-existent
target or if a removed node is still
being referencedStaleItemStateException
- if at least one of the affected item
states has become stale in the meantimeItemStateException
- if an error occurspublic void stateModified(ItemState modified)
ItemState
has successfully
been modified (i.e. its underlying persistent state has changed).
Notification handler gets called for both local states that this state manager has created, as well as states that were created by the shared state manager we're listening to. Check whether the shared state modified is contained in our transactional log: in that case, update its state as well, as it might get reused in a subsequent transaction (see JCR-1554).
stateModified
in interface ItemStateListener
stateModified
in class LocalItemStateManager
modified
- the ItemState
that has been 'modified'Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.