Interface CDOTransactionScope

All Superinterfaces:
AutoCloseable, CDORollbackable, CDOTransactionAware

public interface CDOTransactionScope extends CDOTransactionAware, CDORollbackable, AutoCloseable
A stack-disciplined nested lifecycle region in a transaction.

A scope shares its transaction's view, repository session, resource set, object identities, object cache, dirty state, and locks. Changes made in a scope are immediately visible in the containing transaction and remain part of its effective state until the scope or an enclosing transaction rolls them back.

Committing a scope accepts its changes into its outer scope or the root transaction. It never commits to the repository, assigns permanent IDs, establishes a repository baseline, or starts a repository commit epoch. Only the root transaction's repository commit persists the effective changes. Scopes belong to the transaction rather than to a thread: they may be opened and completed on different threads. Individual lifecycle operations are atomic; callers that need a larger isolated sequence must use the transaction's existing synchronization mechanism.

Since:
4.30
Author:
Eike Stepper
No Implement
This interface is not intended to be implemented by clients.
No Extend
This interface is not intended to be extended by clients.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the transaction-compatible facade for this scope.
    void
    Rolls this scope back when it is still open.
    void
    Accepts this scope into its outer scope or root transaction.
    int
    Returns this scope's one-based nesting depth.
    Returns the immediately nested scope, or null if this is currently innermost.
    Returns the immediately enclosing scope, or null for the outermost scope.
    Returns the root transaction that contains this scope.
    boolean
    Indicates whether this scope is still open.
    Opens a child scope relative to this scope.
    void
    Rolls this scope and all of its open child scopes back to the state at this scope's beginning.
  • Method Details

    • getTransaction

      CDOTransaction getTransaction()
      Returns the root transaction that contains this scope.
      Specified by:
      getTransaction in interface CDOTransactionAware
      Returns:
      the containing root transaction.
    • getOuterScope

      CDOTransactionScope getOuterScope()
      Returns the immediately enclosing scope, or null for the outermost scope.
      Returns:
      the outer scope, or null.
    • getInnerScope

      CDOTransactionScope getInnerScope()
      Returns the immediately nested scope, or null if this is currently innermost.
      Returns:
      the inner scope, or null.
    • getDepth

      int getDepth()
      Returns this scope's one-based nesting depth.
      Returns:
      the scope depth.
    • isOpen

      boolean isOpen()
      Indicates whether this scope is still open.
      Returns:
      true if the scope can still be completed.
    • openScope

      CDOTransactionScope openScope()
      Opens a child scope relative to this scope.
      Returns:
      the newly opened child scope.
      Throws:
      IllegalStateException - if this scope is not the current innermost scope.
    • commit

      void commit()
      Accepts this scope into its outer scope or root transaction.

      This operation is a nested-scope commit only. It does not persist changes, assign permanent IDs, establish a repository baseline, or close the root transaction's repository commit epoch. A later root transaction commit is required for persistence.

      Throws:
      IllegalStateException - if this scope is not the current innermost open scope or is already closed.
    • rollback

      void rollback()
      Rolls this scope and all of its open child scopes back to the state at this scope's beginning.

      Changes made before this scope remain in the containing transaction. The rollback does not affect the repository commit epoch.

      Specified by:
      rollback in interface CDORollbackable
      Throws:
      IllegalStateException - if this scope is already closed.
    • close

      void close()
      Rolls this scope back when it is still open.

      Calling this method after the scope has closed has no effect. In particular, closing an active scope rolls back its changes, while closing an already closed scope is idempotent.

      Specified by:
      close in interface AutoCloseable
    • asTransaction

      CDONestedTransaction asTransaction()
      Returns the transaction-compatible facade for this scope. Repeated calls return the same facade instance.
      Returns:
      the stable nested transaction facade.