Class NestedTransaction

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public final class NestedTransaction
    extends java.lang.Object
    implements java.lang.AutoCloseable
    A transaction which may contain a list of transactions, typically to represent a distributed transaction over multiple systems.
    Author:
    bratseth
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      NestedTransaction add​(Transaction transaction, java.lang.Class<? extends Transaction>... before)
      Adds a transaction to this.
      void close()
      Free up any temporary resources held by this
      void commit()
      Perform a 2 phase commit
      void onCommitted​(java.lang.Runnable runnable)  
      java.lang.String toString()  
      java.util.List<Transaction> transactions()
      Returns the transactions nested in this, as they will be committed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • NestedTransaction

        public NestedTransaction()
    • Method Detail

      • add

        @SafeVarargs
        public final NestedTransaction add​(Transaction transaction,
                                           java.lang.Class<? extends Transaction>... before)
        Adds a transaction to this.
        Parameters:
        transaction - the transaction to add
        before - transaction classes which should commit after this, if present. It is beneficial to order transaction types from the least to most reliable. If conflicting ordering constraints are given this will not be detected at add time but the transaction will fail to commit
        Returns:
        this for convenience
      • transactions

        public java.util.List<Transaction> transactions()
        Returns the transactions nested in this, as they will be committed.
      • commit

        public void commit()
        Perform a 2 phase commit
      • onCommitted

        public void onCommitted​(java.lang.Runnable runnable)
      • close

        public void close()
        Free up any temporary resources held by this
        Specified by:
        close in interface java.lang.AutoCloseable
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object