From e7dce75a9f84c24a73693171fcf4c3e05348f664 Mon Sep 17 00:00:00 2001 From: Galder Zamarreno Date: Tue, 22 Jun 2010 23:52:38 +0000 Subject: [PATCH] [HHH-5332] (JndiInfinispanRegionFactory cannot be instantiated) Fixed. git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19784 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../infinispan/InfinispanRegionFactory.java | 6 +++--- .../JndiInfinispanRegionFactory.java | 10 ++++++++- .../JndiInfinispanRegionFactoryTestCase.java | 21 +++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/JndiInfinispanRegionFactoryTestCase.java diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java index be4f0a0319..56050019bc 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java @@ -159,7 +159,7 @@ public class InfinispanRegionFactory implements RegionFactory { /** {@inheritDoc} */ public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException { - log.debug("Building collection cache region [" + regionName + "]"); + if (log.isDebugEnabled()) log.debug("Building collection cache region [" + regionName + "]"); Cache cache = getCache(regionName, COLLECTION_KEY, properties); CacheAdapter cacheAdapter = CacheAdapterImpl.newInstance(cache); CollectionRegionImpl region = new CollectionRegionImpl(cacheAdapter, regionName, metadata, transactionManager, this); @@ -182,7 +182,7 @@ public class InfinispanRegionFactory implements RegionFactory { */ public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException { - log.debug("Building query results cache region [" + regionName + "]"); + if (log.isDebugEnabled()) log.debug("Building query results cache region [" + regionName + "]"); String cacheName = typeOverrides.get(QUERY_KEY).getCacheName(); CacheAdapter cacheAdapter = CacheAdapterImpl.newInstance(manager.getCache(cacheName)); QueryResultsRegionImpl region = new QueryResultsRegionImpl(cacheAdapter, regionName, properties, transactionManager, this); @@ -195,7 +195,7 @@ public class InfinispanRegionFactory implements RegionFactory { */ public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException { - log.debug("Building timestamps cache region [" + regionName + "]"); + if (log.isDebugEnabled()) log.debug("Building timestamps cache region [" + regionName + "]"); String cacheName = typeOverrides.get(TIMESTAMPS_KEY).getCacheName(); CacheAdapter cacheAdapter = CacheAdapterImpl.newInstance(manager.getCache(cacheName)); TimestampsRegionImpl region = new TimestampsRegionImpl(cacheAdapter, regionName, transactionManager, this); diff --git a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java index 2b5142836a..bc654b4208 100644 --- a/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java +++ b/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/JndiInfinispanRegionFactory.java @@ -51,7 +51,15 @@ public class JndiInfinispanRegionFactory extends InfinispanRegionFactory { * There is no default value -- the user must specify the property. */ public static final String CACHE_MANAGER_RESOURCE_PROP = "hibernate.cache.infinispan.cachemanager"; - + + public JndiInfinispanRegionFactory() { + super(); + } + + public JndiInfinispanRegionFactory(Properties props) { + super(props); + } + @Override protected CacheManager createCacheManager(Properties properties) throws CacheException { String name = PropertiesHelper.getString(CACHE_MANAGER_RESOURCE_PROP, properties, null); diff --git a/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/JndiInfinispanRegionFactoryTestCase.java b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/JndiInfinispanRegionFactoryTestCase.java new file mode 100644 index 0000000000..6a8c8494ef --- /dev/null +++ b/cache-infinispan/src/test/java/org/hibernate/test/cache/infinispan/JndiInfinispanRegionFactoryTestCase.java @@ -0,0 +1,21 @@ +package org.hibernate.test.cache.infinispan; + +import junit.framework.TestCase; +import org.hibernate.cfg.SettingsFactory; + +import java.util.Properties; + +/** + * // TODO: Document this + * + * @author Galder ZamarreƱo + * @since // TODO + */ +public class JndiInfinispanRegionFactoryTestCase extends TestCase { + + public void testConstruction() { + Properties p = new Properties(); + p.setProperty("hibernate.cache.region.factory_class", "org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"); + SettingsFactory.createRegionFactory(p, true); + } +}