Search in sources :

Example 1 with RomanticTransaction

use of org.lastaflute.db.jta.RomanticTransaction 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)

Example 2 with RomanticTransaction

use of org.lastaflute.db.jta.RomanticTransaction in project lastaflute by lastaflute.

the class RomanticTraceableSqlFireHook method saveCommandToRomanticTransaction.

protected void saveCommandToRomanticTransaction(BehaviorCommandMeta meta, SqlFireReadyInfo fireReadyInfo) {
    final RomanticTransaction tx = TransactionRomanticContext.getRomanticTransaction();
    if (tx != null) {
        final String tableName = meta.getDBMeta().getTableDispName();
        final String commandName = meta.getCommandName();
        // cannot get from ready info...
        final Long beginMillis = InternalMapContext.getSqlBeforeTimeMillis();
        final TransactionCurrentSqlBuilder currentSqlBuilder = createCurrentSqlBuilder(fireReadyInfo.getSqlLogInfo());
        tx.registerTableCommand(tableName, commandName, beginMillis, currentSqlBuilder);
    }
}
Also used : RomanticTransaction(org.lastaflute.db.jta.RomanticTransaction) TransactionCurrentSqlBuilder(org.lastaflute.db.jta.romanticist.TransactionCurrentSqlBuilder)

Example 3 with RomanticTransaction

use of org.lastaflute.db.jta.RomanticTransaction in project lastaflute by lastaflute.

the class RomanticTraceableSqlResultHandler method handle.

@Override
public void handle(SqlResultInfo info) {
    final RomanticTransaction tx = TransactionRomanticContext.getRomanticTransaction();
    if (tx != null) {
        // not saved because of internal object
        final BehaviorCommandMeta meta = info.getMeta();
        final String tableName = meta.getDBMeta().getTableDispName();
        final String command = meta.getCommandName();
        final ExecutionTimeInfo timeInfo = info.getExecutionTimeInfo();
        final Long beginMillis = timeInfo.getCommandBeforeTimeMillis();
        final Long endMillis = timeInfo.getCommandAfterTimeMillis();
        final Class<?> resultType = meta.getCommandReturnType();
        final Object resultValue = info.getResult();
        tx.registerRecentResult(tableName, command, beginMillis, endMillis, resultType, resultValue, meta);
    }
}
Also used : RomanticTransaction(org.lastaflute.db.jta.RomanticTransaction) ExecutionTimeInfo(org.dbflute.jdbc.ExecutionTimeInfo) BehaviorCommandMeta(org.dbflute.bhv.core.BehaviorCommandMeta)

Aggregations

RomanticTransaction (org.lastaflute.db.jta.RomanticTransaction)3 Field (java.lang.reflect.Field)1 Map (java.util.Map)1 Transaction (javax.transaction.Transaction)1 BehaviorCommandMeta (org.dbflute.bhv.core.BehaviorCommandMeta)1 ExecutionTimeInfo (org.dbflute.jdbc.ExecutionTimeInfo)1 TransactionCurrentSqlBuilder (org.lastaflute.db.jta.romanticist.TransactionCurrentSqlBuilder)1 ConnectionWrapper (org.lastaflute.jta.dbcp.ConnectionWrapper)1