diff --git a/hibernate-infinispan/hibernate-infinispan.gradle b/hibernate-infinispan/hibernate-infinispan.gradle index 119466347d..f0e6a4d8cf 100644 --- a/hibernate-infinispan/hibernate-infinispan.gradle +++ b/hibernate-infinispan/hibernate-infinispan.gradle @@ -5,7 +5,7 @@ configurations { } dependencies { - infinispanVersion = '5.0.0.CR2' + infinispanVersion = '5.0.0.CR4' jnpVersion = '5.0.3.GA' compile(project(':hibernate-core')) diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java index 6010d4d3a4..9a902ffaf6 100644 --- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java @@ -72,6 +72,16 @@ public class InfinispanRegionFactory implements RegionFactory { public static final String INFINISPAN_GLOBAL_STATISTICS_PROP = "hibernate.cache.infinispan.statistics"; + /** + * Property that controls whether Infinispan should interact with the + * transaction manager as a {@link javax.transaction.Synchronization} or as + * an XA resource. If the property is set to true, it will be a + * synchronization, otherwise an XA resource. + * + * @see #DEF_USE_SYNCHRONIZATION + */ + public static final String INFINISPAN_USE_SYNCHRONIZATION_PROP = "hibernate.cache.infinispan.use_synchronization"; + private static final String ENTITY_KEY = "entity"; /** @@ -131,6 +141,11 @@ public class InfinispanRegionFactory implements RegionFactory { */ public static final String DEF_QUERY_RESOURCE = "local-query"; + /** + * Default value for {@link #INFINISPAN_USE_SYNCHRONIZATION_PROP}. + */ + public static final boolean DEF_USE_SYNCHRONIZATION = true; + private EmbeddedCacheManager manager; private final Map typeOverrides = new HashMap(); @@ -422,6 +437,11 @@ public class InfinispanRegionFactory implements RegionFactory { } else { regionOverrides.setTransactionManagerLookup(transactionManagerlookup); } + + String useSyncProp = ConfigurationHelper.extractPropertyValue(INFINISPAN_USE_SYNCHRONIZATION_PROP, properties); + boolean useSync = useSyncProp == null ? DEF_USE_SYNCHRONIZATION : Boolean.parseBoolean(useSyncProp); + regionOverrides.fluent().transaction().useSynchronization(useSync); + return regionOverrides; }