Class XAItemStateManager
- java.lang.Object
- 
- org.apache.jackrabbit.core.state.LocalItemStateManager
- 
- org.apache.jackrabbit.core.state.XAItemStateManager
 
 
- 
- All Implemented Interfaces:
- ItemStateListener,- ItemStateManager,- NodeStateListener,- UpdatableItemStateManager,- InternalXAResource
 
 public class XAItemStateManager extends LocalItemStateManager implements InternalXAResource Extension toLocalItemStateManagerthat remembers changes on multiple save() requests and commits them only when an associated transaction is itself committed.
- 
- 
Field Summary- 
Fields inherited from class org.apache.jackrabbit.core.state.LocalItemStateManagerfactory, sharedStateMgr
 
- 
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedXAItemStateManager(SharedItemStateManager sharedStateMgr, EventStateCollectionFactory factory, String attributeName, ItemStateCacheFactory cacheFactory)Creates a new instance of this class with a custom attribute name.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterOperation(TransactionContext tx)voidassociate(TransactionContext tx)Associate this resource with a transaction.voidbeforeOperation(TransactionContext tx)voidcommit(TransactionContext tx)Commit transaction.static XAItemStateManagercreateInstance(SharedItemStateManager sharedStateMgr, EventStateCollectionFactory factory, String attributeName, ItemStateCacheFactory cacheFactory)Creates a newXAItemStateManagerinstance and registers it as anItemStateListenerwith the givenSharedItemStateManager.ChangeLoggetChangeLog()Returns the current change log.protected ChangeLoggetChanges()Returns the change log that contains the current changes in this local item state manager.ItemStategetItemState(ItemId id)Return an item state, given its item id.NodeReferencesgetNodeReferences(NodeId id)Return a node references object, given its target idbooleanhasItemState(ItemId id)Return a flag indicating whether an item state for a given item id exists.booleanhasNodeReferences(NodeId id)Return a flag indicating whether a node references object for a given target id exists.voidprepare(TransactionContext tx)Prepare transaction.voidrollback(TransactionContext tx)Rollback transaction.voidsetVirtualProvider(VirtualItemStateProvider virtualProvider)Set optional virtual item state provider.voidstateModified(ItemState modified)Called when anItemStatehas successfully been modified (i.e.protected voidupdate(ChangeLog changeLog)End an update operation.- 
Methods inherited from class org.apache.jackrabbit.core.state.LocalItemStateManageraddListener, cancel, createInstance, createNew, createNew, destroy, dispose, edit, getNodeIdFactory, getNodeState, getOrCreateLocalState, getPropertyState, inEditMode, nodeAdded, nodeModified, nodeRemoved, nodesReplaced, removeListener, stateCreated, stateDestroyed, stateDiscarded, store, update
 
- 
 
- 
- 
- 
Constructor Detail- 
XAItemStateManagerprotected XAItemStateManager(SharedItemStateManager sharedStateMgr, EventStateCollectionFactory factory, String attributeName, ItemStateCacheFactory cacheFactory) Creates a new instance of this class with a custom attribute name.- Parameters:
- sharedStateMgr- shared state manager
- factory- event state collection factory
- attributeName- the attribute name, if- nullthen a default name is used
 
 
- 
 - 
Method Detail- 
createInstancepublic static XAItemStateManager createInstance(SharedItemStateManager sharedStateMgr, EventStateCollectionFactory factory, String attributeName, ItemStateCacheFactory cacheFactory) Creates a newXAItemStateManagerinstance and registers it as anItemStateListenerwith the givenSharedItemStateManager.- Parameters:
- sharedStateMgr- the- SharedItemStateManager
- factory- the- EventStateCollectionFactory
- attributeName- the attribute name, if- nullthen a default name is used
- cacheFactory- the- ItemStateCacheFactory
- Returns:
- a new XAItemStateManagerinstance
 
 - 
setVirtualProviderpublic void setVirtualProvider(VirtualItemStateProvider virtualProvider) Set optional virtual item state provider.
 - 
associatepublic void associate(TransactionContext tx) Associate this resource with a transaction. All further operations on the object should be interpreted as part of this transaction and changes recorded in some attribute of the transaction context.- Specified by:
- associatein interface- InternalXAResource
- Parameters:
- tx- transaction context, if- nulldisassociate
 
 - 
beforeOperationpublic void beforeOperation(TransactionContext tx) Invoked before one of theInternalXAResource.prepare(org.apache.jackrabbit.data.core.TransactionContext),InternalXAResource.commit(org.apache.jackrabbit.data.core.TransactionContext)orInternalXAResource.rollback(org.apache.jackrabbit.data.core.TransactionContext)method is called.- Specified by:
- beforeOperationin interface- InternalXAResource
- Parameters:
- tx- transaction context
 
 - 
preparepublic void prepare(TransactionContext tx) throws TransactionException Prepare transaction. The transaction is identified by a transaction context.- Specified by:
- preparein interface- InternalXAResource
- Parameters:
- tx- transaction context
- Throws:
- TransactionException- if an error occurs
 
 - 
commitpublic void commit(TransactionContext tx) throws TransactionException Commit transaction. The transaction is identified by a transaction context. If the method throws, other resources get their changes rolled back.- Specified by:
- commitin interface- InternalXAResource
- Parameters:
- tx- transaction context
- Throws:
- TransactionException- if an error occurs
 
 - 
rollbackpublic void rollback(TransactionContext tx) Rollback transaction. The transaction is identified by a transaction context.- Specified by:
- rollbackin interface- InternalXAResource
- Parameters:
- tx- transaction context.
 
 - 
afterOperationpublic void afterOperation(TransactionContext tx) Invoked after one of theInternalXAResource.prepare(org.apache.jackrabbit.data.core.TransactionContext),InternalXAResource.commit(org.apache.jackrabbit.data.core.TransactionContext)orInternalXAResource.rollback(org.apache.jackrabbit.data.core.TransactionContext)method has been called.- Specified by:
- afterOperationin interface- InternalXAResource
- Parameters:
- tx- transaction context
 
 - 
getChangeLogpublic ChangeLog getChangeLog() Returns the current change log. First tries thread-local change log, then instance-local change log. Returnsnullif no change log was found.
 - 
getChangesprotected ChangeLog getChanges() Description copied from class:LocalItemStateManagerReturns the change log that contains the current changes in this local item state manager.- Overrides:
- getChangesin class- LocalItemStateManager
- Returns:
- the change log with the current changes.
- Throws:
- UnsupportedOperationException- always.
 
 - 
getItemStatepublic ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException Return an item state, given its item 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. - Specified by:
- getItemStatein interface- ItemStateManager
- Overrides:
- getItemStatein class- LocalItemStateManager
- Parameters:
- id- item id
- Returns:
- item state
- Throws:
- NoSuchItemStateException- if the item does not exist
- ItemStateException- if an error occurs
 
 - 
hasItemStatepublic boolean hasItemState(ItemId id) Return a flag indicating whether an item state for a given item id exists.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. - Specified by:
- hasItemStatein interface- ItemStateManager
- Overrides:
- hasItemStatein class- LocalItemStateManager
- Parameters:
- id- item id
- Returns:
- trueif an item state exists, otherwise- false
 
 - 
getNodeReferencespublic NodeReferences getNodeReferences(NodeId id) throws NoSuchItemStateException, ItemStateException Return a node references object, given its target idIf 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. - Specified by:
- getNodeReferencesin interface- ItemStateManager
- Overrides:
- getNodeReferencesin class- LocalItemStateManager
- Parameters:
- id- target id
- Returns:
- node references object
- Throws:
- NoSuchItemStateException- if the item does not exist
- ItemStateException- if an error occurs
 
 - 
hasNodeReferencespublic boolean hasNodeReferences(NodeId id) Return a flag indicating whether a node references object for a given target id exists.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. - Specified by:
- hasNodeReferencesin interface- ItemStateManager
- Overrides:
- hasNodeReferencesin class- LocalItemStateManager
- Parameters:
- id- target id
- Returns:
- trueif a node reference object exists for the given id, otherwise- false.
 
 - 
updateprotected void update(ChangeLog changeLog) throws ReferentialIntegrityException, StaleItemStateException, ItemStateException End an update operation. Fetch the states and references from the parent (shared) item manager, reconnect them to the items collected in our (local) change log and overwrite the shared items with our copies.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). - Overrides:
- updatein class- LocalItemStateManager
- Parameters:
- changeLog- change log containing local states and references
- Throws:
- ReferentialIntegrityException- if a new or modified REFERENCE property refers to a non-existent target or if a removed node is still being referenced
- StaleItemStateException- if at least one of the affected item states has become stale in the meantime
- ItemStateException- if an error occurs
 
 - 
stateModifiedpublic void stateModified(ItemState modified) Called when anItemStatehas 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). - Specified by:
- stateModifiedin interface- ItemStateListener
- Overrides:
- stateModifiedin class- LocalItemStateManager
- Parameters:
- modified- the- ItemStatethat has been 'modified'
 
 
- 
 
-