Ambient authority and Sleepycat Java Edition and stateful services
I’ve recently written an RMI service which has state – transactions. The service is implemented using Sleepycat Java Edition collections, and the transactions map to sleepycat transactions.
The StoredMap class depends on ambient authority: it determines the current transaction from the thread. The methods will all be invoked in on separate threads, so we need to deal with this somehow. This should be pretty simple – surely there will be a ‘join’ method – to join the current thread to the transaction. Nope. So now what?
I’ll just have to keep a thread running for the transaction, and execute transactional code in that thread.
In Java 5, we get Executors and Futures in java.util.concurrent, which make this very simple to implement. In fact, we can add some sugar – I can generate a proxy class for an interface, which executes its methods inside a single thread.
Anyway, I have, and added it to the LShift Java Library. It even mangles stack traces into something you can read.