-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added RegionFactory to the default Ehcache hibernate integration. Plu…
…s tests. Upgraded Ehcache to 2.4.1
- Loading branch information
Showing
9 changed files
with
441 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
hibernate-ehcache/src/main/java/org/hibernate/cache/DelegatingRegionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.hibernate.cache; | ||
|
||
import org.hibernate.cache.access.AccessType; | ||
import org.hibernate.cfg.Settings; | ||
|
||
import java.util.Properties; | ||
|
||
/** | ||
* @author Alex Snaps | ||
*/ | ||
public class DelegatingRegionFactory implements RegionFactory { | ||
|
||
private final RegionFactory regionFactory; | ||
|
||
DelegatingRegionFactory(final RegionFactory regionFactory) { | ||
this.regionFactory = regionFactory; | ||
} | ||
|
||
public final void start(final Settings settings, final Properties properties) throws CacheException { | ||
regionFactory.start(settings, properties); | ||
} | ||
|
||
public final void stop() { | ||
regionFactory.stop(); | ||
} | ||
|
||
public final boolean isMinimalPutsEnabledByDefault() { | ||
return regionFactory.isMinimalPutsEnabledByDefault(); | ||
} | ||
|
||
public final AccessType getDefaultAccessType() { | ||
return regionFactory.getDefaultAccessType(); | ||
} | ||
|
||
public final long nextTimestamp() { | ||
return regionFactory.nextTimestamp(); | ||
} | ||
|
||
public final EntityRegion buildEntityRegion(final String regionName, final Properties properties, | ||
final CacheDataDescription metadata) throws CacheException { | ||
return regionFactory.buildEntityRegion(regionName, properties, metadata); | ||
} | ||
|
||
public final CollectionRegion buildCollectionRegion(final String regionName, final Properties properties, | ||
final CacheDataDescription metadata) throws CacheException { | ||
return regionFactory.buildCollectionRegion(regionName, properties, metadata); | ||
} | ||
|
||
public final QueryResultsRegion buildQueryResultsRegion(final String regionName, final Properties properties) throws CacheException { | ||
return regionFactory.buildQueryResultsRegion(regionName, properties); | ||
} | ||
|
||
public final TimestampsRegion buildTimestampsRegion(final String regionName, final Properties properties) throws CacheException { | ||
return regionFactory.buildTimestampsRegion(regionName, properties); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
hibernate-ehcache/src/main/java/org/hibernate/cache/EhCacheRegionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.hibernate.cache; | ||
|
||
import java.util.Properties; | ||
|
||
/** | ||
* @author Alex Snaps | ||
*/ | ||
public class EhCacheRegionFactory extends DelegatingRegionFactory { | ||
|
||
public EhCacheRegionFactory(final Properties properties) { | ||
super(new net.sf.ehcache.hibernate.EhCacheRegionFactory(properties)); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
hibernate-ehcache/src/main/java/org/hibernate/cache/SingletonEhCacheRegionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.hibernate.cache; | ||
|
||
import java.util.Properties; | ||
|
||
/** | ||
* @author Alex Snaps | ||
*/ | ||
public class SingletonEhCacheRegionFactory extends DelegatingRegionFactory { | ||
public SingletonEhCacheRegionFactory(Properties properties) { | ||
super(new net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory(properties)); | ||
} | ||
} |
128 changes: 64 additions & 64 deletions
128
...java/org/hibernate/cache/EhCacheTest.java → .../hibernate/cache/EhCacheProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as | ||
* indicated by the @author tags or express copyright attribution | ||
* statements applied by the authors. All third-party contributions are | ||
* distributed under license by Red Hat Middleware LLC. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, modify, | ||
* copy, or redistribute it subject to the terms and conditions of the GNU | ||
* Lesser General Public License, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this distribution; if not, write to: | ||
* Free Software Foundation, Inc. | ||
* 51 Franklin Street, Fifth Floor | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
package org.hibernate.cache; | ||
|
||
import junit.framework.Test; | ||
|
||
import org.hibernate.cfg.Environment; | ||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite; | ||
import org.hibernate.testing.cache.BaseCacheProviderTestCase; | ||
|
||
/** | ||
* @author Emmanuel Bernard | ||
*/ | ||
public class EhCacheTest extends BaseCacheProviderTestCase { | ||
public EhCacheTest(String x) { | ||
super( x ); | ||
} | ||
|
||
public static Test suite() { | ||
return new FunctionalTestClassTestSuite( EhCacheTest.class ); | ||
} | ||
|
||
public String getCacheConcurrencyStrategy() { | ||
return "read-write"; | ||
} | ||
|
||
protected Class getCacheProvider() { | ||
return EhCacheProvider.class; | ||
} | ||
|
||
protected String getConfigResourceKey() { | ||
return Environment.CACHE_PROVIDER_CONFIG; | ||
} | ||
|
||
protected String getConfigResourceLocation() { | ||
return "ehcache.xml"; | ||
} | ||
|
||
protected boolean useTransactionManager() { | ||
return false; | ||
} | ||
|
||
} | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as | ||
* indicated by the @author tags or express copyright attribution | ||
* statements applied by the authors. All third-party contributions are | ||
* distributed under license by Red Hat Middleware LLC. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, modify, | ||
* copy, or redistribute it subject to the terms and conditions of the GNU | ||
* Lesser General Public License, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this distribution; if not, write to: | ||
* Free Software Foundation, Inc. | ||
* 51 Franklin Street, Fifth Floor | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
package org.hibernate.cache; | ||
|
||
import junit.framework.Test; | ||
|
||
import org.hibernate.cfg.Environment; | ||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite; | ||
import org.hibernate.testing.cache.BaseCacheProviderTestCase; | ||
|
||
/** | ||
* @author Emmanuel Bernard | ||
*/ | ||
public class EhCacheProviderTest extends BaseCacheProviderTestCase { | ||
public EhCacheProviderTest(String x) { | ||
super(x); | ||
} | ||
|
||
public static Test suite() { | ||
return new FunctionalTestClassTestSuite(EhCacheProviderTest.class); | ||
} | ||
|
||
public String getCacheConcurrencyStrategy() { | ||
return "read-write"; | ||
} | ||
|
||
protected Class getCacheProvider() { | ||
return EhCacheProvider.class; | ||
} | ||
|
||
protected String getConfigResourceKey() { | ||
return Environment.CACHE_PROVIDER_CONFIG; | ||
} | ||
|
||
protected String getConfigResourceLocation() { | ||
return "ehcache.xml"; | ||
} | ||
|
||
protected boolean useTransactionManager() { | ||
return false; | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
hibernate-ehcache/src/test/java/org/hibernate/cache/EhCacheRegionFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.hibernate.cache; | ||
|
||
import org.hibernate.cfg.Environment; | ||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite; | ||
import org.hibernate.testing.cache.BaseCacheRegionFactoryTestCase; | ||
|
||
import junit.framework.Test; | ||
|
||
/** | ||
* @author Alex Snaps | ||
*/ | ||
public class EhCacheRegionFactoryTest extends BaseCacheRegionFactoryTestCase { | ||
|
||
public EhCacheRegionFactoryTest(String x) { | ||
super(x); | ||
} | ||
|
||
protected Class getCacheRegionFactory() { | ||
return EhCacheRegionFactory.class; | ||
} | ||
|
||
public static Test suite() { | ||
return new FunctionalTestClassTestSuite(EhCacheRegionFactoryTest.class); | ||
} | ||
|
||
public String getCacheConcurrencyStrategy() { | ||
return "read-write"; | ||
} | ||
|
||
protected String getConfigResourceKey() { | ||
return Environment.CACHE_PROVIDER_CONFIG; | ||
} | ||
|
||
protected String getConfigResourceLocation() { | ||
return "ehcache.xml"; | ||
} | ||
|
||
protected boolean useTransactionManager() { | ||
return false; | ||
} | ||
} |
Oops, something went wrong.