HHH-5949 - Migrate, complete and integrate TransactionFactory as a service

This commit is contained in:
Steve Ebersole 2011-03-09 13:02:24 -06:00
parent 613f38fb5c
commit 8e71b82183
4 changed files with 23 additions and 6 deletions

View File

@ -129,11 +129,7 @@ public class TransactionCoordinatorImpl implements TransactionCoordinator {
final boolean success = JtaStatusHelper.isCommitted( status );
// todo : handle stats as observer?
// as is this messes up unit tests which do not build a sf
// if ( sessionFactory().getStatistics().isStatisticsEnabled() ) {
// sessionFactory().getStatisticsImplementor().endTransaction( success );
// }
transactionContext.getTransactionEnvironment().getStatisticsImplementor().endTransaction( success );
getJdbcCoordinator().afterTransaction();

View File

@ -26,6 +26,7 @@ package org.hibernate.engine.transaction.spi;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.stat.StatisticsImplementor;
/**
* Provides access to transactional services.
@ -60,4 +61,11 @@ public interface TransactionEnvironment {
* @return The transaction factory
*/
public TransactionFactory getTransactionFactory();
/**
* Get access to the statistics collector
*
* @return The statistics collector
*/
public StatisticsImplementor getStatisticsImplementor();
}

View File

@ -23,13 +23,13 @@
*/
package org.hibernate.impl;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.transaction.spi.TransactionEnvironment;
import org.hibernate.engine.transaction.spi.TransactionFactory;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.stat.StatisticsImplementor;
/**
* @author Steve Ebersole
@ -64,4 +64,9 @@ public class TransactionEnvironmentImpl implements TransactionEnvironment {
public TransactionFactory getTransactionFactory() {
return serviceRegistry().getService( TransactionFactory.class );
}
@Override
public StatisticsImplementor getStatisticsImplementor() {
return sessionFactory.getStatisticsImplementor();
}
}

View File

@ -30,12 +30,15 @@ import org.hibernate.engine.transaction.spi.TransactionEnvironment;
import org.hibernate.engine.transaction.spi.TransactionFactory;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.stat.ConcurrentStatisticsImpl;
import org.hibernate.stat.StatisticsImplementor;
/**
* @author Steve Ebersole
*/
public class TransactionEnvironmentImpl implements TransactionEnvironment {
private final ServiceRegistry serviceRegistry;
private final ConcurrentStatisticsImpl statistics = new ConcurrentStatisticsImpl();
public TransactionEnvironmentImpl(ServiceRegistry serviceRegistry) {
this.serviceRegistry = serviceRegistry;
@ -60,4 +63,9 @@ public class TransactionEnvironmentImpl implements TransactionEnvironment {
public TransactionFactory getTransactionFactory() {
return serviceRegistry.getService( TransactionFactory.class );
}
@Override
public StatisticsImplementor getStatisticsImplementor() {
return statistics;
}
}