diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java index 72b33a4559..8d2e581f98 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java @@ -84,6 +84,7 @@ import org.hibernate.engine.transaction.jta.platform.internal.SapNetWeaverJtaPla import org.hibernate.engine.transaction.jta.platform.internal.SunOneJtaPlatform; import org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform; import org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.WebSphereLibertyJtaPlatform; import org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform; import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.event.internal.EntityCopyAllowedLoggedObserver; @@ -341,6 +342,13 @@ public class StrategySelectorBuilder { "Weblogic", "org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform" ); + + addJtaPlatforms( + strategySelector, + WebSphereLibertyJtaPlatform.class, + "WebSphereLiberty", + "org.hibernate.engine.transaction.jta.platform.internal.WebSphereLibertyJtaPlatform" + ); addJtaPlatforms( strategySelector, diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/StandardJtaPlatformResolver.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/StandardJtaPlatformResolver.java index bd8db67e05..5e0e8e3e78 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/StandardJtaPlatformResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/StandardJtaPlatformResolver.java @@ -86,8 +86,16 @@ public class StandardJtaPlatformResolver implements JtaPlatformResolver { } catch (ClassLoadingException ignore) { } - - // WebSphere ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // WebSphere Liberty ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + try { + classLoaderService.classForName(WebSphereLibertyJtaPlatform.TMF_CLASS_NAME); + return new WebSphereLibertyJtaPlatform(); + } + catch (ClassLoadingException ignore) { + } + + // WebSphere traditional ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for ( WebSphereJtaPlatform.WebSphereEnvironment webSphereEnvironment : WebSphereJtaPlatform.WebSphereEnvironment.values() ) { try { diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereExtendedJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereExtendedJtaPlatform.java index 4c43621476..9b99d03a41 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereExtendedJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereExtendedJtaPlatform.java @@ -32,7 +32,7 @@ import org.hibernate.HibernateException; *
  • the WAS container in which Hibernate will be utilized
  • * *

    - * This class is reported to work on WAS version 6 in any of the standard J2EE/JEE component containers. + * This class is reported to work on WAS version 6 in any of the standard J2EE/Java EE component containers. * * @author Gavin King * @author TransactionManagerFactory = serviceRegistry() + .getService( ClassLoaderService.class ) + .classForName( TMF_CLASS_NAME ); + return (TransactionManager) TransactionManagerFactory.getMethod("getTransactionManager").invoke(null); + } + catch ( Exception e ) { + throw new JtaPlatformException( "Could not obtain WebSphere Liberty transaction manager instance", e ); + } + } + + @Override + protected UserTransaction locateUserTransaction() { + return (UserTransaction) jndiService().locate( UT_NAME ); + } + + public boolean canRegisterSynchronization() { + try { + return getCurrentStatus() == Status.STATUS_ACTIVE; + } + catch (SystemException x) { + throw new RuntimeException(x); + } + } + + public int getCurrentStatus() throws SystemException { + return retrieveTransactionManager().getStatus(); + } + + public Object getTransactionIdentifier(Transaction transaction) { + return transaction; + } + + public void registerSynchronization(Synchronization synchronization) { + try { + retrieveTransactionManager().getTransaction().registerSynchronization(synchronization); + } + catch ( RollbackException | SystemException x ) { + throw new RuntimeException(x); + } + } + +} diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatform.java index 23c734ad3c..c795555ecb 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatform.java @@ -39,8 +39,7 @@ public interface JtaPlatform extends Service { * Determine an identifier for the given transaction appropriate for use in caching/lookup usages. *

    * Generally speaking the transaction itself will be returned here. This method was added specifically - * for use in WebSphere and other unfriendly JEE containers (although WebSphere is still the only known - * such brain-dead, sales-driven impl). + * for use in WebSphere and other unfriendly Java EE containers. * * @param transaction The transaction to be identified. * @return An appropriate identifier