Class XAItemStateManager

    • Constructor Detail

      • XAItemStateManager

        protected 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 null then a default name is used
    • Method Detail

      • setVirtualProvider

        public void setVirtualProvider​(VirtualItemStateProvider virtualProvider)
        Set optional virtual item state provider.
      • associate

        public void associate​(org.apache.jackrabbit.data.core.TransactionContext tx)
        Specified by:
        associate in interface org.apache.jackrabbit.data.core.InternalXAResource
      • beforeOperation

        public void beforeOperation​(org.apache.jackrabbit.data.core.TransactionContext tx)
        Specified by:
        beforeOperation in interface org.apache.jackrabbit.data.core.InternalXAResource
      • prepare

        public void prepare​(org.apache.jackrabbit.data.core.TransactionContext tx)
                     throws org.apache.jackrabbit.data.core.TransactionException
        Specified by:
        prepare in interface org.apache.jackrabbit.data.core.InternalXAResource
        Throws:
        org.apache.jackrabbit.data.core.TransactionException
      • commit

        public void commit​(org.apache.jackrabbit.data.core.TransactionContext tx)
                    throws org.apache.jackrabbit.data.core.TransactionException
        Specified by:
        commit in interface org.apache.jackrabbit.data.core.InternalXAResource
        Throws:
        org.apache.jackrabbit.data.core.TransactionException
      • rollback

        public void rollback​(org.apache.jackrabbit.data.core.TransactionContext tx)
        Specified by:
        rollback in interface org.apache.jackrabbit.data.core.InternalXAResource
      • afterOperation

        public void afterOperation​(org.apache.jackrabbit.data.core.TransactionContext tx)
        Specified by:
        afterOperation in interface org.apache.jackrabbit.data.core.InternalXAResource
      • getChangeLog

        public ChangeLog getChangeLog()
        Returns the current change log. First tries thread-local change log, then instance-local change log. Returns null if no change log was found.
      • hasItemState

        public 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:
        hasItemState in interface ItemStateManager
        Overrides:
        hasItemState in class LocalItemStateManager
        Parameters:
        id - item id
        Returns:
        true if an item state exists, otherwise false
      • hasNodeReferences

        public 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:
        hasNodeReferences in interface ItemStateManager
        Overrides:
        hasNodeReferences in class LocalItemStateManager
        Parameters:
        id - target id
        Returns:
        true if a node reference object exists for the given id, otherwise false.
      • update

        protected 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:
        update in 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
      • stateModified

        public void stateModified​(ItemState modified)
        Called when an 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).

        Specified by:
        stateModified in interface ItemStateListener
        Overrides:
        stateModified in class LocalItemStateManager
        Parameters:
        modified - the ItemState that has been 'modified'