protected DefaultTransactionStatistics thisStatistics() { Object key = tm.getTransactionKey(); DefaultTransactionStatistics stats; synchronized (this) { stats = activeStatistics.get(key); } if (stats == null) { log.debug(key + " not found in active statistics map"); } return stats; }
@Override public void threadAssociated(Transaction tx) { long now = System.currentTimeMillis(); Object key = tm.getTransactionKey(); ThreadContext.put("tx", id(key)); Stopwatch sw = SimonManager.getStopwatch("tx"); final Thread thread = Thread.currentThread(); DefaultTransactionStatistics info = new DefaultTransactionStatistics(key); info.split = sw.start(); info.threadName = thread.getName(); info.status = TransactionStatistics.Status.fromTx(tx); info.startTimestamp = now; info.startCapturedContext = new Throwable("** start invoke context **"); synchronized (this) { activeStatistics.put(key, info); } if (TransactionStatistics.Status.ACTIVE == info.status) { tm.registerInterposedSynchronization(this); // register end status } if (log.isTraceEnabled()) { log.trace(info.toString()); } }
@Override public void joinTransaction() { //This checks section 5.6.3.1, throwing an EJBException if there is already a PersistenceContext. if (transactionManager.getResource(persistenceUnit) != null) { throw new EJBException("EntityManager " + transactionManager.getResource(persistenceUnit) + " for persistenceUnit " + persistenceUnit + " already associated with this transaction " + transactionManager.getTransactionKey()); } transactionManager.putResource(persistenceUnit, this); entityManager.joinTransaction(); }