Package helma.objectmodel.db
Class Transactor
java.lang.Object
helma.objectmodel.db.Transactor
A subclass of thread that keeps track of changed nodes and triggers
changes in the database when a transaction is commited.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
abort()
Abort the current transaction, rolling back all changes made.void
Start a new transaction with the given name.void
Closes all open JDBC connectionsvoid
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 transactiongetCleanNode
(Object key) Get a reference to an unmodified Node local to this transactiongetConnection
(DbSource src) Get a db connection that was previously registered with this transactor thread.getDirtyNode
(Key key) Get a dirty Node from this transaction.static Transactor
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
Get the transactor for the current thread or throw a IllegalStateException if none exists.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, Connection con) Register a db connection with this transactor thread.toString()
Return a string representation of this Transactor threadvoid
visitCleanNode
(Key key, Node node) Keep a reference to an unmodified Node local to this transactionvoid
visitCleanNode
(Node node) Keep a reference to an unmodified Node local to this transactionvoid
visitDirtyNode
(Node node) Mark a Node as modified/created/deleted during this transactionvoid
visitParentNode
(Node node)
-
Field Details
-
txn
-
-
Method Details
-
getInstance
Get the transactor for the current thread or null if none exists.- Returns:
- the transactor associated with the current thread
-
getInstanceOrFail
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
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
Mark a Node as modified/created/deleted during this transaction- Parameters:
node
- ...
-
dropDirtyNode
Unmark a Node that has previously been marked as modified during the transaction- Parameters:
node
- ...
-
getDirtyNode
Get a dirty Node from this transaction.- Parameters:
key
- the key- Returns:
- the dirty node associated with the key, or null
-
visitCleanNode
Keep a reference to an unmodified Node local to this transaction- Parameters:
node
- the node to register
-
visitCleanNode
Keep a reference to an unmodified Node local to this transaction- Parameters:
key
- the key to register withnode
- the node to register
-
dropCleanNode
Drop a reference to an unmodified Node previously registered with visitCleanNode().- Parameters:
key
- the key
-
getCleanNode
Get a reference to an unmodified Node local to this transaction- Parameters:
key
- ...- Returns:
- ...
-
visitParentNode
- 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
Register a db connection with this transactor thread.- Parameters:
src
- the db sourcecon
- the connection
-
getConnection
Get a db connection that was previously registered with this transactor thread.- Parameters:
src
- the db source- Returns:
- the connection
-
begin
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
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
Return the name of the current transaction. This is usually the request path for the underlying HTTP request. -
toString
Return a string representation of this Transactor thread
-