Skip to content
Browse files

HHH-5990 - Remove non-maintained second level cache integrations

  • Loading branch information...
1 parent 4926904 commit 7f7f073c9bb815a650b6d840722e48e4e9bf0efc @sebersole sebersole committed
View
6 hibernate-oscache/hibernate-oscache.gradle
@@ -1,6 +0,0 @@
-apply plugin: 'java'
-
-dependencies {
- compile ( project( ':hibernate-core' ) )
- compile( [group: 'opensymphony', name: 'oscache', version: '2.1'] )
-}
View
131 hibernate-oscache/src/main/java/org/hibernate/cache/OSCache.java
@@ -1,131 +0,0 @@
-/*
- * 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 java.util.Map;
-import com.opensymphony.oscache.base.NeedsRefreshException;
-import com.opensymphony.oscache.general.GeneralCacheAdministrator;
-
-/**
- * @author <a href="mailto:m.bogaert@intrasoft.be">Mathias Bogaert</a>
- */
-public class OSCache implements Cache {
-
- /**
- * The OSCache 2.0 cache administrator.
- */
- private GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
-
- private final int refreshPeriod;
- private final String cron;
- private final String regionName;
-
- private String toString(Object key) {
- return String.valueOf(key) + '.' + regionName;
- }
-
- public OSCache(int refreshPeriod, String cron, String region) {
- this.refreshPeriod = refreshPeriod;
- this.cron = cron;
- this.regionName = region;
- }
-
- public void setCacheCapacity(int cacheCapacity) {
- cache.setCacheCapacity(cacheCapacity);
- }
-
- public Object get(Object key) throws CacheException {
- try {
- return cache.getFromCache( toString(key), refreshPeriod, cron );
- }
- catch (NeedsRefreshException e) {
- cache.cancelUpdate( toString(key) );
- return null;
- }
- }
-
- public Object read(Object key) throws CacheException {
- return get(key);
- }
-
- public void update(Object key, Object value) throws CacheException {
- put(key, value);
- }
-
- public void put(Object key, Object value) throws CacheException {
- cache.putInCache( toString(key), value );
- }
-
- public void remove(Object key) throws CacheException {
- cache.flushEntry( toString(key) );
- }
-
- public void clear() throws CacheException {
- cache.flushAll();
- }
-
- public void destroy() throws CacheException {
- cache.destroy();
- }
-
- public void lock(Object key) throws CacheException {
- // local cache, so we use synchronization
- }
-
- public void unlock(Object key) throws CacheException {
- // local cache, so we use synchronization
- }
-
- public long nextTimestamp() {
- return Timestamper.next();
- }
-
- public int getTimeout() {
- return Timestamper.ONE_MS * 60000; //ie. 60 seconds
- }
-
- public String getRegionName() {
- return regionName;
- }
-
- public long getSizeInMemory() {
- return -1;
- }
-
- public long getElementCountInMemory() {
- return -1;
- }
-
- public long getElementCountOnDisk() {
- return -1;
- }
-
- public Map toMap() {
- throw new UnsupportedOperationException();
- }
-
- public String toString() {
- return "OSCache(" + regionName + ')';
- }
-
-}
View
107 hibernate-oscache/src/main/java/org/hibernate/cache/OSCacheProvider.java
@@ -1,107 +0,0 @@
-/*
- * 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 java.util.Properties;
-import org.hibernate.internal.util.StringHelper;
-import org.hibernate.internal.util.config.ConfigurationHelper;
-import com.opensymphony.oscache.base.CacheEntry;
-import com.opensymphony.oscache.base.Config;
-
-/**
- * Support for OpenSymphony OSCache. This implementation assumes
- * that identifiers have well-behaved <tt>toString()</tt> methods.
- *
- * @author <a href="mailto:m.bogaert@intrasoft.be">Mathias Bogaert</a>
- */
-public class OSCacheProvider implements CacheProvider {
-
- /**
- * The <tt>OSCache</tt> refresh period property suffix.
- */
- public static final String OSCACHE_REFRESH_PERIOD = "refresh.period";
- /**
- * The <tt>OSCache</tt> CRON expression property suffix.
- */
- public static final String OSCACHE_CRON = "cron";
- /**
- * The <tt>OSCache</tt> cache capacity property suffix.
- */
- public static final String OSCACHE_CAPACITY = "capacity";
-
- private static final Properties OSCACHE_PROPERTIES = new Config().getProperties();
-
- /**
- * Builds a new {@link Cache} instance, and gets it's properties from the OSCache {@link Config}
- * which reads the properties file (<code>oscache.properties</code>) from the classpath.
- * If the file cannot be found or loaded, an the defaults are used.
- *
- * @param region
- * @param properties
- * @return
- * @throws CacheException
- */
- public Cache buildCache(String region, Properties properties) throws CacheException {
-
- int refreshPeriod = ConfigurationHelper.getInt(
- StringHelper.qualify(region, OSCACHE_REFRESH_PERIOD),
- OSCACHE_PROPERTIES,
- CacheEntry.INDEFINITE_EXPIRY
- );
- String cron = OSCACHE_PROPERTIES.getProperty( StringHelper.qualify( region, OSCACHE_CRON ) );
-
- // construct the cache
- final OSCache cache = new OSCache(refreshPeriod, cron, region);
-
- Integer capacity = ConfigurationHelper.getInteger( StringHelper.qualify(region, OSCACHE_CAPACITY), OSCACHE_PROPERTIES );
- if ( capacity!=null ) cache.setCacheCapacity( capacity.intValue() );
-
- return cache;
- }
-
- public long nextTimestamp() {
- return Timestamper.next();
- }
-
- /**
- * Callback to perform any necessary initialization of the underlying cache implementation
- * during SessionFactory construction.
- *
- * @param properties current configuration settings.
- */
- public void start(Properties properties) throws CacheException {
- }
-
- /**
- * Callback to perform any necessary cleanup of the underlying cache implementation
- * during SessionFactory.close().
- */
- public void stop() {
- }
-
- public boolean isMinimalPutsEnabledByDefault() {
- return false;
- }
-
-}
View
6 hibernate-swarmcache/hibernate-swarmcache.gradle
@@ -1,6 +0,0 @@
-apply plugin: 'java'
-
-dependencies {
- compile( project( ':hibernate-core' ) )
- compile( [group: 'swarmcache', name: 'swarmcache', version: '1.0RC2'] )
-}
View
164 hibernate-swarmcache/src/main/java/org/hibernate/cache/SwarmCache.java
@@ -1,164 +0,0 @@
-/*
- * 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 java.io.Serializable;
-import java.util.Map;
-import net.sf.swarmcache.ObjectCache;
-
-/**
- * @author Jason Carreira, Gavin King
- */
-public class SwarmCache implements Cache {
-
- private final ObjectCache cache;
- private final String regionName;
-
- public SwarmCache(ObjectCache cache, String regionName) {
- this.cache = cache;
- this.regionName = regionName;
- }
-
- /**
- * Get an item from the cache
- * @param key
- * @return the cached object or <tt>null</tt>
- * @throws CacheException
- */
- public Object get(Object key) throws CacheException {
- if (key instanceof Serializable) {
- return cache.get( (Serializable) key );
- }
- else {
- throw new CacheException("Keys must implement Serializable");
- }
- }
-
- public Object read(Object key) throws CacheException {
- return get(key);
- }
-
- /**
- * Add an item to the cache
- * @param key
- * @param value
- * @throws CacheException
- */
- public void update(Object key, Object value) throws CacheException {
- put(key, value);
- }
-
- /**
- * Add an item to the cache
- * @param key
- * @param value
- * @throws CacheException
- */
- public void put(Object key, Object value) throws CacheException {
- if (key instanceof Serializable) {
- cache.put( (Serializable) key, value );
- }
- else {
- throw new CacheException("Keys must implement Serializable");
- }
- }
-
- /**
- * Remove an item from the cache
- */
- public void remove(Object key) throws CacheException {
- if (key instanceof Serializable) {
- cache.clear( (Serializable) key );
- }
- else {
- throw new CacheException("Keys must implement Serializable");
- }
- }
-
- /**
- * Clear the cache
- */
- public void clear() throws CacheException {
- cache.clearAll();
- }
-
- /**
- * Clean up
- */
- public void destroy() throws CacheException {
- cache.clearAll();
- }
-
- /**
- * If this is a clustered cache, lock the item
- */
- public void lock(Object key) throws CacheException {
- throw new UnsupportedOperationException("SwarmCache does not support locking (use nonstrict-read-write)");
- }
-
- /**
- * If this is a clustered cache, unlock the item
- */
- public void unlock(Object key) throws CacheException {
- throw new UnsupportedOperationException("SwarmCache does not support locking (use nonstrict-read-write)");
- }
-
- /**
- * Generate a (coarse) timestamp
- */
- public long nextTimestamp() {
- return System.currentTimeMillis() / 100;
- }
-
- /**
- * Get a reasonable "lock timeout"
- */
- public int getTimeout() {
- return 600;
- }
-
- public String getRegionName() {
- return regionName;
- }
-
- public long getSizeInMemory() {
- return -1;
- }
-
- public long getElementCountInMemory() {
- return -1;
- }
-
- public long getElementCountOnDisk() {
- return -1;
- }
-
- public Map toMap() {
- throw new UnsupportedOperationException();
- }
-
- public String toString() {
- return "SwarmCache(" + regionName + ')';
- }
-
-}
View
79 hibernate-swarmcache/src/main/java/org/hibernate/cache/SwarmCacheProvider.java
@@ -1,79 +0,0 @@
-/*
- * 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 java.util.Properties;
-import net.sf.swarmcache.CacheConfiguration;
-import net.sf.swarmcache.CacheConfigurationManager;
-import net.sf.swarmcache.CacheFactory;
-import net.sf.swarmcache.ObjectCache;
-
-/**
- * Support for SwarmCache replicated cache. SwarmCache does not support
- * locking, so strict "read-write" semantics are unsupported.
- *
- * @author Jason Carreira
- */
-public class SwarmCacheProvider implements CacheProvider {
-
- private CacheFactory factory;
-
- public Cache buildCache(String regionName, Properties properties) throws CacheException {
- ObjectCache cache = factory.createCache(regionName);
- if (cache==null) {
- throw new CacheException("SwarmCache did not create a cache: " + regionName);
- }
- return new SwarmCache(cache, regionName);
- }
-
- public long nextTimestamp() {
- return System.currentTimeMillis() / 100;
- }
-
- /**
- * Callback to perform any necessary initialization of the underlying cache implementation
- * during SessionFactory construction.
- *
- * @param properties current configuration settings.
- */
- public void start(Properties properties) throws CacheException {
- CacheConfiguration config = CacheConfigurationManager.getConfig(properties);
- factory = new CacheFactory(config);
- }
-
- /**
- * Callback to perform any necessary cleanup of the underlying cache implementation
- * during SessionFactory.close().
- */
- public void stop() {
- if (factory != null) {
- factory.shutdown();
- factory = null;
- }
- }
-
- public boolean isMinimalPutsEnabledByDefault() {
- return true;
- }
-
-}
View
2 settings.gradle
@@ -7,8 +7,6 @@ include 'hibernate-proxool'
include 'hibernate-ehcache'
include 'hibernate-infinispan'
-include 'hibernate-oscache'
-include 'hibernate-swarmcache'
include 'release'

0 comments on commit 7f7f073

Please sign in to comment.
Something went wrong with that request. Please try again.