Class AbstractTransactionManager

java.lang.Object
org.neo4j.ogm.session.transaction.AbstractTransactionManager
All Implemented Interfaces:
org.neo4j.ogm.transaction.TransactionManager
Direct Known Subclasses:
DefaultTransactionManager

public abstract class AbstractTransactionManager extends Object implements org.neo4j.ogm.transaction.TransactionManager
This abstract base class of a Neo4j-OGM TransactionManager can be used to adapt the handling of thread local transactions to various scenarios that might not be able to deal with Thread locals or that are keen on not having them for performance reasons.

The implemented methods of the interface are intentionally final so that they are guaranteed to work according to the systems' specification.

Since:
4.0.3
Author:
Michael J. Simons
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.neo4j.ogm.transaction.TransactionManager

    org.neo4j.ogm.transaction.TransactionManager.TransactionClosedListener
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractTransactionManager(org.neo4j.ogm.driver.Driver driver, Session session)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    bookmark(String bookmark)
     
    final void
    close(org.neo4j.ogm.transaction.Transaction transaction, Consumer<org.neo4j.ogm.transaction.TransactionManager.TransactionClosedListener> callback)
     
    protected abstract org.neo4j.ogm.transaction.Transaction
    openOrExtend(Supplier<org.neo4j.ogm.transaction.Transaction> opener, UnaryOperator<org.neo4j.ogm.transaction.Transaction> extender)
    Opens a new transaction if there is no current via the opener or passes a current transaction to the extender.
    final org.neo4j.ogm.transaction.Transaction
    Opens a new transaction against a database instance.
    final org.neo4j.ogm.transaction.Transaction
    openTransaction(org.neo4j.ogm.transaction.Transaction.Type type, Iterable<String> bookmarks)
    Opens a new transaction against a database instance.
    protected abstract void
    removeIfCurrent(org.neo4j.ogm.transaction.Transaction transaction, Runnable action)
    Check if transaction is the transaction belonging to this thread, if so, calls the action and then detach the transaction from the thread.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.neo4j.ogm.transaction.TransactionManager

    getCurrentTransaction
  • Constructor Details

    • AbstractTransactionManager

      protected AbstractTransactionManager(org.neo4j.ogm.driver.Driver driver, Session session)
      Parameters:
      driver - The driver that will provide native transactions via Driver.getTransactionFactorySupplier()
      session - The OGM session that requires this transaction manager
  • Method Details

    • bookmark

      public final void bookmark(String bookmark)
      Specified by:
      bookmark in interface org.neo4j.ogm.transaction.TransactionManager
    • openTransaction

      public final org.neo4j.ogm.transaction.Transaction openTransaction()
      Opens a new transaction against a database instance. Instantiation of the transaction is left to the driver
      Specified by:
      openTransaction in interface org.neo4j.ogm.transaction.TransactionManager
      Returns:
      a new Transaction
    • openTransaction

      public final org.neo4j.ogm.transaction.Transaction openTransaction(org.neo4j.ogm.transaction.Transaction.Type type, Iterable<String> bookmarks)
      Opens a new transaction against a database instance. Instantiation of the transaction is left to the driver
      Specified by:
      openTransaction in interface org.neo4j.ogm.transaction.TransactionManager
      Returns:
      a new Transaction
    • openOrExtend

      protected abstract org.neo4j.ogm.transaction.Transaction openOrExtend(Supplier<org.neo4j.ogm.transaction.Transaction> opener, UnaryOperator<org.neo4j.ogm.transaction.Transaction> extender)
      Opens a new transaction if there is no current via the opener or passes a current transaction to the extender. The latter will try to extend the transaction if it's compatible.
      Parameters:
      opener - The opener of new transaction
      extender - The extender trying to create sub transactions
      Returns:
      The new current transaction
    • close

      public final void close(org.neo4j.ogm.transaction.Transaction transaction, Consumer<org.neo4j.ogm.transaction.TransactionManager.TransactionClosedListener> callback)
      Specified by:
      close in interface org.neo4j.ogm.transaction.TransactionManager
    • removeIfCurrent

      protected abstract void removeIfCurrent(org.neo4j.ogm.transaction.Transaction transaction, Runnable action)
      Check if transaction is the transaction belonging to this thread, if so, calls the action and then detach the transaction from the thread.
      Parameters:
      action - The action to be run prior to detaching / unlocking the transaction from the thread.