Class LocalTransactionContext


  • public class LocalTransactionContext
    extends java.lang.Object
    A local transaction's thread context
    Author:
    Ludovic Orban
    • Constructor Detail

      • LocalTransactionContext

        public LocalTransactionContext​(int transactionTimeout,
                                       TransactionIDFactory transactionIdFactory)
        Create a new LocalTransactionContext
        Parameters:
        transactionTimeout - the timeout before the context expires
        transactionIdFactory - the transaction ID factory to retrieve a new transaction id from
    • Method Detail

      • timedOut

        public boolean timedOut()
        Check if the context timed out
        Returns:
        true if the context timed out, false otherwise
      • timeBeforeTimeout

        public long timeBeforeTimeout()
        Get the time until this context will expire
        Returns:
        the time in milliseconds after which this context will expire
      • setRollbackOnly

        public void setRollbackOnly()
        Mark the context for rollback
      • registerSoftLock

        public void registerSoftLock​(java.lang.String cacheName,
                                     LocalTransactionStore store,
                                     SoftLock softLock)
        Register a soft lock in the context
        Parameters:
        cacheName - the name of the cache this soft lock is in
        store - the LocalTransactionStore this soft lock is in
        softLock - the soft lock
      • updateSoftLock

        public void updateSoftLock​(java.lang.String cacheName,
                                   SoftLock softLock)
        Update a soft lock already registered in the context
        Parameters:
        cacheName - the name of the cache this soft lock is in
        softLock - the soft lock
      • getSoftLocksForCache

        public java.util.List<SoftLock> getSoftLocksForCache​(java.lang.String cacheName)
        Get all soft locks registered in this context for a specific cache
        Parameters:
        cacheName - the name of the cache
        Returns:
        a List of registered soft locks for this cache
      • hasLockedAnything

        public boolean hasLockedAnything()
        Check if anything was locked in this transaction's context
        Returns:
        true if at least one soft lock got registered, false otherwise
      • commit

        public void commit​(boolean ignoreTimeout)
        Commit all work done in the context and release all registered soft locks
        Parameters:
        ignoreTimeout - true if commit should proceed no matter the timeout
      • rollback

        public void rollback()
        Rollback all work done in the context and release all registered soft locks
      • getTransactionId

        public TransactionID getTransactionId()
        Get the transaction ID of the context
        Returns:
        the transaction ID
      • addListener

        public void addListener​(TransactionListener listener)
        Add a TransactionListener to this context
        Parameters:
        listener - the listener
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object