Search in sources :

Example 1 with ConnectionWrapper

use of org.lastaflute.jta.dbcp.ConnectionWrapper in project lastaflute by lastaflute.

the class ConnectionPoolViewBuilder method setupTransactionViewListByReflection.

protected void setupTransactionViewListByReflection(ConnectionPool pool, List<String> txViewList) {
    final Field field = DfReflectionUtil.getWholeField(pool.getClass(), "txActivePool");
    @SuppressWarnings("unchecked") final Map<Transaction, ConnectionWrapper> txActivePool = (Map<Transaction, ConnectionWrapper>) DfReflectionUtil.getValueForcedly(field, pool);
    synchronized (pool) {
        // just in case
        for (Entry<Transaction, ConnectionWrapper> entry : txActivePool.entrySet()) {
            final Transaction tx = entry.getKey();
            final ConnectionWrapper wrapper = entry.getValue();
            final String romantic;
            if (tx instanceof RomanticTransaction) {
                romantic = ((RomanticTransaction) tx).toRomanticSnapshot(wrapper);
            } else {
                romantic = tx.toString();
            }
            txViewList.add(romantic);
        }
    }
}
Also used : Field(java.lang.reflect.Field) RomanticTransaction(org.lastaflute.db.jta.RomanticTransaction) Transaction(javax.transaction.Transaction) RomanticTransaction(org.lastaflute.db.jta.RomanticTransaction) ConnectionWrapper(org.lastaflute.jta.dbcp.ConnectionWrapper) Map(java.util.Map)

Aggregations

Field (java.lang.reflect.Field)1 Map (java.util.Map)1 Transaction (javax.transaction.Transaction)1 RomanticTransaction (org.lastaflute.db.jta.RomanticTransaction)1 ConnectionWrapper (org.lastaflute.jta.dbcp.ConnectionWrapper)1