Class StagedTransaction

java.lang.Object
com.vaadin.signals.impl.Transaction
com.vaadin.signals.impl.StagedTransaction

public class StagedTransaction extends Transaction
A conventional read-write transaction that stages commands to be submitted as a single commit. Commits by incorporating staged changes into the outer transaction if it's another staged transaction and otherwise performs a two-phase commit to atomically apply changes to all participating trees. Provides repeatable reads that are supplemented by changes from any staged commands.
  • Constructor Details

    • StagedTransaction

      public StagedTransaction(Transaction outer)
      Creates a new staged transaction for the given outer transaction.
      Parameters:
      outer - the outer transaction to wrap, not null
  • Method Details

    • commit

      protected void commit(Consumer<SignalOperation.ResultOrError<Void>> resultHandler)
      Description copied from class: Transaction
      Commits any staged commands in this transaction.
      Specified by:
      commit in class Transaction
      Parameters:
      resultHandler - a consumer to update the result value in the corresponding transaction operation, not null
    • include

      public void include(SignalTree tree, SignalCommand command, Consumer<CommandResult> resultHandler, boolean applyToTree)
      Description copied from class: Transaction
      Includes the given command to the given tree in the context of this transaction and optionally also sets the command to be applied to the underlying signal tree. Depending on the transaction type, an applied command may be applied immediately, collected to be applied upon committing, or rejected with an IllegalStateException.
      Specified by:
      include in class Transaction
      Parameters:
      tree - the signal tree against which to run the command, not null
      command - the command to include, not null
      resultHandler - the handler of the command result, or null to ignore the result
      applyToTree - true to apply the command to the underlying tree, false to only update the transaction's repeatable-read revision
    • read

      public TreeRevision read(SignalTree tree)
      Description copied from class: Transaction
      Gets a revision for reading from the given tree in the context of this transaction.
      Specified by:
      read in class Transaction
      Parameters:
      tree - the tree to read from, not null
      Returns:
      a tree revision to read from, not null
    • rollback

      protected void rollback()
      Description copied from class: Transaction
      Rolls back any staged commands in this transaction and notifies the result handlers for those commands.
      Specified by:
      rollback in class Transaction
    • readonly

      protected boolean readonly()
      Description copied from class: Transaction
      Checks whether this is a read-only transaction. A read-only transaction only allows writes to computed signal trees since those are not user-originated write operations but just side effects of lazy evaluation.
      Specified by:
      readonly in class Transaction
      Returns:
      false if this transaction allows regular writes to the underlying tree, true otherwise.