Class Transactor

java.lang.Object
helma.objectmodel.db.Transactor

public class Transactor extends Object
A subclass of thread that keeps track of changed nodes and triggers changes in the database when a transaction is commited.
  • Field Details

  • Method Details

    • getInstance

      public static Transactor getInstance()
      Get the transactor for the current thread or null if none exists.
      Returns:
      the transactor associated with the current thread
    • getInstanceOrFail

      public static Transactor getInstanceOrFail() throws IllegalStateException
      Get the transactor for the current thread or throw a IllegalStateException if none exists.
      Returns:
      the transactor associated with the current thread
      Throws:
      IllegalStateException - if no transactor is associated with the current thread
    • getInstance

      public static Transactor getInstance(NodeManager nmgr)
      Get the transactor for the current thread, creating a new one if none exists.
      Parameters:
      nmgr - the NodeManager used to create the transactor
      Returns:
      the transactor associated with the current thread
    • visitDirtyNode

      public void visitDirtyNode(Node node)
      Mark a Node as modified/created/deleted during this transaction
      Parameters:
      node - ...
    • dropDirtyNode

      public void dropDirtyNode(Node node)
      Unmark a Node that has previously been marked as modified during the transaction
      Parameters:
      node - ...
    • getDirtyNode

      public Node getDirtyNode(Key key)
      Get a dirty Node from this transaction.
      Parameters:
      key - the key
      Returns:
      the dirty node associated with the key, or null
    • visitCleanNode

      public void visitCleanNode(Node node)
      Keep a reference to an unmodified Node local to this transaction
      Parameters:
      node - the node to register
    • visitCleanNode

      public void visitCleanNode(Key key, Node node)
      Keep a reference to an unmodified Node local to this transaction
      Parameters:
      key - the key to register with
      node - the node to register
    • dropCleanNode

      public void dropCleanNode(Key key)
      Drop a reference to an unmodified Node previously registered with visitCleanNode().
      Parameters:
      key - the key
    • getCleanNode

      public Node getCleanNode(Object key)
      Get a reference to an unmodified Node local to this transaction
      Parameters:
      key - ...
      Returns:
      ...
    • visitParentNode

      public void visitParentNode(Node node)
      Parameters:
      node - ...
    • isActive

      public boolean isActive()
      Returns true if a transaction is currently active.
      Returns:
      true if currently a transaction is active
    • isAlive

      public boolean isAlive()
      Check whether the thread associated with this transactor is alive. This is a proxy to Thread.isAlive().
      Returns:
      true if the thread running this transactor is currently alive.
    • registerConnection

      public void registerConnection(DbSource src, Connection con)
      Register a db connection with this transactor thread.
      Parameters:
      src - the db source
      con - the connection
    • getConnection

      public Connection getConnection(DbSource src)
      Get a db connection that was previously registered with this transactor thread.
      Parameters:
      src - the db source
      Returns:
      the connection
    • begin

      public void begin(String name) throws Exception
      Start a new transaction with the given name.
      Parameters:
      name - The name of the transaction. This is usually the request path for the underlying HTTP request.
      Throws:
      Exception - ...
    • commit

      public void commit() throws Exception
      Commit the current transaction, persisting all changes to DB.
      Throws:
      Exception - ...
    • abort

      public void abort()
      Abort the current transaction, rolling back all changes made.
    • kill

      public void kill()
      Kill this transaction thread. Used as last measure only.
    • closeConnections

      public void closeConnections()
      Closes all open JDBC connections
    • getTransactionName

      public String getTransactionName()
      Return the name of the current transaction. This is usually the request path for the underlying HTTP request.
    • toString

      public String toString()
      Return a string representation of this Transactor thread
      Overrides:
      toString in class Object
      Returns:
      ...