// Give users the option to use thread-local transactions
// with a single PersistenceManager.
Transaction txn = null;
if (transaction instanceof WeakHashMap) {
WeakHashMap threadTransactionMap = (WeakHashMap)transaction;
Thread currentThread = Thread.currentThread();
synchronized(threadTransactionMap) {
txn = (Transaction)threadTransactionMap.get(currentThread);
if(txn == null) {
txn = new TransactionImpl(this, factory.newDatastoreDriver(), jdoOptions);
threadTransactionMap.put(currentThread, txn);
}
}
} else {
txn = (Transaction) transaction;
}