From d2c88d55dfee8b105b1072b1a7afea82632e2869 Mon Sep 17 00:00:00 2001
From: Steve Ebersole Returns the directory to generate the documentation into. Sets the directory to generate the documentation into. Returns the title for the generated documentation. Sets the title for the generated documentation.
- * The expected usage by a thread that is taking an action such that any pending
- * putFromLoad
may have stale data and should not cache it is to either
- * call
- *
- *
- * This class also supports the concept of "naked puts", which are calls to - * {@link #acquirePutFromLoadLock(Object)} without a preceding {@link #registerPendingPut(Object)} - * call. - *
- * - * @author Brian Stansberry - * - * @version $Revision: $ - */ -public class PutFromLoadValidator { - /** - * Period in ms after a removal during which a call to - * {@link #acquirePutFromLoadLock(Object)} that hasn't been - * {@link #registerPendingPut(Object) pre-registered} (aka a "naked put") - * will return false. - */ - public static final long NAKED_PUT_INVALIDATION_PERIOD = 20 * 1000; - - /** Period (in ms) after which a pending put is placed in the over-age queue */ - private static final long PENDING_PUT_OVERAGE_PERIOD = 5 * 1000; - - /** Period (in ms) before which we stop trying to clean out pending puts */ - private static final long PENDING_PUT_RECENT_PERIOD = 2 * 1000; - - /** - * Period (in ms) after which a pending put is never expected to come in - * and should be cleaned - */ - private static final long MAX_PENDING_PUT_DELAY = 2 * 60 * 1000; - - /** - * Used to determine whether the owner of a pending put is a thread or a - * transaction - */ - private final TransactionManager transactionManager; - - private final long nakedPutInvalidationPeriod; - private final long pendingPutOveragePeriod; - private final long pendingPutRecentPeriod; - private final long maxPendingPutDelay; - - /** - * Registry of expected, future, isPutValid calls. If a key+owner is - * registered in this map, it is not a "naked put" and is allowed to - * proceed. - */ - private final ConcurrentMapnull
- */
- public PutFromLoadValidator(TransactionManager transactionManager) {
- this(transactionManager, NAKED_PUT_INVALIDATION_PERIOD,
- PENDING_PUT_OVERAGE_PERIOD, PENDING_PUT_RECENT_PERIOD,
- MAX_PENDING_PUT_DELAY);
- }
-
- /**
- * Constructor variant for use by unit tests; allows control of various
- * timeouts by the test.
- */
- protected PutFromLoadValidator(TransactionManager transactionManager,
- long nakedPutInvalidationPeriod, long pendingPutOveragePeriod,
- long pendingPutRecentPeriod, long maxPendingPutDelay) {
- this.transactionManager = transactionManager;
- this.nakedPutInvalidationPeriod = nakedPutInvalidationPeriod;
- this.pendingPutOveragePeriod = pendingPutOveragePeriod;
- this.pendingPutRecentPeriod = pendingPutRecentPeriod;
- this.maxPendingPutDelay = maxPendingPutDelay;
- }
-
- // ----------------------------------------------------------------- Public
-
- /**
- * Acquire a lock giving the calling thread the right to put data in the
- * cache for the given key.
- *
- * NOTE: A call to this method that returns true
- * should always be matched with a call to {@link #releasePutFromLoadLock(Object)}.
- *
true
if the lock is acquired and the cache put
- * can proceed; false
if the data should not be cached
- */
- public boolean acquirePutFromLoadLock(Object key) {
-
- boolean valid = false;
- boolean locked = false;
- long now = System.currentTimeMillis();
-
- // Important: Do cleanup before we acquire any locks so we
- // don't deadlock with invalidateRegion
- cleanOutdatedPendingPuts(now, true);
-
- try {
- PendingPutMap pending = pendingPuts.get(key);
- if (pending != null) {
- locked = pending.acquireLock(100, TimeUnit.MILLISECONDS);
- if (locked) {
- try {
- PendingPut toCancel = pending.remove(getOwnerForPut());
- if (toCancel != null) {
- valid = !toCancel.completed;
- toCancel.completed = true;
- }
- }
- finally {
- if (!valid) {
- pending.releaseLock();
- locked = false;
- }
- }
- }
- }
- else {
- // Key wasn't in pendingPuts, so either this is a "naked put"
- // or regionRemoved has been called. Check if we can proceed
- if (now > invalidationTimestamp) {
- Long removedTime = recentRemovals.get(key);
- if (removedTime == null || now > removedTime.longValue()) {
- // It's legal to proceed. But we have to record this key
- // in pendingPuts so releasePutFromLoadLock can find it.
- // To do this we basically simulate a normal "register
- // then acquire lock" pattern
- registerPendingPut(key);
- locked = acquirePutFromLoadLock(key);
- valid = locked;
- }
- }
- }
- }
- catch (Throwable t) {
-
- valid = false;
-
- if (locked) {
- PendingPutMap toRelease = pendingPuts.get(key);
- if (toRelease != null) {
- toRelease.releaseLock();
- }
- }
-
- if (t instanceof RuntimeException) {
- throw (RuntimeException) t;
- }
- else if (t instanceof Error) {
- throw (Error) t;
- }
- else {
- throw new RuntimeException(t);
- }
- }
-
- return valid;
- }
-
- /**
- * Releases the lock previously obtained by a call to
- * {@link #acquirePutFromLoadLock(Object)} that returned true
.
- *
- * @param key the key
- */
- public void releasePutFromLoadLock(Object key) {
- PendingPutMap pending = pendingPuts.get(key);
- if (pending != null) {
- if (pending.size() == 0) {
- pendingPuts.remove(key);
- }
- pending.releaseLock();
- }
- }
-
- /**
- * Invalidates any {@link #registerPendingPut(Object) previously registered pending puts}
- * ensuring a subsequent call to {@link #acquirePutFromLoadLock(Object)} will
- * return false
.
- * - * This method will block until any concurrent thread that has - * {@link #acquirePutFromLoadLock(Object) acquired the putFromLoad lock} for - * the given key has released the lock. This allows the caller to be certain - * the putFromLoad will not execute after this method returns, possibly - * caching stale data. - *
- * - * @param key key identifying data whose pending puts should be invalidated - * - * @returntrue
if the invalidation was successful; false
- * if a problem occured (which the caller should treat as an
- * exception condition)
- */
- public boolean invalidateKey(Object key) {
-
- boolean success = true;
-
- // Invalidate any pending puts
- PendingPutMap pending = pendingPuts.get(key);
- if (pending != null) {
- // This lock should be available very quickly, but we'll be
- // very patient waiting for it as callers should treat not
- // acquiring it as an exception condition
- if (pending.acquireLock(60, TimeUnit.SECONDS)) {
- try {
- pending.invalidate();
- }
- finally {
- pending.releaseLock();
- }
- }
- else {
- success = false;
- }
- }
-
- // Record when this occurred to invalidate later naked puts
- RecentRemoval removal = new RecentRemoval(key,
- this.nakedPutInvalidationPeriod);
- recentRemovals.put(key, removal.timestamp);
-
- // Don't let recentRemovals map become a memory leak
- RecentRemoval toClean = null;
- boolean attemptClean = removal.timestamp.longValue() > earliestRemovalTimestamp;
- removalsLock.lock();
- try {
- removalsQueue.add(removal);
-
- if (attemptClean) {
- if (removalsQueue.size() > 1) { // we have at least one as we
- // just added it
- toClean = removalsQueue.remove(0);
- }
- earliestRemovalTimestamp = removalsQueue.get(0).timestamp
- .longValue();
- }
- } finally {
- removalsLock.unlock();
- }
-
- if (toClean != null) {
- Long cleaned = recentRemovals.get(toClean.key);
- if (cleaned != null && cleaned.equals(toClean.timestamp)) {
- cleaned = recentRemovals.remove(toClean.key);
- if (cleaned != null
- && cleaned.equals(toClean.timestamp) == false) {
- // Oops; removed the wrong timestamp; restore it
- recentRemovals.putIfAbsent(toClean.key, cleaned);
- }
- }
- }
-
- return success;
- }
-
- /**
- * Invalidates all {@link #registerPendingPut(Object) previously registered pending puts}
- * ensuring a subsequent call to {@link #acquirePutFromLoadLock(Object)} will
- * return false
.
- * - * This method will block until any concurrent thread that has - * {@link #acquirePutFromLoadLock(Object) acquired the putFromLoad lock} for - * the any key has released the lock. This allows the caller to be certain - * the putFromLoad will not execute after this method returns, possibly - * caching stale data. - *
- * - * @returntrue
if the invalidation was successful; false
- * if a problem occured (which the caller should treat as an
- * exception condition)
- */
- public boolean invalidateRegion() {
-
- boolean ok = false;
- invalidationTimestamp = System.currentTimeMillis()
- + this.nakedPutInvalidationPeriod;
-
- try {
-
- // Acquire the lock for each entry to ensure any ongoing
- // work associated with it is completed before we return
- for (PendingPutMap entry : pendingPuts.values()) {
- if (entry.acquireLock(60, TimeUnit.SECONDS)) {
- try {
- entry.invalidate();
- }
- finally {
- entry.releaseLock();
- }
- }
- else {
- ok = false;
- }
- }
-
- removalsLock.lock();
- try {
- recentRemovals.clear();
- removalsQueue.clear();
-
- ok = true;
-
- } finally {
- removalsLock.unlock();
- }
- }
- catch (Exception e) {
- ok = false;
- }
- finally {
- earliestRemovalTimestamp = invalidationTimestamp;
- }
-
- return ok;
- }
-
- /**
- * Notifies this validator that it is expected that a database read followed
- * by a subsequent {@link #acquirePutFromLoadLock(Object)} call will occur. The intent
- * is this method would be called following a cache miss wherein it is
- * expected that a database read plus cache put will occur. Calling this
- * method allows the validator to treat the subsequent
- * acquirePutFromLoadLock
as if the database read occurred when this method
- * was invoked. This allows the validator to compare the timestamp of this
- * call against the timestamp of subsequent removal notifications. A put
- * that occurs without this call preceding it is "naked"; i.e the validator
- * must assume the put is not valid if any relevant removal has occurred
- * within {@link #NAKED_PUT_INVALIDATION_PERIOD} milliseconds.
- *
- * @param key key that will be used for subsequent cache put
- */
- public void registerPendingPut(Object key) {
- PendingPut pendingPut = new PendingPut(key, getOwnerForPut());
- PendingPutMap pendingForKey = new PendingPutMap(pendingPut);
-
- for (;;) {
- PendingPutMap existing = pendingPuts.putIfAbsent(key,
- pendingForKey);
- if (existing != null) {
- if (existing.acquireLock(10, TimeUnit.SECONDS)) {
- try {
- existing.put(pendingPut);
- PendingPutMap doublecheck = pendingPuts.putIfAbsent(
- key, existing);
- if (doublecheck == null || doublecheck == existing) {
- break;
- }
- // else we hit a race and need to loop to try again
- }
- finally {
- existing.releaseLock();
- }
- }
- else {
- // Can't get the lock; when we come back we'll be a "naked put"
- break;
- }
- } else {
- // normal case
- break;
- }
- }
-
- // Guard against memory leaks
- preventOutdatedPendingPuts(pendingPut);
- }
-
- // -------------------------------------------------------------- Protected
-
- /** Only for use by unit tests; may be removed at any time */
- protected int getPendingPutQueueLength() {
- pendingLock.lock();
- try {
- return pendingQueue.size();
- } finally {
- pendingLock.unlock();
- }
- }
-
- /** Only for use by unit tests; may be removed at any time */
- protected int getOveragePendingPutQueueLength() {
- pendingLock.lock();
- try {
- return overagePendingQueue.size();
- } finally {
- pendingLock.unlock();
- }
- }
-
- /** Only for use by unit tests; may be removed at any time */
- protected int getRemovalQueueLength() {
- removalsLock.lock();
- try {
- return removalsQueue.size();
- } finally {
- removalsLock.unlock();
- }
- }
-
- // ---------------------------------------------------------------- Private
-
- private Object getOwnerForPut() {
- Transaction tx = null;
- try {
- if (transactionManager != null) {
- tx = transactionManager.getTransaction();
- }
- } catch (SystemException se) {
- throw new CacheException("Could not obtain transaction", se);
- }
- return tx == null ? Thread.currentThread() : tx;
-
- }
-
- private void preventOutdatedPendingPuts(PendingPut pendingPut) {
- pendingLock.lock();
- try {
- pendingQueue.add(new WeakReference- * The intent of this class is to encapsulate common code and serve as a - * delegate for {@link EntityRegionAccessStrategy} and - * {@link CollectionRegionAccessStrategy} implementations. - *
- * - * @author Brian Stansberry - */ -public class TransactionalAccessDelegate { - - protected final Cache cache; - protected final Fqn regionFqn; - protected final boolean invalidation; - protected final BasicRegionAdapter region; - protected final PutFromLoadValidator putValidator; - - public TransactionalAccessDelegate(BasicRegionAdapter adapter, PutFromLoadValidator validator) { - this.region = adapter; - this.cache = adapter.getCacheInstance(); - this.regionFqn = adapter.getRegionFqn(); - this.putValidator = validator; - this.invalidation = CacheHelper.isClusteredInvalidation(this.cache); - } - - public Object get(Object key, long txTimestamp) throws CacheException { - - if (!region.checkValid()) - return null; - - region.ensureRegionRootExists(); - - Object val = CacheHelper.get(cache, regionFqn, key); - - if (val == null) { - putValidator.registerPendingPut(key); - } - - return val; - } - - public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException { - - if (!region.checkValid()) - return false; - - if (!putValidator.acquirePutFromLoadLock(key)) - return false; - - try { - region.ensureRegionRootExists(); - - return CacheHelper.putForExternalRead(cache, regionFqn, key, value); - } - finally { - putValidator.releasePutFromLoadLock(key); - } - } - - public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) - throws CacheException { - - if (!region.checkValid()) - return false; - - if (!putValidator.acquirePutFromLoadLock(key)) - return false; - - try { - region.ensureRegionRootExists(); - - // We ignore minimalPutOverride. JBossCache putForExternalRead is - // already about as minimal as we can get; it will promptly return - // if it discovers that the node we want to write to already exists - return CacheHelper.putForExternalRead(cache, regionFqn, key, value); - } - finally { - putValidator.releasePutFromLoadLock(key); - } - } - - public SoftLock lockItem(Object key, Object version) throws CacheException { - return null; - } - - public SoftLock lockRegion() throws CacheException { - return null; - } - - public void unlockItem(Object key, SoftLock lock) throws CacheException { - } - - public void unlockRegion(SoftLock lock) throws CacheException { - } - - public boolean insert(Object key, Object value, Object version) throws CacheException { - - if (!region.checkValid()) - return false; - - region.ensureRegionRootExists(); - if (invalidation) { - Option opt = new Option(); - opt.setCacheModeLocal(true); - CacheHelper.put(cache, regionFqn, key, value, opt); - } - else { - CacheHelper.put(cache, regionFqn, key, value); - } - return true; - } - - public boolean afterInsert(Object key, Object value, Object version) throws CacheException { - return false; - } - - public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) - throws CacheException { - - // We update whether or not the region is valid. Other nodes - // may have already restored the region so they need to - // be informed of the change. - - region.ensureRegionRootExists(); - - CacheHelper.put(cache, regionFqn, key, value); - return true; - } - - public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) - throws CacheException { - return false; - } - - public void remove(Object key) throws CacheException { - - if (!putValidator.invalidateKey(key)) { - throw new CacheException("Failed to invalidate pending putFromLoad calls for key " + key + " from region " + region.getName()); - } - - // We remove whether or not the region is valid. Other nodes - // may have already restored the region so they need to - // be informed of the change. - - region.ensureRegionRootExists(); - - CacheHelper.remove(cache, regionFqn, key); - } - - public void removeAll() throws CacheException { - if (!putValidator.invalidateRegion()) { - throw new CacheException("Failed to invalidate pending putFromLoad calls for region " + region.getName()); - } - CacheHelper.removeAll(cache, regionFqn); - } - - public void evict(Object key) throws CacheException { - - if (!putValidator.invalidateKey(key)) { - throw new CacheException("Failed to invalidate pending putFromLoad calls for key " + key + " from region " + region.getName()); - } - - region.ensureRegionRootExists(); - - CacheHelper.remove(cache, regionFqn, key); - } - - public void evictAll() throws CacheException { - if (!putValidator.invalidateRegion()) { - throw new CacheException("Failed to invalidate pending putFromLoad calls for region " + region.getName()); - } - - Transaction tx = region.suspend(); - try { - region.ensureRegionRootExists(); - - CacheHelper.sendEvictAllNotification(cache, regionFqn, region.getMemberId(), null); - } - finally { - region.resume(tx); - } - } -} diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/JndiMultiplexingCacheInstanceManager.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/JndiMultiplexingCacheInstanceManager.java deleted file mode 100644 index 69270e5013..0000000000 --- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/JndiMultiplexingCacheInstanceManager.java +++ /dev/null @@ -1,103 +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.jbc.builder; - -import java.util.Properties; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import org.hibernate.cache.CacheException; -import org.hibernate.cfg.Settings; -import org.hibernate.internal.util.jndi.JndiHelper; -import org.hibernate.internal.util.config.ConfigurationHelper; -import org.jboss.cache.CacheManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * A {@link MultiplexingCacheInstanceManager} that finds its cache factory - * in JNDI rather than creating one itself. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class JndiMultiplexingCacheInstanceManager extends MultiplexingCacheInstanceManager { - - private static final Logger log = LoggerFactory.getLogger(JndiMultiplexingCacheInstanceManager.class); - - /** - * Specifies the JNDI name under which the {@link CacheManager} to use is bound. - * There is no default value -- the user must specify the property. - */ - public static final String CACHE_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.cachefactory"; - - /** - * Create a new JndiMultiplexingCacheInstanceManager. - */ - public JndiMultiplexingCacheInstanceManager() { - super(); - } - - @Override - public void start(Settings settings, Properties properties) throws CacheException { - - String name = ConfigurationHelper.getString(CACHE_FACTORY_RESOURCE_PROP, properties, null); - if (name == null) - throw new CacheException("Configuration property " + CACHE_FACTORY_RESOURCE_PROP + " not set"); - - CacheManager cf = locateCacheFactory( name, JndiHelper.extractJndiProperties( properties ) ); - setCacheFactory( cf ); - - super.start(settings, properties); - } - - private CacheManager locateCacheFactory(String jndiNamespace, Properties jndiProperties) { - - Context ctx = null; - try { - ctx = new InitialContext( jndiProperties ); - return (CacheManager) ctx.lookup( jndiNamespace ); - } - catch (NamingException ne) { - String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]"; - log.info( msg, ne ); - throw new CacheException( msg ); - } - finally { - if ( ctx != null ) { - try { - ctx.close(); - } - catch( NamingException ne ) { - log.info( "Unable to release initial context", ne ); - } - } - } - } - - -} diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/JndiSharedCacheInstanceManager.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/JndiSharedCacheInstanceManager.java deleted file mode 100644 index baeee98da8..0000000000 --- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/JndiSharedCacheInstanceManager.java +++ /dev/null @@ -1,112 +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.jbc.builder; - -import java.util.Properties; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import org.hibernate.cache.CacheException; -import org.hibernate.cfg.Settings; -import org.hibernate.internal.util.jndi.JndiHelper; -import org.hibernate.internal.util.config.ConfigurationHelper; -import org.jboss.cache.Cache; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A {@link SharedCacheInstanceManager} that finds the shared cache in JNDI - * rather than instantiating one from an XML config file. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class JndiSharedCacheInstanceManager extends SharedCacheInstanceManager { - - private static final Logger log = LoggerFactory.getLogger(JndiSharedCacheInstanceManager.class); - - /** - * Specifies the JNDI name under which the {@link Cache} to use is bound. - *- * Note that although this configuration property has the same name as that by - * in {@link SharedCacheInstanceManager#CACHE_RESOURCE_PROP the superclass}, - * the meaning here is different. Note also that in this class' usage - * of the property, there is no default value -- the user must specify - * the property. - */ - public static final String CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.shared"; - - /** - * Create a new JndiSharedCacheInstanceManager. - * - */ - public JndiSharedCacheInstanceManager() { - super(); - } - - @Override - protected Cache createSharedCache(Settings settings, Properties properties) { - - String name = ConfigurationHelper.getString(CACHE_RESOURCE_PROP, properties, null); - if (name == null) - throw new CacheException("Configuration property " + CACHE_RESOURCE_PROP + " not set"); - - return locateCache( name, JndiHelper.extractJndiProperties( properties ) ); - } - - /** - * No-op; we don't own the cache so we shouldn't stop it. - */ - @Override - protected void stopSharedCache(Cache cache) { - // no-op. We don't own the cache so we shouldn't stop it. - } - - private Cache locateCache(String jndiNamespace, Properties jndiProperties) { - - Context ctx = null; - try { - ctx = new InitialContext( jndiProperties ); - return (Cache) ctx.lookup( jndiNamespace ); - } - catch (NamingException ne) { - String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]"; - log.info( msg, ne ); - throw new CacheException( msg ); - } - finally { - if ( ctx != null ) { - try { - ctx.close(); - } - catch( NamingException ne ) { - log.info( "Unable to release initial context", ne ); - } - } - } - } - -} diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/MultiplexingCacheInstanceManager.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/MultiplexingCacheInstanceManager.java deleted file mode 100644 index c85c7ecc8f..0000000000 --- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/MultiplexingCacheInstanceManager.java +++ /dev/null @@ -1,555 +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.jbc.builder; - -import java.util.Properties; -import javax.transaction.TransactionManager; - -import org.jboss.cache.Cache; -import org.jboss.cache.CacheManager; -import org.jboss.cache.CacheManagerImpl; -import org.jboss.cache.CacheStatus; -import org.jboss.cache.config.Configuration; -import org.jgroups.ChannelFactory; -import org.jgroups.JChannelFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.hibernate.cache.CacheException; -import org.hibernate.cache.jbc.CacheInstanceManager; -import org.hibernate.cache.jbc.util.CacheHelper; -import org.hibernate.cfg.Settings; -import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.transaction.TransactionManagerLookup; - -/** - * Allows building separate {@link Cache} instances for each type of region, - * with the expectation that a single multiplexed JGroups resource (i.e. a - * multiplexed channel or a shared transport channel) will be shared between - * the caches.
- * - * @author Steve Ebersole - * @author Brian Stansberry - */ -public class MultiplexingCacheInstanceManager implements CacheInstanceManager { - - private static final Logger log = LoggerFactory.getLogger(MultiplexingCacheInstanceManager.class); - - /** - * Classpath or filesystem resource containing JBoss Cache - * configurations the factory should use. - * - * @see #DEF_CACHE_FACTORY_RESOURCE - */ - public static final String CACHE_FACTORY_RESOURCE_PROP = "hibernate.cache.jbc.configs"; - /** - * Legacy name for configuration property {@link #CACHE_FACTORY_RESOURCE_PROP}. - * - * @see #DEF_CACHE_FACTORY_RESOURCE - */ - public static final String LEGACY_CACHE_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.configs"; - /** - * Classpath or filesystem resource containing JGroups protocol - * stack configurations theorg.jgroups.ChannelFactory
- * should use.
- *
- * @see #DEF_JGROUPS_RESOURCE
- */
- public static final String CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.jbc.jgroups.stacks";
- /**
- * Legacy name for configuration property {@link #CHANNEL_FACTORY_RESOURCE_PROP}.
- *
- * @see #DEF_JGROUPS_RESOURCE
- */
- public static final String LEGACY_CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.jgroups.stacks";
-
- /**
- * Name of the configuration that should be used for entity caches.
- *
- * @see #DEF_ENTITY_RESOURCE
- */
- public static final String ENTITY_CACHE_RESOURCE_PROP = "hibernate.cache.jbc.cfg.entity";
- /**
- * Legacy name for configuration property {@link #ENTITY_CACHE_RESOURCE_PROP}.
- *
- * @see #DEF_ENTITY_RESOURCE
- */
- public static final String LEGACY_ENTITY_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.entity";
- /**
- * Name of the configuration that should be used for collection caches.
- * No default value, as by default we try to use the same JBoss Cache
- * instance we use for entity caching.
- *
- * @see #ENTITY_CACHE_RESOURCE_PROP
- * @see #DEF_ENTITY_RESOURCE
- */
- public static final String COLLECTION_CACHE_RESOURCE_PROP = "hibernate.cache.jbc.cfg.collection";
- /**
- * Legacy name for configuration property {@link #COLLECTION_CACHE_RESOURCE_PROP}.
- *
- * @see #ENTITY_CACHE_RESOURCE_PROP
- * @see #DEF_ENTITY_RESOURCE
- */
- public static final String LEGACY_COLLECTION_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.collection";
- /**
- * Name of the configuration that should be used for timestamp caches.
- *
- * @see #DEF_TS_RESOURCE
- */
- public static final String TIMESTAMP_CACHE_RESOURCE_PROP = "hibernate.cache.jbc.cfg.timestamps";
- /**
- * Legacy name for configuration property {@link #TIMESTAMP_CACHE_RESOURCE_PROP}.
- *
- * @see #DEF_TS_RESOURCE
- */
- public static final String LEGACY_TIMESTAMP_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.ts";
- /**
- * Name of the configuration that should be used for query caches.
- *
- * @see #DEF_QUERY_RESOURCE
- */
- public static final String QUERY_CACHE_RESOURCE_PROP = "hibernate.cache.jbc.cfg.query";
-
- /**
- * Legacy name for configuration property {@link #QUERY_CACHE_RESOURCE_PROP}.
- *
- * @see #DEF_QUERY_RESOURCE
- */
- public static final String LEGACY_QUERY_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.query";
-
- /**
- * Default value for {@link #CACHE_FACTORY_RESOURCE_PROP}. Specifies
- * the "jbc2-configs.xml" file in this package.
- */
- public static final String DEF_CACHE_FACTORY_RESOURCE = "org/hibernate/cache/jbc/builder/jbc-configs.xml";
- /**
- * Default value for {@link #CHANNEL_FACTORY_RESOURCE_PROP}. Specifies
- * the "jgroups-stacks.xml" file in this package.
- */
- public static final String DEF_JGROUPS_RESOURCE = "org/hibernate/cache/jbc/builder/jgroups-stacks.xml";
- /**
- * Default value for {@link #ENTITY_CACHE_RESOURCE_PROP}.
- */
- public static final String DEF_ENTITY_RESOURCE = "optimistic-entity";
- /**
- * Default value for {@link #TIMESTAMP_CACHE_RESOURCE_PROP}.
- */
- public static final String DEF_TS_RESOURCE = "timestamps-cache";
- /**
- * Default value for {@link #ENTITY_CACHE_RESOURCE_PROP}.
- */
- public static final String DEF_QUERY_RESOURCE = "local-query";
-
- /** Cache for entities */
- private Cache jbcEntityCache;
- /** Cache for collections */
- private Cache jbcCollectionCache;
- /** Cache for timestamps */
- private Cache jbcTsCache;
- /** Cache for queries */
- private Cache jbcQueryCache;
- /** Name of config used for entities. */
- private String entityConfig = null;
- /** Name of config used for collections. */
- private String collectionConfig = null;
- /** Name of config used for queries. */
- private String queryConfig = null;
- /** Name of config used for timestamps. */
- private String tsConfig = null;
-
- /** Our cache factory */
- private CacheManager jbcFactory;
- /** Our channel factory */
- private ChannelFactory channelFactory;
- /**
- * Did we create the factory ourself and thus can assume we are not
- * sharing it (and the caches) with other users?
- */
- private boolean selfCreatedFactory;
-
- /**
- * Create a new MultiplexingCacheInstanceManager.
- */
- public MultiplexingCacheInstanceManager() {
- }
-
- /**
- * Create a new MultiplexingCacheInstanceManager using the provided {@link Cache}s.
- *
- * If this constructor is used, the {@link #start(Settings, Properties)}
- * method will make no attempt to create a cache factory or obtain caches
- * from it. Only the Cache
s passed as arguments to this
- * constructor will be available.
- *
- * @param jbcEntityCache The entity cache
- * @param jbcCollectionCache the collection cache
- * @param jbcTsCache The timestamps cache
- * @param jbcQueryCache The query cache
- */
- public MultiplexingCacheInstanceManager(
- Cache jbcEntityCache,
- Cache jbcCollectionCache,
- Cache jbcTsCache,
- Cache jbcQueryCache) {
- this.jbcEntityCache = jbcEntityCache;
- this.jbcCollectionCache = jbcCollectionCache;
- this.jbcTsCache = jbcTsCache;
- this.jbcQueryCache = jbcQueryCache;
- }
-
- /**
- * Getter for property 'cacheFactory'.
- * @see #setCacheFactory
- *
- * @return Value for property 'cacheFactory'.
- */
- public CacheManager getCacheFactory() {
- return jbcFactory;
- }
-
- /**
- * Setter for property 'cacheFactory'.
- * @see #getCacheFactory
- *
- * @param factory Value to set for property 'cacheFactory'.
- */
- public void setCacheFactory(CacheManager factory) {
- this.jbcFactory = factory;
- }
-
- /**
- * Getter for property 'channelFactory'.
- * @see #setChannelFactory
- *
- * @return Value for property 'channelFactory'.
- */
- public ChannelFactory getChannelFactory() {
- return channelFactory;
- }
-
- /**
- * Setter for property 'channelFactory'.
- * @see #getChannelFactory
- *
- * @param factory Value to set for property 'channelFactory'.
- */
- public void setChannelFactory(ChannelFactory factory) {
- this.channelFactory = factory;
- }
-
- /**
- * {@inheritDoc}
- */
- public Cache getEntityCacheInstance() {
- return jbcEntityCache;
- }
-
- /**
- * {@inheritDoc}
- */
- public Cache getCollectionCacheInstance() {
- return jbcCollectionCache;
- }
-
- /**
- * {@inheritDoc}
- */
- public Cache getQueryCacheInstance() {
-
- if (jbcQueryCache != null && jbcTsCache == null) {
- // This should only be possible if the caches are constructor injected
- throw new CacheException("Timestamps cache must be configured if a query cache is used");
- }
-
- return jbcQueryCache;
- }
-
- /**
- * {@inheritDoc}
- */
- public Cache getTimestampsCacheInstance() {
-
- if (jbcTsCache != null && CacheHelper.isClusteredInvalidation(jbcTsCache)) {
- throw new CacheException("Clustered invalidation not supported for timestamps cache");
- }
- return jbcTsCache;
- }
-
- /**
- * {@inheritDoc}
- */
- public void start(Settings settings, Properties properties) throws CacheException {
- try {
- // We need our tm, so get it now and avoid doing other work
- // if there is a problem
- TransactionManagerLookup tml = settings.getTransactionManagerLookup();
- TransactionManager tm = (tml == null ? null : tml.getTransactionManager(properties));
-
- // We only build caches if *none* were passed in. Passing in
- // caches counts as a clear statement of exactly what is wanted
- boolean buildCaches = jbcEntityCache == null
- && jbcCollectionCache == null
- && jbcTsCache == null
- && jbcQueryCache == null;
-
- // Set up the cache factory
- if (buildCaches && jbcFactory == null) {
- // See if the user configured a multiplexer stack
- if (channelFactory == null) {
- String muxStacks = ConfigurationHelper.getString(CHANNEL_FACTORY_RESOURCE_PROP, properties, null);
- if (muxStacks == null) {
- muxStacks = ConfigurationHelper.getString(LEGACY_CHANNEL_FACTORY_RESOURCE_PROP, properties, DEF_JGROUPS_RESOURCE);
- }
- if (muxStacks != null) {
- channelFactory = new JChannelFactory();
- channelFactory.setMultiplexerConfig(muxStacks);
- }
- }
-
- String factoryRes = ConfigurationHelper.getString(CACHE_FACTORY_RESOURCE_PROP, properties, null);
- if (factoryRes == null) {
- factoryRes = ConfigurationHelper.getString(LEGACY_CACHE_FACTORY_RESOURCE_PROP, properties, DEF_CACHE_FACTORY_RESOURCE);
- }
- jbcFactory = new CacheManagerImpl(factoryRes, channelFactory);
- ((CacheManagerImpl) jbcFactory).start();
- selfCreatedFactory = true;
- }
-
- if (settings.isSecondLevelCacheEnabled()) {
-
- if (buildCaches) {
- entityConfig = ConfigurationHelper
- .getString(ENTITY_CACHE_RESOURCE_PROP, properties, null);
- if (entityConfig == null) {
- entityConfig = ConfigurationHelper.getString(LEGACY_ENTITY_CACHE_RESOURCE_PROP,
- properties, DEF_ENTITY_RESOURCE);
- }
- jbcEntityCache = jbcFactory.getCache(entityConfig, true);
-
- // Default to collections sharing entity cache if there is one
- collectionConfig = ConfigurationHelper.getString(COLLECTION_CACHE_RESOURCE_PROP, properties, null);
- if (collectionConfig == null) {
- collectionConfig = ConfigurationHelper.getString(LEGACY_COLLECTION_CACHE_RESOURCE_PROP, properties, entityConfig);
- }
- if (entityConfig.equals(collectionConfig)) {
- jbcCollectionCache = jbcEntityCache;
- }
- else {
- jbcCollectionCache = jbcFactory.getCache(collectionConfig, true);
- }
- }
-
- if (jbcEntityCache != null) {
- configureTransactionManager(jbcEntityCache, tm, false);
- jbcEntityCache.start();
- }
- if (jbcCollectionCache != null) {
- configureTransactionManager(jbcCollectionCache, tm, false);
- jbcCollectionCache.start();
- }
-
- }
- else {
- jbcEntityCache = null;
- jbcCollectionCache = null;
- }
-
- if (settings.isQueryCacheEnabled()) {
-
- if (buildCaches) {
- // Default to sharing the entity cache if there is one
- String dfltQueryResource = (entityConfig == null ? DEF_QUERY_RESOURCE : entityConfig);
- queryConfig = ConfigurationHelper.getString(QUERY_CACHE_RESOURCE_PROP, properties, null);
- if (queryConfig == null) {
- queryConfig = ConfigurationHelper.getString(LEGACY_QUERY_CACHE_RESOURCE_PROP, properties, dfltQueryResource);
- }
- if (queryConfig.equals(entityConfig)) {
- jbcQueryCache = jbcEntityCache;
- } else if (queryConfig.equals(collectionConfig)) {
- jbcQueryCache = jbcCollectionCache;
- } else {
- jbcQueryCache = jbcFactory.getCache(queryConfig, true);
- }
-
- // For Timestamps, we default to a separate config
- tsConfig = ConfigurationHelper.getString(TIMESTAMP_CACHE_RESOURCE_PROP, properties, null);
- if (tsConfig == null) {
- tsConfig = ConfigurationHelper.getString(LEGACY_TIMESTAMP_CACHE_RESOURCE_PROP, properties, DEF_TS_RESOURCE);
- }
- if (tsConfig.equals(queryConfig)) {
- jbcTsCache = jbcQueryCache;
- }
- else if (tsConfig.equals(entityConfig)) {
- jbcTsCache = jbcEntityCache;
- }
- else if (tsConfig.equals(collectionConfig)) {
- jbcTsCache = jbcCollectionCache;
- }
- else {
- jbcTsCache = jbcFactory.getCache(tsConfig, true);
- }
- }
-
- if (jbcQueryCache != null) {
- configureTransactionManager(jbcQueryCache, tm, false);
- jbcQueryCache.start();
- // TODO: I considered validating the presence of the TS cache here,
- // but decided to defer unti getQueryCacheInstance() in case the
- // cache is never actually used
- }
- if (jbcTsCache != null) {
- configureTransactionManager(jbcTsCache, tm, true);
- jbcTsCache.start();
- // TODO: I considered validating TS cache config here,
- // but decided to defer unti getTimestampsCacheInstance() in case the
- // cache is never actually used
- }
- }
- else {
- jbcTsCache = null;
- jbcQueryCache = null;
- }
- }
- catch (CacheException ce) {
- throw ce;
- }
- catch (Throwable t) {
- throw new CacheException("Unable to start region factory", t);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void stop() {
- releaseCaches();
- if (selfCreatedFactory) {
- ((CacheManagerImpl) jbcFactory).stop();
- }
- }
-
- /**
- * Injects the given TransactionManager into the cache.
- *
- * @param cache the cache. cannot be null
- * @param tm the transaction manager Hibernate recognizes
- * May be null
- * @param allowNull whether we accept a null transaction manager in the cache
- * if tm
is not null
- *
- * @throws CacheException if cache
is already started and is
- * configured with a different TransactionManager
- * than the one we would inject
- */
- private void configureTransactionManager(Cache cache, TransactionManager tm, boolean allowNull) {
- Configuration cacheConfig = cache.getConfiguration();
- TransactionManager cacheTm = cacheConfig.getRuntimeConfig().getTransactionManager();
- if (!safeEquals(tm, cacheTm)) {
- if (cache.getCacheStatus() != CacheStatus.INSTANTIATED) {
- // We can't change the TM on a running cache; just check
- // if the cache has no TM and we're OK with that
- if (!allowNull && cacheTm == null) {
- throw new CacheException("JBoss Cache is already started with no transaction manager configured");
- } else {
- log.debug("JBoss Cache is already started with a transaction manager ("
- + cacheTm + ") that is not equal to our own (" + tm + ")");
- }
- } else {
- // Configure the cache to use our TM
- cacheConfig.getRuntimeConfig().setTransactionManager(tm);
- if (tm == null) {
- // Make sure JBC doesn't look one up
- cacheConfig.setTransactionManagerLookupClass(null);
- }
- }
- }
- }
-
- /**
- * Notify cache factory that we are no longer using the caches.
- */
- private void releaseCaches() {
-
- // This method should be implemented assuming it's valid to
- // do start/stop/start -- leave state appropriate for another start
-
- if (jbcEntityCache != null && entityConfig != null) {
- try {
- jbcFactory.releaseCache(entityConfig);
- jbcEntityCache = null;
-
- // Make sure we don't re-release the same cache
- if (entityConfig.equals(collectionConfig))
- collectionConfig = null;
- if (entityConfig.equals(queryConfig))
- queryConfig = null;
- if (entityConfig.equals(tsConfig))
- tsConfig = null;
- entityConfig = null;
- } catch (Throwable t) {
- log.info("Unable to release entity cache instance", t);
- }
- }
- if (jbcCollectionCache != null && collectionConfig != null) {
- try {
- jbcFactory.releaseCache(collectionConfig);
- jbcCollectionCache = null;
-
- if (collectionConfig.equals(queryConfig))
- queryConfig = null;
- if (collectionConfig.equals(tsConfig))
- tsConfig = null;
- collectionConfig = null;
- } catch (Throwable t) {
- log.info("Unable to stop collection cache instance", t);
- }
- }
- if (jbcQueryCache != null && queryConfig != null) {
- try {
- jbcFactory.releaseCache(queryConfig);
- jbcQueryCache = null;
-
- if (queryConfig.equals(tsConfig))
- tsConfig = null;
- queryConfig = null;
- } catch (Throwable t) {
- log.info("Unable to stop query cache instance", t);
- }
- }
- if (jbcTsCache != null && tsConfig != null) {
- try {
- jbcFactory.releaseCache(tsConfig);
- jbcTsCache = null;
-
- tsConfig = null;
- } catch (Throwable t) {
- log.info("Unable to stop timestamp cache instance", t);
- }
- }
- }
-
- private boolean safeEquals(Object a, Object b) {
- return (a == b || (a != null && a.equals(b)));
- }
-}
diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/SharedCacheInstanceManager.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/SharedCacheInstanceManager.java
deleted file mode 100644
index 6f1deade6a..0000000000
--- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/builder/SharedCacheInstanceManager.java
+++ /dev/null
@@ -1,274 +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.jbc.builder;
-
-import java.util.Properties;
-import javax.transaction.TransactionManager;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheStatus;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.config.Configuration;
-import org.jgroups.ChannelFactory;
-import org.jgroups.JChannelFactory;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.jbc.CacheInstanceManager;
-import org.hibernate.cache.jbc.util.CacheHelper;
-import org.hibernate.cfg.Settings;
-import org.hibernate.internal.util.config.ConfigurationHelper;
-
-/**
- * A {@link CacheInstanceManager} implementation where we use a single JBoss Cache
- * instance for each type of region. If operating on a cluster, the cache must
- * be configured for REPL_SYNC if query caching is enabled. If query caching
- * is not used, REPL_SYNC or INVALIDATION_SYNC are valid, with
- * INVALIDATION_SYNC preferred.
- *
- * @author Steve Ebersole
- * @author Brian Stansberry
- */
-public class SharedCacheInstanceManager implements CacheInstanceManager {
-
- private static final Logger log = LoggerFactory.getLogger(SharedCacheInstanceManager.class);
-
- /**
- * Classpath or filesystem resource containing JBoss Cache
- * configuration settings the {@link Cache} should use.
- *
- * @see #DEFAULT_CACHE_RESOURCE
- */
- public static final String CACHE_RESOURCE_PROP = "hibernate.cache.jbc.cfg.shared";
-
- /**
- * Legacy name for configuration property {@link #CACHE_RESOURCE_PROP}.
- *
- * @see #DEFAULT_CACHE_RESOURCE
- */
- public static final String LEGACY_CACHE_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.shared";
-
- /**
- * Default name for the JBoss Cache configuration file.
- */
- public static final String DEFAULT_CACHE_RESOURCE = "treecache.xml";
- /**
- * Classpath or filesystem resource containing JGroups protocol
- * stack configurations the org.jgroups.ChannelFactory
- * should use.
- *
- * @see #DEF_JGROUPS_RESOURCE
- */
- public static final String CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.jbc.cfg.jgroups.stacks";
- /**
- * Legacy name for configuration property {@link #CHANNEL_FACTORY_RESOURCE_PROP}.
- *
- * @see #DEF_JGROUPS_RESOURCE
- */
- public static final String LEGACY_CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.jgroups.stacks";
- /**
- * Default value for {@link #CHANNEL_FACTORY_RESOURCE_PROP}. Specifies
- * the "jgroups-stacks.xml" file in this package.
- */
- public static final String DEF_JGROUPS_RESOURCE = "org/hibernate/cache/jbc/builder/jgroups-stacks.xml";
-
- private Cache cache;
- private ChannelFactory channelFactory;
- private boolean use2ndLevel;
- private boolean useQuery;
-
- public SharedCacheInstanceManager() {
- }
-
- public SharedCacheInstanceManager(ChannelFactory channelFactory) {
- this.channelFactory = channelFactory;
- }
-
- public SharedCacheInstanceManager(Cache cache) {
- this.cache = cache;
- }
-
- /**
- * {@inheritDoc}
- */
- public Cache getEntityCacheInstance() {
- return use2ndLevel ? cache : null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Cache getCollectionCacheInstance() {
- return use2ndLevel ? cache : null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Cache getQueryCacheInstance() {
-
- if (!useQuery)
- return null;
-
- if (CacheHelper.isClusteredInvalidation(cache)) {
- throw new CacheException("Query cache not supported for clustered invalidation");
- }
- return cache;
- }
-
- /**
- * {@inheritDoc}
- */
- public void start(Settings settings, Properties properties) throws CacheException {
-
- use2ndLevel = settings.isSecondLevelCacheEnabled();
- useQuery = settings.isQueryCacheEnabled();
-
- if (cache == null) {
-
- if (channelFactory == null) {
- String muxStacks = ConfigurationHelper.getString(CHANNEL_FACTORY_RESOURCE_PROP, properties, null);
- if (muxStacks == null) {
- ConfigurationHelper.getString(LEGACY_CHANNEL_FACTORY_RESOURCE_PROP, properties, DEF_JGROUPS_RESOURCE);
- }
- if (muxStacks != null) {
- channelFactory = new JChannelFactory();
- try {
- channelFactory.setMultiplexerConfig(muxStacks);
- }
- catch (Exception e) {
- throw new CacheException("Problem setting ChannelFactory config", e);
- }
- }
- }
- cache = createSharedCache(settings, properties);
- configureTransactionManager(cache, settings, properties);
- if (cache.getConfiguration().getMultiplexerStack() != null
- && cache.getConfiguration().getRuntimeConfig().getMuxChannelFactory() == null) {
- cache.getConfiguration().getRuntimeConfig().setMuxChannelFactory(channelFactory);
- }
- }
- cache.start();
- }
-
- /**
- * {@inheritDoc}
- */
- public Cache getTimestampsCacheInstance() {
-
- if (!useQuery)
- return null;
-
- if (CacheHelper.isClusteredInvalidation(cache)) {
- throw new CacheException("Query cache not supported for clustered invalidation");
- }
- return cache;
- }
-
- /**
- * {@inheritDoc}
- */
- public void stop() {
- if (cache != null) {
- stopSharedCache(cache);
- }
- }
-
- /**
- * Create a cache using the given settings and properties.
- *
- * @param settings The Hibernate settings
- * @param properties The configuration properties
- * @return The created cache
- */
- protected Cache createSharedCache(Settings settings, Properties properties)
- {
- String configResource = ConfigurationHelper.getString(CACHE_RESOURCE_PROP, properties, null);
- if (configResource == null) {
- configResource = ConfigurationHelper.getString(LEGACY_CACHE_RESOURCE_PROP, properties, DEFAULT_CACHE_RESOURCE);
- }
- return new DefaultCacheFactory().createCache(configResource, false);
- }
-
- /**
- * Injects the TransactionManager found via {@link Settings#getTransactionManagerLookup()}
- * into the cache.
- *
- * @param cache The cache instance
- * @param settings The Hibernate settings
- * @param properties The configuration properties
- *
- * @throws CacheException if cache
is already started and is
- * configured with a different TransactionManager
- * than the one we would inject
- */
- protected void configureTransactionManager(Cache cache, Settings settings, Properties properties) {
-
- TransactionManager tm = null;
- if (settings.getTransactionManagerLookup() != null) {
- tm = settings.getTransactionManagerLookup().getTransactionManager(properties);
- }
-
- Configuration cacheConfig = cache.getConfiguration();
- TransactionManager cacheTm = cacheConfig.getRuntimeConfig().getTransactionManager();
-
- if (!safeEquals(tm, cacheTm)) {
- if (cache.getCacheStatus() != CacheStatus.INSTANTIATED
- && cache.getCacheStatus() != CacheStatus.DESTROYED) {
- log.debug("JBoss Cache is already started with a transaction manager ("
- + cacheTm + ") that is not equal to our own (" + tm + ")");
- } else {
- // Configure the cache to use our TM
- cacheConfig.getRuntimeConfig().setTransactionManager(tm);
- if (tm == null) {
- // Make sure JBC doesn't look one up
- cacheConfig.setTransactionManagerLookupClass(null);
- }
- }
- }
- }
-
- private boolean safeEquals(Object a, Object b) {
- return (a == b || (a != null && a.equals(b)));
- }
-
- /**
- * Stops the shared cache.
- * @param cache the shared cache
- */
- protected void stopSharedCache(Cache cache) {
- try {
- if (cache.getCacheStatus() == CacheStatus.STARTED) {
- cache.stop();
- }
- if (cache.getCacheStatus() != CacheStatus.DESTROYED
- && cache.getCacheStatus() != CacheStatus.INSTANTIATED) {
- cache.destroy();
- }
- } catch (Throwable t) {
- log.warn("Unable to stop cache instance", t);
- }
- }
-}
diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/collection/CollectionRegionImpl.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/collection/CollectionRegionImpl.java
deleted file mode 100644
index ed751350ed..0000000000
--- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/collection/CollectionRegionImpl.java
+++ /dev/null
@@ -1,76 +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.jbc.collection;
-
-import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.notifications.annotation.CacheListener;
-
-import org.hibernate.cache.CacheDataDescription;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CollectionRegion;
-import org.hibernate.cache.access.AccessType;
-import org.hibernate.cache.access.CollectionRegionAccessStrategy;
-import org.hibernate.cache.jbc.TransactionalDataRegionAdapter;
-import org.hibernate.cache.jbc.access.PutFromLoadValidator;
-
-/**
- * Defines the behavior of the collection cache regions for JBossCache 2.x.
- *
- * @author Steve Ebersole
- */
-@CacheListener
-public class CollectionRegionImpl extends TransactionalDataRegionAdapter implements CollectionRegion {
-
- public static final String TYPE = "COLL";
- private boolean optimistic;
-
- public CollectionRegionImpl(Cache jbcCache, String regionName, String regionPrefix, CacheDataDescription metadata) {
- super(jbcCache, regionName, regionPrefix, metadata);
- optimistic = (jbcCache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC);
- }
-
- public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
- if (AccessType.READ_ONLY.equals(accessType)) {
- return optimistic ? new OptimisticReadOnlyAccess(this) : new ReadOnlyAccess(this);
- }
- if (AccessType.TRANSACTIONAL.equals(accessType)) {
- return optimistic ? new OptimisticTransactionalAccess(this) : new TransactionalAccess(this);
- }
-
- // todo : add support for READ_WRITE ( + NONSTRICT_READ_WRITE ??? )
-
- throw new CacheException("unsupported access type [" + accessType.getName() + "]");
- }
-
- @Override
- protected Fqn- * Maintains a local (authoritative) cache of timestamps along with the - * distributed cache held in JBoss Cache. Listens for changes in the distributed - * cache and updates the local cache accordingly. Ensures that any changes in - * the local cache represent either 1) an increase in the timestamp or - * 2) a stepback in the timestamp by the caller that initially increased - * it as part of a pre-invalidate call. This approach allows - * timestamp changes to be replicated asynchronously by JBoss Cache while still - * preventing invalid backward changes in timestamps. - *
- * - * NOTE: This is just a prototype!!! Only useful if we change the - * TimestampsRegion API. - * - * @author Brian Stansberry - * @version $Revision: 14106 $ - */ -@CacheListener -public class ClusteredConcurrentTimestampsRegionImpl extends TransactionalDataRegionAdapter implements TimestampsRegion { - - public static final String TYPE = "TS"; - - private final ConcurrentHashMap localCache = new ConcurrentHashMap(); - - /** - * Create a new ClusteredConccurentTimestampsRegionImpl. - * - * @param jbcCache - * @param regionName - * @param regionPrefix - * TODO - * @param metadata - */ - public ClusteredConcurrentTimestampsRegionImpl(Cache jbcCache, String regionName, String regionPrefix, Properties properties) { - super(jbcCache, regionName, regionPrefix, null); - - jbcCache.addCacheListener(this); - - populateLocalCache(); - } - - @Override - protected Fqnregion
and key
- * and performs a JBoss Cache get(Fqn, Object)
, wrapping any
- * exception in a {@link CacheException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- * @param key
- * specific key to append to the region
to form
- * the full Fqn
- */
- public static Object get(Cache cache, Fqn region, Object key) throws CacheException {
- try {
- return cache.get(new Fqn(region, key), ITEM);
- } catch (Exception e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Builds an {@link Fqn} from region
and key
- * and performs a JBoss Cache get(Fqn, Object)
, wrapping any
- * exception in a {@link CacheException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- * @param key
- * specific key to append to the region
to form
- * the full Fqn
- */
- public static Object getAllowingTimeout(Cache cache, Fqn region, Object key) throws CacheException {
- try {
- return cache.get(new Fqn(region, key), ITEM);
- }
- catch (TimeoutException ignored) {
- // ignore it
- return null;
- }
- catch (Exception e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Builds an {@link Fqn} from region
and key
- * and performs a JBoss Cache put(Object, Object)
, wrapping
- * any exception in a {@link CacheException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- * @param key
- * specific key to append to the region
to form
- * the full Fqn
- * @param value
- * data to store in the cache node
- */
- public static void put(Cache cache, Fqn region, Object key, Object value) throws CacheException {
-
- put(cache, region, key, value, null);
- }
-
- /**
- * Builds an {@link Fqn} from region
and key
- * and performs a JBoss Cache put(Object, Object)
, wrapping
- * any exception in a {@link CacheException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- * @param key
- * specific key to append to the region
to form
- * the full Fqn
- * @param value
- * data to store in the cache node
- * @param option
- * invocation Option to set for this invocation. May be
- * null
.
- */
- public static void put(Cache cache, Fqn region, Object key, Object value, Option option) throws CacheException {
- try {
- setInvocationOption(cache, option);
- cache.put(new Fqn(region, key), ITEM, value);
- } catch (Exception e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Builds an {@link Fqn} from region
and key
- * and performs a JBoss Cache put(Object, Object)
, ignoring any
- * {@link TimeoutException} and wrapping any other exception in a {@link CacheException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- * @param key
- * specific key to append to the region
to form
- * the full Fqn
- * @param value
- * data to store in the cache node
- * @param option
- * invocation Option to set for this invocation. May be
- * null
.
- */
- public static void putAllowingTimeout(Cache cache, Fqn region, Object key, Object value, Option option) throws CacheException {
- try {
- setInvocationOption(cache, option);
- cache.put(new Fqn(region, key), ITEM, value);
- }
- catch (TimeoutException allowed) {
- // ignore it
- }
- catch (Exception e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Builds an {@link Fqn} from region
and key
- * and performs a JBoss Cache
- * putForExternalRead(Object, Object)
, wrapping any
- * exception in a {@link CacheException}. Ignores any JBoss Cache
- * {@link TimeoutException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- * @param key
- * specific key to append to the region
to form
- * the full Fqn
- * @param value
- * data to store in the cache node
- */
- public static boolean putForExternalRead(Cache cache, Fqn region, Object key, Object value) throws CacheException {
-
- return putForExternalRead(cache, region, key, value, null);
- }
-
- /**
- * Builds an {@link Fqn} from region
and key
- * and performs a JBoss Cache
- * putForExternalRead(Object, Object)
, wrapping any
- * exception in a {@link CacheException}. Ignores any JBoss Cache
- * {@link TimeoutException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- * @param key
- * specific key to append to the region
to form
- * the full Fqn
- * @param value
- * data to store in the cache node
- * @param option
- * invocation Option to set for this invocation. May be
- * null
.
- */
- public static boolean putForExternalRead(Cache cache, Fqn region, Object key, Object value, Option option)
- throws CacheException {
- try {
- setInvocationOption(cache, option);
- cache.putForExternalRead(new Fqn(region, key), ITEM, value);
- return true;
- } catch (TimeoutException te) {
- // ignore!
- log.debug("ignoring write lock acquisition failure");
- return false;
- } catch (Throwable t) {
- throw new CacheException(t);
- }
- }
-
- /**
- * Builds an {@link Fqn} from region
and key
- * and performs a JBoss Cache removeNode(Fqn)
, wrapping any
- * exception in a {@link CacheException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- * @param key
- * specific key to append to the region
to form
- * the full Fqn
- */
- public static void remove(Cache cache, Fqn region, Object key) throws CacheException {
-
- remove(cache, region, key, null);
- }
-
- /**
- * Builds an {@link Fqn} from region
and key
- * and performs a JBoss Cache removeNode(Fqn)
, wrapping any
- * exception in a {@link CacheException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- * @param key
- * specific key to append to the region
to form
- * the full Fqn
- * @param option
- * invocation Option to set for this invocation. May be
- * null
.
- */
- public static void remove(Cache cache, Fqn region, Object key, Option option) throws CacheException {
- try {
- setInvocationOption(cache, option);
- cache.removeNode(new Fqn(region, key));
- } catch (Exception e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Performs a JBoss Cache removeNode(Fqn)
, wrapping any
- * exception in a {@link CacheException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- */
- public static void removeAll(Cache cache, Fqn region) throws CacheException {
-
- removeAll(cache, region, null);
- }
-
- /**
- * Performs a JBoss Cache removeNode(Fqn)
, wrapping any
- * exception in a {@link CacheException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- * @param option
- * invocation Option to set for this invocation. May be
- * null
.
- */
- public static void removeAll(Cache cache, Fqn region, Option option) throws CacheException {
- try {
- setInvocationOption(cache, option);
- cache.removeNode(region);
- } catch (Exception e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Performs a JBoss Cache removeNode(Fqn)
, wrapping any
- * exception in a {@link CacheException}.
- *
- * @param cache
- * the cache to invoke on
- * @param region
- * base Fqn for the cache region
- * @param option
- * invocation Option to set for this invocation. May be
- * null
.
- */
- public static void removeNode(Cache cache, Fqn region, Object key, Option option) throws CacheException {
- try {
- setInvocationOption(cache, option);
- cache.removeNode(new Fqn(region, key));
- } catch (Exception e) {
- throw new CacheException(e);
- }
- }
-
- public static Node addNode(Cache cache, Fqn fqn, boolean localOnly, boolean resident, DataVersion version)
- throws CacheException {
- try {
- Option option = null;
- if (localOnly || version != null) {
- option = new Option();
- option.setCacheModeLocal(localOnly);
- option.setDataVersion(version);
- }
-
- Node root = cache.getRoot();
- setInvocationOption(cache, option);
- // FIXME hack to work around fact that calling
- // Node added = root.addChild( fqn ); doesn't
- // properly set the version on the node
- Node added = null;
- if (version == null) {
- added = root.addChild( fqn );
- }
- else {
- cache.put(fqn, DUMMY, DUMMY);
- added = root.getChild(fqn);
- }
- if (resident)
- added.setResident(true);
- return added;
- }
- catch (Exception e) {
- throw new CacheException(e);
- }
- }
-
-
- /**
- * Assigns the given Option to the cache's {@link InvocationContext}. Does
- * nothing if option
is null
.
- *
- * @param cache
- * the cache. Cannot be null
.
- * @param option
- * the option. May be null
.
- *
- * @see {@link Cache#getInvocationContext()}
- * @see {@link InvocationContext#setOptionOverrides(Option)}
- */
- public static void setInvocationOption(Cache cache, Option option) {
- if (option != null) {
- cache.getInvocationContext().setOptionOverrides(option);
- }
- }
-
- /**
- * Creates an {@link Option} using the given {@link DataVersion} and passes
- * it to {@link #setInvocationOption(Cache, Option)}.
- *
- * @param cache
- * the cache to set the Option on. Cannot be null
.
- * @param version
- * the DataVersion to set. Cannot be null
.
- */
- public static void setDataVersionOption(Cache cache, DataVersion version) {
- Option option = new Option();
- option.setDataVersion(version);
- setInvocationOption(cache, option);
- }
-
- public static Fqn getInternalFqn(Fqn region)
- {
- return Fqn.fromRelativeElements(region, Internal.NODE);
- }
-
- public static void sendEvictNotification(Cache cache, Fqn region, Object member, Object key, Option option)
- {
- setInvocationOption(cache, option);
- Fqn f = Fqn.fromRelativeElements(region, Internal.NODE, member == null ? Internal.LOCAL : member, key);
- cache.put(f, ITEM, DUMMY);
- }
-
- public static void sendEvictAllNotification(Cache cache, Fqn region, Object member, Option option)
- {
- setInvocationOption(cache, option);
- Fqn f = Fqn.fromRelativeElements(region, Internal.NODE, member == null ? Internal.LOCAL : member);
- cache.put(f, ITEM, DUMMY);
- }
-}
diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/util/CircumventChecksDataVersion.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/util/CircumventChecksDataVersion.java
deleted file mode 100755
index 81092587e8..0000000000
--- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/util/CircumventChecksDataVersion.java
+++ /dev/null
@@ -1,54 +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.jbc.util;
-
-import org.hibernate.cache.CacheException;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.optimistic.DataVersion;
-
-/**
- * Used to signal to a DataVersionAdapter to simply not perform any checks. This
- * is currently needed for proper handling of remove() calls for entity cache
- * regions (we do not know the version info...).
- *
- * @author Brian Stansberry
- * @version $Revision: 1 $
- */
-public class CircumventChecksDataVersion implements DataVersion {
-
- private static final long serialVersionUID = 7996980646166032369L;
-
- public static final DataVersion INSTANCE = new CircumventChecksDataVersion();
-
- public static Option getInvocationOption() {
- Option option = new Option();
- option.setDataVersion(INSTANCE);
- return option;
- }
-
- public boolean newerThan(DataVersion dataVersion) {
- throw new CacheException("optimistic locking checks should never happen on CircumventChecksDataVersion");
- }
-
-}
diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/util/DataVersionAdapter.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/util/DataVersionAdapter.java
deleted file mode 100755
index a08f25191b..0000000000
--- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/util/DataVersionAdapter.java
+++ /dev/null
@@ -1,166 +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.jbc.util;
-
-import java.io.IOException;
-import java.util.Comparator;
-
-import org.hibernate.cache.jbc.entity.TransactionalAccess;
-import org.hibernate.util.CalendarComparator;
-import org.hibernate.util.ComparableComparator;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.optimistic.DefaultDataVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A DataVersionAdapter.
- *
- * @author Brian Stansberry
- * @version $Revision: 1 $
- */
-public class DataVersionAdapter implements DataVersion {
-
- private static final Logger log = LoggerFactory.getLogger(TransactionalAccess.class);
-
- private static final long serialVersionUID = 5564692336076405571L;
-
- private final Object currentVersion;
-
- private final Object previousVersion;
-
- /**
- * Comparator does not extend Serializable and the std impls don't either,
- * so we make the field transient to allow special handling
- */
- private transient Comparator versionComparator;
-
- private final String sourceIdentifer;
-
- public DataVersionAdapter(Object currentVersion, Object previousVersion, Comparator versionComparator,
- String sourceIdentifer) {
- this.currentVersion = currentVersion;
- this.previousVersion = previousVersion;
- this.versionComparator = versionComparator;
- this.sourceIdentifer = sourceIdentifer;
- log.trace("created " + this);
- }
-
- /**
- * newerThan() call is dispatched against the DataVersion currently
- * associated with the node; the passed dataVersion param is the DataVersion
- * associated with the data we are trying to put into the node. we are
- * expected to return true in the case where we (the current node
- * DataVersion) are newer that then incoming value. Returning true here
- * essentially means that a optimistic lock failure has occured (because
- * conversely, the value we are trying to put into the node is "older than"
- * the value already there...)
- */
- public boolean newerThan(DataVersion dataVersion) {
- log.trace("checking [" + this + "] against [" + dataVersion + "]");
- if (dataVersion instanceof CircumventChecksDataVersion) {
- log.trace("skipping lock checks...");
- return false;
- } else if (dataVersion instanceof NonLockingDataVersion) {
- // can happen because of the multiple ways Cache.remove()
- // can be invoked :(
- log.trace("skipping lock checks...");
- return false;
- } else if (dataVersion instanceof DefaultDataVersion) {
- // JBC put a version in the node when it created as part of
- // some internal operation. We are always newer, but if
- // the JBC version is > 1 something odd has happened
- if (((DefaultDataVersion) dataVersion).getRawVersion() > 1) {
- log.warn("Unexpected comparison to " + dataVersion +
- " -- we are " + toString());
- }
- return true;
- }
-
- DataVersionAdapter other = (DataVersionAdapter) dataVersion;
- if (other.previousVersion == null) {
- log.warn("Unexpected optimistic lock check on inserting data");
- // work around the "feature" where tree cache is validating the
- // inserted node during the next transaction. no idea...
- if (this == dataVersion) {
- log.trace("skipping lock checks due to same DV instance");
- return false;
- }
- }
-
- if (currentVersion == null) {
- // If the workspace node has null as well, OK; if not we've
- // been modified in a non-comparable manner, which we have to
- // treat as us being newer
- return (other.previousVersion != null);
- }
-
- // Can't be newer than itself
- if ( this == dataVersion ) {
- return false;
- }
-
- return versionComparator.compare(currentVersion, other.previousVersion) >= 1;
- }
-
- public String toString() {
- return super.toString() + " [current=" + currentVersion + ", previous=" + previousVersion + ", src="
- + sourceIdentifer + "]";
- }
-
-
- private void writeObject(java.io.ObjectOutputStream out) throws IOException {
- out.defaultWriteObject();
-
- // The standard comparator types are not Serializable but are singletons
- if (versionComparator instanceof ComparableComparator)
- out.writeByte(0);
- else if (versionComparator instanceof CalendarComparator)
- out.writeByte(1);
- else {
- out.writeByte(999);
- out.writeObject(versionComparator);
- }
- }
-
- private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
-
- in.defaultReadObject();
- byte comparatorType = in.readByte();
- switch (comparatorType) {
- case 0:
- versionComparator = ComparableComparator.INSTANCE;
- break;
- case 1:
- versionComparator = CalendarComparator.INSTANCE;
- break;
- default:
- versionComparator = (Comparator) in.readObject();
- }
- }
-
-
-
-}
diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/util/NonLockingDataVersion.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/util/NonLockingDataVersion.java
deleted file mode 100755
index 85519643c2..0000000000
--- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc/util/NonLockingDataVersion.java
+++ /dev/null
@@ -1,65 +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.jbc.util;
-
-import org.hibernate.cache.jbc.entity.TransactionalAccess;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.optimistic.DataVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@link DataVersion} used in regions where no locking should ever occur. This
- * includes query-caches, update-timestamps caches, collection caches, and
- * entity caches where the entity is not versioned.
- *
- * @author Brian Stansberry
- * @version $Revision: 1 $
- */
-public class NonLockingDataVersion implements DataVersion {
-
- private static final Logger log = LoggerFactory.getLogger(TransactionalAccess.class);
-
- private static final long serialVersionUID = 7050722490368630553L;
-
- public static final DataVersion INSTANCE = new NonLockingDataVersion();
-
- public static Option getInvocationOption() {
- Option option = new Option();
- option.setDataVersion(INSTANCE);
- return option;
- }
-
- public boolean newerThan(DataVersion dataVersion) {
-// if (dataVersion instanceof DefaultDataVersion) {
-// log.info("unexpectedly validating against a DefaultDataVersion", new Exception("Just a stack trace"));
-// return true;
-// }
-// else {
- log.trace("non locking lock check...");
- return false;
-// }
- }
-
-}
diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/JBossCacheRegionFactory.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/JBossCacheRegionFactory.java
deleted file mode 100755
index 81212368ad..0000000000
--- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/JBossCacheRegionFactory.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. 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, Inc.
- *
- * 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.jbc2;
-
-import java.util.Properties;
-
-import org.hibernate.cache.jbc.CacheInstanceManager;
-
-/**
- * Deprecated version of superclass maintained solely for forwards
- * compatibility.
- *
- * @deprecated use {@link org.hibernate.cache.jbc.JBossCacheRegionFactory}
- *
- * @author Steve Ebersole
- * @author Brian Stansberry
- */
-@Deprecated
-public class JBossCacheRegionFactory extends org.hibernate.cache.jbc.JBossCacheRegionFactory {
-
- /**
- * FIXME Per the RegionFactory class Javadoc, this constructor version
- * should not be necessary.
- *
- * @param props The configuration properties
- */
- public JBossCacheRegionFactory(Properties props) {
- super(props);
- }
-
- /**
- * Create a new JBossCacheRegionFactory.
- */
- public JBossCacheRegionFactory() {
- super();
- }
-
- /**
- * Create a new JBossCacheRegionFactory that uses the provided
- * {@link CacheInstanceManager}.
- *
- * @param cacheInstanceManager The contract for how we get JBC cache instances.
- */
- public JBossCacheRegionFactory(CacheInstanceManager cacheInstanceManager) {
- super(cacheInstanceManager);
- }
-
-}
diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/JndiMultiplexedJBossCacheRegionFactory.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/JndiMultiplexedJBossCacheRegionFactory.java
deleted file mode 100644
index 42f91f2849..0000000000
--- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/JndiMultiplexedJBossCacheRegionFactory.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. 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, Inc.
- *
- * 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.jbc2;
-
-import java.util.Properties;
-
-/**
- * Deprecated version of superclass maintained solely for forwards
- * compatibility.
- *
- * @deprecated use {@link org.hibernate.cache.jbc.JndiMultiplexedJBossCacheRegionFactory}
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-@Deprecated
-public class JndiMultiplexedJBossCacheRegionFactory extends org.hibernate.cache.jbc.JndiMultiplexedJBossCacheRegionFactory {
-
- /**
- * FIXME Per the RegionFactory class Javadoc, this constructor version
- * should not be necessary.
- *
- * @param props The configuration properties
- */
- public JndiMultiplexedJBossCacheRegionFactory(Properties props) {
- super(props);
- }
-
- /**
- * Create a new MultiplexedJBossCacheRegionFactory.
- *
- */
- public JndiMultiplexedJBossCacheRegionFactory() {
- super();
- }
-
-}
diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/JndiSharedJBossCacheRegionFactory.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/JndiSharedJBossCacheRegionFactory.java
deleted file mode 100644
index 7612ac12ea..0000000000
--- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/JndiSharedJBossCacheRegionFactory.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. 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, Inc.
- *
- * 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.jbc2;
-
-import java.util.Properties;
-
-/**
- * Deprecated version of superclass maintained solely for forwards
- * compatibility.
- *
- * @deprecated use {@link org.hibernate.cache.jbc.JndiSharedJBossCacheRegionFactory}
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-@Deprecated
-public class JndiSharedJBossCacheRegionFactory extends org.hibernate.cache.jbc.JndiSharedJBossCacheRegionFactory {
-
- /**
- * FIXME Per the RegionFactory class Javadoc, this constructor version
- * should not be necessary.
- *
- * @param props The configuration properties
- */
- public JndiSharedJBossCacheRegionFactory(Properties props) {
- super(props);
- }
-
- /**
- * Create a new JndiSharedJBossCacheRegionFactory.
- *
- */
- public JndiSharedJBossCacheRegionFactory() {
- super();
- }
-
-}
diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/MultiplexedJBossCacheRegionFactory.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/MultiplexedJBossCacheRegionFactory.java
deleted file mode 100644
index 2285dbe1e7..0000000000
--- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/MultiplexedJBossCacheRegionFactory.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. 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, Inc.
- *
- * 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.jbc2;
-
-import java.util.Properties;
-
-/**
- * Deprecated version of superclass maintained solely for forwards
- * compatibility.
- *
- * @deprecated use {@link org.hibernate.cache.jbc.MultiplexedJBossCacheRegionFactory}
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class MultiplexedJBossCacheRegionFactory extends org.hibernate.cache.jbc.MultiplexedJBossCacheRegionFactory {
-
- /**
- * FIXME Per the RegionFactory class Javadoc, this constructor version
- * should not be necessary.
- *
- * @param props The configuration properties
- */
- public MultiplexedJBossCacheRegionFactory(Properties props) {
- super(props);
- }
-
- /**
- * Create a new MultiplexedJBossCacheRegionFactory.
- *
- */
- public MultiplexedJBossCacheRegionFactory() {
- super();
- }
-
-}
diff --git a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/SharedJBossCacheRegionFactory.java b/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/SharedJBossCacheRegionFactory.java
deleted file mode 100644
index 89bb9a04ee..0000000000
--- a/cache-jbosscache/src/main/java/org/hibernate/cache/jbc2/SharedJBossCacheRegionFactory.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. 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, Inc.
- *
- * 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.jbc2;
-
-import java.util.Properties;
-
-/**
- * Deprecated version of superclass maintained solely for forwards
- * compatibility.
- *
- * @deprecated use {@link org.hibernate.cache.jbc.SharedJBossCacheRegionFactory}
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-@Deprecated
-public class SharedJBossCacheRegionFactory extends org.hibernate.cache.jbc.SharedJBossCacheRegionFactory {
-
- /**
- * FIXME Per the RegionFactory class Javadoc, this constructor version
- * should not be necessary.
- *
- * @param props The configuration properties
- */
- public SharedJBossCacheRegionFactory(Properties props) {
- super(props);
- }
-
- /**
- * Create a new SharedJBossCacheRegionFactory.
- *
- */
- public SharedJBossCacheRegionFactory() {
- super();
- }
-
-}
diff --git a/cache-jbosscache/src/main/resources/org/hibernate/cache/jbc/builder/jbc-configs.xml b/cache-jbosscache/src/main/resources/org/hibernate/cache/jbc/builder/jbc-configs.xml
deleted file mode 100644
index baad4f9ec7..0000000000
--- a/cache-jbosscache/src/main/resources/org/hibernate/cache/jbc/builder/jbc-configs.xml
+++ /dev/null
@@ -1,1143 +0,0 @@
-
-
-
-- * By "extra API" we mean those methods that are superfluous to the - * function of the JBC integration, where the impl is a no-op or a static - * false return value, UnsupportedOperationException, etc. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class MvccReadOnlyExtraAPITestCase extends OptimisticReadOnlyExtraAPITestCase { - - private static CollectionRegionAccessStrategy localAccessStrategy; - - /** - * Create a new PessimisticAccessStrategyExtraAPITestCase. - * - * @param name - */ - public MvccReadOnlyExtraAPITestCase(String name) { - super(name); - } - - @Override - protected String getCacheConfigName() { - return "mvcc-entity"; - } - - @Override - protected CollectionRegionAccessStrategy getCollectionAccessStrategy() { - return localAccessStrategy; - } - - @Override - protected void setCollectionAccessStrategy(CollectionRegionAccessStrategy strategy) { - localAccessStrategy = strategy; - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/MvccReadOnlyTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/MvccReadOnlyTestCase.java deleted file mode 100644 index 465e01a339..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/MvccReadOnlyTestCase.java +++ /dev/null @@ -1,63 +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.test.cache.jbc.collection; - -import org.hibernate.test.util.CacheTestUtil; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests READ_ONLY access when pessimistic locking and invalidation are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class MvccReadOnlyTestCase extends AbstractReadOnlyAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public MvccReadOnlyTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - TestSuite suite = CacheTestUtil.createFailureExpectedSuite(MvccReadOnlyTestCase.class); - return getTestSetup(suite, "mvcc-entity"); - } - - // Known failures - - // Overrides - - @Override - public void testCacheConfiguration() { - assertTrue("Using Invalidation", isUsingInvalidation()); - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/MvccReplicatedTransactionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/MvccReplicatedTransactionalTestCase.java deleted file mode 100644 index 2c766c2a09..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/MvccReplicatedTransactionalTestCase.java +++ /dev/null @@ -1,58 +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.test.cache.jbc.collection; - -import junit.framework.Test; - -/** - * Tests TRANSACTIONAL access when pessimistic locking and replication are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class MvccReplicatedTransactionalTestCase extends AbstractTransactionalAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public MvccReplicatedTransactionalTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - return getTestSetup(MvccReplicatedTransactionalTestCase.class, "mvcc-shared"); - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Invalidation", isUsingInvalidation()); - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - - - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/MvccTransactionalExtraAPITestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/MvccTransactionalExtraAPITestCase.java deleted file mode 100644 index 0e93f84426..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/MvccTransactionalExtraAPITestCase.java +++ /dev/null @@ -1,72 +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.test.cache.jbc.collection; - -import org.hibernate.cache.access.CollectionRegionAccessStrategy; - -/** - * Tests for the "extra API" in EntityRegionAccessStrategy; in this base - * version using Optimistic locking with TRANSACTIONAL access. - *
- * By "extra API" we mean those methods that are superfluous to the - * function of the JBC integration, where the impl is a no-op or a static - * false return value, UnsupportedOperationException, etc. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class MvccTransactionalExtraAPITestCase extends OptimisticTransactionalExtraAPITestCase { - - private static CollectionRegionAccessStrategy localAccessStrategy; - - /** - * Create a new PessimisticAccessStrategyExtraAPITestCase. - * - * @param name - */ - public MvccTransactionalExtraAPITestCase(String name) { - super(name); - } - - @Override - protected String getCacheConfigName() { - return "mvcc-entity"; - } - - @Override - protected CollectionRegionAccessStrategy getCollectionAccessStrategy() { - return localAccessStrategy; - } - - @Override - protected void setCollectionAccessStrategy(CollectionRegionAccessStrategy strategy) { - localAccessStrategy = strategy; - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticInvalidatedTransactionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticInvalidatedTransactionalTestCase.java deleted file mode 100644 index 051eb9c8d2..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticInvalidatedTransactionalTestCase.java +++ /dev/null @@ -1,61 +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.test.cache.jbc.collection; - -import org.hibernate.test.util.CacheTestUtil; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests TRANSACTIONAL access when optimistic locking and invalidation are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class OptimisticInvalidatedTransactionalTestCase - extends AbstractTransactionalAccessTestCase { - - /** - * Create a new TransactionalAccessTestCase. - * - * @param name - */ - public OptimisticInvalidatedTransactionalTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - TestSuite suite = CacheTestUtil.createFailureExpectedSuite(OptimisticInvalidatedTransactionalTestCase.class); - return getTestSetup(suite, "optimistic-entity"); - } - - @Override - public void testCacheConfiguration() { - assertTrue("Using Invalidation", isUsingInvalidation()); - assertTrue("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticReadOnlyExtraAPITestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticReadOnlyExtraAPITestCase.java deleted file mode 100644 index 3c9a27f262..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticReadOnlyExtraAPITestCase.java +++ /dev/null @@ -1,93 +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.test.cache.jbc.collection; - -import org.hibernate.cache.access.AccessType; -import org.hibernate.cache.access.CollectionRegionAccessStrategy; -import org.hibernate.cache.jbc.entity.TransactionalAccess; - -/** - * Tests for the "extra API" in EntityRegionAccessStrategy; in this - * version using Optimistic locking with READ_ONLY access. - *
- * By "extra API" we mean those methods that are superfluous to the - * function of the JBC integration, where the impl is a no-op or a static - * false return value, UnsupportedOperationException, etc. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class OptimisticReadOnlyExtraAPITestCase extends OptimisticTransactionalExtraAPITestCase { - - private static CollectionRegionAccessStrategy localAccessStrategy; - - /** - * Create a new TransactionalAccessTestCase. - * - * @param name - */ - public OptimisticReadOnlyExtraAPITestCase(String name) { - super(name); - } - - @Override - protected AccessType getAccessType() { - return AccessType.READ_ONLY; - } - - @Override - protected CollectionRegionAccessStrategy getCollectionAccessStrategy() { - return localAccessStrategy; - } - - @Override - protected void setCollectionAccessStrategy(CollectionRegionAccessStrategy strategy) { - localAccessStrategy = strategy; - } - - /** - * Test method for {@link TransactionalAccess#lockItem(java.lang.Object, java.lang.Object)}. - */ - @Override - public void testLockItem() { - try { - getCollectionAccessStrategy().lockItem(KEY, new Integer(1)); - fail("Call to lockItem did not throw exception"); - } - catch (UnsupportedOperationException expected) {} - } - - /** - * Test method for {@link TransactionalAccess#lockRegion()}. - */ - @Override - public void testLockRegion() { - try { - getCollectionAccessStrategy().lockRegion(); - fail("Call to lockRegion did not throw exception"); - } - catch (UnsupportedOperationException expected) {} - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticReadOnlyTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticReadOnlyTestCase.java deleted file mode 100644 index 9f10cf8615..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticReadOnlyTestCase.java +++ /dev/null @@ -1,60 +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.test.cache.jbc.collection; - -import org.hibernate.test.util.CacheTestUtil; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests READ_ONLY access when optimistic locking and invalidation are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class OptimisticReadOnlyTestCase extends AbstractReadOnlyAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public OptimisticReadOnlyTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - TestSuite suite = CacheTestUtil.createFailureExpectedSuite(OptimisticReadOnlyTestCase.class); - return getTestSetup(suite, "optimistic-entity"); - } - - @Override - public void testCacheConfiguration() { - assertTrue("Using Invalidation", isUsingInvalidation()); - assertTrue("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticReplicatedTransactionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticReplicatedTransactionalTestCase.java deleted file mode 100644 index 4fabd312f5..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticReplicatedTransactionalTestCase.java +++ /dev/null @@ -1,58 +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.test.cache.jbc.collection; - -import junit.framework.Test; - -/** - * Tests TRANSACTIONAL access when optimistic locking and replication are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class OptimisticReplicatedTransactionalTestCase extends AbstractTransactionalAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public OptimisticReplicatedTransactionalTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - return getTestSetup(OptimisticReplicatedTransactionalTestCase.class, "optimistic-shared"); - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Invalidation", isUsingInvalidation()); - assertTrue("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - - - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticTransactionalExtraAPITestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticTransactionalExtraAPITestCase.java deleted file mode 100644 index 0557cd568f..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/OptimisticTransactionalExtraAPITestCase.java +++ /dev/null @@ -1,158 +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.test.cache.jbc.collection; - -import org.hibernate.cache.CollectionRegion; -import org.hibernate.cache.access.AccessType; -import org.hibernate.cache.access.CollectionRegionAccessStrategy; -import org.hibernate.cache.access.SoftLock; -import org.hibernate.cache.jbc.JBossCacheRegionFactory; -import org.hibernate.cache.jbc.MultiplexedJBossCacheRegionFactory; -import org.hibernate.cache.jbc.builder.MultiplexingCacheInstanceManager; -import org.hibernate.cache.jbc.entity.TransactionalAccess; -import org.hibernate.cfg.Configuration; -import org.hibernate.test.cache.jbc.AbstractJBossCacheTestCase; -import org.hibernate.test.util.CacheTestUtil; -import org.jboss.cache.Cache; - -/** - * Tests for the "extra API" in CollectionRegionAccessStrategy; in this base - * version using Optimistic locking with TRANSACTIONAL access. - *
- * By "extra API" we mean those methods that are superfluous to the - * function of the JBC integration, where the impl is a no-op or a static - * false return value, UnsupportedOperationException, etc. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class OptimisticTransactionalExtraAPITestCase extends AbstractJBossCacheTestCase { - - public static final String REGION_NAME = "test/com.foo.test"; - public static final String KEY = "KEY"; - public static final String VALUE1 = "VALUE1"; - public static final String VALUE2 = "VALUE2"; - - private static CollectionRegionAccessStrategy localAccessStrategy; - - private static boolean optimistic; - - /** - * Create a new TransactionalAccessTestCase. - * - * @param name - */ - public OptimisticTransactionalExtraAPITestCase(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - - if (getCollectionAccessStrategy() == null) { - Configuration cfg = createConfiguration(); - JBossCacheRegionFactory rf = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); - Cache localCache = rf.getCacheInstanceManager().getEntityCacheInstance(); - optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC; - - // Sleep a bit to avoid concurrent FLUSH problem - avoidConcurrentFlush(); - - CollectionRegion localCollectionRegion = rf.buildCollectionRegion(REGION_NAME, cfg.getProperties(), null); - setCollectionAccessStrategy(localCollectionRegion.buildAccessStrategy(getAccessType())); - } - } - - protected void tearDown() throws Exception { - - super.tearDown(); - } - - protected Configuration createConfiguration() { - Configuration cfg = CacheTestUtil.buildConfiguration(REGION_PREFIX, MultiplexedJBossCacheRegionFactory.class, true, false); - cfg.setProperty(MultiplexingCacheInstanceManager.ENTITY_CACHE_RESOURCE_PROP, getCacheConfigName()); - return cfg; - } - - protected String getCacheConfigName() { - return "optimistic-entity"; - } - - protected boolean isUsingOptimisticLocking() { - return optimistic; - } - - protected AccessType getAccessType() { - return AccessType.TRANSACTIONAL; - } - - protected CollectionRegionAccessStrategy getCollectionAccessStrategy() { - return localAccessStrategy; - } - - protected void setCollectionAccessStrategy(CollectionRegionAccessStrategy strategy) { - localAccessStrategy = strategy; - } - - /** - * This is just a setup test where we assert that the cache config is - * as we expected. - */ - public void testCacheConfiguration() { - assertTrue("Using Optimistic locking", isUsingOptimisticLocking()); - } - - /** - * Test method for {@link TransactionalAccess#lockItem(java.lang.Object, java.lang.Object)}. - */ - public void testLockItem() { - assertNull(getCollectionAccessStrategy().lockItem(KEY, new Integer(1))); - } - - /** - * Test method for {@link TransactionalAccess#lockRegion()}. - */ - public void testLockRegion() { - assertNull(getCollectionAccessStrategy().lockRegion()); - } - - /** - * Test method for {@link TransactionalAccess#unlockItem(java.lang.Object, org.hibernate.cache.access.SoftLock)}. - */ - public void testUnlockItem() { - getCollectionAccessStrategy().unlockItem(KEY, new MockSoftLock()); - } - - /** - * Test method for {@link TransactionalAccess#unlockRegion(org.hibernate.cache.access.SoftLock)}. - */ - public void testUnlockRegion() { - getCollectionAccessStrategy().unlockItem(KEY, new MockSoftLock()); - } - - public static class MockSoftLock implements SoftLock { - - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticInvalidatedTransactionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticInvalidatedTransactionalTestCase.java deleted file mode 100644 index 51010fd082..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticInvalidatedTransactionalTestCase.java +++ /dev/null @@ -1,62 +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.test.cache.jbc.collection; - -import org.hibernate.test.util.CacheTestUtil; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests TRANSACTIONAL access when pessimistic locking and invalidation are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class PessimisticInvalidatedTransactionalTestCase extends AbstractTransactionalAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public PessimisticInvalidatedTransactionalTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - TestSuite suite = CacheTestUtil.createFailureExpectedSuite(PessimisticInvalidatedTransactionalTestCase.class); - return getTestSetup(suite, "pessimistic-entity"); - } - - @Override - public void testCacheConfiguration() { - assertTrue("Using Invalidation", isUsingInvalidation()); - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - - // Known failures - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticReadOnlyExtraAPITestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticReadOnlyExtraAPITestCase.java deleted file mode 100644 index 16bda8ead5..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticReadOnlyExtraAPITestCase.java +++ /dev/null @@ -1,72 +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.test.cache.jbc.collection; - -import org.hibernate.cache.access.CollectionRegionAccessStrategy; - -/** - * Tests for the "extra API" in EntityRegionAccessStrategy; in this - * version using pessimistic locking with READ_ONLY access. - *
- * By "extra API" we mean those methods that are superfluous to the - * function of the JBC integration, where the impl is a no-op or a static - * false return value, UnsupportedOperationException, etc. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class PessimisticReadOnlyExtraAPITestCase extends OptimisticReadOnlyExtraAPITestCase { - - private static CollectionRegionAccessStrategy localAccessStrategy; - - /** - * Create a new PessimisticAccessStrategyExtraAPITestCase. - * - * @param name - */ - public PessimisticReadOnlyExtraAPITestCase(String name) { - super(name); - } - - @Override - protected String getCacheConfigName() { - return "pessimistic-entity"; - } - - @Override - protected CollectionRegionAccessStrategy getCollectionAccessStrategy() { - return localAccessStrategy; - } - - @Override - protected void setCollectionAccessStrategy(CollectionRegionAccessStrategy strategy) { - localAccessStrategy = strategy; - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticReadOnlyTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticReadOnlyTestCase.java deleted file mode 100644 index b4bb59c2cc..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticReadOnlyTestCase.java +++ /dev/null @@ -1,63 +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.test.cache.jbc.collection; - -import org.hibernate.test.util.CacheTestUtil; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests READ_ONLY access when pessimistic locking and invalidation are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class PessimisticReadOnlyTestCase extends AbstractReadOnlyAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public PessimisticReadOnlyTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - TestSuite suite = CacheTestUtil.createFailureExpectedSuite(PessimisticReadOnlyTestCase.class); - return getTestSetup(suite, "pessimistic-entity"); - } - - // Known failures - - // Overrides - - @Override - public void testCacheConfiguration() { - assertTrue("Using Invalidation", isUsingInvalidation()); - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticReplicatedTransactionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticReplicatedTransactionalTestCase.java deleted file mode 100644 index 5cc452921e..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticReplicatedTransactionalTestCase.java +++ /dev/null @@ -1,58 +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.test.cache.jbc.collection; - -import junit.framework.Test; - -/** - * Tests TRANSACTIONAL access when pessimistic locking and replication are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class PessimisticReplicatedTransactionalTestCase extends AbstractTransactionalAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public PessimisticReplicatedTransactionalTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - return getTestSetup(PessimisticReplicatedTransactionalTestCase.class, "pessimistic-shared"); - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Invalidation", isUsingInvalidation()); - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - - - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticTransactionalExtraAPITestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticTransactionalExtraAPITestCase.java deleted file mode 100644 index 412b19f106..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/PessimisticTransactionalExtraAPITestCase.java +++ /dev/null @@ -1,72 +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.test.cache.jbc.collection; - -import org.hibernate.cache.access.CollectionRegionAccessStrategy; - -/** - * Tests for the "extra API" in EntityRegionAccessStrategy; in this base - * version using Optimistic locking with TRANSACTIONAL access. - *
- * By "extra API" we mean those methods that are superfluous to the - * function of the JBC integration, where the impl is a no-op or a static - * false return value, UnsupportedOperationException, etc. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class PessimisticTransactionalExtraAPITestCase extends OptimisticTransactionalExtraAPITestCase { - - private static CollectionRegionAccessStrategy localAccessStrategy; - - /** - * Create a new PessimisticAccessStrategyExtraAPITestCase. - * - * @param name - */ - public PessimisticTransactionalExtraAPITestCase(String name) { - super(name); - } - - @Override - protected String getCacheConfigName() { - return "pessimistic-entity"; - } - - @Override - protected CollectionRegionAccessStrategy getCollectionAccessStrategy() { - return localAccessStrategy; - } - - @Override - protected void setCollectionAccessStrategy(CollectionRegionAccessStrategy strategy) { - localAccessStrategy = strategy; - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractEntityRegionAccessStrategyTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractEntityRegionAccessStrategyTestCase.java deleted file mode 100644 index 3a50b14b60..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractEntityRegionAccessStrategyTestCase.java +++ /dev/null @@ -1,809 +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.test.cache.jbc.entity; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import junit.extensions.TestSetup; -import junit.framework.AssertionFailedError; -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.hibernate.cache.CacheDataDescription; -import org.hibernate.cache.EntityRegion; -import org.hibernate.cache.access.AccessType; -import org.hibernate.cache.access.EntityRegionAccessStrategy; -import org.hibernate.cache.impl.CacheDataDescriptionImpl; -import org.hibernate.cache.jbc.BasicRegionAdapter; -import org.hibernate.cache.jbc.JBossCacheRegionFactory; -import org.hibernate.cache.jbc.MultiplexedJBossCacheRegionFactory; -import org.hibernate.cache.jbc.builder.MultiplexingCacheInstanceManager; -import org.hibernate.cache.jbc.entity.EntityRegionImpl; -import org.hibernate.cache.jbc.entity.TransactionalAccess; -import org.hibernate.cache.jbc.util.CacheHelper; -import org.hibernate.cache.jbc.util.NonLockingDataVersion; -import org.hibernate.cfg.Configuration; -import org.hibernate.test.cache.jbc.AbstractJBossCacheTestCase; -import org.hibernate.test.util.CacheTestUtil; -import org.hibernate.util.ComparableComparator; -import org.jboss.cache.Cache; -import org.jboss.cache.Fqn; -import org.jboss.cache.Node; -import org.jboss.cache.NodeSPI; -import org.jboss.cache.transaction.BatchModeTransactionManager; - -/** - * Base class for tests of EntityRegionAccessStrategy impls. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public abstract class AbstractEntityRegionAccessStrategyTestCase extends AbstractJBossCacheTestCase { - - public static final String REGION_NAME = "test/com.foo.test"; - public static final String KEY_BASE = "KEY"; - public static final String VALUE1 = "VALUE1"; - public static final String VALUE2 = "VALUE2"; - - protected static int testCount; - - protected static Configuration localCfg; - protected static JBossCacheRegionFactory localRegionFactory; - protected static Cache localCache; - protected static Configuration remoteCfg; - protected static JBossCacheRegionFactory remoteRegionFactory; - protected static Cache remoteCache; - - protected static boolean invalidation; - protected static boolean optimistic; - protected static boolean synchronous; - - protected EntityRegion localEntityRegion; - protected EntityRegionAccessStrategy localAccessStrategy; - - protected EntityRegion remoteEntityRegion; - protected EntityRegionAccessStrategy remoteAccessStrategy; - - protected Exception node1Exception; - protected Exception node2Exception; - - protected AssertionFailedError node1Failure; - protected AssertionFailedError node2Failure; - - - public static Test getTestSetup(Class testClass, String configName) { - return getTestSetup(testClass, configName, null); - } - - public static Test getTestSetup(Test test, String configName) { - return getTestSetup(test, configName, null); - } - - public static Test getTestSetup(Class testClass, String configName, String configResource) { - TestSuite suite = new TestSuite(testClass); - return new AccessStrategyTestSetup(suite, configName, configResource); - } - - public static Test getTestSetup(Test test, String configName, String configResource) { - return new AccessStrategyTestSetup(test, configName, configResource); - } - - - /** - * Create a new TransactionalAccessTestCase. - * - * @param name - */ - public AbstractEntityRegionAccessStrategyTestCase(String name) { - super(name); - } - - protected abstract AccessType getAccessType(); - - protected void setUp() throws Exception { - super.setUp(); - - // Sleep a bit to avoid concurrent FLUSH problem - avoidConcurrentFlush(); - - localEntityRegion = localRegionFactory.buildEntityRegion(REGION_NAME, localCfg.getProperties(), getCacheDataDescription()); - localAccessStrategy = localEntityRegion.buildAccessStrategy(getAccessType()); - - // Sleep a bit to avoid concurrent FLUSH problem - avoidConcurrentFlush(); - - remoteEntityRegion = remoteRegionFactory.buildEntityRegion(REGION_NAME, remoteCfg.getProperties(), getCacheDataDescription()); - remoteAccessStrategy = remoteEntityRegion.buildAccessStrategy(getAccessType()); - - node1Exception = null; - node2Exception = null; - - node1Failure = null; - node2Failure = null; - } - - protected void tearDown() throws Exception { - - super.tearDown(); - - if (localEntityRegion != null) - localEntityRegion.destroy(); - if (remoteEntityRegion != null) - remoteEntityRegion.destroy(); - - try { - localCache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true); - localCache.removeNode(Fqn.ROOT); - } - catch (Exception e) { - log.error("Problem purging local cache" ,e); - } - - try { - remoteCache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true); - remoteCache.removeNode(Fqn.ROOT); - } - catch (Exception e) { - log.error("Problem purging remote cache" ,e); - } - - node1Exception = null; - node2Exception = null; - - node1Failure = null; - node2Failure = null; - } - - protected static Configuration createConfiguration(String configName, String configResource) { - Configuration cfg = CacheTestUtil.buildConfiguration(REGION_PREFIX, MultiplexedJBossCacheRegionFactory.class, true, false); - cfg.setProperty(MultiplexingCacheInstanceManager.ENTITY_CACHE_RESOURCE_PROP, configName); - if (configResource != null) { - cfg.setProperty(MultiplexingCacheInstanceManager.CACHE_FACTORY_RESOURCE_PROP, configResource); - } - return cfg; - } - - protected CacheDataDescription getCacheDataDescription() { - return new CacheDataDescriptionImpl(true, true, ComparableComparator.INSTANCE); - } - - protected boolean isUsingOptimisticLocking() { - return optimistic; - } - - protected boolean isUsingInvalidation() { - return invalidation; - } - - protected boolean isSynchronous() { - return synchronous; - } - - protected Fqn getRegionFqn(String regionName, String regionPrefix) { - return BasicRegionAdapter.getTypeLastRegionFqn(regionName, regionPrefix, EntityRegionImpl.TYPE); - } - - protected void assertThreadsRanCleanly() - { - if (node1Failure != null) - throw node1Failure; - if (node2Failure != null) - throw node2Failure; - - if (node1Exception != null) { - log.error("node1 saw an exception", node1Exception); - assertEquals("node1 saw no exceptions", null, node1Exception); - } - - if (node2Exception != null) { - log.error("node2 saw an exception", node2Exception); - assertEquals("node2 saw no exceptions", null, node2Exception); - } - } - - /** - * This is just a setup test where we assert that the cache config is - * as we expected. - */ - public abstract void testCacheConfiguration(); - - /** - * Test method for {@link TransactionalAccess#getRegion()}. - */ - public void testGetRegion() { - assertEquals("Correct region", localEntityRegion, localAccessStrategy.getRegion()); - } - - /** - * Test method for {@link TransactionalAccess#putFromLoad(java.lang.Object, java.lang.Object, long, java.lang.Object)}. - */ - public void testPutFromLoad() throws Exception { - putFromLoadTest(false); - } - - /** - * Test method for {@link TransactionalAccess#putFromLoad(java.lang.Object, java.lang.Object, long, java.lang.Object, boolean)}. - */ - public void testPutFromLoadMinimal() throws Exception { - putFromLoadTest(true); - } - - /** - * Simulate 2 nodes, both start, tx do a get, experience a cache miss, - * then 'read from db.' First does a putFromLoad, then an update. - * Second tries to do a putFromLoad with stale data (i.e. it took - * longer to read from the db). Both commit their tx. Then - * both start a new tx and get. First should see the updated data; - * second should either see the updated data (isInvalidation() == false) - * or null (isInvalidation() == true). - * - * @param useMinimalAPI - * @throws Exception - */ - private void putFromLoadTest(final boolean useMinimalAPI) throws Exception { - - final String KEY = KEY_BASE + testCount++; - - final CountDownLatch writeLatch1 = new CountDownLatch(1); - final CountDownLatch writeLatch2 = new CountDownLatch(1); - final CountDownLatch completionLatch = new CountDownLatch(2); - - Thread node1 = new Thread() { - - public void run() { - - try { - long txTimestamp = System.currentTimeMillis(); - BatchModeTransactionManager.getInstance().begin(); - - assertNull("node1 starts clean", localAccessStrategy.get(KEY, txTimestamp)); - - writeLatch1.await(); - - if (useMinimalAPI) { - localAccessStrategy.putFromLoad(KEY, VALUE1, txTimestamp, new Integer(1), true); - } - else { - localAccessStrategy.putFromLoad(KEY, VALUE1, txTimestamp, new Integer(1)); - } - - localAccessStrategy.update(KEY, VALUE2, new Integer(2), new Integer(1)); - - BatchModeTransactionManager.getInstance().commit(); - } - catch (Exception e) { - log.error("node1 caught exception", e); - node1Exception = e; - rollback(); - } - catch (AssertionFailedError e) { - node1Failure = e; - rollback(); - } - finally { - // Let node2 write - writeLatch2.countDown(); - completionLatch.countDown(); - } - } - }; - - Thread node2 = new Thread() { - - public void run() { - - try { - long txTimestamp = System.currentTimeMillis(); - BatchModeTransactionManager.getInstance().begin(); - - assertNull("node1 starts clean", remoteAccessStrategy.get(KEY, txTimestamp)); - - // Let node1 write - writeLatch1.countDown(); - // Wait for node1 to finish - writeLatch2.await(); - - if (useMinimalAPI) { - remoteAccessStrategy.putFromLoad(KEY, VALUE1, txTimestamp, new Integer(1), true); - } - else { - remoteAccessStrategy.putFromLoad(KEY, VALUE1, txTimestamp, new Integer(1)); - } - - BatchModeTransactionManager.getInstance().commit(); - } - catch (Exception e) { - log.error("node2 caught exception", e); - node2Exception = e; - rollback(); - } - catch (AssertionFailedError e) { - node2Failure = e; - rollback(); - } - finally { - completionLatch.countDown(); - } - } - }; - - node1.setDaemon(true); - node2.setDaemon(true); - - node1.start(); - node2.start(); - - assertTrue("Threads completed", completionLatch.await(2, TimeUnit.SECONDS)); - - assertThreadsRanCleanly(); - - long txTimestamp = System.currentTimeMillis(); - assertEquals("Correct node1 value", VALUE2, localAccessStrategy.get(KEY, txTimestamp)); - - if (isUsingInvalidation()) { - if (isUsingOptimisticLocking()) - // The node is "deleted" but it's ghost data version prevents the stale node2 PFER - assertEquals("Correct node2 value", null, remoteAccessStrategy.get(KEY, txTimestamp)); - else { - // no data version to prevent the PFER; we count on db locks preventing this - assertEquals("Expected node2 value", VALUE1, remoteAccessStrategy.get(KEY, txTimestamp)); - } - } - else { - // The node1 update is replicated, preventing the node2 PFER - assertEquals("Correct node2 value", VALUE2, remoteAccessStrategy.get(KEY, txTimestamp)); - } - } - - /** - * Test method for {@link TransactionalAccess#insert(java.lang.Object, java.lang.Object, java.lang.Object)}. - */ - public void testInsert() throws Exception { - - final String KEY = KEY_BASE + testCount++; - - final CountDownLatch readLatch = new CountDownLatch(1); - final CountDownLatch commitLatch = new CountDownLatch(1); - final CountDownLatch completionLatch = new CountDownLatch(2); - - Thread inserter = new Thread() { - - public void run() { - - try { - long txTimestamp = System.currentTimeMillis(); - BatchModeTransactionManager.getInstance().begin(); - - assertNull("Correct initial value", localAccessStrategy.get(KEY, txTimestamp)); - - localAccessStrategy.insert(KEY, VALUE1, new Integer(1)); - - readLatch.countDown(); - commitLatch.await(); - - BatchModeTransactionManager.getInstance().commit(); - } - catch (Exception e) { - log.error("node1 caught exception", e); - node1Exception = e; - rollback(); - } - catch (AssertionFailedError e) { - node1Failure = e; - rollback(); - } - finally { - completionLatch.countDown(); - } - } - }; - - Thread reader = new Thread() { - - public void run() { - - try { - long txTimestamp = System.currentTimeMillis(); - BatchModeTransactionManager.getInstance().begin(); - - readLatch.await(); - Object expected = !isBlockingReads() ? null : VALUE1; - - assertEquals("Correct initial value", expected, localAccessStrategy.get(KEY, txTimestamp)); - - BatchModeTransactionManager.getInstance().commit(); - } - catch (Exception e) { - log.error("node1 caught exception", e); - node1Exception = e; - rollback(); - } - catch (AssertionFailedError e) { - node1Failure = e; - rollback(); - } - finally { - commitLatch.countDown(); - completionLatch.countDown(); - } - } - }; - - inserter.setDaemon(true); - reader.setDaemon(true); - inserter.start(); - reader.start(); - - if (! isBlockingReads()) - assertTrue("Threads completed", completionLatch.await(1, TimeUnit.SECONDS)); - else { - // Reader should be blocking for lock - assertFalse("Threads completed", completionLatch.await(250, TimeUnit.MILLISECONDS)); - commitLatch.countDown(); - assertTrue("Threads completed", completionLatch.await(1, TimeUnit.SECONDS)); - } - - assertThreadsRanCleanly(); - - long txTimestamp = System.currentTimeMillis(); - assertEquals("Correct node1 value", VALUE1, localAccessStrategy.get(KEY, txTimestamp)); - Object expected = isUsingInvalidation() ? null : VALUE1; - assertEquals("Correct node2 value", expected, remoteAccessStrategy.get(KEY, txTimestamp)); - } - - public boolean isBlockingReads() - { - return !isUsingOptimisticLocking(); - } - - /** - * Test method for {@link TransactionalAccess#update(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)}. - */ - public void testUpdate() throws Exception { - - final String KEY = KEY_BASE + testCount++; - - // Set up initial state - localAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1)); - remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1)); - - // Let the async put propagate - sleep(250); - - final CountDownLatch readLatch = new CountDownLatch(1); - final CountDownLatch commitLatch = new CountDownLatch(1); - final CountDownLatch completionLatch = new CountDownLatch(2); - - Thread updater = new Thread() { - - public void run() { - - try { - long txTimestamp = System.currentTimeMillis(); - BatchModeTransactionManager.getInstance().begin(); - - assertEquals("Correct initial value", VALUE1, localAccessStrategy.get(KEY, txTimestamp)); - - localAccessStrategy.update(KEY, VALUE2, new Integer(2), new Integer(1)); - - readLatch.countDown(); - commitLatch.await(); - - BatchModeTransactionManager.getInstance().commit(); - } - catch (Exception e) { - log.error("node1 caught exception", e); - node1Exception = e; - rollback(); - } - catch (AssertionFailedError e) { - node1Failure = e; - rollback(); - } - finally { - completionLatch.countDown(); - } - } - }; - - Thread reader = new Thread() { - - public void run() { - try { - long txTimestamp = System.currentTimeMillis(); - BatchModeTransactionManager.getInstance().begin(); - - readLatch.await(); - - // This will block w/ pessimistic locking and then - // read the new value; w/ optimistic it shouldn't - // block and will read the old value - Object expected = !isBlockingReads() ? VALUE1 : VALUE2; - assertEquals("Correct value", expected, localAccessStrategy.get(KEY, txTimestamp)); - - BatchModeTransactionManager.getInstance().commit(); - } - catch (Exception e) { - log.error("node1 caught exception", e); - node1Exception = e; - rollback(); - } - catch (AssertionFailedError e) { - node1Failure = e; - rollback(); - } - finally { - commitLatch.countDown(); - completionLatch.countDown(); - } - } - }; - - updater.setDaemon(true); - reader.setDaemon(true); - updater.start(); - reader.start(); - - if (! isBlockingReads()) - // Should complete promptly - assertTrue(completionLatch.await(1, TimeUnit.SECONDS)); - else { - // Reader thread should be blocking - assertFalse(completionLatch.await(250, TimeUnit.MILLISECONDS)); - // Let the writer commit down - commitLatch.countDown(); - assertTrue(completionLatch.await(1, TimeUnit.SECONDS)); - } - - assertThreadsRanCleanly(); - - long txTimestamp = System.currentTimeMillis(); - assertEquals("Correct node1 value", VALUE2, localAccessStrategy.get(KEY, txTimestamp)); - Object expected = isUsingInvalidation() ? null : VALUE2; - assertEquals("Correct node2 value", expected, remoteAccessStrategy.get(KEY, txTimestamp)); - } - - /** - * Test method for {@link TransactionalAccess#remove(java.lang.Object)}. - */ - public void testRemove() { - evictOrRemoveTest(false); - } - - /** - * Test method for {@link TransactionalAccess#removeAll()}. - */ - public void testRemoveAll() { - evictOrRemoveAllTest(false); - } - - /** - * Test method for {@link TransactionalAccess#evict(java.lang.Object)}. - * - * FIXME add testing of the "immediately without regard for transaction - * isolation" bit in the EntityRegionAccessStrategy API. - */ - public void testEvict() { - evictOrRemoveTest(true); - } - - /** - * Test method for {@link TransactionalAccess#evictAll()}. - * - * FIXME add testing of the "immediately without regard for transaction - * isolation" bit in the EntityRegionAccessStrategy API. - */ - public void testEvictAll() { - evictOrRemoveAllTest(true); - } - - private void evictOrRemoveTest(boolean evict) { - - final String KEY = KEY_BASE + testCount++; - - assertNull("local is clean", localAccessStrategy.get(KEY, System.currentTimeMillis())); - assertNull("remote is clean", remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - - localAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1)); - assertEquals(VALUE1, localAccessStrategy.get(KEY, System.currentTimeMillis())); - remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1)); - assertEquals(VALUE1, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - - // Wait for async propagation - sleep(250); - - if (evict) - localAccessStrategy.evict(KEY); - else - localAccessStrategy.remove(KEY); - - assertEquals(null, localAccessStrategy.get(KEY, System.currentTimeMillis())); - -// sleep(1000); - - assertEquals(null, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - } - - private void evictOrRemoveAllTest(boolean evict) { - - final String KEY = KEY_BASE + testCount++; - - Fqn regionFqn = getRegionFqn(REGION_NAME, REGION_PREFIX); - - Node regionRoot = localCache.getRoot().getChild(regionFqn); - assertFalse(regionRoot == null); - assertEquals(0, getValidChildrenCount(regionRoot)); - assertTrue(regionRoot.isResident()); - - if (isUsingOptimisticLocking()) { - assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass()); - } - - regionRoot = remoteCache.getRoot().getChild(regionFqn); - assertFalse(regionRoot == null); - assertEquals(0, getValidChildrenCount(regionRoot)); - assertTrue(regionRoot.isResident()); - - if (isUsingOptimisticLocking()) { - assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass()); - } - - assertNull("local is clean", localAccessStrategy.get(KEY, System.currentTimeMillis())); - assertNull("remote is clean", remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - - localAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1)); - assertEquals(VALUE1, localAccessStrategy.get(KEY, System.currentTimeMillis())); - - // Wait for async propagation - sleep(250); - - remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1)); - assertEquals(VALUE1, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - - // Wait for async propagation - sleep(250); - - if (isUsingOptimisticLocking()) { - regionRoot = localCache.getRoot().getChild(regionFqn); - assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass()); - regionRoot = remoteCache.getRoot().getChild(regionFqn); - assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass()); - } - - if (evict) - localAccessStrategy.evictAll(); - else - localAccessStrategy.removeAll(); - - // This should re-establish the region root node in the optimistic case - assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis())); - - regionRoot = localCache.getRoot().getChild(regionFqn); - assertFalse(regionRoot == null); - assertEquals(0, getValidChildrenCount(regionRoot)); - assertTrue(regionRoot.isValid()); - assertTrue(regionRoot.isResident()); - - // Re-establishing the region root on the local node doesn't - // propagate it to other nodes. Do a get on the remote node to re-establish - assertEquals(null, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - - regionRoot = remoteCache.getRoot().getChild(regionFqn); - assertFalse(regionRoot == null); - assertTrue(regionRoot.isValid()); - assertTrue(regionRoot.isResident()); - // Not invalidation, so we didn't insert a child above - assertEquals(0, getValidChildrenCount(regionRoot)); - - // Test whether the get above messes up the optimistic version - remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1)); - assertEquals(VALUE1, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - - // Revalidate the region root - regionRoot = remoteCache.getRoot().getChild(regionFqn); - assertFalse(regionRoot == null); - assertTrue(regionRoot.isValid()); - assertTrue(regionRoot.isResident()); - // Region root should have 1 child -- the one we added above - assertEquals(1, getValidChildrenCount(regionRoot)); - - // Wait for async propagation - sleep(250); - - assertEquals("local is correct", (isUsingInvalidation() ? null : VALUE1), localAccessStrategy.get(KEY, System.currentTimeMillis())); - assertEquals("remote is correct", VALUE1, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - } - - protected void rollback() { - try { - BatchModeTransactionManager.getInstance().rollback(); - } - catch (Exception e) { - log.error(e.getMessage(), e); - } - } - - private static class AccessStrategyTestSetup extends TestSetup { - - private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack"; - - private final String configResource; - private final String configName; - private String preferIPv4Stack; - - public AccessStrategyTestSetup(Test test, String configName) { - this(test, configName, null); - } - - public AccessStrategyTestSetup(Test test, String configName, String configResource) { - super(test); - this.configName = configName; - this.configResource = configResource; - } - - @Override - protected void setUp() throws Exception { - try { - super.tearDown(); - } - finally { - if (preferIPv4Stack == null) - System.clearProperty(PREFER_IPV4STACK); - else - System.setProperty(PREFER_IPV4STACK, preferIPv4Stack); - } - - // Try to ensure we use IPv4; otherwise cluster formation is very slow - preferIPv4Stack = System.getProperty(PREFER_IPV4STACK); - System.setProperty(PREFER_IPV4STACK, "true"); - - localCfg = createConfiguration(configName, configResource); - localRegionFactory = CacheTestUtil.startRegionFactory(localCfg); - localCache = localRegionFactory.getCacheInstanceManager().getEntityCacheInstance(); - - remoteCfg = createConfiguration(configName, configResource); - remoteRegionFactory = CacheTestUtil.startRegionFactory(remoteCfg); - remoteCache = remoteRegionFactory.getCacheInstanceManager().getEntityCacheInstance(); - - invalidation = CacheHelper.isClusteredInvalidation(localCache); - synchronous = CacheHelper.isSynchronous(localCache); - optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC; - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - if (localRegionFactory != null) - localRegionFactory.stop(); - - if (remoteRegionFactory != null) - remoteRegionFactory.stop(); - } - - - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractReadOnlyAccessTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractReadOnlyAccessTestCase.java deleted file mode 100644 index 1df79d149a..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractReadOnlyAccessTestCase.java +++ /dev/null @@ -1,93 +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.test.cache.jbc.entity; - -import org.hibernate.cache.access.AccessType; -import org.jboss.cache.transaction.BatchModeTransactionManager; - -/** - * Base class for tests of TRANSACTIONAL access. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public abstract class AbstractReadOnlyAccessTestCase extends AbstractEntityRegionAccessStrategyTestCase { - - /** - * Create a new AbstractTransactionalAccessTestCase. - * - */ - public AbstractReadOnlyAccessTestCase(String name) { - super(name); - } - - @Override - protected AccessType getAccessType() { - return AccessType.READ_ONLY; - } - - @Override - public void testPutFromLoad() throws Exception { - putFromLoadTest(false); - } - - @Override - public void testPutFromLoadMinimal() throws Exception { - putFromLoadTest(true); - } - - private void putFromLoadTest(boolean minimal) throws Exception { - - final String KEY = KEY_BASE + testCount++; - - long txTimestamp = System.currentTimeMillis(); - BatchModeTransactionManager.getInstance().begin(); - assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis())); - if (minimal) - localAccessStrategy.putFromLoad(KEY, VALUE1, txTimestamp, new Integer(1), true); - else - localAccessStrategy.putFromLoad(KEY, VALUE1, txTimestamp, new Integer(1)); - - sleep(250); - Object expected = isUsingInvalidation() ? null : VALUE1; - assertEquals(expected, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - - BatchModeTransactionManager.getInstance().commit(); - assertEquals(VALUE1, localAccessStrategy.get(KEY, System.currentTimeMillis())); - assertEquals(expected, remoteAccessStrategy.get(KEY, System.currentTimeMillis())); - } - - @Override - public void testUpdate() throws Exception { - - final String KEY = KEY_BASE + testCount++; - - try { - localAccessStrategy.update(KEY, VALUE2, new Integer(2), new Integer(1)); - fail("Call to update did not throw exception"); - } - catch (UnsupportedOperationException good) {} - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractTransactionalAccessTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractTransactionalAccessTestCase.java deleted file mode 100644 index 0e963c9101..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractTransactionalAccessTestCase.java +++ /dev/null @@ -1,140 +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.test.cache.jbc.entity; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import junit.framework.AssertionFailedError; - -import org.hibernate.cache.access.AccessType; -import org.jboss.cache.transaction.BatchModeTransactionManager; - -/** - * Base class for tests of TRANSACTIONAL access. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public abstract class AbstractTransactionalAccessTestCase extends AbstractEntityRegionAccessStrategyTestCase { - - /** - * Create a new AbstractTransactionalAccessTestCase. - * - */ - public AbstractTransactionalAccessTestCase(String name) { - super(name); - } - - @Override - protected AccessType getAccessType() { - return AccessType.TRANSACTIONAL; - } - - public void testContestedPutFromLoad() throws Exception { - - final String KEY = KEY_BASE + testCount++; - - localAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1)); - - final CountDownLatch pferLatch = new CountDownLatch(1); - final CountDownLatch pferCompletionLatch = new CountDownLatch(1); - final CountDownLatch commitLatch = new CountDownLatch(1); - final CountDownLatch completionLatch = new CountDownLatch(1); - - Thread blocker = new Thread("Blocker") { - - public void run() { - - try { - long txTimestamp = System.currentTimeMillis(); - BatchModeTransactionManager.getInstance().begin(); - - assertEquals("Correct initial value", VALUE1, localAccessStrategy.get(KEY, txTimestamp)); - - localAccessStrategy.update(KEY, VALUE2, new Integer(2), new Integer(1)); - - pferLatch.countDown(); - commitLatch.await(); - - BatchModeTransactionManager.getInstance().commit(); - } - catch (Exception e) { - log.error("node1 caught exception", e); - node1Exception = e; - rollback(); - } - catch (AssertionFailedError e) { - node1Failure = e; - rollback(); - } - finally { - completionLatch.countDown(); - } - } - }; - - Thread putter = new Thread("Putter") { - - public void run() { - - try { - long txTimestamp = System.currentTimeMillis(); - BatchModeTransactionManager.getInstance().begin(); - - localAccessStrategy.putFromLoad(KEY, VALUE1, txTimestamp, new Integer(1)); - - BatchModeTransactionManager.getInstance().commit(); - } - catch (Exception e) { - log.error("node1 caught exception", e); - node1Exception = e; - rollback(); - } - catch (AssertionFailedError e) { - node1Failure = e; - rollback(); - } - finally { - pferCompletionLatch.countDown(); - } - } - }; - - blocker.start(); - assertTrue("Active tx has done an update", pferLatch.await(1, TimeUnit.SECONDS)); - putter.start(); - assertTrue("putFromLoadreturns promtly", pferCompletionLatch.await(10, TimeUnit.MILLISECONDS)); - - commitLatch.countDown(); - - assertTrue("Threads completed", completionLatch.await(1, TimeUnit.SECONDS)); - - assertThreadsRanCleanly(); - - long txTimestamp = System.currentTimeMillis(); - assertEquals("Correct node1 value", VALUE2, localAccessStrategy.get(KEY, txTimestamp)); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/EntityRegionImplTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/EntityRegionImplTestCase.java deleted file mode 100644 index 09d57efef9..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/EntityRegionImplTestCase.java +++ /dev/null @@ -1,116 +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.test.cache.jbc.entity; - -import java.util.Properties; - -import org.hibernate.cache.CacheDataDescription; -import org.hibernate.cache.CacheException; -import org.hibernate.cache.EntityRegion; -import org.hibernate.cache.Region; -import org.hibernate.cache.RegionFactory; -import org.hibernate.cache.access.AccessType; -import org.hibernate.cache.jbc.BasicRegionAdapter; -import org.hibernate.cache.jbc.CacheInstanceManager; -import org.hibernate.cache.jbc.JBossCacheRegionFactory; -import org.hibernate.cache.jbc.entity.EntityRegionImpl; -import org.hibernate.test.cache.jbc.AbstractEntityCollectionRegionTestCase; -import org.jboss.cache.Cache; -import org.jboss.cache.Fqn; - -/** - * Tests of EntityRegionImpl. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class EntityRegionImplTestCase extends AbstractEntityCollectionRegionTestCase { - - /** - * Create a new EntityRegionImplTestCase. - * - * @param name - */ - public EntityRegionImplTestCase(String name) { - super(name); - } - - @Override - protected void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties) { - - EntityRegion region = regionFactory.buildEntityRegion("test", properties, null); - - assertNull("Got TRANSACTIONAL", region.buildAccessStrategy(AccessType.TRANSACTIONAL).lockRegion()); - - try - { - region.buildAccessStrategy(AccessType.READ_ONLY).lockRegion(); - fail("Did not get READ_ONLY"); - } - catch (UnsupportedOperationException good) {} - - try - { - region.buildAccessStrategy(AccessType.NONSTRICT_READ_WRITE); - fail("Incorrectly got NONSTRICT_READ_WRITE"); - } - catch (CacheException good) {} - - try - { - region.buildAccessStrategy(AccessType.READ_WRITE); - fail("Incorrectly got READ_WRITE"); - } - catch (CacheException good) {} - - } - - @Override - protected Region createRegion(JBossCacheRegionFactory regionFactory, String regionName, Properties properties, CacheDataDescription cdd) { - return regionFactory.buildEntityRegion(regionName, properties, cdd); - } - - @Override - protected Cache getJBossCache(JBossCacheRegionFactory regionFactory) { - CacheInstanceManager mgr = regionFactory.getCacheInstanceManager(); - return mgr.getEntityCacheInstance(); - } - - @Override - protected Fqn getRegionFqn(String regionName, String regionPrefix) { - return BasicRegionAdapter.getTypeLastRegionFqn(regionName, regionPrefix, EntityRegionImpl.TYPE); - } - - @Override - protected void putInRegion(Region region, Object key, Object value) { - ((EntityRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).insert(key, value, new Integer(1)); - } - - @Override - protected void removeFromRegion(Region region, Object key) { - ((EntityRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).remove(key); - } - - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccInvalidatedTransactionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccInvalidatedTransactionalTestCase.java deleted file mode 100644 index 42745215e1..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccInvalidatedTransactionalTestCase.java +++ /dev/null @@ -1,68 +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.test.cache.jbc.entity; - -import org.hibernate.test.util.CacheTestUtil; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests TRANSACTIONAL access when MVCC locking and invalidation are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class MvccInvalidatedTransactionalTestCase extends AbstractTransactionalAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public MvccInvalidatedTransactionalTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - TestSuite suite = CacheTestUtil.createFailureExpectedSuite(MvccInvalidatedTransactionalTestCase.class); - return getTestSetup(suite, "mvcc-entity"); - } - - // Known failures - - // Overrides - - @Override - public void testCacheConfiguration() { - assertTrue("Using Invalidation", isUsingInvalidation()); - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - - @Override - public boolean isBlockingReads() { - return false; - } -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccReadOnlyExtraAPITestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccReadOnlyExtraAPITestCase.java deleted file mode 100644 index ce42deff21..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccReadOnlyExtraAPITestCase.java +++ /dev/null @@ -1,71 +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.test.cache.jbc.entity; - -import org.hibernate.cache.access.EntityRegionAccessStrategy; - -/** - * Tests for the "extra API" in EntityRegionAccessStrategy; in this - * version using pessimistic locking with READ_ONLY access. - *
- * By "extra API" we mean those methods that are superfluous to the - * function of the JBC integration, where the impl is a no-op or a static - * false return value, UnsupportedOperationException, etc. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class MvccReadOnlyExtraAPITestCase extends OptimisticReadOnlyExtraAPITestCase { - - private static EntityRegionAccessStrategy localAccessStrategy; - - /** - * Create a new PessimisticAccessStrategyExtraAPITestCase. - * - * @param name - */ - public MvccReadOnlyExtraAPITestCase(String name) { - super(name); - } - - @Override - protected String getCacheConfigName() { - return "mvcc-entity"; - } - - @Override - protected EntityRegionAccessStrategy getEntityAccessStrategy() { - return localAccessStrategy; - } - - @Override - protected void setEntityRegionAccessStrategy(EntityRegionAccessStrategy strategy) { - localAccessStrategy = strategy; - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - } -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccReadOnlyTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccReadOnlyTestCase.java deleted file mode 100644 index 5a19655d9f..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccReadOnlyTestCase.java +++ /dev/null @@ -1,68 +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.test.cache.jbc.entity; - -import org.hibernate.test.util.CacheTestUtil; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests READ_ONLY access when pessimistic locking and invalidation are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class MvccReadOnlyTestCase extends AbstractReadOnlyAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public MvccReadOnlyTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - TestSuite suite = CacheTestUtil.createFailureExpectedSuite(MvccReadOnlyTestCase.class); - return getTestSetup(suite, "mvcc-entity"); - } - - // Known failures - - // Overrides - - - @Override - public void testCacheConfiguration() { - assertTrue("Using Invalidation", isUsingInvalidation()); - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - } - - @Override - public boolean isBlockingReads() { - return false; - } -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccReplicatedTransactionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccReplicatedTransactionalTestCase.java deleted file mode 100644 index 050c919d27..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccReplicatedTransactionalTestCase.java +++ /dev/null @@ -1,62 +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.test.cache.jbc.entity; - -import junit.framework.Test; - -/** - * Tests TRANSACTIONAL access when pessimistic locking and replication are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class MvccReplicatedTransactionalTestCase extends AbstractTransactionalAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public MvccReplicatedTransactionalTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - return getTestSetup(MvccReplicatedTransactionalTestCase.class, "mvcc-shared"); - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Invalidation", isUsingInvalidation()); - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - - @Override - public boolean isBlockingReads() { - return false; - } - - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccTransactionalExtraAPITestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccTransactionalExtraAPITestCase.java deleted file mode 100644 index a67b190e67..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/MvccTransactionalExtraAPITestCase.java +++ /dev/null @@ -1,71 +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.test.cache.jbc.entity; - -import org.hibernate.cache.access.EntityRegionAccessStrategy; - -/** - * Tests for the "extra API" in EntityRegionAccessStrategy; in this base - * version using Optimistic locking with TRANSACTIONAL access. - *
- * By "extra API" we mean those methods that are superfluous to the - * function of the JBC integration, where the impl is a no-op or a static - * false return value, UnsupportedOperationException, etc. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class MvccTransactionalExtraAPITestCase extends OptimisticTransactionalExtraAPITestCase { - - private static EntityRegionAccessStrategy localAccessStrategy; - - /** - * Create a new PessimisticAccessStrategyExtraAPITestCase. - * - * @param name - */ - public MvccTransactionalExtraAPITestCase(String name) { - super(name); - } - - @Override - protected String getCacheConfigName() { - return "mvcc-entity"; - } - - @Override - protected EntityRegionAccessStrategy getEntityAccessStrategy() { - return localAccessStrategy; - } - - @Override - protected void setEntityRegionAccessStrategy(EntityRegionAccessStrategy strategy) { - localAccessStrategy = strategy; - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - } -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticInvalidatedTransactionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticInvalidatedTransactionalTestCase.java deleted file mode 100644 index cc4067f04a..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticInvalidatedTransactionalTestCase.java +++ /dev/null @@ -1,60 +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.test.cache.jbc.entity; - -import org.hibernate.test.util.CacheTestUtil; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests TRANSACTIONAL access when optimistic locking and invalidation are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class OptimisticInvalidatedTransactionalTestCase extends AbstractTransactionalAccessTestCase { - - /** - * Create a new OptimisticInvalidatedTransactionalTestCase. - * - * @param name - */ - public OptimisticInvalidatedTransactionalTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - TestSuite suite = CacheTestUtil.createFailureExpectedSuite(OptimisticInvalidatedTransactionalTestCase.class); - return getTestSetup(suite, "optimistic-entity"); - } - - @Override - public void testCacheConfiguration() { - assertTrue("Using Invalidation", isUsingInvalidation()); - assertTrue("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticReadOnlyExtraAPITestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticReadOnlyExtraAPITestCase.java deleted file mode 100644 index c17f21e07c..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticReadOnlyExtraAPITestCase.java +++ /dev/null @@ -1,105 +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.test.cache.jbc.entity; - -import org.hibernate.cache.access.AccessType; -import org.hibernate.cache.access.EntityRegionAccessStrategy; -import org.hibernate.cache.jbc.entity.TransactionalAccess; - -/** - * Tests for the "extra API" in EntityRegionAccessStrategy; in this - * version using Optimistic locking with READ_ONLY access. - *
- * By "extra API" we mean those methods that are superfluous to the - * function of the JBC integration, where the impl is a no-op or a static - * false return value, UnsupportedOperationException, etc. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class OptimisticReadOnlyExtraAPITestCase extends OptimisticTransactionalExtraAPITestCase { - - private static EntityRegionAccessStrategy localAccessStrategy; - - /** - * Create a new TransactionalAccessTestCase. - * - * @param name - */ - public OptimisticReadOnlyExtraAPITestCase(String name) { - super(name); - } - - @Override - protected AccessType getAccessType() { - return AccessType.READ_ONLY; - } - - @Override - protected EntityRegionAccessStrategy getEntityAccessStrategy() { - return localAccessStrategy; - } - - @Override - protected void setEntityRegionAccessStrategy(EntityRegionAccessStrategy strategy) { - localAccessStrategy = strategy; - } - - /** - * Test method for {@link TransactionalAccess#lockItem(java.lang.Object, java.lang.Object)}. - */ - @Override - public void testLockItem() { - try { - getEntityAccessStrategy().lockItem(KEY, new Integer(1)); - fail("Call to lockItem did not throw exception"); - } - catch (UnsupportedOperationException expected) {} - } - - /** - * Test method for {@link TransactionalAccess#lockRegion()}. - */ - @Override - public void testLockRegion() { - try { - getEntityAccessStrategy().lockRegion(); - fail("Call to lockRegion did not throw exception"); - } - catch (UnsupportedOperationException expected) {} - } - - /** - * Test method for {@link TransactionalAccess#afterUpdate(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, org.hibernate.cache.access.SoftLock)}. - */ - @Override - public void testAfterUpdate() { - try { - getEntityAccessStrategy().afterUpdate(KEY, VALUE2, new Integer(1), new Integer(2), new MockSoftLock()); - fail("Call to afterUpdate did not throw exception"); - } - catch (UnsupportedOperationException expected) {} - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticReadOnlyTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticReadOnlyTestCase.java deleted file mode 100644 index e786a2eec7..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticReadOnlyTestCase.java +++ /dev/null @@ -1,60 +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.test.cache.jbc.entity; - -import org.hibernate.test.util.CacheTestUtil; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests READ_ONLY access when optimistic locking and invalidation are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class OptimisticReadOnlyTestCase extends AbstractReadOnlyAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public OptimisticReadOnlyTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - TestSuite suite = CacheTestUtil.createFailureExpectedSuite(OptimisticReadOnlyTestCase.class); - return getTestSetup(suite, "optimistic-entity"); - } - - @Override - public void testCacheConfiguration() { - assertTrue("Using Invalidation", isUsingInvalidation()); - assertTrue("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticReplicatedTransactionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticReplicatedTransactionalTestCase.java deleted file mode 100644 index 4ca61bd983..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticReplicatedTransactionalTestCase.java +++ /dev/null @@ -1,58 +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.test.cache.jbc.entity; - -import junit.framework.Test; - -/** - * Tests TRANSACTIONAL access when optimistic locking and replication are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class OptimisticReplicatedTransactionalTestCase extends AbstractTransactionalAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public OptimisticReplicatedTransactionalTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - return getTestSetup(OptimisticReplicatedTransactionalTestCase.class, "optimistic-shared"); - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Invalidation", isUsingInvalidation()); - assertTrue("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - - - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticTransactionalExtraAPITestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticTransactionalExtraAPITestCase.java deleted file mode 100644 index 07ff676434..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/OptimisticTransactionalExtraAPITestCase.java +++ /dev/null @@ -1,172 +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.test.cache.jbc.entity; - -import org.hibernate.cache.EntityRegion; -import org.hibernate.cache.access.AccessType; -import org.hibernate.cache.access.EntityRegionAccessStrategy; -import org.hibernate.cache.access.SoftLock; -import org.hibernate.cache.jbc.JBossCacheRegionFactory; -import org.hibernate.cache.jbc.MultiplexedJBossCacheRegionFactory; -import org.hibernate.cache.jbc.builder.MultiplexingCacheInstanceManager; -import org.hibernate.cache.jbc.entity.TransactionalAccess; -import org.hibernate.cfg.Configuration; -import org.hibernate.test.cache.jbc.AbstractJBossCacheTestCase; -import org.hibernate.test.util.CacheTestUtil; -import org.jboss.cache.Cache; - -/** - * Tests for the "extra API" in EntityRegionAccessStrategy; in this base - * version using Optimistic locking with TRANSACTIONAL access. - *
- * By "extra API" we mean those methods that are superfluous to the - * function of the JBC integration, where the impl is a no-op or a static - * false return value, UnsupportedOperationException, etc. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class OptimisticTransactionalExtraAPITestCase extends AbstractJBossCacheTestCase { - - public static final String REGION_NAME = "test/com.foo.test"; - public static final String KEY = "KEY"; - public static final String VALUE1 = "VALUE1"; - public static final String VALUE2 = "VALUE2"; - - private static EntityRegionAccessStrategy localAccessStrategy; - - private static boolean optimistic; - - /** - * Create a new TransactionalAccessTestCase. - * - * @param name - */ - public OptimisticTransactionalExtraAPITestCase(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - - if (getEntityAccessStrategy() == null) { - Configuration cfg = createConfiguration(); - JBossCacheRegionFactory rf = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport()); - Cache localCache = rf.getCacheInstanceManager().getEntityCacheInstance(); - optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC; - - // Sleep a bit to avoid concurrent FLUSH problem - avoidConcurrentFlush(); - - EntityRegion localEntityRegion = rf.buildEntityRegion(REGION_NAME, cfg.getProperties(), null); - setEntityRegionAccessStrategy(localEntityRegion.buildAccessStrategy(getAccessType())); - } - } - - protected void tearDown() throws Exception { - - super.tearDown(); - } - - protected Configuration createConfiguration() { - Configuration cfg = CacheTestUtil.buildConfiguration(REGION_PREFIX, MultiplexedJBossCacheRegionFactory.class, true, false); - cfg.setProperty(MultiplexingCacheInstanceManager.ENTITY_CACHE_RESOURCE_PROP, getCacheConfigName()); - return cfg; - } - - protected String getCacheConfigName() { - return "optimistic-entity"; - } - - protected boolean isUsingOptimisticLocking() { - return optimistic; - } - - protected AccessType getAccessType() { - return AccessType.TRANSACTIONAL; - } - - protected EntityRegionAccessStrategy getEntityAccessStrategy() { - return localAccessStrategy; - } - - protected void setEntityRegionAccessStrategy(EntityRegionAccessStrategy strategy) { - localAccessStrategy = strategy; - } - - /** - * This is just a setup test where we assert that the cache config is - * as we expected. - */ - public void testCacheConfiguration() { - assertTrue("Using Optimistic locking", isUsingOptimisticLocking()); - } - - /** - * Test method for {@link TransactionalAccess#lockItem(java.lang.Object, java.lang.Object)}. - */ - public void testLockItem() { - assertNull(getEntityAccessStrategy().lockItem(KEY, new Integer(1))); - } - - /** - * Test method for {@link TransactionalAccess#lockRegion()}. - */ - public void testLockRegion() { - assertNull(getEntityAccessStrategy().lockRegion()); - } - - /** - * Test method for {@link TransactionalAccess#unlockItem(java.lang.Object, org.hibernate.cache.access.SoftLock)}. - */ - public void testUnlockItem() { - getEntityAccessStrategy().unlockItem(KEY, new MockSoftLock()); - } - - /** - * Test method for {@link TransactionalAccess#unlockRegion(org.hibernate.cache.access.SoftLock)}. - */ - public void testUnlockRegion() { - getEntityAccessStrategy().unlockItem(KEY, new MockSoftLock()); - } - - /** - * Test method for {@link TransactionalAccess#afterInsert(java.lang.Object, java.lang.Object, java.lang.Object)}. - */ - public void testAfterInsert() { - assertFalse("afterInsert always returns false", getEntityAccessStrategy().afterInsert(KEY, VALUE1, new Integer(1))); - } - - /** - * Test method for {@link TransactionalAccess#afterUpdate(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, org.hibernate.cache.access.SoftLock)}. - */ - public void testAfterUpdate() { - assertFalse("afterInsert always returns false", getEntityAccessStrategy().afterUpdate(KEY, VALUE2, new Integer(1), new Integer(2), new MockSoftLock())); - } - - public static class MockSoftLock implements SoftLock { - - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticInvalidatedTransactionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticInvalidatedTransactionalTestCase.java deleted file mode 100644 index b80cbd3b87..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticInvalidatedTransactionalTestCase.java +++ /dev/null @@ -1,64 +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.test.cache.jbc.entity; - -import org.hibernate.test.util.CacheTestUtil; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests TRANSACTIONAL access when pessimistic locking and invalidation are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class PessimisticInvalidatedTransactionalTestCase extends AbstractTransactionalAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public PessimisticInvalidatedTransactionalTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - TestSuite suite = CacheTestUtil.createFailureExpectedSuite(PessimisticInvalidatedTransactionalTestCase.class); - return getTestSetup(suite, "pessimistic-entity"); - } - - // Known failures - - // Overrides - - @Override - public void testCacheConfiguration() { - assertTrue("Using Invalidation", isUsingInvalidation()); - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticReadOnlyExtraAPITestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticReadOnlyExtraAPITestCase.java deleted file mode 100644 index 5dafc5976c..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticReadOnlyExtraAPITestCase.java +++ /dev/null @@ -1,72 +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.test.cache.jbc.entity; - -import org.hibernate.cache.access.EntityRegionAccessStrategy; - -/** - * Tests for the "extra API" in EntityRegionAccessStrategy; in this - * version using pessimistic locking with READ_ONLY access. - *
- * By "extra API" we mean those methods that are superfluous to the - * function of the JBC integration, where the impl is a no-op or a static - * false return value, UnsupportedOperationException, etc. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class PessimisticReadOnlyExtraAPITestCase extends OptimisticReadOnlyExtraAPITestCase { - - private static EntityRegionAccessStrategy localAccessStrategy; - - /** - * Create a new PessimisticAccessStrategyExtraAPITestCase. - * - * @param name - */ - public PessimisticReadOnlyExtraAPITestCase(String name) { - super(name); - } - - @Override - protected String getCacheConfigName() { - return "pessimistic-entity"; - } - - @Override - protected EntityRegionAccessStrategy getEntityAccessStrategy() { - return localAccessStrategy; - } - - @Override - protected void setEntityRegionAccessStrategy(EntityRegionAccessStrategy strategy) { - localAccessStrategy = strategy; - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - } - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticReadOnlyTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticReadOnlyTestCase.java deleted file mode 100644 index 6e16d70c5e..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticReadOnlyTestCase.java +++ /dev/null @@ -1,65 +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.test.cache.jbc.entity; - -import org.hibernate.test.util.CacheTestUtil; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests READ_ONLY access when pessimistic locking and invalidation are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class PessimisticReadOnlyTestCase extends AbstractReadOnlyAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public PessimisticReadOnlyTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - TestSuite suite = CacheTestUtil.createFailureExpectedSuite(PessimisticReadOnlyTestCase.class); - return getTestSetup(suite, "pessimistic-entity"); - } - - // Known failures - - // Overrides - - - @Override - public void testCacheConfiguration() { - assertTrue("Using Invalidation", isUsingInvalidation()); - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - } - - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticReplicatedTransactionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticReplicatedTransactionalTestCase.java deleted file mode 100644 index e609779cf4..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticReplicatedTransactionalTestCase.java +++ /dev/null @@ -1,58 +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.test.cache.jbc.entity; - -import junit.framework.Test; - -/** - * Tests TRANSACTIONAL access when pessimistic locking and replication are used. - * - * @author Brian Stansberry - * @version $Revision: 1 $ - */ -public class PessimisticReplicatedTransactionalTestCase extends AbstractTransactionalAccessTestCase { - - /** - * Create a new PessimisticTransactionalAccessTestCase. - * - * @param name - */ - public PessimisticReplicatedTransactionalTestCase(String name) { - super(name); - } - - public static Test suite() throws Exception { - return getTestSetup(PessimisticReplicatedTransactionalTestCase.class, "pessimistic-shared"); - } - - @Override - public void testCacheConfiguration() { - assertFalse("Using Invalidation", isUsingInvalidation()); - assertFalse("Using Optimistic locking", isUsingOptimisticLocking()); - assertTrue("Synchronous mode", isSynchronous()); - } - - - -} diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticTransactionalExtraAPITestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticTransactionalExtraAPITestCase.java deleted file mode 100644 index 5693179780..0000000000 --- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/PessimisticTransactionalExtraAPITestCase.java +++ /dev/null @@ -1,72 +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.test.cache.jbc.entity; - -import org.hibernate.cache.access.EntityRegionAccessStrategy; - -/** - * Tests for the "extra API" in EntityRegionAccessStrategy; in this base - * version using Optimistic locking with TRANSACTIONAL access. - *
- * By "extra API" we mean those methods that are superfluous to the
- * function of the JBC integration, where the impl is a no-op or a static
- * false return value, UnsupportedOperationException, etc.
- *
- * @author Brian Stansberry
- * @version $Revision: 1 $
- */
-public class PessimisticTransactionalExtraAPITestCase extends OptimisticTransactionalExtraAPITestCase {
-
- private static EntityRegionAccessStrategy localAccessStrategy;
-
- /**
- * Create a new PessimisticAccessStrategyExtraAPITestCase.
- *
- * @param name
- */
- public PessimisticTransactionalExtraAPITestCase(String name) {
- super(name);
- }
-
- @Override
- protected String getCacheConfigName() {
- return "pessimistic-entity";
- }
-
- @Override
- protected EntityRegionAccessStrategy getEntityAccessStrategy() {
- return localAccessStrategy;
- }
-
- @Override
- protected void setEntityRegionAccessStrategy(EntityRegionAccessStrategy strategy) {
- localAccessStrategy = strategy;
- }
-
- @Override
- public void testCacheConfiguration() {
- assertFalse("Using Optimistic locking", isUsingOptimisticLocking());
- }
-
-}
diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/AbstractEntityCacheFunctionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/AbstractEntityCacheFunctionalTestCase.java
deleted file mode 100644
index 62cd713d7a..0000000000
--- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/AbstractEntityCacheFunctionalTestCase.java
+++ /dev/null
@@ -1,126 +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.test.cache.jbc.functional;
-
-import java.util.Map;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cache.ReadWriteCache;
-import org.hibernate.stat.SecondLevelCacheStatistics;
-import org.hibernate.stat.Statistics;
-
-/**
- * Common requirement entity caching testing for each
- * {@link org.hibernate.cache.RegionFactory} impl.
- *
- * @author Steve Ebersole
- */
-public abstract class AbstractEntityCacheFunctionalTestCase extends CacheTestCaseBase {
-
- // note that a lot of the functionality here is intended to be used
- // in creating specific tests for each CacheProvider that would extend
- // from a base test case (this) for common requirement testing...
-
- public AbstractEntityCacheFunctionalTestCase(String x) {
- super(x);
- }
-
- @Override
- protected boolean getUseQueryCache() {
- return false;
- }
-
- public void testEmptySecondLevelCacheEntry() throws Exception {
- getSessions().evictEntity(Item.class.getName());
- Statistics stats = getSessions().getStatistics();
- stats.clear();
- SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics(getPrefixedRegionName(Item.class.getName()));
- Map cacheEntries = statistics.getEntries();
- assertEquals(0, cacheEntries.size());
- }
-
- public void testStaleWritesLeaveCacheConsistent() {
- Session s = openSession();
- Transaction txn = s.beginTransaction();
- VersionedItem item = new VersionedItem();
- item.setName("steve");
- item.setDescription("steve's item");
- s.save(item);
- txn.commit();
- s.close();
-
- Long initialVersion = item.getVersion();
-
- // manually revert the version property
- item.setVersion(new Long(item.getVersion().longValue() - 1));
-
- try {
- s = openSession();
- txn = s.beginTransaction();
- s.update(item);
- txn.commit();
- s.close();
- fail("expected stale write to fail");
- } catch (Throwable expected) {
- // expected behavior here
- if (txn != null) {
- try {
- txn.rollback();
- } catch (Throwable ignore) {
- }
- }
- } finally {
- if (s != null && s.isOpen()) {
- try {
- s.close();
- } catch (Throwable ignore) {
- }
- }
- }
-
- // check the version value in the cache...
- SecondLevelCacheStatistics slcs = sfi().getStatistics().getSecondLevelCacheStatistics(
- getPrefixedRegionName(VersionedItem.class.getName()));
-
- Object entry = slcs.getEntries().get(item.getId());
- Long cachedVersionValue;
- if (entry instanceof ReadWriteCache.Lock) {
- // FIXME don't know what to test here
- cachedVersionValue = new Long(((ReadWriteCache.Lock) entry).getUnlockTimestamp());
- } else {
- cachedVersionValue = (Long) ((Map) entry).get("_version");
- assertEquals(initialVersion.longValue(), cachedVersionValue.longValue());
- }
-
- // cleanup
- s = openSession();
- txn = s.beginTransaction();
- item = (VersionedItem) s.load(VersionedItem.class, item.getId());
- s.delete(item);
- txn.commit();
- s.close();
-
- }
-}
diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/AbstractQueryCacheFunctionalTestCase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/AbstractQueryCacheFunctionalTestCase.java
deleted file mode 100755
index 7fc871e39e..0000000000
--- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/AbstractQueryCacheFunctionalTestCase.java
+++ /dev/null
@@ -1,104 +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.test.cache.jbc.functional;
-
-import java.util.Map;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cache.ReadWriteCache;
-import org.hibernate.stat.SecondLevelCacheStatistics;
-
-/**
- * A QueryCacheEnabledCacheProviderTestCase.
- *
- * @author Brian Stansberry
- * @version $Revision: 1 $
- */
-public abstract class AbstractQueryCacheFunctionalTestCase extends AbstractEntityCacheFunctionalTestCase {
-
- /**
- * Create a new QueryCacheEnabledCacheProviderTestCase.
- *
- * @param x
- */
- public AbstractQueryCacheFunctionalTestCase(String x) {
- super(x);
- }
-
- @Override
- protected boolean getUseQueryCache() {
- return true;
- }
-
- public void testQueryCacheInvalidation() {
- Session s = openSession();
- Transaction t = s.beginTransaction();
- Item i = new Item();
- i.setName("widget");
- i.setDescription("A really top-quality, full-featured widget.");
- s.persist(i);
- t.commit();
- s.close();
-
- SecondLevelCacheStatistics slcs = s.getSessionFactory().getStatistics().getSecondLevelCacheStatistics(
- getPrefixedRegionName(Item.class.getName()));
-
- assertEquals(slcs.getPutCount(), 1);
- assertEquals(slcs.getElementCountInMemory(), 1);
- assertEquals(slcs.getEntries().size(), 1);
-
- s = openSession();
- t = s.beginTransaction();
- i = (Item) s.get(Item.class, i.getId());
-
- assertEquals(slcs.getHitCount(), 1);
- assertEquals(slcs.getMissCount(), 0);
-
- i.setDescription("A bog standard item");
-
- t.commit();
- s.close();
-
- assertEquals(slcs.getPutCount(), 2);
-
- Object entry = slcs.getEntries().get(i.getId());
- Map map;
- if (entry instanceof ReadWriteCache.Item) {
- map = (Map) ((ReadWriteCache.Item) entry).getValue();
- } else {
- map = (Map) entry;
- }
- assertTrue(map.get("description").equals("A bog standard item"));
- assertTrue(map.get("name").equals("widget"));
-
- // cleanup
- s = openSession();
- t = s.beginTransaction();
- s.delete(i);
- t.commit();
- s.close();
- }
-
-}
diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/CacheTestCaseBase.java b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/CacheTestCaseBase.java
deleted file mode 100755
index d9313effbd..0000000000
--- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/CacheTestCaseBase.java
+++ /dev/null
@@ -1,160 +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.test.cache.jbc.functional;
-
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.cfg.Mappings;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.testing.junit.functional.FunctionalTestCase;
-import org.hibernate.testing.tm.ConnectionProviderImpl;
-import org.hibernate.testing.tm.TransactionManagerLookupImpl;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Provides common configuration setups for cache testing.
- *
- * @author Brian Stansberry
- */
-public abstract class CacheTestCaseBase extends FunctionalTestCase {
-
- private static final Logger log = LoggerFactory.getLogger( CacheTestCaseBase.class );
-
- private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack";
-
- private String preferIPv4Stack;
-
- // note that a lot of the functionality here is intended to be used
- // in creating specific tests for each CacheProvider that would extend
- // from a base test case (this) for common requirement testing...
-
- public CacheTestCaseBase(String x) {
- super(x);
- }
-
- public String[] getMappings() {
- return new String[] {
- "cache/jbc/functional/Item.hbm.xml",
- "cache/jbc/functional/Customer.hbm.xml",
- "cache/jbc/functional/Contact.hbm.xml"
- };
- }
-
- public void configure(Configuration cfg) {
- super.configure(cfg);
-
- if (getRegionPrefix() != null) {
- cfg.setProperty(Environment.CACHE_REGION_PREFIX, getRegionPrefix());
- }
-
- cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
- cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
- cfg.setProperty(Environment.USE_STRUCTURED_CACHE, "true");
- cfg.setProperty(Environment.CACHE_REGION_FACTORY, getCacheRegionFactory().getName());
-
- cfg.setProperty(Environment.USE_QUERY_CACHE, String.valueOf(getUseQueryCache()));
- cfg.setProperty(Environment.CONNECTION_PROVIDER, getConnectionProviderClass().getName());
- cfg.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, getTransactionManagerLookupClass().getName());
-
- Class> transactionFactory = getTransactionFactoryClass();
- if (transactionFactory != null)
- cfg.setProperty( Environment.TRANSACTION_STRATEGY, transactionFactory.getName() );
-
- configureCacheFactory(cfg);
- }
-
- protected String getRegionPrefix() {
- return "test";
- }
-
- protected String getPrefixedRegionName(String regionName)
- {
- String prefix = getRegionPrefix() == null ? "" : getRegionPrefix() + ".";
- return prefix + regionName;
- }
-
- public String getCacheConcurrencyStrategy() {
- return "transactional";
- }
-
- /**
- * Apply any region-factory specific configurations.
- *
- * @param cfg the Configuration to update.
- */
- protected abstract void configureCacheFactory(Configuration cfg);
-
- protected abstract Class> getCacheRegionFactory();
-
- protected abstract boolean getUseQueryCache();
-
- protected Class> getConnectionProviderClass() {
- return ConnectionProviderImpl.class;
- }
-
- protected Class> getTransactionManagerLookupClass() {
- return TransactionManagerLookupImpl.class;
- }
-
- protected Class> getTransactionFactoryClass() {
- return null;
- }
-
- @Override
- public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
-
- super.afterConfigurationBuilt(mappings, dialect);
-
- // Try to ensure we use IPv4; otherwise cluster formation is very slow
- preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
- System.setProperty(PREFER_IPV4STACK, "true");
- }
-
- @Override
- protected void cleanupTest() throws Exception {
- try {
- super.cleanupTest();
- }
- finally {
- if (preferIPv4Stack == null)
- System.clearProperty(PREFER_IPV4STACK);
- else
- System.setProperty(PREFER_IPV4STACK, preferIPv4Stack);
- }
-
- }
-
- protected void sleep(long ms) {
- try {
- Thread.sleep(ms);
- }
- catch (InterruptedException e) {
- log.warn("Interrupted during sleep", e);
- }
- }
-
-
-}
diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/Contact.hbm.xml b/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/Contact.hbm.xml
deleted file mode 100755
index c32a30c6d5..0000000000
--- a/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/functional/Contact.hbm.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
- * This version lets a test fixture to access {@link CacheManager},
- * making it easy for the test fixture to get access to the caches being
- * used. Intended for FunctionalUnitTestCase subclasses where the creation
- * of the region factory is hidden inside the initialization of a SessionFactory.
- *
- * This class is intended to allow emulation of 2 different types of common J2EE
- * classloading situations.
- *
- *
- *
- * This class can also be configured to raise a ClassNotFoundException if - * asked to load certain classes, thus allowing classes on the classpath - * to be hidden from a test environment. - *
- * - * @author Brian Stansberry - */ -public class SelectedClassnameClassLoader extends ClassLoader -{ - private Logger log = LoggerFactory.getLogger(SelectedClassnameClassLoader.class); - - private String[] includedClasses = null; - private String[] excludedClasses = null; - private String[] notFoundClasses = null; - - private MapexcludedClasses
.
- * Can be null
- * @param excludedClasses array of class or package names that should NOT
- * be directly loaded by this loader. Loading of
- * classes whose name starts with any of the
- * strings in this array will be delegated to
- * parent
, even if the classes
- * package or classname appears in
- * includedClasses
. Typically this
- * parameter is used to exclude loading one or
- * more classes in a package whose other classes
- * are loaded by this object.
- * @param parent ClassLoader to which loading of classes should
- * be delegated if necessary
- */
- public SelectedClassnameClassLoader(String[] includedClasses,
- String[] excludedClasses,
- ClassLoader parent)
- {
- this(includedClasses, excludedClasses, null, parent);
- }
-
- /**
- * Creates a new classloader that loads the given classes.
- *
- * @param includedClasses array of class or package names that should be
- * directly loaded by this loader. Classes
- * whose name starts with any of the strings
- * in this array will be loaded by this class,
- * unless their name appears in
- * excludedClasses
.
- * Can be null
- * @param excludedClasses array of class or package names that should NOT
- * be directly loaded by this loader. Loading of
- * classes whose name starts with any of the
- * strings in this array will be delegated to
- * parent
, even if the classes
- * package or classname appears in
- * includedClasses
. Typically this
- * parameter is used to exclude loading one or
- * more classes in a package whose other classes
- * are loaded by this object.
- * @param notFoundClasses array of class or package names for which this
- * should raise a ClassNotFoundException
- * @param parent ClassLoader to which loading of classes should
- * be delegated if necessary
- */
- public SelectedClassnameClassLoader(String[] includedClasses,
- String[] excludedClasses,
- String[] notFoundClasses,
- ClassLoader parent)
- {
- super(parent);
- this.includedClasses = includedClasses;
- this.excludedClasses = excludedClasses;
- this.notFoundClasses = notFoundClasses;
-
- log.debug("created " + this);
- }
-
- protected synchronized Class> loadClass(String name, boolean resolve)
- throws ClassNotFoundException
- {
- log.trace("loadClass(" + name + "," + resolve + ")");
- if (isIncluded(name) && (isExcluded(name) == false))
- {
- Class c = findClass(name);
-
- if (resolve)
- {
- resolveClass(c);
- }
- return c;
- }
- else if (isNotFound(name))
- {
- throw new ClassNotFoundException(name + " is discarded");
- }
- else
- {
- return super.loadClass(name, resolve);
- }
- }
-
- protected Class> findClass(String name) throws ClassNotFoundException
- {
- log.trace("findClass(" + name + ")");
- Class result = classes.get(name);
- if (result != null)
- {
- return result;
- }
-
- if (isIncluded(name) && (isExcluded(name) == false))
- {
- result = createClass(name);
- }
- else if (isNotFound(name))
- {
- throw new ClassNotFoundException(name + " is discarded");
- }
- else
- {
- result = super.findClass(name);
- }
-
- classes.put(name, result);
-
- return result;
- }
-
- protected Class createClass(String name) throws ClassFormatError, ClassNotFoundException
- {
- log.info("createClass(" + name + ")");
- try
- {
- InputStream is = getResourceAsStream(name.replace('.', '/').concat(".class"));
- byte[] bytes = new byte[1024];
- ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
- int read;
- while ((read = is.read(bytes)) > -1)
- {
- baos.write(bytes, 0, read);
- }
- bytes = baos.toByteArray();
- return this.defineClass(name, bytes, 0, bytes.length);
- }
- catch (FileNotFoundException e)
- {
- throw new ClassNotFoundException("cannot find " + name, e);
- }
- catch (IOException e)
- {
- throw new ClassNotFoundException("cannot read " + name, e);
- }
- }
-
- protected boolean isIncluded(String className)
- {
-
- if (includedClasses != null)
- {
- for (int i = 0; i < includedClasses.length; i++)
- {
- if (className.startsWith(includedClasses[i]))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- protected boolean isExcluded(String className)
- {
-
- if (excludedClasses != null)
- {
- for (int i = 0; i < excludedClasses.length; i++)
- {
- if (className.startsWith(excludedClasses[i]))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- protected boolean isNotFound(String className)
- {
-
- if (notFoundClasses != null)
- {
- for (int i = 0; i < notFoundClasses.length; i++)
- {
- if (className.startsWith(notFoundClasses[i]))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public String toString() {
- String s = getClass().getName();
- s += "[includedClasses=";
- s += listClasses(includedClasses);
- s += ";excludedClasses=";
- s += listClasses(excludedClasses);
- s += ";notFoundClasses=";
- s += listClasses(notFoundClasses);
- s += ";parent=";
- s += getParent();
- s += "]";
- return s;
- }
-
- private static String listClasses(String[] classes) {
- if (classes == null) return null;
- String s = "";
- for (int i = 0; i < classes.length; i++) {
- if (i > 0)
- s += ",";
- s += classes[i];
- }
- return s;
- }
-
-}
diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/util/SelectedClassnameClassLoaderTestSetup.java b/cache-jbosscache/src/test/java/org/hibernate/test/util/SelectedClassnameClassLoaderTestSetup.java
deleted file mode 100644
index 216bea16fc..0000000000
--- a/cache-jbosscache/src/test/java/org/hibernate/test/util/SelectedClassnameClassLoaderTestSetup.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
- *
- * 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, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Brian Stansberry
- */
-
-package org.hibernate.test.util;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-
-/**
- * A TestSetup that makes SelectedClassnameClassLoader the thread
- * context classloader for the duration of the test.
- *
- * @author Brian Stansberry
- * @version $Revision: 1 $
- */
-public class SelectedClassnameClassLoaderTestSetup extends TestSetup
-{
- private ClassLoader originalTCCL;
- private String[] includedClasses;
- private String[] excludedClasses;
- private String[] notFoundClasses;
-
-
- /**
- * Create a new SelectedClassnameClassLoaderTestSetup.
- *
- * @param test
- */
- public SelectedClassnameClassLoaderTestSetup(Test test,
- String[] includedClasses,
- String[] excludedClasses,
- String[] notFoundClasses)
- {
- super(test);
- this.includedClasses = includedClasses;
- this.excludedClasses = excludedClasses;
- this.notFoundClasses = notFoundClasses;
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- originalTCCL = Thread.currentThread().getContextClassLoader();
- ClassLoader parent = originalTCCL == null ? getClass().getClassLoader() : originalTCCL;
- ClassLoader selectedTCCL = new SelectedClassnameClassLoader(includedClasses, excludedClasses, notFoundClasses, parent);
- Thread.currentThread().setContextClassLoader(selectedTCCL);
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- Thread.currentThread().setContextClassLoader(originalTCCL);
- super.tearDown();
- }
-
-
-
-}
diff --git a/cache-jbosscache/src/test/java/org/hibernate/test/util/optimistic-local-cache.xml b/cache-jbosscache/src/test/java/org/hibernate/test/util/optimistic-local-cache.xml
deleted file mode 100755
index 745f67db20..0000000000
--- a/cache-jbosscache/src/test/java/org/hibernate/test/util/optimistic-local-cache.xml
+++ /dev/null
@@ -1,160 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-S
zrC07@hNI8xD^AB~Gw<)6F|_+W=Tl~U3!+4B_gHss$l`Ae!mJ6q52B1@+}$oKjA!uh
zv7b|MXWPN-8r}Wg^!rAggregated Hibernate Core JavaDocs
-
-Hibernate provides both
-
-
-
-Native API
-In addition to {@link org.hibernate.SessionFactory} and {@link org.hibernate.Session}, applications using the
-native API will often need to utilize the following interfaces:
-
-These interfaces are fully intended to be exposed to application code.
-
-
-JPA
-The JPA interfaces are all defined by the JPA specification. For details see {@link javax.persistence}
-
-
-Extensions
-Hibernate defines a number of interfaces that are completely intended to be extendable by application programmers and/or
-integrators. Listed below is a (not necessarily exhaustive) list of the most commonly utilized extension points:
-
-Note that there is a large degree of crossover between the notion of extension points and that of an integration SPI (below).
-
-
-Integration SPI
-Hibernate provides a number of SPIs intended to integrate itself with various third party frameworks or application code to provide
-additional capabilities. The SPIs fall mainly into 2 categories:
-
-Certainly {@link org.hibernate.dialect.Dialect} could fit in here as well, though we chose to list it under extensions since application
-developers tend to provide extended dialects rather frequently for various reasons.
-
-Another SPI that is not yet exposed but is planned for such is the bytecode provider SPI. See {@link org.hibernate.bytecode}
-for details.
-
-
-Complete Hibernate documentation may be found online at http://docs.jboss.org/hibernate/.
-
-
\ No newline at end of file
diff --git a/distribution/src/javadoc/stylesheet.css b/distribution/src/javadoc/stylesheet.css
deleted file mode 100644
index fd51b1a36c..0000000000
--- a/distribution/src/javadoc/stylesheet.css
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat Inc. 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 Inc.
- *
- * 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
- */
-
-/*
- * Custom Hibernate javadoc style sheet
- */
-
-/* Page background color */
-body {
- background: #FFFFFF url(images/bkg_gradient.gif) repeat-x;
- margin:0 auto;
- font-family:'Lucida Grande', Geneva, Verdana, Arial, sans-serif;
- font-size:12px;
- padding:0 2em;
- color:#333;
-
- }
-
-/* Common elements */
-
-font {
- font-family: inherit, sans-serif;
- font-size: inherit;
- color: inherit;
- font-weight: inherit;
-}
-
-hr {
- border-style: none;
- border-bottom: 1px solid #CCCCCC;
-}
-
-/* Links */
-a:link {
- color:#003399;
-}
-a:visited {
- color:#888888;
-}
-a:hover {
- color:#6699cc;
-}
-a:active {
- color: #003399;
-}
-
-/* Headings */
-h1 {
- background: url(images/h1_hdr.png) no-repeat;
- line-height:1.2em;
- color:#586464;
- font-size:2em;
- padding:1.5em;
- margin-top: 0;
- text-align:left;
-}
-
-h2 {
- color:#586464;
-}
-
-
-/* Default Table elements and colors */
-
-th, table {
- border-collapse:collapse;
- border-color: #E6E7E8;
-}
-
-
-.TableHeadingColor {
- background:#000000 url(images/bkg_blkheader.png) repeat-x scroll left top;
- color:#FFFFFF;
- font-size:12px;
- font-weight:bold;
- height:31px;
- text-align:left;
- padding:1.5em;
-}
-
-.TableHeadingColor th {
- padding-left: 10px;
-}
-
-
-.TableSubHeadingColor {
- background: #ebe7d7;
-}
-.TableRowColor {
- background: #FFFFFF;
- border-color: #E6E7E8;
-}
-.TableRowColor td {
- line-height: 175%;
- padding-left: 10px;
-}
-
-/* Font used in left-hand frame lists */
-.FrameTitleFont {
- font-size: 125%;
- font-family: Helvetica, Arial, sans-serif;
- font-weight: bold;
- margin-top: 1em;
- display: block;
-}
-.FrameHeadingFont {
- font-size: 125%;
- font-family: 'Lucida Grande', Geneva, Verdana, Arial, sans-serif;
- font-weight: bold;
- margin-top: 1em;
- display: block;
- color:#586464;
- border-bottom:1px dotted #CCCCCC;
-}
-.FrameItemFont {
- font-size: 100%;
- font-family: Helvetica, Arial, sans-serif
-}
-
-/* Navigation bar fonts and colors */
-
-.NavBarCell1 {
- background: #ffffff url(images/bkgheader.png) repeat-x;
- line-height:3em;
- padding-left:10px;
- padding-right:10px;
-}
-
-.NavBarFont1 {
- color: white;
-}
-.NavBarCell1 a {
- color: white;
-}
-
-.NavBarCell1Rev {
- background-color:#FFFFFF;
- padding-left:6px;
- padding-right:6px;
-}
-.NavBarFont1 {
- color:#FFFFFF;
-}
-.NavBarFont1Rev {
- color:#243446;
-}
-
-.NavBarCell2 {
- background-color:#FFFFFF;
-}
-.NavBarCell3 {
- background-color:#FFFFFF;
-}
diff --git a/distribution/src/site/apt/documentation.apt b/distribution/src/site/apt/documentation.apt
deleted file mode 100644
index a4a58458db..0000000000
--- a/distribution/src/site/apt/documentation.apt
+++ /dev/null
@@ -1,33 +0,0 @@
- ------
- Documentation
- ------
- Steve Ebersole
- ------
- 17 March 2008
- ------
-
-~~ Hibernate, Relational Persistence for Idiomatic Java
-~~
-~~ Copyright (c) 2008, 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
-
-Hibernate Core - Documentation
-
- Coming Soon... intended as a central aggregation of documentation and resource information.
\ No newline at end of file
diff --git a/distribution/src/site/apt/index.apt b/distribution/src/site/apt/index.apt
deleted file mode 100644
index 3ce3b395c2..0000000000
--- a/distribution/src/site/apt/index.apt
+++ /dev/null
@@ -1,59 +0,0 @@
- ------
- Introduction
- ------
- Steve Ebersole
- ------
- 20 July 2007
- ------
-
-~~ Hibernate, Relational Persistence for Idiomatic Java
-~~
-~~ Copyright (c) 2008, 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
-
-Hibernate Core - Relational Persistence for Idiomatic Java
-
- Hibernate is a powerful, high performance object/relational persistence and query
- service. Hibernate lets you develop persistent classes following common object-oriented
- idioms such as association, inheritance, polymorphism, composition, and collections.
-
- Hibernate's goal is to relieve the developer from 95 percent of common data persistence related
- programming tasks, compared to manual coding with SQL and the JDBC API. Hibernate Core for Java
- generates SQL for you, relieves you from manual JDBC result set handling and object conversion,
- and keeps your application portable to all SQL databases. However, unlike many other persistence
- solutions, Hibernate does not hide the power of SQL from you and guarantees that your investment
- in relational technology and knowledge is as valid as always.
-
- Hibernate provides transparent persistence, the only requirement for a persistent class is a
- no-argument constructor. You don't even need classes, you can also persist a model using Maps of
- Maps, or just about anything else.
-
- Hibernate offers sophisticated query options. You can write plain SQL, object-oriented
- HQL (Hibernate Query Language), or create programatic Criteria and Example queries. Hibernate can
- optimize object loading all the time, with various fetching and caching options.
-
- Hibernate adapts to your development process, no matter if you start with a design from scratch or
- work with an existing database, and it will support any application architecture. Combined with
- Hibernate EntityManager and Hibernate Annotations you can use Hibernate as a certified Java Persistence
- provider.
-
- Please visit the {{{http://hibernate.org}website}} for more information.
-
- Happpy Hibernating!
diff --git a/distribution/src/site/resources/css/site.css b/distribution/src/site/resources/css/site.css
deleted file mode 100644
index df7a9c86dc..0000000000
--- a/distribution/src/site/resources/css/site.css
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
- *
- * 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, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Steve Ebersole
- */
-
-/*
- * Apply the colors taken from the Hibernate logo in various places
- * thoughout the generated site pages.
- *
- * brown : #aea477
- * gray : #59666c
- */
-
-h1, h2, h3, h4, h5, h6 {
- color: #aea477;
-}
-
-#navcolumn h5 {
- color: #59666c;
-}
diff --git a/distribution/src/site/resources/images/favicon.ico b/distribution/src/site/resources/images/favicon.ico
deleted file mode 100644
index 2fcbb8595fd388eed37833b940fed21b9d7c3ec7..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 3638
zcmeHJX;f5K68@giXm*oKc9W3J7_-MDig5!JWRYg4n}()=-WyOrkYDjpl
z?mPO#!%q(m9_6a$CznPSKRM~CBVIo_XWO$c{_D>ru5G3;`cIGiR#FzJaEnwng_(SE
zYtpN_O=08cy`R~-XFx@>WL==7ux0?4FmvIZi-QMR+V>p;C>%IK6yfvgP4R8-o*qV&
z)j#^qH-|sUwRU+uv2BIac<0demBq?zdOB5HiX|d^ENs%4+vQoBUteBa^e|Sy%?hdV
z*(;J-r`B~hpZopE@pBi_bQbZ&MY~FeYIpBH_|UVDug}yBRF`a=FjU1vU4H!N1NTjR
zu+YDAi?=>XMyS+k1|^BcI&W%GTsP$s#ZAx5m)BE0eH~0!UtZpT20=#4!M@%=Kz-(=
z$7y`awoipPgwLf%9{AFcZ{7LB*M9elyT0*&7Yl?Bed^7Z{*??MSrvKp)%R62z3;Al
zh4-ht;lSdoRnI1rjTKLX=85#ay?q5H`t&z{!nLC};dt-ee_yTGs<6>Mbm(vY{7Jh3
zJNfpA;jVIA(6;IMYcr&dskMT;p)Qxp1z6}?GQMyy+0r>Nc_k5v5IVtzczL7p`@eqi
zuKV`g^OetM)78}5BdmgPnD?dU|9MtRZH))M^1Z))`M2j+&%KThG%Zc5u^qvd!+U=E
zlYf|9y3)OGz%U4ejT