// locate and return the lock for a given TransactionLocal+Transaction tuple.
// create it if it does not exist.
private TransactionLocalLock findLock(final TransactionLocal local, final Transaction transaction) {
TransactionImple transactionImple = (TransactionImple) transaction;
Map<TransactionLocal, TransactionLocalLock> locks;
// ideally for performance we should sync on the tx instance itself but that may have nasty
// side effects so we use something else as the lock object for the sync block
synchronized (LOCKS_MAP) {
// ensure there is a holder for lock storage on the given tx instance.
locks = (Map) transactionImple.getTxLocalResource(LOCKS_MAP);
if (locks == null) {
locks = new HashMap<TransactionLocal, TransactionLocalLock>();
transactionImple.putTxLocalResource(LOCKS_MAP, locks);
}
}
TransactionLocalLock transactionLocalLock;
synchronized (locks) {