Class DbTransactionFactory

java.lang.Object
org.tentackle.dbms.DbTransactionFactory

@Service(DbTransactionFactory.class) public class DbTransactionFactory extends Object
Factory for transactions.
Collects duration statistics and monitors transactions.
  • Constructor Details

    • DbTransactionFactory

      public DbTransactionFactory()
      Creates the transaction factory.
  • Method Details

    • getInstance

      public static DbTransactionFactory getInstance()
      The singleton.
      Returns:
      the singleton
    • configure

      public void configure(EncryptedProperties properties)
      Configures the factory from the main session properties.
      Parameters:
      properties - the properties
    • create

      public DbTransaction create(Db db, String txName, boolean fromRemote)
      Creates a transaction.
      Notice that this method is only invoked for local sessions, never for remote sessions.
      Parameters:
      db - the session
      txName - the transaction name, null if <unnamed>
      fromRemote - true if initiated from remote client
    • finish

      public void finish(DbTransaction transaction, boolean rolledBack)
      Finishes a transaction.
      Invoked when a transaction is committed or rolled back.
      Notice that this method is only invoked for local sessions, never for remote sessions.
      Parameters:
      transaction - the transaction
      rolledBack - true if transaction was rolled back, false if committed
    • setCollectingStatistics

      public void setCollectingStatistics(boolean collectingStatistics)
      Sets whether statistics should be collected.
      Parameters:
      collectingStatistics - true if transactions are counted and execution times measured
    • isCollectingStatistics

      public boolean isCollectingStatistics()
      Returns whether statistics are collected.
      Returns:
      true if transactions are counted and execution times measured
    • logStatistics

      public void logStatistics(Logger.Level level, boolean clear)
      Logs the statistics.
      Parameters:
      level - the logging level
      clear - true if clear statistics after dump
    • getTxIdleInterval

      public long getTxIdleInterval()
      Gets the check interval for idle or unreferenced transactions in ms.
      Returns:
      the check interval
    • setTxIdleInterval

      public void setTxIdleInterval(long txIdleInterval)
      Sets the check interval for idle or unreferenced transactions in ms.
      Parameters:
      txIdleInterval - the check interval
    • getTxIdleTimeout

      public int getTxIdleTimeout()
      Gets the number of check intervals that must elapse to for an idle transaction to time out.
      Returns:
      the idle count
    • setTxIdleTimeout

      public void setTxIdleTimeout(int txIdleTimeout)
      Sets the number of check intervals that must elapse to for an idle transaction to time out.
      Parameters:
      txIdleTimeout - the idle count, ≤ 0 to disable
    • requestTermination

      public void requestTermination()
      Requests supervisor thread termination.