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);
}
}
}
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);
}
}
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);
}
}
Aggregations