corda / net.corda.node.utilities / StrandLocalTransactionManager / <init>

# <init>

`StrandLocalTransactionManager(initWithDatabase: Database)`

A relatively close copy of the ThreadLocalTransactionManager in Exposed but with the following adjustments to suit our environment:

Because the construction of a Database instance results in replacing the singleton TransactionManager instance, our tests involving two MockNodes effectively replace the database instances of each other and continue to trample over each other. So here we use a companion object to hold them as ThreadLocal and StrandLocalTransactionManager is otherwise effectively stateless so it's replacement does not matter. The ThreadLocal is then set correctly and explicitly just prior to initiating a transaction in databaseTransaction and createDatabaseTransaction above.

The StrandLocalTransactionManager instances have an Observable of the transaction close Boundarys which facilitates the use of Observable.afterDatabaseCommit to create event streams that only emit once the database transaction is closed and the data has been persisted and becomes visible to other observers.