[ISPN-6] [HHH-4103] Tidy up commented code.

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17488 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Galder Zamarreno 2009-09-08 09:55:19 +00:00
parent fc6da13a85
commit 9e7e49d1f1
23 changed files with 164 additions and 570 deletions

View File

@ -102,10 +102,6 @@ public class TransactionalAccessDelegate {
cache.clear();
}
// public void evict(Object key) throws CacheException {
// cache.evict(key);
// }
public void evictAll() throws CacheException {
evictOrRemoveAll();
}

View File

@ -17,7 +17,7 @@ import org.infinispan.Cache;
*/
public class CollectionRegionImpl extends BaseTransactionalDataRegion implements CollectionRegion {
public CollectionRegionImpl(Cache<Object, Object> cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) {
public CollectionRegionImpl(Cache cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) {
super(cache, name, metadata, transactionManager);
}

View File

@ -25,7 +25,6 @@ class TransactionalAccess implements CollectionRegionAccessStrategy {
}
public void evict(Object key) throws CacheException {
// delegate.evict(key);
delegate.remove(key);
}

View File

@ -17,7 +17,7 @@ import org.infinispan.Cache;
*/
public class EntityRegionImpl extends BaseTransactionalDataRegion implements EntityRegion {
public EntityRegionImpl(Cache<Object, Object> cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) {
public EntityRegionImpl(Cache cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) {
super(cache, name, metadata, transactionManager);
}

View File

@ -15,7 +15,7 @@ import org.infinispan.Cache;
*/
public abstract class BaseGeneralDataRegion extends BaseRegion implements GeneralDataRegion {
public BaseGeneralDataRegion(Cache<Object, Object> cache, String name, TransactionManager transactionManager) {
public BaseGeneralDataRegion(Cache cache, String name, TransactionManager transactionManager) {
super(cache, name, transactionManager);
}

View File

@ -138,43 +138,4 @@ public abstract class BaseRegion implements Region {
}
}
// /**
// * HACKY WAY TO GET THE TRANSACTION MANAGER, TODO: resolve it!
// */
// private static TransactionManager getTransactionManager(Properties properties) {
//// return cache == null ? null : extractComponent(cache, TransactionManager.class);
// return TransactionManagerLookupFactory.getTransactionManager(properties);
// }
//
// public static <T> T extractComponent(Cache cache, Class<T> componentType) {
// ComponentRegistry cr = extractComponentRegistry(cache);
// return cr.getComponent(componentType);
// }
//
// public static ComponentRegistry extractComponentRegistry(Cache cache) {
// return (ComponentRegistry) extractField(cache, "componentRegistry");
// }
//
// public static Object extractField(Object target, String fieldName) {
// return extractField(target.getClass(), target, fieldName);
// }
//
// public static Object extractField(Class type, Object target, String fieldName) {
// Field field;
// try {
// field = type.getDeclaredField(fieldName);
// field.setAccessible(true);
// return field.get(target);
// }
// catch (Exception e) {
// if (type.equals(Object.class)) {
// e.printStackTrace();
// return null;
// } else {
// // try with superclass!!
// return extractField(type.getSuperclass(), target, fieldName);
// }
// }
// }
}

View File

@ -17,7 +17,7 @@ public abstract class BaseTransactionalDataRegion extends BaseRegion implements
private final CacheDataDescription metadata;
public BaseTransactionalDataRegion(Cache<Object, Object> cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) {
public BaseTransactionalDataRegion(Cache cache, String name, CacheDataDescription metadata, TransactionManager transactionManager) {
super(cache, name, transactionManager);
this.metadata = metadata;
}

View File

@ -19,7 +19,7 @@ import org.infinispan.context.Flag;
public class QueryResultsRegionImpl extends BaseTransactionalDataRegion implements QueryResultsRegion {
private boolean localOnly;
public QueryResultsRegionImpl(Cache<Object, Object> cache, String name, Properties properties, TransactionManager transactionManager) {
public QueryResultsRegionImpl(Cache cache, String name, Properties properties, TransactionManager transactionManager) {
super(cache, name, null, transactionManager);
// If Infinispan is using INVALIDATION for query cache, we don't want to propagate changes.

View File

@ -31,7 +31,7 @@ public class TimestampsRegionImpl extends BaseGeneralDataRegion implements Times
private Map localCache = new ConcurrentHashMap();
public TimestampsRegionImpl(Cache<Object, Object> cache, String name, TransactionManager transactionManager) {
public TimestampsRegionImpl(Cache cache, String name, TransactionManager transactionManager) {
super(cache, name, transactionManager);
cache.addListener(this);
populateLocalCache();
@ -99,14 +99,6 @@ public class TimestampsRegionImpl extends BaseGeneralDataRegion implements Times
public void nodeRemoved(CacheEntryRemovedEvent event) {
if (event.isPre()) return;
localCache.remove(event.getKey());
// Fqn fqn = event.getFqn();
// Fqn regFqn = getRegionFqn();
// if (fqn.size() == regFqn.size() + 1 && fqn.isChildOf(regFqn)) {
// Object key = fqn.get(regFqn.size());
// localCache.remove(key);
// } else if (fqn.equals(regFqn)) {
// localCache.clear();
// }
}
/**

View File

@ -36,18 +36,11 @@ import org.slf4j.LoggerFactory;
/**
* Helper for dealing with Infinisan cache instances.
*
* @author Steve Ebersole
* @author Brian Stansberry
* @author Galder Zamarreño
* @since 3.5
*/
public class CacheHelper {
/** Key under which items are cached */
public static final String ITEM = "item";
/** Key and value used in a hack to create region root nodes */
public static final String DUMMY = "dummy";
private static final Logger log = LoggerFactory.getLogger(CacheHelper.class);
/**
@ -368,14 +361,6 @@ public class CacheHelper {
}
}
// public static void evict(Cache cache, Object key) throws CacheException {
// try {
// cache.evict(key);
// } catch (Exception e) {
// throw new CacheException(e);
// }
// }
public static boolean containsKey(Cache cache, Object key, Flag... flags) {
try {
return cache.getAdvancedCache().containsKey(key, flags);
@ -384,64 +369,4 @@ public class CacheHelper {
}
}
// public static Node addNode(Cache cache, Fqn fqn, boolean localOnly, boolean resident) throws CacheException {
// try {
// Option option = null;
// if (localOnly) {
// option = new Option();
// option.setCacheModeLocal(localOnly);
// }
//
// 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
// * <code>option</code> is <code>null</code>.
// *
// * @param cache
// * the cache. Cannot be <code>null</code>.
// * @param option
// * the option. May be <code>null</code>.
// *
// * @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 <code>null</code>.
// * @param version
// * the DataVersion to set. Cannot be <code>null</code>.
// */
// public static void setDataVersionOption(Cache cache, DataVersion version) {
// Option option = new Option();
// option.setDataVersion(version);
// setInvocationOption(cache, option);
// }
}

View File

@ -52,9 +52,9 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
}
/**
* Creates a Region backed by an PESSIMISTIC locking JBoss Cache, and then
* ensures that it handles calls to buildAccessStrategy as expected when
* all the various {@link AccessType}s are passed as arguments.
* Creates a Region backed by an PESSIMISTIC locking JBoss Cache, and then ensures that it
* handles calls to buildAccessStrategy as expected when all the various {@link AccessType}s are
* passed as arguments.
*/
public void testSupportedAccessTypes() throws Exception {
supportedAccessTypeTest();
@ -69,60 +69,41 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
}
/**
* Creates a Region using the given factory, and then ensure that it
* handles calls to buildAccessStrategy as expected when all the
* various {@link AccessType}s are passed as arguments.
* Creates a Region using the given factory, and then ensure that it handles calls to
* buildAccessStrategy as expected when all the various {@link AccessType}s are passed as
* arguments.
*/
protected abstract void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties);
/**
* Test that the Region properly implements
* {@link TransactionalDataRegion#isTransactionAware()}.
* Test that the Region properly implements {@link TransactionalDataRegion#isTransactionAware()}.
*
* @throws Exception
*/
public void testIsTransactionAware() throws Exception {
Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false);
// cfg.setProperty(SharedCacheInstanceManager.CACHE_RESOURCE_PROP, CacheTestUtil.LOCAL_PESSIMISTIC_CACHE);
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
assertTrue("Region is transaction-aware", region.isTransactionAware());
CacheTestUtil.stopRegionFactory(regionFactory, getCacheTestSupport());
cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false);
// cfg.setProperty(SharedCacheInstanceManager.CACHE_RESOURCE_PROP, CacheTestUtil.LOCAL_PESSIMISTIC_CACHE);
// Make it non-transactional
cfg.getProperties().remove(Environment.TRANSACTION_MANAGER_STRATEGY);
regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
assertFalse("Region is not transaction-aware", region.isTransactionAware());
CacheTestUtil.stopRegionFactory(regionFactory, getCacheTestSupport());
}
public void testGetCacheDataDescription() throws Exception {
Configuration cfg = CacheTestUtil.buildConfiguration("test", InfinispanRegionFactory.class, true, false);
// cfg.setProperty(SharedCacheInstanceManager.CACHE_RESOURCE_PROP, CacheTestUtil.LOCAL_PESSIMISTIC_CACHE);
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", cfg.getProperties(), getCacheDataDescription());
CacheDataDescription cdd = region.getCacheDataDescription();
assertNotNull(cdd);
CacheDataDescription expected = getCacheDataDescription();
assertEquals(expected.isMutable(), cdd.isMutable());
assertEquals(expected.isVersioned(), cdd.isVersioned());
assertEquals(expected.getVersionComparator(), cdd.getVersionComparator());
}
}

View File

@ -124,7 +124,6 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
Cache localCache = getInfinispanCache(regionFactory);
// boolean invalidation = CacheHelper.isClusteredInvalidation(localCache);
// Sleep a bit to avoid concurrent FLUSH problem
avoidConcurrentFlush();
@ -141,7 +140,6 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory,
getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
// String regionName = REGION_PREFIX;
Set children = CacheHelper.getKeySet(localCache);
assertEquals("No children in " + children, 0, children.size());

View File

@ -402,18 +402,8 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs
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());
assertEquals(0, localCache.keySet().size());
// regionRoot = remoteCache.getRoot().getChild(regionFqn);
// assertFalse(regionRoot == null);
// assertEquals(0, getValidChildrenCount(regionRoot));
// assertTrue(regionRoot.isResident());
assertEquals(0, remoteCache.keySet().size());
assertNull("local is clean", localAccessStrategy.get(KEY, System.currentTimeMillis()));
@ -435,37 +425,18 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs
// This should re-establish the region root node
assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis()));
// regionRoot = localCache.getRoot().getChild(regionFqn);
// assertFalse(regionRoot == null);
// assertEquals(0, getValidChildrenCount(regionRoot));
// assertTrue(regionRoot.isValid());
// assertTrue(regionRoot.isResident());
assertEquals(0, localCache.keySet().size());
// 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());
//
// assertEquals(0, getValidChildrenCount(regionRoot));
// Not invalidation, so we didn't insert a child above
assertEquals(0, remoteCache.keySet().size());
// 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()));
// 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));
// Revalidate the region root
assertEquals(1, remoteCache.keySet().size());
// Wait for async propagation of the putFromLoad

View File

@ -415,14 +415,7 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
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();
@ -496,10 +489,7 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
readLatch.await();
log.debug("Read latch acquired, verify local access strategy");
// 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;
// This won't block w/ mvc and will read the old value
Object expected = VALUE1;
assertEquals("Correct value", expected, localAccessStrategy.get(KEY, txTimestamp));
@ -524,16 +514,8 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
updater.start();
reader.start();
// if (!isBlockingReads())
// Should complete promptly
assertTrue(completionLatch.await(2, 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();
@ -599,8 +581,6 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
assertEquals(null, localAccessStrategy.get(KEY, System.currentTimeMillis()));
// sleep(1000);
assertEquals(null, remoteAccessStrategy.get(KEY, System.currentTimeMillis()));
}
@ -608,17 +588,8 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
final String KEY = KEY_BASE + testCount++;
// Fqn regionFqn = getRegionFqn(REGION_NAME, REGION_PREFIX);
//
// Node regionRoot = localCache.getRoot().getChild(regionFqn);
// assertFalse(regionRoot == null);
assertEquals(0, localCache.keySet().size());
// assertTrue(regionRoot.isResident());
// regionRoot = remoteCache.getRoot().getChild(regionFqn);
// assertFalse(regionRoot == null);
assertEquals(0, remoteCache.keySet().size());
// assertTrue(regionRoot.isResident());
assertNull("local is clean", localAccessStrategy.get(KEY, System.currentTimeMillis()));
assertNull("remote is clean", remoteAccessStrategy.get(KEY, System.currentTimeMillis()));
@ -643,36 +614,18 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
// 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());
assertEquals(0, localCache.keySet().size());
// 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));
assertEquals(0, remoteCache.keySet().size());
// 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));
assertEquals(1, remoteCache.keySet().size());
// Wait for async propagation
@ -720,11 +673,9 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
localCfg = createConfiguration(configName);
localRegionFactory = CacheTestUtil.startRegionFactory(localCfg);
// localCache = localRegionFactory.getCacheManager().getCache("entity");
remoteCfg = createConfiguration(configName);
remoteRegionFactory = CacheTestUtil.startRegionFactory(remoteCfg);
// remoteCache = remoteRegionFactory.getCacheManager().getCache("entity");
}
@Override

View File

@ -28,7 +28,6 @@ public abstract class AbstractFunctionalTestCase extends FunctionalTestCase {
}
public void testEmptySecondLevelCacheEntry() throws Exception {
// getSessions().evictEntity(Item.class.getName());
getSessions().getCache().evictEntityRegion(Item.class.getName());
Statistics stats = getSessions().getStatistics();
stats.clear();

View File

@ -69,13 +69,11 @@ public class BulkOperationsTestCase extends FunctionalTestCase {
}
protected Class getConnectionProviderClass() {
// return org.hibernate.test.tm.ConnectionProviderImpl.class;
return org.hibernate.test.cache.infinispan.tm.XaConnectionProvider.class;
}
protected Class<? extends TransactionManagerLookup> getTransactionManagerLookupClass() {
return org.hibernate.test.cache.infinispan.tm.XaTransactionManagerLookup.class;
// return org.hibernate.test.tm.TransactionManagerLookupImpl.class;
}
public void configure(Configuration cfg) {
@ -245,25 +243,6 @@ public class BulkOperationsTestCase extends FunctionalTestCase {
}
}
// public void cleanup() throws Exception {
// String deleteContactHQL = "delete from Contact";
// String deleteCustomerHQL = "delete from Customer";
// tm.begin();
// try {
// Session session = getSessions().getCurrentSession();
// session.createQuery(deleteContactHQL).setFlushMode(FlushMode.AUTO).executeUpdate();
// session.createQuery(deleteCustomerHQL).setFlushMode(FlushMode.AUTO).executeUpdate();
// tm.commit();
// } catch (Exception e) {
// try {
// tm.rollback();
// } catch (Exception ee) {
// // ignored
// }
// throw e;
// }
// }
public void cleanup(boolean ignore) throws Exception {
String deleteContactHQL = "delete from Contact";
String deleteCustomerHQL = "delete from Customer";

View File

@ -40,8 +40,6 @@ import org.slf4j.LoggerFactory;
public class CacheAccessListener {
protected final Logger log = LoggerFactory.getLogger(getClass());
// HashSet<Fqn<String>> modified = new HashSet<Fqn<String>>();
// HashSet<Fqn<String>> accessed = new HashSet<Fqn<String>>();
HashSet modified = new HashSet();
HashSet accessed = new HashSet();
@ -107,19 +105,6 @@ public class CacheAccessListener {
return true;
}
return false;
// boolean saw = false;
// for (Object key : sawEvents) {
//
// }
// Fqn<String> fqn = Fqn.fromString(regionName);
// for (Iterator<Fqn<String>> it = sawEvent.iterator(); it.hasNext();) {
// Fqn<String> modified = (Fqn<String>) it.next();
// if (modified.isChildOf(fqn)) {
// it.remove();
// saw = true;
// }
// }
// return saw;
}
}

View File

@ -16,21 +16,16 @@
package org.hibernate.test.cache.infinispan.functional.classloader;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.test.cache.infinispan.functional.cluster.AbstractDualNodeTestCase;
import org.hibernate.test.cache.infinispan.functional.cluster.ClusterAwareRegionFactory;
import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeJtaTransactionManagerImpl;
import org.hibernate.util.PropertiesHelper;
import org.infinispan.manager.CacheManager;
import org.infinispan.manager.DefaultCacheManager;
import junit.framework.Test;
/**
* A TestSetup that uses SelectedClassnameClassLoader to ensure that certain classes are not visible
* to JBoss Cache or JGroups' classloader.
* to Infinispan or JGroups' classloader.
*
* @author <a href="brian.stansberry@jboss.com">Brian Stansberry</a>
* @author Galder Zamarreño
*/
public class IsolatedCacheTestSetup extends SelectedClassnameClassLoaderTestSetup {
@ -43,42 +38,16 @@ public class IsolatedCacheTestSetup extends SelectedClassnameClassLoaderTestSetu
public IsolatedCacheTestSetup(Test test, String[] isolatedClasses) {
super(test, null, null, isolatedClasses);
this.isolatedClasses = isolatedClasses;
// this.cacheConfig = cacheConfig;
}
@Override
protected void setUp() throws Exception {
super.setUp();
// // At this point the TCCL cannot see the isolatedClasses
// // We want the caches to use this CL as their default classloader
// At this point the TCCL cannot see the isolatedClasses
// We want the caches to use this CL as their default classloader
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
// org.jgroups.ChannelFactory cf = new org.jgroups.JChannelFactory();
// cf.setMultiplexerConfig(DEF_JGROUPS_RESOURCE);
//
// // Use a CacheManager that will inject the desired defaultClassLoader into our caches
// CustomClassLoaderCacheManager cm = new CustomClassLoaderCacheManager(DEF_CACHE_FACTORY_RESOURCE, cf, tccl);
// cm.start();
// CacheManager manager = new DefaultCacheManager("org/hibernate/test/cache/infinispan/functional/classloader/infinispan-configs.xml");
// ClusterAwareRegionFactory.addCacheManager(AbstractDualNodeTestCase.LOCAL, manager);
// ClusterAwareRegionFactory.addCacheManager(AbstractDualNodeTestCase.REMOTE, manager);
// cm.getCache(cacheConfig, true);
//
// // Repeat for the "remote" cache
//
// cf = new org.jgroups.JChannelFactory();
// cf.setMultiplexerConfig(DEF_JGROUPS_RESOURCE);
//
// cm = new CustomClassLoaderCacheManager(DEF_CACHE_FACTORY_RESOURCE, cf, tccl);
// cm.start();
// TestCacheInstanceManager.addTestCacheManager(DualNodeTestUtil.REMOTE, cm);
//
// cm.getCache(cacheConfig, true);
// Now make the isolatedClasses visible to the test driver itself
SelectedClassnameClassLoader visible = new SelectedClassnameClassLoader(isolatedClasses, null, null, tccl);
Thread.currentThread().setContextClassLoader(visible);

View File

@ -33,29 +33,24 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A ClassLoader that loads classes whose classname begins with one of a
* given set of strings, without attempting first to delegate to its
* parent loader.
* A ClassLoader that loads classes whose classname begins with one of a given set of strings,
* without attempting first to delegate to its parent loader.
* <p>
* This class is intended to allow emulation of 2 different types of common J2EE
* classloading situations.
* This class is intended to allow emulation of 2 different types of common J2EE classloading
* situations.
* <ul>
* <li>Servlet-style child-first classloading, where this class is the
* child loader.</li>
* <li>Parent-first classloading where the parent does not have access to
* certain classes</li>
* <li>Servlet-style child-first classloading, where this class is the child loader.</li>
* <li>Parent-first classloading where the parent does not have access to certain classes</li>
* </ul>
* </p>
* <p>
* 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.
* 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.
* </p>
*
* @author Brian Stansberry
*/
public class SelectedClassnameClassLoader extends ClassLoader
{
public class SelectedClassnameClassLoader extends ClassLoader {
private Logger log = LoggerFactory.getLogger(SelectedClassnameClassLoader.class);
private String[] includedClasses = null;
@ -67,63 +62,45 @@ public class SelectedClassnameClassLoader extends ClassLoader
/**
* 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
* <code>excludedClasses</code>.
* Can be <code>null</code>
* @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
* <code>parent</code>, even if the classes
* package or classname appears in
* <code>includedClasses</code>. 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
* @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 <code>excludedClasses</code>. Can be
* <code>null</code>
* @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 <code>parent</code>, even if the classes package or classname appears
* in <code>includedClasses</code>. 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)
{
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
* <code>excludedClasses</code>.
* Can be <code>null</code>
* @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
* <code>parent</code>, even if the classes
* package or classname appears in
* <code>includedClasses</code>. 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
* @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 <code>excludedClasses</code>. Can be
* <code>null</code>
* @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 <code>parent</code>, even if the classes package or classname appears
* in <code>includedClasses</code>. 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)
{
public SelectedClassnameClassLoader(String[] includedClasses, String[] excludedClasses, String[] notFoundClasses,
ClassLoader parent) {
super(parent);
this.includedClasses = includedClasses;
this.excludedClasses = excludedClasses;
@ -132,49 +109,34 @@ public class SelectedClassnameClassLoader extends ClassLoader
log.debug("created " + this);
}
protected synchronized Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
log.trace("loadClass(" + name + "," + resolve + ")");
if (isIncluded(name) && (isExcluded(name) == false))
{
if (isIncluded(name) && (isExcluded(name) == false)) {
Class c = findClass(name);
if (resolve)
{
if (resolve) {
resolveClass(c);
}
return c;
}
else if (isNotFound(name))
{
} else if (isNotFound(name)) {
throw new ClassNotFoundException(name + " is discarded");
}
else
{
} else {
return super.loadClass(name, resolve);
}
}
protected Class<?> findClass(String name) throws ClassNotFoundException
{
protected Class<?> findClass(String name) throws ClassNotFoundException {
log.trace("findClass(" + name + ")");
Class result = classes.get(name);
if (result != null)
{
if (result != null) {
return result;
}
if (isIncluded(name) && (isExcluded(name) == false))
{
if (isIncluded(name) && (isExcluded(name) == false)) {
result = createClass(name);
}
else if (isNotFound(name))
{
} else if (isNotFound(name)) {
throw new ClassNotFoundException(name + " is discarded");
}
else
{
} else {
result = super.findClass(name);
}
@ -183,41 +145,30 @@ public class SelectedClassnameClassLoader extends ClassLoader
return result;
}
protected Class createClass(String name) throws ClassFormatError, ClassNotFoundException
{
protected Class createClass(String name) throws ClassFormatError, ClassNotFoundException {
log.info("createClass(" + name + ")");
try
{
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)
{
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)
{
} catch (FileNotFoundException e) {
throw new ClassNotFoundException("cannot find " + name, e);
}
catch (IOException e)
{
} catch (IOException e) {
throw new ClassNotFoundException("cannot read " + name, e);
}
}
protected boolean isIncluded(String className)
{
protected boolean isIncluded(String className) {
if (includedClasses != null)
{
for (int i = 0; i < includedClasses.length; i++)
{
if (className.startsWith(includedClasses[i]))
{
if (includedClasses != null) {
for (int i = 0; i < includedClasses.length; i++) {
if (className.startsWith(includedClasses[i])) {
return true;
}
}
@ -226,15 +177,11 @@ public class SelectedClassnameClassLoader extends ClassLoader
return false;
}
protected boolean isExcluded(String className)
{
protected boolean isExcluded(String className) {
if (excludedClasses != null)
{
for (int i = 0; i < excludedClasses.length; i++)
{
if (className.startsWith(excludedClasses[i]))
{
if (excludedClasses != null) {
for (int i = 0; i < excludedClasses.length; i++) {
if (className.startsWith(excludedClasses[i])) {
return true;
}
}
@ -243,15 +190,11 @@ public class SelectedClassnameClassLoader extends ClassLoader
return false;
}
protected boolean isNotFound(String className)
{
protected boolean isNotFound(String className) {
if (notFoundClasses != null)
{
for (int i = 0; i < notFoundClasses.length; i++)
{
if (className.startsWith(notFoundClasses[i]))
{
if (notFoundClasses != null) {
for (int i = 0; i < notFoundClasses.length; i++) {
if (className.startsWith(notFoundClasses[i])) {
return true;
}
}
@ -275,7 +218,8 @@ public class SelectedClassnameClassLoader extends ClassLoader
}
private static String listClasses(String[] classes) {
if (classes == null) return null;
if (classes == null)
return null;
String s = "";
for (int i = 0; i < classes.length; i++) {
if (i > 0)

View File

@ -20,30 +20,24 @@ import junit.extensions.TestSetup;
import junit.framework.Test;
/**
* A TestSetup that makes SelectedClassnameClassLoader the thread
* context classloader for the duration of the test.
* A TestSetup that makes SelectedClassnameClassLoader the thread context classloader for the
* duration of the test.
*
* @author <a href="brian.stansberry@jboss.com">Brian Stansberry</a>
* @version $Revision: 1 $
*/
public class SelectedClassnameClassLoaderTestSetup extends TestSetup
{
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)
{
public SelectedClassnameClassLoaderTestSetup(Test test, String[] includedClasses, String[] excludedClasses, String[] notFoundClasses) {
super(test);
this.includedClasses = includedClasses;
this.excludedClasses = excludedClasses;
@ -51,8 +45,7 @@ public class SelectedClassnameClassLoaderTestSetup extends TestSetup
}
@Override
protected void setUp() throws Exception
{
protected void setUp() throws Exception {
super.setUp();
originalTCCL = Thread.currentThread().getContextClassLoader();
@ -62,12 +55,9 @@ public class SelectedClassnameClassLoaderTestSetup extends TestSetup
}
@Override
protected void tearDown() throws Exception
{
protected void tearDown() throws Exception {
Thread.currentThread().setContextClassLoader(originalTCCL);
super.tearDown();
}
}

View File

@ -244,17 +244,6 @@ public class EntityCollectionInvalidationTestCase extends AbstractDualNodeTestCa
Customer customer = doGetCustomer(id, session, tm);
customer.setName("NewJBoss");
ids.customerId = customer.getId();
// Set<Contact> contacts = customer.getContacts();
// for (Contact c : contacts) {
// if (c.getName().equals("Kabir")) {
// contacts.remove(c);
// } else {
// contactIds.add(c.getId());
// }
// }
// ids.contactIds = contactIds;
// customer.setContacts(contacts);
Set<Contact> contacts = customer.getContacts();
for (Contact c : contacts) {
contactIds.add(c.getId());
@ -356,27 +345,6 @@ public class EntityCollectionInvalidationTestCase extends AbstractDualNodeTestCa
}
}
}
// @CacheEntryModified
// public void nodeModified(CacheEntryModifiedEvent event) {
// log.debug(event.toString());
// if (!event.isPre()) {
// MarshalledValue mv = (MarshalledValue) event.getKey();
// CacheKey cacheKey = (CacheKey) mv.get();
// Integer primKey = (Integer) cacheKey.getKey();
// String key = (String) cacheKey.getEntityOrRoleName() + '#' + primKey;
// log.debug("MyListener[" + name +"] - Modified key " + key);
// // String name = fqn.toString();
// String token = ".functional.";
// int index = key.indexOf(token);
// if (index > -1) {
// index += token.length();
// key = key.substring(index);
// log.debug("MyListener[" + name +"] - recording modification of " + key);
// visited.add(key);
// }
// }
// }
}
private class IdContainer {

View File

@ -172,10 +172,6 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
getDoesNotBlockPutTest();
}
// public void testGetDoesNotBlockPutPessimisticRepeatableRead() throws Exception {
// getDoesNotBlockPutTest();
// }
private void getDoesNotBlockPutTest() throws Exception {
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());

View File

@ -81,12 +81,6 @@ public class XaTransactionImpl implements Transaction {
s.beforeCompletion();
}
// if (!runXaResourcePrepare()) {
// status = Status.STATUS_ROLLING_BACK;
// } else {
// status = Status.STATUS_PREPARED;
// }
status = Status.STATUS_COMMITTING;
if (connection != null) {
@ -99,8 +93,6 @@ public class XaTransactionImpl implements Transaction {
}
}
// runXaResourceCommitTx();
status = Status.STATUS_COMMITTED;
for (int i = 0; i < synchronizations.size(); i++) {
@ -114,8 +106,6 @@ public class XaTransactionImpl implements Transaction {
}
public void rollback() throws IllegalStateException, SystemException {
// status = Status.STATUS_ROLLING_BACK;
// runXaResourceRollback();
status = Status.STATUS_ROLLEDBACK;
if (connection != null) {