Class LogicRunner

java.lang.Object
com.github.sttk.sabi.LogicRunner
All Implemented Interfaces:
AutoCloseable

public final class LogicRunner extends Object implements AutoCloseable
Manages local DataSrc registrations and executes Logic units against a DataHub in either non-transactional or transactional scopes.
  • Method Summary

    Modifier and Type
    Method
    Description
    Begins a sequential transactional LogicTxn chain.
    void
    Closes the underlying DataHub and releases all local data sources and connections.
    void
    Unregisters the data source associated with the specified name if execution has not yet begun.
    <D> void
    run(Logic<D> logic)
    Executes the specified Logic in a single non-transactional scope.
    Starts a sequential non-transactional LogicRun chain.
    <D> void
    txn(Logic<D> logic)
    Executes the specified Logic within a transaction, automatically handling pre-commit, commit, post-commit, rollback, and failure reporting.
    void
    uses(String name, DataSrc ds)
    Registers a session-local DataSrc under the specified name if execution has not yet begun.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • close

      public void close()
      Closes the underlying DataHub and releases all local data sources and connections.
      Specified by:
      close in interface AutoCloseable
    • uses

      public void uses(String name, DataSrc ds)
      Registers a session-local DataSrc under the specified name if execution has not yet begun.
      Parameters:
      name - the logical name of the data source
      ds - the DataSrc instance to register
    • disuses

      public void disuses(String name)
      Unregisters the data source associated with the specified name if execution has not yet begun.
      Parameters:
      name - the logical name of the data source to remove
    • run

      public <D> void run(Logic<D> logic) throws com.github.sttk.errs.Err
      Executes the specified Logic in a single non-transactional scope.
      Type Parameters:
      D - the type of data access interface expected by the logic
      Parameters:
      logic - the logic unit to execute
      Throws:
      com.github.sttk.errs.Err - if the runner is in an abnormal state, local data source setup fails, or logic throws an Err
    • start

      public LogicRun start()
      Starts a sequential non-transactional LogicRun chain.
      Returns:
      a new LogicRun instance
    • txn

      public <D> void txn(Logic<D> logic) throws com.github.sttk.errs.Err
      Executes the specified Logic within a transaction, automatically handling pre-commit, commit, post-commit, rollback, and failure reporting.
      Type Parameters:
      D - the type of data access interface expected by the logic
      Parameters:
      logic - the logic unit to execute within the transaction
      Throws:
      com.github.sttk.errs.Err - if the runner is in an abnormal state, local data source setup fails, logic throws an Err, or committing the transaction fails
    • beginTxn

      public LogicTxn beginTxn()
      Begins a sequential transactional LogicTxn chain.
      Returns:
      a new LogicTxn instance