HHH-5949 - Migrate, complete and integrate TransactionFactory as a service
This commit is contained in:
parent
08d9fe2117
commit
b4a440e8d3
|
@ -1,4 +1,3 @@
|
|||
// $Id$
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
|
@ -24,15 +23,51 @@
|
|||
*/
|
||||
package org.hibernate.ejb;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.ObjectDeletedException;
|
||||
import org.hibernate.ObjectNotFoundException;
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.StaleObjectStateException;
|
||||
import org.hibernate.StaleStateException;
|
||||
import org.hibernate.TransientObjectException;
|
||||
import org.hibernate.TypeMismatchException;
|
||||
import org.hibernate.UnresolvableObjectException;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
|
||||
import org.hibernate.ejb.criteria.ValueHandlerFactory;
|
||||
import org.hibernate.ejb.criteria.expression.CompoundSelectionImpl;
|
||||
import org.hibernate.ejb.util.CacheModeHelper;
|
||||
import org.hibernate.ejb.util.ConfigurationHelper;
|
||||
import org.hibernate.ejb.util.LockModeTypeHelper;
|
||||
import org.hibernate.engine.NamedSQLQueryDefinition;
|
||||
import org.hibernate.engine.ResultSetMappingDefinition;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
|
||||
import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
|
||||
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
||||
import org.hibernate.engine.transaction.spi.JoinStatus;
|
||||
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
||||
import org.hibernate.engine.transaction.synchronization.spi.AfterCompletionAction;
|
||||
import org.hibernate.engine.transaction.synchronization.spi.ExceptionMapper;
|
||||
import org.hibernate.engine.transaction.synchronization.spi.ManagedFlushChecker;
|
||||
import org.hibernate.engine.transaction.synchronization.spi.SynchronizationCallbackCoordinator;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.service.jta.platform.spi.JtaPlatform;
|
||||
import org.hibernate.transform.BasicTransformerAdapter;
|
||||
import org.hibernate.util.ReflectHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.CacheRetrieveMode;
|
||||
import javax.persistence.CacheStoreMode;
|
||||
import javax.persistence.EntityManager;
|
||||
|
@ -59,55 +94,17 @@ import javax.persistence.criteria.CriteriaQuery;
|
|||
import javax.persistence.criteria.Selection;
|
||||
import javax.persistence.metamodel.Metamodel;
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.Synchronization;
|
||||
import javax.transaction.SystemException;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.ObjectDeletedException;
|
||||
import org.hibernate.ObjectNotFoundException;
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.StaleObjectStateException;
|
||||
import org.hibernate.StaleStateException;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.TransientObjectException;
|
||||
import org.hibernate.TypeMismatchException;
|
||||
import org.hibernate.UnresolvableObjectException;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
|
||||
import org.hibernate.ejb.criteria.ValueHandlerFactory;
|
||||
import org.hibernate.ejb.criteria.expression.CompoundSelectionImpl;
|
||||
import org.hibernate.ejb.transaction.JoinableCMTTransaction;
|
||||
import org.hibernate.ejb.util.CacheModeHelper;
|
||||
import org.hibernate.ejb.util.ConfigurationHelper;
|
||||
import org.hibernate.ejb.util.LockModeTypeHelper;
|
||||
import org.hibernate.engine.NamedSQLQueryDefinition;
|
||||
import org.hibernate.engine.ResultSetMappingDefinition;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
|
||||
import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.transaction.TransactionFactory;
|
||||
import org.hibernate.transaction.synchronization.AfterCompletionAction;
|
||||
import org.hibernate.transaction.synchronization.BeforeCompletionManagedFlushChecker;
|
||||
import org.hibernate.transaction.synchronization.CallbackCoordinator;
|
||||
import org.hibernate.transaction.synchronization.ExceptionMapper;
|
||||
import org.hibernate.transform.BasicTransformerAdapter;
|
||||
import org.hibernate.util.JTAHelper;
|
||||
import org.hibernate.util.ReflectHelper;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:gavin@hibernate.org">Gavin King</a>
|
||||
|
@ -944,6 +941,10 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
|||
return ( ( SessionImplementor ) getRawSession() ).isTransactionInProgress();
|
||||
}
|
||||
|
||||
private SessionFactoryImplementor sfi() {
|
||||
return ( SessionFactoryImplementor ) getRawSession().getSessionFactory();
|
||||
}
|
||||
|
||||
protected void markAsRollback() {
|
||||
log.debug( "mark transaction for rollback" );
|
||||
if ( tx.isActive() ) {
|
||||
|
@ -952,8 +953,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
|||
else {
|
||||
//no explicit use of the tx. boundaries methods
|
||||
if ( PersistenceUnitTransactionType.JTA == transactionType ) {
|
||||
TransactionManager transactionManager =
|
||||
( ( SessionFactoryImplementor ) getRawSession().getSessionFactory() ).getTransactionManager();
|
||||
TransactionManager transactionManager = sfi().getServiceRegistry().getService( JtaPlatform.class ).retrieveTransactionManager();
|
||||
if ( transactionManager == null ) {
|
||||
throw new PersistenceException(
|
||||
"Using a JTA persistence context wo setting hibernate.transaction.manager_lookup_class"
|
||||
|
@ -987,105 +987,52 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
|||
}
|
||||
|
||||
private void joinTransaction(boolean ignoreNotJoining) {
|
||||
//set the joined status
|
||||
getSession().isOpen(); //for sync
|
||||
if ( transactionType == PersistenceUnitTransactionType.JTA ) {
|
||||
try {
|
||||
log.debug( "Looking for a JTA transaction to join" );
|
||||
final Session session = getSession();
|
||||
final Transaction transaction = session.getTransaction();
|
||||
if ( transaction != null && transaction instanceof JoinableCMTTransaction ) {
|
||||
//can't handle it if not a joinnable transaction
|
||||
final JoinableCMTTransaction joinableCMTTransaction = ( JoinableCMTTransaction ) transaction;
|
||||
|
||||
if ( joinableCMTTransaction.getStatus() == JoinableCMTTransaction.JoinStatus.JOINED ) {
|
||||
log.debug( "Transaction already joined" );
|
||||
return; //no-op
|
||||
}
|
||||
joinableCMTTransaction.markForJoined();
|
||||
session.isOpen(); //register to the Tx
|
||||
if ( joinableCMTTransaction.getStatus() == JoinableCMTTransaction.JoinStatus.NOT_JOINED ) {
|
||||
if ( ignoreNotJoining ) {
|
||||
log.debug( "No JTA transaction found" );
|
||||
return;
|
||||
}
|
||||
else {
|
||||
throw new TransactionRequiredException(
|
||||
"No active JTA transaction on joinTransaction call"
|
||||
);
|
||||
}
|
||||
}
|
||||
else if ( joinableCMTTransaction.getStatus() == JoinableCMTTransaction.JoinStatus.MARKED_FOR_JOINED ) {
|
||||
throw new AssertionFailure( "Transaction MARKED_FOR_JOINED after isOpen() call" );
|
||||
}
|
||||
//flush before completion and
|
||||
//register clear on rollback
|
||||
log.trace( "Adding flush() and close() synchronization" );
|
||||
CallbackCoordinator callbackCoordinator = ( (SessionImplementor ) getSession() ).getJDBCContext().getJtaSynchronizationCallbackCoordinator();
|
||||
if ( callbackCoordinator == null ) {
|
||||
throw new AssertionFailure( "Expecting CallbackCoordinator to be non-null" );
|
||||
}
|
||||
callbackCoordinator.setBeforeCompletionManagedFlushChecker(
|
||||
new BeforeCompletionManagedFlushChecker() {
|
||||
public boolean shouldDoManagedFlush(TransactionFactory.Context ctx, javax.transaction.Transaction jtaTransaction)
|
||||
throws SystemException {
|
||||
if ( transaction == null ) {
|
||||
log.warn( "Transaction not available on beforeCompletion: assuming valid" );
|
||||
}
|
||||
return !ctx.isFlushModeNever()
|
||||
&& ( jtaTransaction == null || !JTAHelper.isRollback( jtaTransaction.getStatus() ) );
|
||||
}
|
||||
}
|
||||
);
|
||||
callbackCoordinator.setAfterCompletionAction(
|
||||
new AfterCompletionAction() {
|
||||
public void doAction(TransactionFactory.Context ctx, int status) {
|
||||
try {
|
||||
if ( !ctx.isClosed() ) {
|
||||
if ( Status.STATUS_ROLLEDBACK == status
|
||||
&& transactionType == PersistenceUnitTransactionType.JTA ) {
|
||||
session.clear();
|
||||
}
|
||||
JoinableCMTTransaction joinable = ( JoinableCMTTransaction ) session.getTransaction();
|
||||
joinable.resetStatus();
|
||||
}
|
||||
}
|
||||
catch ( HibernateException e ) {
|
||||
throw convert( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
callbackCoordinator.setExceptionMapper(
|
||||
new ExceptionMapper() {
|
||||
public RuntimeException mapStatusCheckFailure(String message, SystemException systemException) {
|
||||
throw new PersistenceException( message, systemException );
|
||||
}
|
||||
|
||||
public RuntimeException mapManagedFlushFailure(String message, RuntimeException failure) {
|
||||
if ( HibernateException.class.isInstance( failure ) ) {
|
||||
throw convert( failure );
|
||||
}
|
||||
if ( PersistenceException.class.isInstance( failure ) ) {
|
||||
throw failure;
|
||||
}
|
||||
throw new PersistenceException( message, failure );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
log.warn( "Cannot join transaction: do not override {}", Environment.TRANSACTION_STRATEGY );
|
||||
}
|
||||
}
|
||||
catch ( HibernateException he ) {
|
||||
throw convert( he );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( transactionType != PersistenceUnitTransactionType.JTA ) {
|
||||
if ( !ignoreNotJoining ) {
|
||||
log.warn( "Calling joinTransaction() on a non JTA EntityManager" );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final SessionImplementor session = (SessionImplementor) getSession();
|
||||
session.getTransactionCoordinator().pulse();
|
||||
|
||||
log.debug( "Looking for a JTA transaction to join" );
|
||||
if ( ! session.getTransactionCoordinator().isTransactionJoinable() ) {
|
||||
log.warn( "Cannot join transaction: do not override {}", Environment.TRANSACTION_STRATEGY );
|
||||
}
|
||||
|
||||
try {
|
||||
final TransactionImplementor transaction = session.getTransactionCoordinator().getTransaction();
|
||||
|
||||
if ( transaction.getJoinStatus() == JoinStatus.JOINED ) {
|
||||
log.debug( "Transaction already joined" );
|
||||
return; // noop
|
||||
}
|
||||
|
||||
// join the transaction and then recheck the status
|
||||
transaction.join();
|
||||
if ( transaction.getJoinStatus() == JoinStatus.NOT_JOINED ) {
|
||||
if ( ignoreNotJoining ) {
|
||||
log.debug( "No JTA transaction found" );
|
||||
return;
|
||||
}
|
||||
else {
|
||||
throw new TransactionRequiredException( "No active JTA transaction on joinTransaction call" );
|
||||
}
|
||||
}
|
||||
else if ( transaction.getJoinStatus() == JoinStatus.MARKED_FOR_JOINED ) {
|
||||
throw new AssertionFailure( "Transaction MARKED_FOR_JOINED after isOpen() call" );
|
||||
}
|
||||
|
||||
// register behavior changes
|
||||
SynchronizationCallbackCoordinator callbackCoordinator = session.getTransactionCoordinator().getSynchronizationCallbackCoordinator();
|
||||
callbackCoordinator.setManagedFlushChecker( new ManagedFlushCheckerImpl() );
|
||||
callbackCoordinator.setExceptionMapper( new CallbackExceptionMapperImpl() );
|
||||
callbackCoordinator.setAfterCompletionAction( new AfterCompletionActionImpl( session, transactionType ) );
|
||||
}
|
||||
catch ( HibernateException he ) {
|
||||
throw convert( he );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1278,4 +1225,54 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
|||
}
|
||||
return pe;
|
||||
}
|
||||
|
||||
private static class AfterCompletionActionImpl implements AfterCompletionAction {
|
||||
private final SessionImplementor session;
|
||||
private final PersistenceUnitTransactionType transactionType;
|
||||
|
||||
private AfterCompletionActionImpl(SessionImplementor session, PersistenceUnitTransactionType transactionType) {
|
||||
this.session = session;
|
||||
this.transactionType = transactionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(TransactionCoordinator transactionCoordinator, int status) {
|
||||
if ( session.isClosed() ) {
|
||||
log.trace( "Session was closed; nothing to do" );
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean successful = JtaStatusHelper.isCommitted( status );
|
||||
if ( !successful && transactionType == PersistenceUnitTransactionType.JTA ) {
|
||||
( (Session) session ).clear();
|
||||
}
|
||||
session.getTransactionCoordinator().resetJoinStatus();
|
||||
}
|
||||
}
|
||||
|
||||
private static class ManagedFlushCheckerImpl implements ManagedFlushChecker {
|
||||
@Override
|
||||
public boolean shouldDoManagedFlush(TransactionCoordinator coordinator, int jtaStatus) {
|
||||
return ! coordinator.getTransactionContext().isFlushModeNever() &&
|
||||
! JtaStatusHelper.isRollback( jtaStatus );
|
||||
}
|
||||
}
|
||||
|
||||
private class CallbackExceptionMapperImpl implements ExceptionMapper {
|
||||
@Override
|
||||
public RuntimeException mapStatusCheckFailure(String message, SystemException systemException) {
|
||||
throw new PersistenceException( message, systemException );
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeException mapManagedFlushFailure(String message, RuntimeException failure) {
|
||||
if ( HibernateException.class.isInstance( failure ) ) {
|
||||
throw convert( failure );
|
||||
}
|
||||
if ( PersistenceException.class.isInstance( failure ) ) {
|
||||
throw failure;
|
||||
}
|
||||
throw new PersistenceException( message, failure );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ import org.hibernate.ejb.util.ConfigurationHelper;
|
|||
import org.hibernate.ejb.util.LogHelper;
|
||||
import org.hibernate.ejb.util.NamingHelper;
|
||||
import org.hibernate.engine.FilterDefinition;
|
||||
import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory;
|
||||
import org.hibernate.event.EventListeners;
|
||||
import org.hibernate.mapping.AuxiliaryDatabaseObject;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
|
@ -95,7 +96,6 @@ import org.hibernate.proxy.EntityNotFoundDelegate;
|
|||
import org.hibernate.secure.JACCConfiguration;
|
||||
import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator;
|
||||
import org.hibernate.service.spi.ServiceRegistry;
|
||||
import org.hibernate.transaction.JDBCTransactionFactory;
|
||||
import org.hibernate.util.CollectionHelper;
|
||||
import org.hibernate.util.ReflectHelper;
|
||||
import org.hibernate.util.StringHelper;
|
||||
|
@ -1256,7 +1256,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
);
|
||||
}
|
||||
else if ( ! hasTxStrategy && transactionType == PersistenceUnitTransactionType.RESOURCE_LOCAL ) {
|
||||
preparedProperties.setProperty( Environment.TRANSACTION_STRATEGY, JDBCTransactionFactory.class.getName() );
|
||||
preparedProperties.setProperty( Environment.TRANSACTION_STRATEGY, JdbcTransactionFactory.class.getName() );
|
||||
}
|
||||
if ( hasTxStrategy ) {
|
||||
log.warn(
|
||||
|
|
|
@ -21,79 +21,63 @@
|
|||
*/
|
||||
package org.hibernate.ejb.transaction;
|
||||
|
||||
import javax.transaction.SystemException;
|
||||
import javax.transaction.Transaction;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.TransactionException;
|
||||
import org.hibernate.engine.jdbc.spi.JDBCContext;
|
||||
import org.hibernate.transaction.CMTTransaction;
|
||||
import org.hibernate.transaction.TransactionFactory;
|
||||
import org.hibernate.util.JTAHelper;
|
||||
import org.hibernate.engine.transaction.internal.jta.CMTTransaction;
|
||||
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
||||
import org.hibernate.engine.transaction.spi.JoinStatus;
|
||||
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
|
||||
|
||||
/**
|
||||
* Implements a joinable transaction. Until the transaction is marked for joined, the TM.isTransactionInProgress()
|
||||
* must return false
|
||||
*
|
||||
* @author Emmanuel Bernard
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JoinableCMTTransaction extends CMTTransaction {
|
||||
private JoinStatus status;
|
||||
private JoinStatus joinStatus = JoinStatus.NOT_JOINED;
|
||||
|
||||
public JoinableCMTTransaction(JDBCContext jdbcContext, TransactionFactory.Context transactionContext) {
|
||||
super( jdbcContext, transactionContext );
|
||||
//status = JoinStatus.MARKED_FOR_JOINED;
|
||||
//tryJoiningTransaction();
|
||||
public JoinableCMTTransaction(TransactionCoordinator transactionCoordinator) {
|
||||
super( transactionCoordinator );
|
||||
}
|
||||
|
||||
public boolean isTransactionInProgress(
|
||||
JDBCContext jdbcContext,
|
||||
TransactionFactory.Context transactionContext) {
|
||||
try {
|
||||
return status == JoinStatus.JOINED && isTransactionInProgress(
|
||||
transactionContext.getFactory().getTransactionManager().getTransaction()
|
||||
);
|
||||
}
|
||||
catch (SystemException se) {
|
||||
throw new TransactionException( "Unable to check transaction status", se );
|
||||
}
|
||||
boolean isJoinable() {
|
||||
return joinStatus == JoinStatus.JOINED && JtaStatusHelper.isActive( transactionManager() );
|
||||
}
|
||||
|
||||
private boolean isTransactionInProgress() {
|
||||
try {
|
||||
Transaction transaction = transactionContext.getFactory().getTransactionManager().getTransaction();
|
||||
return isTransactionInProgress(transaction);
|
||||
}
|
||||
catch (SystemException se) {
|
||||
throw new TransactionException( "Unable to check transaction status", se );
|
||||
}
|
||||
public JoinStatus getJoinStatus() {
|
||||
return joinStatus;
|
||||
}
|
||||
|
||||
private boolean isTransactionInProgress(Transaction tx) throws SystemException {
|
||||
return JTAHelper.isTransactionInProgress(tx) && ! JTAHelper.isRollback( tx.getStatus() );
|
||||
}
|
||||
|
||||
void tryJoiningTransaction() {
|
||||
if ( status == JoinStatus.MARKED_FOR_JOINED ) {
|
||||
if ( isTransactionInProgress() ) {
|
||||
status = JoinStatus.JOINED;
|
||||
@Override
|
||||
public void join() {
|
||||
if ( joinStatus == JoinStatus.MARKED_FOR_JOINED ) {
|
||||
if ( JtaStatusHelper.isActive( transactionManager() ) ) {
|
||||
joinStatus = JoinStatus.JOINED;
|
||||
// register synchronization if needed
|
||||
transactionCoordinator().pulse();
|
||||
}
|
||||
else {
|
||||
status = JoinStatus.NOT_JOINED;
|
||||
joinStatus = JoinStatus.NOT_JOINED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetJoinStatus() {
|
||||
joinStatus = JoinStatus.NOT_JOINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void begin() throws HibernateException {
|
||||
super.begin();
|
||||
status = JoinStatus.JOINED;
|
||||
joinStatus = JoinStatus.JOINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() throws HibernateException {
|
||||
/* this method is not supposed to be called
|
||||
* it breaks the flushBeforeCompletion flag optimizeation
|
||||
* it breaks the flushBeforeCompletion flag optimization
|
||||
* regarding flushing skip.
|
||||
* In its current form, it will generate too much flush() calls
|
||||
*/
|
||||
|
@ -102,20 +86,11 @@ public class JoinableCMTTransaction extends CMTTransaction {
|
|||
|
||||
|
||||
public JoinStatus getStatus() {
|
||||
return status;
|
||||
return joinStatus;
|
||||
}
|
||||
|
||||
public void resetStatus() {
|
||||
status = JoinStatus.NOT_JOINED;
|
||||
joinStatus = JoinStatus.NOT_JOINED;
|
||||
}
|
||||
|
||||
public void markForJoined() {
|
||||
if ( status != JoinStatus.JOINED ) status = JoinStatus.MARKED_FOR_JOINED;
|
||||
}
|
||||
|
||||
public static enum JoinStatus {
|
||||
NOT_JOINED,
|
||||
MARKED_FOR_JOINED,
|
||||
JOINED
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
/*
|
||||
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2009-2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -21,34 +23,46 @@
|
|||
*/
|
||||
package org.hibernate.ejb.transaction;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.engine.jdbc.spi.JDBCContext;
|
||||
import org.hibernate.transaction.CMTTransactionFactory;
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.engine.transaction.spi.JoinStatus;
|
||||
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.engine.transaction.spi.TransactionFactory;
|
||||
|
||||
/**
|
||||
* A transaction is in progress if the underlying JTA tx is in progress and if the Tx is marked as
|
||||
* MARKED_FOR_JOINED
|
||||
*
|
||||
* @author Emmanuel Bernard
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JoinableCMTTransactionFactory extends CMTTransactionFactory {
|
||||
public Transaction createTransaction(
|
||||
JDBCContext jdbcContext,
|
||||
Context transactionContext) throws HibernateException {
|
||||
return new JoinableCMTTransaction( jdbcContext, transactionContext );
|
||||
public class JoinableCMTTransactionFactory implements TransactionFactory<JoinableCMTTransaction> {
|
||||
@Override
|
||||
public boolean compatibleWithJtaSynchronization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTransactionInProgress(
|
||||
JDBCContext jdbcContext,
|
||||
Context transactionContext,
|
||||
Transaction transaction) {
|
||||
if ( transaction == null ) {
|
||||
return false; //should not happen though
|
||||
}
|
||||
JoinableCMTTransaction joinableCMTTransaction = ( (JoinableCMTTransaction) transaction );
|
||||
joinableCMTTransaction.tryJoiningTransaction();
|
||||
return joinableCMTTransaction.isTransactionInProgress( jdbcContext, transactionContext );
|
||||
public boolean canBeDriver() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JoinableCMTTransaction createTransaction(TransactionCoordinator transactionCoordinator) {
|
||||
return new JoinableCMTTransaction( transactionCoordinator );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJoinableJtaTransaction(TransactionCoordinator transactionCoordinator, JoinableCMTTransaction transaction) {
|
||||
return transaction.isJoinable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JoinStatus getJoinStatus(TransactionCoordinator transactionCoordinator, JoinableCMTTransaction transaction) {
|
||||
return transaction.getJoinStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionReleaseMode getDefaultReleaseMode() {
|
||||
return ConnectionReleaseMode.AFTER_STATEMENT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ import org.hibernate.engine.QueryParameters;
|
|||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.engine.NonFlushedChanges;
|
||||
import org.hibernate.engine.jdbc.spi.JDBCContext;
|
||||
import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
|
||||
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.event.EventListeners;
|
||||
import org.hibernate.impl.CriteriaImpl;
|
||||
import org.hibernate.loader.custom.CustomQuery;
|
||||
|
@ -140,14 +140,6 @@ public abstract class AbstractDelegateSessionImplementor implements SessionImple
|
|||
return delegate.getEntityUsingInterceptor(key);
|
||||
}
|
||||
|
||||
public void afterTransactionCompletion(boolean successful, Transaction tx) {
|
||||
delegate.afterTransactionCompletion(successful, tx);
|
||||
}
|
||||
|
||||
public void beforeTransactionCompletion(Transaction tx) {
|
||||
delegate.beforeTransactionCompletion(tx);
|
||||
}
|
||||
|
||||
public Serializable getContextEntityIdentifier(Object object) {
|
||||
return delegate.getContextEntityIdentifier(object);
|
||||
}
|
||||
|
@ -280,11 +272,12 @@ public abstract class AbstractDelegateSessionImplementor implements SessionImple
|
|||
return delegate.getFetchProfile();
|
||||
}
|
||||
|
||||
public JDBCContext getJDBCContext() {
|
||||
return delegate.getJDBCContext();
|
||||
}
|
||||
@Override
|
||||
public TransactionCoordinator getTransactionCoordinator() {
|
||||
return delegate.getTransactionCoordinator();
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
public boolean isClosed() {
|
||||
return delegate.isClosed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,11 @@
|
|||
*/
|
||||
package org.hibernate.cache.infinispan.tm;
|
||||
|
||||
import java.util.Properties;
|
||||
import org.hibernate.cfg.Settings;
|
||||
import org.hibernate.service.jta.platform.spi.JtaPlatform;
|
||||
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.hibernate.cfg.Settings;
|
||||
import org.hibernate.transaction.TransactionManagerLookup;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* HibernateTransactionManagerLookup.
|
||||
|
@ -35,20 +34,19 @@ import org.hibernate.transaction.TransactionManagerLookup;
|
|||
* @since 3.5
|
||||
*/
|
||||
public class HibernateTransactionManagerLookup implements org.infinispan.transaction.lookup.TransactionManagerLookup {
|
||||
private final TransactionManagerLookup hibernateLookup;
|
||||
|
||||
private final Properties properties;
|
||||
|
||||
public HibernateTransactionManagerLookup(Settings settings, Properties properties) {
|
||||
if (settings != null)
|
||||
this.hibernateLookup = settings.getTransactionManagerLookup();
|
||||
else
|
||||
this.hibernateLookup = null;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public TransactionManager getTransactionManager() throws Exception {
|
||||
return hibernateLookup == null ? null : hibernateLookup.getTransactionManager(properties);
|
||||
}
|
||||
private final JtaPlatform jtaPlatform;
|
||||
|
||||
public HibernateTransactionManagerLookup(Settings settings, Properties properties) {
|
||||
if ( settings != null ) {
|
||||
jtaPlatform = settings.getJtaPlatform();
|
||||
}
|
||||
else {
|
||||
jtaPlatform = null;
|
||||
}
|
||||
}
|
||||
|
||||
public TransactionManager getTransactionManager() throws Exception {
|
||||
return jtaPlatform == null ? null : jtaPlatform.retrieveTransactionManager();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
|
|||
String entityCfg = "entity";
|
||||
cfg.setProperty(InfinispanRegionFactory.ENTITY_CACHE_RESOURCE_PROP, entityCfg);
|
||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
supportedAccessTypeTest(regionFactory, cfg.getProperties());
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
|
|||
public void testIsTransactionAware() throws Exception {
|
||||
Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false);
|
||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
|
||||
assertTrue("Region is transaction-aware", region.isTransactionAware());
|
||||
|
@ -94,7 +94,7 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
|
|||
// Make it non-transactional
|
||||
cfg.getProperties().remove(Environment.TRANSACTION_MANAGER_STRATEGY);
|
||||
regionFactory = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
|
||||
assertFalse("Region is not transaction-aware", region.isTransactionAware());
|
||||
|
@ -104,7 +104,7 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
|
|||
public void testGetCacheDataDescription() throws Exception {
|
||||
Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false);
|
||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
|
||||
CacheDataDescription cdd = region.getCacheDataDescription();
|
||||
|
|
|
@ -73,7 +73,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
|||
private void evictOrRemoveTest() throws Exception {
|
||||
Configuration cfg = createConfiguration();
|
||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
CacheAdapter localCache = getInfinispanCache(regionFactory);
|
||||
boolean invalidation = localCache.isClusteredInvalidation();
|
||||
|
@ -86,7 +86,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
|||
|
||||
cfg = createConfiguration();
|
||||
regionFactory = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
|
||||
GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory,
|
||||
|
@ -126,7 +126,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
|||
private void evictOrRemoveAllTest(String configName) throws Exception {
|
||||
Configuration cfg = createConfiguration();
|
||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
CacheAdapter localCache = getInfinispanCache(regionFactory);
|
||||
|
||||
|
@ -138,7 +138,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
|||
|
||||
cfg = createConfiguration();
|
||||
regionFactory = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
CacheAdapter remoteCache = getInfinispanCache(regionFactory);
|
||||
|
||||
|
|
|
@ -542,14 +542,11 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs
|
|||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||
|
||||
localCfg = createConfiguration(configName, configResource);
|
||||
localRegionFactory = CacheTestUtil.startRegionFactory(
|
||||
serviceRegistry.getService( JdbcServices.class ),
|
||||
localCfg
|
||||
);
|
||||
localRegionFactory = CacheTestUtil.startRegionFactory( serviceRegistry, localCfg );
|
||||
|
||||
remoteCfg = createConfiguration(configName, configResource);
|
||||
remoteRegionFactory = CacheTestUtil.startRegionFactory(
|
||||
serviceRegistry.getService( JdbcServices.class ),
|
||||
serviceRegistry,
|
||||
remoteCfg
|
||||
);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class TransactionalExtraAPITestCase extends AbstractNonFunctionalTestCase
|
|||
if (getCollectionAccessStrategy() == null) {
|
||||
Configuration cfg = createConfiguration();
|
||||
InfinispanRegionFactory rf = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
|
||||
// Sleep a bit to avoid concurrent FLUSH problem
|
||||
|
@ -93,30 +93,18 @@ public class TransactionalExtraAPITestCase extends AbstractNonFunctionalTestCase
|
|||
localAccessStrategy = strategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link TransactionalAccess#lockItem(java.lang.Object, java.lang.Object)}.
|
||||
*/
|
||||
public void testLockItem() {
|
||||
assertNull(getCollectionAccessStrategy().lockItem(KEY, new Integer(1)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link TransactionalAccess#lockRegion()}.
|
||||
*/
|
||||
public void testLockRegion() {
|
||||
assertNull(getCollectionAccessStrategy().lockRegion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link TransactionalAccess#unlockItem(java.lang.Object, org.hibernate.cache.access.SoftLock)}.
|
||||
*/
|
||||
public void testUnlockItem() {
|
||||
getCollectionAccessStrategy().unlockItem(KEY, new MockSoftLock());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link TransactionalAccess#unlockRegion(org.hibernate.cache.access.SoftLock)}.
|
||||
*/
|
||||
public void testUnlockRegion() {
|
||||
getCollectionAccessStrategy().unlockItem(KEY, new MockSoftLock());
|
||||
}
|
||||
|
|
|
@ -666,16 +666,10 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
|
|||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||
|
||||
localCfg = createConfiguration(configName);
|
||||
localRegionFactory = CacheTestUtil.startRegionFactory(
|
||||
serviceRegistry.getService( JdbcServices.class ),
|
||||
localCfg
|
||||
);
|
||||
localRegionFactory = CacheTestUtil.startRegionFactory( serviceRegistry, localCfg );
|
||||
|
||||
remoteCfg = createConfiguration(configName);
|
||||
remoteRegionFactory = CacheTestUtil.startRegionFactory(
|
||||
serviceRegistry.getService( JdbcServices.class ),
|
||||
remoteCfg
|
||||
);
|
||||
remoteRegionFactory = CacheTestUtil.startRegionFactory( serviceRegistry, remoteCfg );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -61,7 +61,7 @@ public class TransactionalExtraAPITestCase extends AbstractNonFunctionalTestCase
|
|||
if (getEntityAccessStrategy() == null) {
|
||||
Configuration cfg = createConfiguration();
|
||||
InfinispanRegionFactory rf = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
|
||||
// Sleep a bit to avoid concurrent FLUSH problem
|
||||
|
@ -99,44 +99,26 @@ public class TransactionalExtraAPITestCase extends AbstractNonFunctionalTestCase
|
|||
localAccessStrategy = strategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link TransactionalAccess#lockItem(java.lang.Object, java.lang.Object)}.
|
||||
*/
|
||||
public void testLockItem() {
|
||||
assertNull(getEntityAccessStrategy().lockItem(KEY, new Integer(1)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link TransactionalAccess#lockRegion()}.
|
||||
*/
|
||||
public void testLockRegion() {
|
||||
assertNull(getEntityAccessStrategy().lockRegion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link TransactionalAccess#unlockItem(java.lang.Object, org.hibernate.cache.access.SoftLock)}.
|
||||
*/
|
||||
public void testUnlockItem() {
|
||||
getEntityAccessStrategy().unlockItem(KEY, new MockSoftLock());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link TransactionalAccess#unlockRegion(org.hibernate.cache.access.SoftLock)}.
|
||||
*/
|
||||
public void testUnlockRegion() {
|
||||
getEntityAccessStrategy().unlockItem(KEY, new MockSoftLock());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link TransactionalAccess#afterInsert(java.lang.Object, java.lang.Object, java.lang.Object)}.
|
||||
*/
|
||||
public void testAfterInsert() {
|
||||
assertFalse("afterInsert always returns false", getEntityAccessStrategy().afterInsert(KEY, VALUE1, new Integer(1)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link TransactionalAccess#afterUpdate(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, org.hibernate.cache.access.SoftLock)}.
|
||||
*/
|
||||
public void testAfterUpdate() {
|
||||
assertFalse("afterInsert always returns false", getEntityAccessStrategy().afterUpdate(KEY, VALUE2, new Integer(1), new Integer(2), new MockSoftLock()));
|
||||
}
|
||||
|
|
|
@ -25,10 +25,10 @@ package org.hibernate.test.cache.infinispan.functional;
|
|||
import java.util.Map;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory;
|
||||
import org.hibernate.engine.transaction.spi.TransactionFactory;
|
||||
import org.hibernate.stat.SecondLevelCacheStatistics;
|
||||
import org.hibernate.stat.Statistics;
|
||||
import org.hibernate.transaction.JDBCTransactionFactory;
|
||||
import org.hibernate.transaction.TransactionFactory;
|
||||
import org.hibernate.transaction.TransactionManagerLookup;
|
||||
import org.infinispan.util.logging.Log;
|
||||
import org.infinispan.util.logging.LogFactory;
|
||||
|
@ -47,7 +47,7 @@ public class BasicJdbcTransactionalTestCase extends SingleNodeTestCase {
|
|||
}
|
||||
|
||||
protected Class<? extends TransactionFactory> getTransactionFactoryClass() {
|
||||
return JDBCTransactionFactory.class;
|
||||
return JdbcTransactionFactory.class;
|
||||
}
|
||||
|
||||
protected Class<? extends TransactionManagerLookup> getTransactionManagerLookupClass() {
|
||||
|
|
|
@ -7,12 +7,10 @@ import org.hibernate.cache.RegionFactory;
|
|||
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.engine.transaction.spi.TransactionFactory;
|
||||
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestCase;
|
||||
import org.hibernate.stat.SecondLevelCacheStatistics;
|
||||
import org.hibernate.stat.Statistics;
|
||||
import org.hibernate.transaction.CMTTransactionFactory;
|
||||
import org.hibernate.transaction.TransactionFactory;
|
||||
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
|
||||
import org.hibernate.transaction.TransactionManagerLookup;
|
||||
import org.infinispan.util.logging.Log;
|
||||
import org.infinispan.util.logging.LogFactory;
|
||||
|
|
|
@ -34,13 +34,13 @@ import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
|||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.classic.Session;
|
||||
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
|
||||
import org.hibernate.engine.transaction.spi.TransactionFactory;
|
||||
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestCase;
|
||||
import org.hibernate.stat.SecondLevelCacheStatistics;
|
||||
import org.hibernate.test.cache.infinispan.functional.Contact;
|
||||
import org.hibernate.test.cache.infinispan.functional.Customer;
|
||||
import org.hibernate.transaction.CMTTransactionFactory;
|
||||
import org.hibernate.transaction.TransactionFactory;
|
||||
import org.hibernate.transaction.TransactionManagerLookup;
|
||||
import org.infinispan.util.logging.Log;
|
||||
import org.infinispan.util.logging.LogFactory;
|
||||
|
|
|
@ -30,9 +30,10 @@ import org.hibernate.cfg.Environment;
|
|||
import org.hibernate.cfg.Mappings;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
|
||||
import org.hibernate.testing.junit.functional.ExecutionEnvironment;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestCase;
|
||||
import org.hibernate.transaction.CMTTransactionFactory;
|
||||
|
||||
import org.infinispan.util.logging.Log;
|
||||
import org.infinispan.util.logging.LogFactory;
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
|
|||
private void putDoesNotBlockGetTest() throws Exception {
|
||||
Configuration cfg = createConfiguration();
|
||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport());
|
||||
getServiceRegistry(), cfg, getCacheTestSupport());
|
||||
|
||||
// Sleep a bit to avoid concurrent FLUSH problem
|
||||
avoidConcurrentFlush();
|
||||
|
@ -177,7 +177,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
|
|||
private void getDoesNotBlockPutTest() throws Exception {
|
||||
Configuration cfg = createConfiguration();
|
||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
|
||||
// Sleep a bit to avoid concurrent FLUSH problem
|
||||
|
|
|
@ -87,14 +87,14 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC
|
|||
public void testClearTimestampsRegionInIsolated() throws Exception {
|
||||
Configuration cfg = createConfiguration();
|
||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg, getCacheTestSupport()
|
||||
);
|
||||
// Sleep a bit to avoid concurrent FLUSH problem
|
||||
avoidConcurrentFlush();
|
||||
|
||||
Configuration cfg2 = createConfiguration();
|
||||
InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory(
|
||||
getJdbcServices(), cfg2, getCacheTestSupport()
|
||||
getServiceRegistry(), cfg2, getCacheTestSupport()
|
||||
);
|
||||
// Sleep a bit to avoid concurrent FLUSH problem
|
||||
avoidConcurrentFlush();
|
||||
|
|
|
@ -226,7 +226,7 @@ public class JBossStandaloneJtaExampleTest extends TestCase {
|
|||
}
|
||||
|
||||
private void bindUserTransaction() throws Exception {
|
||||
// also the UserTransaction must be registered on jndi: org.hibernate.transaction.JTATransactionFactory#getUserTransaction() requires this
|
||||
// also the UserTransaction must be registered on jndi: org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory#getUserTransaction() requires this
|
||||
bind("UserTransaction", lookup.getUserTransaction(), lookup.getUserTransaction().getClass(), ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.hibernate.cfg.Configuration;
|
|||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.cfg.Settings;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.service.spi.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* Utilities for cache testing.
|
||||
|
@ -72,11 +73,11 @@ public class CacheTestUtil {
|
|||
return cfg;
|
||||
}
|
||||
|
||||
public static InfinispanRegionFactory startRegionFactory(JdbcServices jdbcServices,
|
||||
Configuration cfg)
|
||||
throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
public static InfinispanRegionFactory startRegionFactory(
|
||||
ServiceRegistry serviceRegistry,
|
||||
Configuration cfg) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
|
||||
Settings settings = cfg.buildSettings( jdbcServices );
|
||||
Settings settings = cfg.buildSettings( serviceRegistry );
|
||||
Properties properties = cfg.getProperties();
|
||||
|
||||
String factoryType = cfg.getProperty(Environment.CACHE_REGION_FACTORY);
|
||||
|
@ -88,11 +89,11 @@ public class CacheTestUtil {
|
|||
return regionFactory;
|
||||
}
|
||||
|
||||
public static InfinispanRegionFactory startRegionFactory(JdbcServices jdbcServices,
|
||||
Configuration cfg,
|
||||
CacheTestSupport testSupport)
|
||||
throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
InfinispanRegionFactory factory = startRegionFactory(jdbcServices, cfg);
|
||||
public static InfinispanRegionFactory startRegionFactory(
|
||||
ServiceRegistry serviceRegistry,
|
||||
Configuration cfg,
|
||||
CacheTestSupport testSupport) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
InfinispanRegionFactory factory = startRegionFactory( serviceRegistry, cfg );
|
||||
testSupport.registerFactory(factory);
|
||||
return factory;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue