HHH-12640 deprecate WildFlyStandAloneJtaPlatform but still allow apps to reference it until we remove it in the future

This commit is contained in:
Scott Marlow 2018-05-31 12:13:20 -04:00 committed by Sanne Grinovero
parent 9fac6747ef
commit 1a89a167b4
3 changed files with 33 additions and 53 deletions

View File

@ -13,8 +13,8 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
/**
* Return a standalone JTA transaction manager for JBoss Transactions
* Known to work for org.jboss.jbossts:jbossjta:4.9.0.GA
* Return a standalone JTA transaction manager for JBoss (Arjuna) Transactions or WildFly transaction client
* Known to work for org.jboss.jbossts:jbossjta:4.9.0.GA as well as WildFly 11+
*
* @author Emmanuel Bernard
* @author Steve Ebersole
@ -22,9 +22,22 @@ import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
public class JBossStandAloneJtaPlatform extends AbstractJtaPlatform {
public static final String JBOSS_TM_CLASS_NAME = "com.arjuna.ats.jta.TransactionManager";
public static final String JBOSS_UT_CLASS_NAME = "com.arjuna.ats.jta.UserTransaction";
public static final String WILDFLY_TM_CLASS_NAME = "org.wildfly.transaction.client.ContextTransactionManager";
public static final String WILDFLY_UT_CLASS_NAME = "org.wildfly.transaction.client.LocalUserTransaction";
@Override
protected TransactionManager locateTransactionManager() {
try {
final Class wildflyTmClass = serviceRegistry()
.getService( ClassLoaderService.class )
.classForName( WILDFLY_TM_CLASS_NAME );
return (TransactionManager) wildflyTmClass.getMethod( "getInstance" ).invoke( null );
}
catch ( Exception ignore) {
// ignore and look for Arjuna class
}
try {
final Class jbossTmClass = serviceRegistry()
.getService( ClassLoaderService.class )
@ -38,6 +51,16 @@ public class JBossStandAloneJtaPlatform extends AbstractJtaPlatform {
@Override
protected UserTransaction locateUserTransaction() {
try {
final Class jbossUtClass = serviceRegistry()
.getService( ClassLoaderService.class )
.classForName( WILDFLY_UT_CLASS_NAME );
return (UserTransaction) jbossUtClass.getMethod( "getInstance" ).invoke( null );
}
catch ( Exception ignore) {
// ignore and look for Arjuna class
}
try {
final Class jbossUtClass = serviceRegistry()
.getService( ClassLoaderService.class )

View File

@ -47,11 +47,11 @@ public class StandardJtaPlatformResolver implements JtaPlatformResolver {
// first try loading WildFly Transaction Client
try {
classLoaderService.classForName( WildFlyStandAloneJtaPlatform.WILDFLY_TM_CLASS_NAME );
classLoaderService.classForName( WildFlyStandAloneJtaPlatform.WILDFLY_UT_CLASS_NAME );
classLoaderService.classForName( JBossStandAloneJtaPlatform.WILDFLY_TM_CLASS_NAME );
classLoaderService.classForName( JBossStandAloneJtaPlatform.WILDFLY_UT_CLASS_NAME );
// we know that the WildFly Transaction Client TM classes are available
// if neither of these look-ups resulted in an error (no such class), then WildFly Transaction Client TM available on
// if neither of these look-ups resulted in an error (no such class), then WildFly Transaction Client TM is available on
// the classpath.
//
// todo : we cannot really distinguish between the need for JBossStandAloneJtaPlatform versus JBossApServerJtaPlatform
@ -59,7 +59,7 @@ public class StandardJtaPlatformResolver implements JtaPlatformResolver {
// should be relying on that.
// Note that on WF13+, we can expect org.jboss.as.jpa.hibernate5.service.WildFlyCustomJtaPlatformInitiator to choose
// the WildFlyCustomJtaPlatform, unless the application has disabled WildFlyCustomJtaPlatformInitiator.
return new WildFlyStandAloneJtaPlatform();
return new JBossStandAloneJtaPlatform();
}
catch (ClassLoadingException ignore) {
}

View File

@ -1,10 +1,3 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@ -13,51 +6,15 @@
*/
package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
/**
* Return a standalone JTA transaction manager for WildFly transaction client
* Known to work for WildFly 13+
*
* @author Scott Marlow
*
* @deprecated (since 5.3.1), use {@link org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform} instead
*/
public class WildFlyStandAloneJtaPlatform extends AbstractJtaPlatform {
public static final String WILDFLY_TM_CLASS_NAME = "org.wildfly.transaction.client.ContextTransactionManager";
public static final String WILDFLY_UT_CLASS_NAME = "org.wildfly.transaction.client.LocalUserTransaction";
@Deprecated
public class WildFlyStandAloneJtaPlatform extends JBossStandAloneJtaPlatform {
@Override
protected TransactionManager locateTransactionManager() {
try {
final Class wildflyTmClass = serviceRegistry()
.getService( ClassLoaderService.class )
.classForName( WILDFLY_TM_CLASS_NAME );
return (TransactionManager) wildflyTmClass.getMethod( "getInstance" ).invoke( null );
}
catch (Exception e) {
throw new JtaPlatformException(
"Could not obtain WildFly Transaction Client transaction manager instance",
e
);
}
}
@Override
protected UserTransaction locateUserTransaction() {
try {
final Class jbossUtClass = serviceRegistry()
.getService( ClassLoaderService.class )
.classForName( WILDFLY_UT_CLASS_NAME );
return (UserTransaction) jbossUtClass.getMethod( "getInstance" ).invoke( null );
}
catch (Exception e) {
throw new JtaPlatformException(
"Could not obtain WildFly Transaction Client user transaction instance",
e
);
}
}
}