HHH-8942 log level checks should not be static

This commit is contained in:
Brett Meyer 2014-02-07 11:10:19 -05:00
parent 3e40bfab12
commit 29cf10b3e2
1 changed files with 19 additions and 8 deletions

View File

@ -62,8 +62,6 @@ import org.hibernate.internal.util.collections.CollectionHelper;
*/
public final class TransactionCoordinatorImpl implements TransactionCoordinator {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( TransactionCoordinatorImpl.class );
private static final boolean DEBUGGING = LOG.isDebugEnabled();
private static final boolean TRACING = LOG.isTraceEnabled();
private final transient TransactionContext transactionContext;
private final transient JdbcCoordinatorImpl jdbcCoordinator;
@ -80,6 +78,9 @@ public final class TransactionCoordinatorImpl implements TransactionCoordinator
private transient boolean open = true;
private transient boolean synchronizationRegistered;
private transient boolean ownershipTaken;
private transient boolean isDebugging = LOG.isDebugEnabled();
private transient boolean isTracing = LOG.isTraceEnabled();
public TransactionCoordinatorImpl(
Connection userSuppliedConnection,
@ -134,7 +135,9 @@ public final class TransactionCoordinatorImpl implements TransactionCoordinator
}
public void afterTransaction(TransactionImplementor hibernateTransaction, int status) {
if (TRACING) LOG.trace( "after transaction completion" );
if (isTracing) {
LOG.trace( "after transaction completion" );
}
final boolean success = JtaStatusHelper.isCommitted( status );
@ -214,7 +217,7 @@ public final class TransactionCoordinatorImpl implements TransactionCoordinator
return;
}
JtaPlatform jtaPlatform = getTransactionEnvironment().getJtaPlatform();
final JtaPlatform jtaPlatform = getTransactionEnvironment().getJtaPlatform();
if ( jtaPlatform == null ) {
// if no jta platform was registered we wont be able to register a jta synchronization
return;
@ -232,7 +235,9 @@ public final class TransactionCoordinatorImpl implements TransactionCoordinator
// we are supposed to not auto join transactions; if the transaction is not marked for join
// we cannot go any further in attempting to join (register sync).
if ( joinStatus != JoinStatus.MARKED_FOR_JOINED ) {
if (DEBUGGING) LOG.debug( "Skipping JTA sync registration due to auto join checking" );
if (isDebugging) {
LOG.debug( "Skipping JTA sync registration due to auto join checking" );
}
return;
}
}
@ -245,20 +250,26 @@ public final class TransactionCoordinatorImpl implements TransactionCoordinator
// Can we resister a synchronization
if ( !jtaPlatform.canRegisterSynchronization() ) {
if (TRACING) LOG.trace( "registered JTA platform says we cannot currently register synchronization; skipping" );
if (isTracing) {
LOG.trace( "registered JTA platform says we cannot currently register synchronization; skipping" );
}
return;
}
// Should we resister a synchronization
if ( !transactionFactory().isJoinableJtaTransaction( this, currentHibernateTransaction ) ) {
if (TRACING) LOG.trace( "TransactionFactory reported no JTA transaction to join; skipping Synchronization registration" );
if (isTracing) {
LOG.trace( "TransactionFactory reported no JTA transaction to join; skipping Synchronization registration" );
}
return;
}
jtaPlatform.registerSynchronization( new RegisteredSynchronization( getSynchronizationCallbackCoordinator() ) );
getSynchronizationCallbackCoordinator().synchronizationRegistered();
synchronizationRegistered = true;
if (DEBUGGING) LOG.debug( "successfully registered Synchronization" );
if (isDebugging) {
LOG.debug( "successfully registered Synchronization" );
}
}
@Override