HHH-6164 - Prefer regsitering JTA syncs via TransactionManager
This commit is contained in:
parent
5f607c6b9f
commit
627b4ea6a1
|
@ -48,6 +48,8 @@ public abstract class AbstractJtaPlatform
|
|||
private boolean cacheUserTransaction;
|
||||
private ServiceRegistryImplementor serviceRegistry;
|
||||
|
||||
private final JtaSynchronizationStrategy tmSynchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
|
@ -116,7 +118,9 @@ public abstract class AbstractJtaPlatform
|
|||
return transaction;
|
||||
}
|
||||
|
||||
protected abstract JtaSynchronizationStrategy getSynchronizationStrategy();
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return tmSynchronizationStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSynchronization(Synchronization synchronization) {
|
||||
|
|
|
@ -35,13 +35,6 @@ import org.hibernate.service.jta.platform.spi.JtaPlatformException;
|
|||
public class BitronixJtaPlatform extends AbstractJtaPlatform {
|
||||
private static final String TM_CLASS_NAME = "bitronix.tm.TransactionManagerServices";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
try {
|
||||
|
|
|
@ -33,8 +33,6 @@ public class BorlandEnterpriseServerJtaPlatform extends AbstractJtaPlatform {
|
|||
protected static final String TM_NAME = "java:pm/TransactionManager";
|
||||
protected static final String UT_NAME = "java:comp/UserTransaction";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
return (TransactionManager) jndiService().locate( TM_NAME );
|
||||
|
@ -44,9 +42,4 @@ public class BorlandEnterpriseServerJtaPlatform extends AbstractJtaPlatform {
|
|||
protected UserTransaction locateUserTransaction() {
|
||||
return (UserTransaction) jndiService().locate( UT_NAME );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
package org.hibernate.service.jta.platform.internal;
|
||||
|
||||
import javax.transaction.TransactionManager;
|
||||
import javax.transaction.TransactionSynchronizationRegistry;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
/**
|
||||
|
@ -32,12 +31,10 @@ import javax.transaction.UserTransaction;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JBossAppServerPlatform extends AbstractJtaPlatform implements SynchronizationRegistryAccess {
|
||||
public class JBossAppServerJtaPlatform extends AbstractJtaPlatform {
|
||||
public static final String TM_NAME = "java:/TransactionManager";
|
||||
public static final String UT_NAME = "UserTransaction";
|
||||
public static final String REG_NAME = "java:comp/TransactionSynchronizationRegistry";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new SynchronizationRegistryBasedSynchronizationStrategy( this );
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
return (TransactionManager) jndiService().locate( TM_NAME );
|
||||
|
@ -47,14 +44,4 @@ public class JBossAppServerPlatform extends AbstractJtaPlatform implements Synch
|
|||
protected UserTransaction locateUserTransaction() {
|
||||
return (UserTransaction) jndiService().locate( UT_NAME );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionSynchronizationRegistry getSynchronizationRegistry() {
|
||||
return (TransactionSynchronizationRegistry) jndiService().locate( REG_NAME );
|
||||
}
|
||||
}
|
|
@ -40,8 +40,6 @@ public class JBossStandAloneJtaPlatform extends AbstractJtaPlatform {
|
|||
private static final String JBOSS_TM_CLASS_NAME = "com.arjuna.ats.jta.TransactionManager";
|
||||
private static final String JBOSS_UT_CLASS_NAME = "com.arjuna.ats.jta.UserTransaction";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
try {
|
||||
|
@ -67,9 +65,4 @@ public class JBossStandAloneJtaPlatform extends AbstractJtaPlatform {
|
|||
throw new JtaPlatformException( "Could not obtain JBoss Transactions user transaction instance", e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,6 @@ public class JOTMJtaPlatform extends AbstractJtaPlatform {
|
|||
public static final String TM_CLASS_NAME = "org.objectweb.jotm.Current";
|
||||
public static final String UT_NAME = "java:comp/UserTransaction";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
try {
|
||||
|
@ -55,9 +53,4 @@ public class JOTMJtaPlatform extends AbstractJtaPlatform {
|
|||
protected UserTransaction locateUserTransaction() {
|
||||
return (UserTransaction) jndiService().locate( UT_NAME );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,6 @@ public class JOnASJtaPlatform extends AbstractJtaPlatform {
|
|||
public static final String UT_NAME = "java:comp/UserTransaction";
|
||||
private static final String TM_CLASS_NAME = "org.objectweb.jonas_tm.Current";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
try {
|
||||
|
@ -55,9 +53,4 @@ public class JOnASJtaPlatform extends AbstractJtaPlatform {
|
|||
protected UserTransaction locateUserTransaction() {
|
||||
return (UserTransaction) jndiService().locate( UT_NAME );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ public class JRun4JtaPlatform extends AbstractJtaPlatform {
|
|||
public static final String TM_NAME = "java:/TransactionManager";
|
||||
public static final String UT_NAME = "java:comp/UserTransaction";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
return (TransactionManager) jndiService().locate( TM_NAME );
|
||||
|
@ -47,9 +45,4 @@ public class JRun4JtaPlatform extends AbstractJtaPlatform {
|
|||
protected UserTransaction locateUserTransaction() {
|
||||
return (UserTransaction) jndiService().locate( UT_NAME );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ public class JtaPlatformInitiator implements BasicServiceInitiator<JtaPlatform>
|
|||
}
|
||||
|
||||
if ( "org.hibernate.transaction.JBossTransactionManagerLookup".equals( tmlImplName ) ) {
|
||||
return new JBossAppServerPlatform();
|
||||
return new JBossAppServerJtaPlatform();
|
||||
}
|
||||
|
||||
if ( "org.hibernate.transaction.JBossTSStandaloneTransactionManagerLookup".equals( tmlImplName ) ) {
|
||||
|
|
|
@ -36,8 +36,6 @@ public class OC4JJtaPlatform extends AbstractJtaPlatform {
|
|||
public static final String TM_NAME = "java:comp/pm/TransactionManager";
|
||||
public static final String UT_NAME = "java:comp/UserTransaction";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
return (TransactionManager) jndiService().locate( TM_NAME );
|
||||
|
@ -47,9 +45,4 @@ public class OC4JJtaPlatform extends AbstractJtaPlatform {
|
|||
protected UserTransaction locateUserTransaction() {
|
||||
return (UserTransaction) jndiService().locate( UT_NAME );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ public class OrionJtaPlatform extends AbstractJtaPlatform {
|
|||
public static final String TM_NAME = "java:comp/UserTransaction";
|
||||
public static final String UT_NAME = "java:comp/UserTransaction";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
return (TransactionManager) jndiService().locate( TM_NAME );
|
||||
|
@ -47,9 +45,4 @@ public class OrionJtaPlatform extends AbstractJtaPlatform {
|
|||
protected UserTransaction locateUserTransaction() {
|
||||
return (UserTransaction) jndiService().locate( UT_NAME );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ public class ResinJtaPlatform extends AbstractJtaPlatform {
|
|||
public static final String TM_NAME = "java:comp/TransactionManager";
|
||||
public static final String UT_NAME = "java:comp/UserTransaction";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
return (TransactionManager) jndiService().locate( TM_NAME );
|
||||
|
@ -47,9 +45,4 @@ public class ResinJtaPlatform extends AbstractJtaPlatform {
|
|||
protected UserTransaction locateUserTransaction() {
|
||||
return (UserTransaction) jndiService().locate( UT_NAME );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,6 @@ public class SunOneJtaPlatform extends AbstractJtaPlatform {
|
|||
public static final String TM_NAME = "java:appserver/TransactionManager";
|
||||
public static final String UT_NAME = "java:comp/UserTransaction";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
return (TransactionManager) jndiService().locate( TM_NAME );
|
||||
|
@ -49,9 +47,4 @@ public class SunOneJtaPlatform extends AbstractJtaPlatform {
|
|||
protected UserTransaction locateUserTransaction() {
|
||||
return (UserTransaction) jndiService().locate( UT_NAME );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,6 @@ public class TransactionManagerLookupBridge extends AbstractJtaPlatform {
|
|||
private final TransactionManagerLookup lookup;
|
||||
private final Properties jndiProperties;
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
public TransactionManagerLookupBridge(TransactionManagerLookup lookup, Properties jndiProperties) {
|
||||
this.lookup = lookup;
|
||||
this.jndiProperties = jndiProperties;
|
||||
|
@ -55,11 +53,6 @@ public class TransactionManagerLookupBridge extends AbstractJtaPlatform {
|
|||
return (UserTransaction) serviceRegistry().getService( JndiService.class ).locate( lookup.getUserTransactionName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTransactionIdentifier(Transaction transaction) {
|
||||
return lookup.getTransactionIdentifier( transaction );
|
||||
|
|
|
@ -57,8 +57,6 @@ import org.hibernate.HibernateException;
|
|||
public class WebSphereExtendedJtaPlatform extends AbstractJtaPlatform {
|
||||
public static final String UT_NAME = "java:comp/UserTransaction";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected boolean canCacheTransactionManager() {
|
||||
return true;
|
||||
|
@ -81,11 +79,6 @@ public class WebSphereExtendedJtaPlatform extends AbstractJtaPlatform {
|
|||
return Integer.valueOf( transaction.hashCode() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
|
||||
public class TransactionManagerAdapter implements TransactionManager {
|
||||
private final Class synchronizationCallbackClass;
|
||||
private final Method registerSynchronizationMethod;
|
||||
|
|
|
@ -38,14 +38,11 @@ import org.jboss.logging.Logger;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class WebSphereJtaPlatform extends AbstractJtaPlatform {
|
||||
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, WebSphereJtaPlatform.class.getName());
|
||||
|
||||
public static final String VERSION_5_UT_NAME = "java:comp/UserTransaction";
|
||||
public static final String VERSION_4_UT_NAME = "jta/usertransaction";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
private final Class transactionManagerAccessClass;
|
||||
private final int webSphereVersion;
|
||||
|
||||
|
@ -96,9 +93,4 @@ public class WebSphereJtaPlatform extends AbstractJtaPlatform {
|
|||
final String utName = webSphereVersion == 5 ? VERSION_5_UT_NAME : VERSION_4_UT_NAME;
|
||||
return (UserTransaction) jndiService().locate( utName );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ public class WeblogicJtaPlatform extends AbstractJtaPlatform {
|
|||
public static final String TM_NAME = "javax.transaction.TransactionManager";
|
||||
public static final String UT_NAME = "javax.transaction.UserTransaction";
|
||||
|
||||
private final JtaSynchronizationStrategy synchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( this );
|
||||
|
||||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
return (TransactionManager) jndiService().locate( TM_NAME );
|
||||
|
@ -47,9 +45,4 @@ public class WeblogicJtaPlatform extends AbstractJtaPlatform {
|
|||
protected UserTransaction locateUserTransaction() {
|
||||
return (UserTransaction) jndiService().locate( UT_NAME );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JtaSynchronizationStrategy getSynchronizationStrategy() {
|
||||
return synchronizationStrategy;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue