From ec899d5b4ba12d59c7b7a26d0542f6ddffeb08a7 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 11 Jan 2025 08:02:11 +0100 Subject: [PATCH] some very minor cleanups in o.h.e.t.jta.platform --- .../internal/DefaultJtaPlatformSelector.java | 5 ---- .../internal/AbstractJtaPlatform.java | 26 ++++++++----------- .../internal/JBossAppServerJtaPlatform.java | 5 ---- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/DefaultJtaPlatformSelector.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/DefaultJtaPlatformSelector.java index eea0f43fa19b..58906588def4 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/DefaultJtaPlatformSelector.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/DefaultJtaPlatformSelector.java @@ -61,11 +61,6 @@ private static Class legacy( case "org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform" -> { return JBossStandAloneJtaPlatform.class; } - //This one shouldn't be necessary as it matches the implementation FQN, - //but let's translate the existing code faithfully. - case "org.hibernate.engine.transaction.jta.platform.internal.WebSphereLibertyJtaPlatform" -> { - return WebSphereLibertyJtaPlatform.class; - } } //All other ones follow a pattern, beginning with the same prefix and ending with the same postfix, diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java index 42ade53e7c23..4b2e4127cfb1 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java @@ -11,17 +11,19 @@ import jakarta.transaction.TransactionManager; import jakarta.transaction.UserTransaction; -import org.hibernate.cfg.AvailableSettings; import org.hibernate.engine.jndi.spi.JndiService; import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper; import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException; -import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.ServiceRegistry; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.ServiceRegistryAwareService; import org.hibernate.service.spi.ServiceRegistryImplementor; +import static org.hibernate.cfg.TransactionSettings.JTA_CACHE_TM; +import static org.hibernate.cfg.TransactionSettings.JTA_CACHE_UT; +import static org.hibernate.internal.util.config.ConfigurationHelper.getBoolean; + /** * @author Steve Ebersole */ @@ -43,7 +45,7 @@ private final class TransactionManagerBasedSynchronizationStrategy implements Jt @Override public void registerSynchronization(Synchronization synchronization) { try { - AbstractJtaPlatform.this.getTransactionManager().getTransaction().registerSynchronization( synchronization ); + getTransactionManager().getTransaction().registerSynchronization( synchronization ); } catch (Exception e) { throw new JtaPlatformException( "Could not access JTA Transaction to register synchronization", e ); @@ -52,7 +54,7 @@ public void registerSynchronization(Synchronization synchronization) { @Override public boolean canRegisterSynchronization() { - return JtaStatusHelper.isActive( AbstractJtaPlatform.this.getTransactionManager() ); + return JtaStatusHelper.isActive( getTransactionManager() ); } } @@ -68,16 +70,8 @@ protected JndiService jndiService() { protected abstract UserTransaction locateUserTransaction(); public void configure(Map configValues) { - cacheTransactionManager = ConfigurationHelper.getBoolean( - AvailableSettings.JTA_CACHE_TM, - configValues, - canCacheTransactionManagerByDefault() - ); - cacheUserTransaction = ConfigurationHelper.getBoolean( - AvailableSettings.JTA_CACHE_UT, - configValues, - canCacheUserTransactionByDefault() - ); + cacheTransactionManager = getBoolean( JTA_CACHE_TM, configValues, canCacheTransactionManagerByDefault() ); + cacheUserTransaction = getBoolean( JTA_CACHE_UT, configValues, canCacheUserTransactionByDefault() ); } protected boolean canCacheTransactionManagerByDefault() { @@ -126,7 +120,9 @@ public UserTransaction retrieveUserTransaction() { } return userTransaction; } - return locateUserTransaction(); + else { + return locateUserTransaction(); + } } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java index e0784228fe1f..05951bfd2cf3 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java @@ -25,11 +25,6 @@ protected boolean canCacheUserTransactionByDefault() { return true; } - @Override - protected boolean canCacheTransactionManagerByDefault() { - return true; - } - @Override protected TransactionManager locateTransactionManager() { try {