helma.objectmodel.db
Class Transactor

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

public class Transactor
extends java.lang.Object

A subclass of thread that keeps track of changed nodes and triggers changes in the database when a transaction is commited.


Field Summary
protected  ITransaction txn
           
 
Method Summary
 void abort()
          Abort the current transaction, rolling back all changes made.
 void begin(java.lang.String name)
          Start a new transaction with the given name.
 void closeConnections()
          Closes all open JDBC connections
 void commit()
          Commit the current transaction, persisting all changes to DB.
 void dropCleanNode(Key key)
          Drop a reference to an unmodified Node previously registered with visitCleanNode().
 void dropDirtyNode(Node node)
          Unmark a Node that has previously been marked as modified during the transaction
 Node getCleanNode(java.lang.Object key)
          Get a reference to an unmodified Node local to this transaction
 java.sql.Connection getConnection(DbSource src)
          Get a db connection that was previously registered with this transactor thread.
 Node getDirtyNode(Key key)
          Get a dirty Node from this transaction.
static Transactor getInstance()
          Get the transactor for the current thread or null if none exists.
static Transactor getInstance(NodeManager nmgr)
          Get the transactor for the current thread, creating a new one if none exists.
static Transactor getInstanceOrFail()
          Get the transactor for the current thread or throw a IllegalStateException if none exists.
 java.lang.String getTransactionName()
          Return the name of the current transaction.
 boolean isActive()
          Returns true if a transaction is currently active.
 boolean isAlive()
          Check whether the thread associated with this transactor is alive.
 void kill()
          Kill this transaction thread.
 void registerConnection(DbSource src, java.sql.Connection con)
          Register a db connection with this transactor thread.
 java.lang.String toString()
          Return a string representation of this Transactor thread
 void visitCleanNode(Key key, Node node)
          Keep a reference to an unmodified Node local to this transaction
 void visitCleanNode(Node node)
          Keep a reference to an unmodified Node local to this transaction
 void visitDirtyNode(Node node)
          Mark a Node as modified/created/deleted during this transaction
 void visitParentNode(Node node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

txn

protected ITransaction txn
Method Detail

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 java.lang.IllegalStateException
Get the transactor for the current thread or throw a IllegalStateException if none exists.

Returns:
the transactor associated with the current thread
Throws:
java.lang.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(java.lang.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,
                               java.sql.Connection con)
Register a db connection with this transactor thread.

Parameters:
src - the db source
con - the connection

getConnection

public java.sql.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(java.lang.String name)
           throws java.lang.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:
java.lang.Exception - ...

commit

public void commit()
            throws java.lang.Exception
Commit the current transaction, persisting all changes to DB.

Throws:
java.lang.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 java.lang.String getTransactionName()
Return the name of the current transaction. This is usually the request path for the underlying HTTP request.


toString

public java.lang.String toString()
Return a string representation of this Transactor thread

Overrides:
toString in class java.lang.Object
Returns:
...


Copyright © 1998-1998-${year} Helma.org. All Rights Reserved.