Skip to content

Commit

Permalink
some very minor cleanups in o.h.e.t.jta.platform
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Jan 11, 2025
1 parent 4fc57c0 commit ec899d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ private static Class<? extends JtaPlatform> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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 );
Expand All @@ -52,7 +54,7 @@ public void registerSynchronization(Synchronization synchronization) {

@Override
public boolean canRegisterSynchronization() {
return JtaStatusHelper.isActive( AbstractJtaPlatform.this.getTransactionManager() );
return JtaStatusHelper.isActive( getTransactionManager() );
}
}

Expand All @@ -68,16 +70,8 @@ protected JndiService jndiService() {
protected abstract UserTransaction locateUserTransaction();

public void configure(Map<String, Object> 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() {
Expand Down Expand Up @@ -126,7 +120,9 @@ public UserTransaction retrieveUserTransaction() {
}
return userTransaction;
}
return locateUserTransaction();
else {
return locateUserTransaction();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ protected boolean canCacheUserTransactionByDefault() {
return true;
}

@Override
protected boolean canCacheTransactionManagerByDefault() {
return true;
}

@Override
protected TransactionManager locateTransactionManager() {
try {
Expand Down

0 comments on commit ec899d5

Please sign in to comment.