Author: manik.surtani(a)jboss.com
Date: 2008-01-08 10:13:15 -0500 (Tue, 08 Jan 2008)
New Revision: 5065
Removed:
core/trunk/src/main/java/org/jboss/cache/factories/CacheLoaderConfigFactory.java
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
core/trunk/src/main/java/org/jboss/cache/util/BeanUtils.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java
core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryUnitTest.java
core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/CorruptedFileCacheLoader.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
Log:
Fixed failing state transfer issues plus cache startup changes wrt component registry
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-08 15:01:40 UTC (rev
5064)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-08 15:13:15 UTC (rev
5065)
@@ -517,54 +517,11 @@
configureLogCategory();
componentRegistry.wire();
-
- // initialise the node factory and set this in the runtime.
-// NodeFactory nf;
-// if ((nf = configuration.getRuntimeConfig().getNodeFactory()) == null)
-// {
-// nf = new NodeFactory(this);
-// configuration.getRuntimeConfig().setNodeFactory(nf);
-// }
-// else
-// {
-// // don't create a new one each and every time. After stopping and
starting the cache, the old NodeFactory may still be valid.
-// nf.init();
-// }
-
-// if (notifier == null)
-// notifier = new Notifier(this);
-
correctRootNodeType();
-// if (configuration.getCacheLoaderConfig() != null && cacheLoaderManager ==
null)
-// {
-// initialiseCacheLoaderManager();
-// }
- // first set up the Buddy Manager and an RPCManager
-// if (configuration.getCacheMode() != Configuration.CacheMode.LOCAL)
-// {
- //getConfiguration().getRuntimeConfig().setRPCManager(new RPCManagerImpl(this));
-// setBuddyReplicationConfig(configuration.getBuddyReplicationConfig());
-// }
- // build interceptor chain
-// try
-// {
-// interceptor_chain =
InterceptorChainFactory.getInstance().buildInterceptorChain(configuration,
componentRegistry);
-// }
-// catch (Exception e)
-// {
-// throw new CacheException("Unable to build interceptor chain", e);
-// }
-
-
setUseReplQueue(configuration.isUseReplQueue());
setIsolationLevel(configuration.getIsolationLevel());
- //createEvictionPolicy();
-
- // now done inside the regionManager
- //regionManager.setDefaultInactive(configuration.isInactiveOnStartup());
-
cacheStatus = CacheStatus.CREATED;
}
@@ -626,20 +583,11 @@
*/
private void internalStart() throws CacheException, IllegalArgumentException
{
- // re-wire all dependencies in case stuff has changed since the cache was created?
- // TODO: Do we really need to nuke old deps? :/
- CacheSPI spi = componentRegistry.getComponent(CacheSPI.class);
+ // re-wire all dependencies in case stuff has changed since the cache was created
// remove the Interceptor.class component though, since it may pertain to an old
config
componentRegistry.unregisterComponent(Interceptor.class);
- // re-do the bootstrap sequence
- componentRegistry.registerComponent(configuration);
- componentRegistry.registerComponent(this);
- componentRegistry.registerComponent(CacheSPI.class.getName(), spi);
- componentRegistry.registerComponent(Cache.class.getName(), spi);
- componentRegistry.registerComponent(componentRegistry);
-
componentRegistry.updateDependencies();
componentRegistry.wireDependencies(root);
@@ -656,20 +604,6 @@
correctRootNodeType();
-// createTransactionManager();
-
- // cache loaders should be initialised *before* any state transfers take place to
prevent
- // exceptions involving cache loaders not being started. - Manik
- // create cache loader
-
- // now done in the CLM
-// if (cacheLoaderManager != null)
-// {
-// cacheLoaderManager.startCacheLoader();
-// }
- // now that we have a TM we can init the interceptor chain
-// InterceptorChainFactory.getInstance().initialiseInterceptors(interceptor_chain,
this);
-
switch (configuration.getCacheMode())
{
case LOCAL:
@@ -905,7 +839,7 @@
cacheStatus = CacheStatus.STOPPING;
// if this is called from a source other than the shutdown hook, deregister the
shutdown hook.
- if (!invokedFromShutdownHook)
Runtime.getRuntime().removeShutdownHook(shutdownHook);
+ if (!invokedFromShutdownHook && shutdownHook != null)
Runtime.getRuntime().removeShutdownHook(shutdownHook);
componentRegistry.stop();
@@ -3646,7 +3580,7 @@
private void setInterceptorChain(Interceptor startOfNewChain)
{
- componentRegistry.registerComponent(Interceptor.class.getName(), startOfNewChain);
+ componentRegistry.registerComponent(Interceptor.class.getName(), startOfNewChain,
Interceptor.class);
}
public synchronized void addInterceptor(Interceptor i, int position)
@@ -3712,7 +3646,7 @@
if (found)
{
- componentRegistry.registerComponent(i);
+ componentRegistry.registerComponent(i, Interceptor.class);
interceptors.add(++position, i);
setInterceptorChain(factory.correctInterceptorChaining(interceptors));
}
Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-01-08 15:01:40
UTC (rev 5064)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-01-08 15:13:15
UTC (rev 5065)
@@ -135,8 +135,8 @@
this.configuration = configuration;
// make sure we set the CacheImpl and CacheSPI instance in the component registry.
- componentRegistry.registerComponent(cache);
- componentRegistry.registerComponent(CacheSPI.class.getName(), spi);
+ componentRegistry.registerComponent(cache, CacheImpl.class);
+ componentRegistry.registerComponent(CacheSPI.class.getName(), spi,
CacheSPI.class);
}
public Cache<K, V> createCache(InputStream is) throws ConfigurationException
Deleted: core/trunk/src/main/java/org/jboss/cache/factories/CacheLoaderConfigFactory.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/factories/CacheLoaderConfigFactory.java 2008-01-08
15:01:40 UTC (rev 5064)
+++
core/trunk/src/main/java/org/jboss/cache/factories/CacheLoaderConfigFactory.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -1,21 +0,0 @@
-package org.jboss.cache.factories;
-
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
-
-/**
- * Factory class to create cache loader managers
- *
- * @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
- * @since 2.1.0
- */
-@DefaultFactoryFor(classes = {CacheLoaderConfig.class})
-public class CacheLoaderConfigFactory extends ComponentFactory
-{
- @Override
- @SuppressWarnings("unchecked")
- protected <T> T construct(String componentName, Class<T> componentType)
- {
- return (T) configuration.getCacheLoaderConfig();
- }
-}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-01-08
15:01:40 UTC (rev 5064)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -14,6 +14,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
+import org.jboss.cache.invocation.RemoteCacheInvocationDelegate;
import org.jboss.cache.util.BeanUtils;
import org.jboss.cache.util.reflect.ClasspathScanner;
import org.jboss.cache.util.reflect.ReflectionUtil;
@@ -83,14 +84,14 @@
public ComponentRegistry(Configuration configuration)
{
// bootstrap.
- registerComponent(this);
- registerComponent(configuration);
+ registerComponent(this, ComponentRegistry.class);
+ registerComponent(configuration, Configuration.class);
}
/**
* Adds a singleton instance to the registry. Note that if an instance of this
component already exists in the
* registry it is overwritten. The instance is registered under type
<tt>component.getClass()</tt>. If the component
- * implements an interface or extends an abstract class, it may make more sense to use
{@link #registerComponent(String, Object)}
+ * implements an interface or extends an abstract class, it may make more sense to use
{@link #registerComponent(String, Object, Class)}
* <p/>
* The status of the component is updated th the overall state of the registry, which
may involve calling of methods annotated
* with {@link org.jboss.cache.factories.annotations.Inject}, {@link
org.jboss.cache.factories.annotations.Start} or
@@ -99,9 +100,9 @@
*
* @param component component to add to the registry.
*/
- public void registerComponent(Object component)
+ public void registerComponent(Object component, Class type)
{
- registerComponent(component.getClass().getName(), component);
+ registerComponent(component.getClass().getName(), component, type);
}
/**
@@ -116,13 +117,22 @@
* @param name name of the instance
* @param component component to add
*/
- public void registerComponent(String name, Object component)
+ public void registerComponent(String name, Object component, Class type)
{
// this will make sure all dependent components are stopped or set to CONSTRUCTED
so they can be re-wired later.
- Component c = new Component(name, component);
+ Component c = new Component(name, component, type);
Component old = componentLookup.get(name);
+ if (log.isTraceEnabled())
+ log.trace("Registering component " + c + " under name " +
name + " replacing old component " + old);
if (old != null)
{
+ // if they are equal don't bother
+ if (old.instance.equals(component))
+ {
+ if (log.isTraceEnabled())
+ log.trace("Attempting to register a component equal to one that
already exists under the same name (" + name + "). Not doing anything.");
+ return;
+ }
// unregister the old component so that components that depend on it can be
stopped if necessary
unregisterComponent(name);
// components that depended on the old component should now depend on the new
one.
@@ -256,32 +266,34 @@
if (component != null)
{
- registerComponent(componentNameToUse, component);
+ registerComponent(componentNameToUse, component, componentClass);
}
else if (attemptedFactoryConstruction)
{
- registerNullComponent(componentNameToUse);
+ if (log.isTraceEnabled()) log.trace("Registering a null for component
" + componentNameToUse);
+ registerNullComponent(componentNameToUse, componentClass);
}
}
return component;
}
// registers a special "null" component that has no dependencies.
- void registerNullComponent(String componentName)
+ void registerNullComponent(String componentName, Class type)
{
- registerComponent(componentName, NULL_COMPONENT);
+ registerComponent(componentName, NULL_COMPONENT, type);
}
private boolean isNonBootstrap(Class<?> componentClass)
{
return !(componentClass.equals(CacheSPI.class) ||
componentClass.equals(CacheImpl.class) || componentClass.equals(Cache.class)
- || componentClass.equals(ComponentRegistry.class));
+ || componentClass.equals(ComponentRegistry.class) ||
componentClass.equals(Configuration.class));
}
@SuppressWarnings("unchecked")
<T> T getFromConfiguration(Class<T> componentClass)
{
- //if (log.isDebugEnabled()) log.debug("Looking in configuration for an
instance of " + componentClass + " that may have been injected from an external
source.");
+ if (log.isDebugEnabled())
+ log.debug("Looking in configuration for an instance of " +
componentClass + " that may have been injected from an external source.");
Method getter = BeanUtils.getterMethod(Configuration.class, componentClass);
T returnValue = null;
@@ -328,8 +340,20 @@
public void updateDependencies()
{
State originalState = overallState;
- moveComponentsToState(overallState == STARTED ? CONSTRUCTED : STOPPED);
+ moveComponentsToState(overallState == STARTED ? STOPPED : CONSTRUCTED);
moveComponentsToState(originalState);
+ // re- add a few key components - this is a hack for now
+ CacheImpl ci = getComponent(CacheImpl.class);
+ CacheSPI rcid = getComponent("remoteDelegate",
RemoteCacheInvocationDelegate.class);
+ CacheSPI spi = getComponent(CacheSPI.class.getName(), CacheSPI.class);
+
+ unregisterComponent(CacheImpl.class);
+ unregisterComponent(CacheSPI.class.getName());
+ unregisterComponent("remoteDelegate");
+
+ registerComponent(CacheImpl.class.getName(), ci, CacheImpl.class);
+ registerComponent(CacheSPI.class.getName(), spi, CacheSPI.class);
+ registerComponent("remoteDelegate", rcid,
RemoteCacheInvocationDelegate.class);
}
/**
@@ -464,7 +488,7 @@
if (cf != null)
{
// we simply register this factory. Registration will take care of
constructing any dependencies.
- registerComponent(cf);
+ registerComponent(cf, cfClass);
}
}
@@ -677,6 +701,7 @@
{
Object instance;
String name;
+ Class type;
State state = CONSTRUCTED;
Set<Dependency> dependencies = new HashSet<Dependency>(3);
Set<Dependency> dependencyFor = new HashSet<Dependency>(3);
@@ -690,10 +715,11 @@
* @param name name of component
* @param instance component instance
*/
- public Component(String name, Object instance)
+ public Component(String name, Object instance, Class type)
{
this.instance = instance;
this.name = name;
+ this.type = type;
// now scan the instance for all dependencies.
List<Method> injectionMethods =
ReflectionUtil.getAllMethods(instance.getClass(), Inject.class);
@@ -707,7 +733,7 @@
*/
Dependency asDependency()
{
- if (me == null) me = new Dependency(name, null);
+ if (me == null) me = new Dependency(name, type);
return me;
}
@@ -753,6 +779,12 @@
for (Dependency d : dependentComponents)
{
Component c = componentLookup.get(d.name);
+// if (c == null && increase)
+// {
+// if (log.isTraceEnabled()) log.trace(name + " depends on " +
d.name + " (type "+d.type+") but it does not exist in the registry,
attempting to create.");
+// getOrCreateComponent(d.name, d.type);
+// c = componentLookup.get(d.name);
+// }
if (c != null)
{
if (isShallowCyclic(c))
@@ -764,10 +796,21 @@
{
// of we are "moving up" - only do this if the component
is lower than what is needed.
if ((increase && newState.isGreaterThan(c.state)) ||
(!increase && newState.isLessThan(c.state)))
+ {
+ if (c.name.endsWith("CacheLoaderManager"))
+ {
+ boolean itrue = true;
+ }
c.changeState(newState);
+ }
}
}
+ else
+ {
+ if (log.isTraceEnabled())
+ log.trace(name + " depends on " + d.name + " (type
" + d.type + ") but it does not exist in the registry");
+ }
}
// NOW we update our state.
Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-01-08
15:01:40 UTC (rev 5064)
+++
core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -65,7 +65,7 @@
i = clazz.newInstance();
// componentRegistry.wireDependencies(i);
// add this interceptor as a NAMED component into the registry
- componentRegistry.registerComponent(clazz.getName(), i);
+ componentRegistry.registerComponent(clazz.getName(), i, clazz);
}
else
{
@@ -608,7 +608,7 @@
// now set the 'last' pointer.
Interceptor i = setLastInterceptorPointer(first, last);
// re-register this interceptor
- componentRegistry.registerComponent(Interceptor.class.getName(), i);
+ componentRegistry.registerComponent(Interceptor.class.getName(), i,
Interceptor.class);
return i;
}
Modified: core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-01-08
15:01:40 UTC (rev 5064)
+++ core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -70,14 +70,33 @@
private boolean fetchPersistentState;
private Configuration configuration;
+ @Inject
+ private void injectDependencies(CacheSPI cache, Configuration configuration)
+ {
+ this.config = configuration.getCacheLoaderConfig();
+ this.cache = cache;
+ this.configuration = configuration;
+
+ if (config != null)
+ {
+ try
+ {
+ loader = createCacheLoader();
+ }
+ catch (Exception e)
+ {
+ throw new CacheException("Unable to create cache loaders", e);
+ }
+ }
+ }
+
/**
- * Sets a configuration object and creates a cacheloader accordingly.
+ * Sets a configuration object and creates a cacheloader accordingly. Primarily used
for testing.
*
* @param config
* @param cache
* @throws CacheException
*/
- @Inject
public void setConfig(CacheLoaderConfig config, CacheSPI cache, Configuration
configuration) throws CacheException
{
this.config = config == null ? configuration.getCacheLoaderConfig() : config;
Modified: core/trunk/src/main/java/org/jboss/cache/util/BeanUtils.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/BeanUtils.java 2008-01-08 15:01:40 UTC
(rev 5064)
+++ core/trunk/src/main/java/org/jboss/cache/util/BeanUtils.java 2008-01-08 15:13:15 UTC
(rev 5065)
@@ -44,6 +44,7 @@
*/
public static String getterName(Class componentClass)
{
+ if (componentClass == null) return null;
StringBuilder sb = new StringBuilder("get");
sb.append(componentClass.getSimpleName());
return sb.toString();
@@ -57,6 +58,7 @@
*/
public static String setterName(Class componentClass)
{
+ if (componentClass == null) return null;
StringBuilder sb = new StringBuilder("set");
sb.append(componentClass.getSimpleName());
return sb.toString();
@@ -81,6 +83,10 @@
//if (log.isTraceEnabled()) log.trace("Unable to find method " +
getterName(componentClass) + " in class " + target);
return null;
}
+ catch (NullPointerException e)
+ {
+ return null;
+ }
}
/**
@@ -101,5 +107,9 @@
//if (log.isTraceEnabled()) log.trace("Unable to find method " +
setterName(componentClass) + " in class " + target);
return null;
}
+ catch (NullPointerException e)
+ {
+ return null;
+ }
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-01-08
15:01:40 UTC (rev 5064)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -171,7 +171,7 @@
// inject a mock RPC manager so that we can test whether calls made are sync or
async.
//cache1.getConfiguration().getRuntimeConfig().setRPCManager(rpcManager);
-
TestingUtil.extractComponentRegistry(cache1).registerComponent(RPCManager.class.getName(),
rpcManager);
+
TestingUtil.extractComponentRegistry(cache1).registerComponent(RPCManager.class.getName(),
rpcManager, RPCManager.class);
// invalidations will not trigger any rpc call sfor PFER
if (!isUsingInvalidation())
@@ -189,7 +189,7 @@
verify(rpcManager);
// cleanup
-
TestingUtil.extractComponentRegistry(cache1).registerComponent(RPCManager.class.getName(),
originalRpcManager);
+
TestingUtil.extractComponentRegistry(cache1).registerComponent(RPCManager.class.getName(),
originalRpcManager, RPCManager.class);
cache1.removeNode(fqn);
}
@@ -244,7 +244,7 @@
}
};
-
TestingUtil.extractComponentRegistry(cache1).registerComponent(RPCManager.class.getName(),
barfingRpcManager);
+
TestingUtil.extractComponentRegistry(cache1).registerComponent(RPCManager.class.getName(),
barfingRpcManager, RPCManager.class);
cache1.getConfiguration().getRuntimeConfig().setRPCManager(barfingRpcManager);
try
Modified:
core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java 2008-01-08
15:01:40 UTC (rev 5064)
+++
core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -78,7 +78,7 @@
public void testNamedComponents()
{
- cr.registerComponent("blah", new Object());
+ cr.registerComponent("blah", new Object(), Object.class);
Object namedComponent1 = cr.getOrCreateComponent("blah", Object.class);
Object namedComponent2 = cr.getOrCreateComponent("blah", Object.class);
Modified:
core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryUnitTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryUnitTest.java 2008-01-08
15:01:40 UTC (rev 5064)
+++
core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryUnitTest.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -25,9 +25,9 @@
public void testChangingComponentState()
{
- cr.registerComponent("c2", new C2());
- cr.registerComponent("c1", new C1());
- cr.registerComponent("c3", new C3());
+ cr.registerComponent("c2", new C2(), C2.class);
+ cr.registerComponent("c1", new C1(), C1.class);
+ cr.registerComponent("c3", new C3(), C3.class);
ComponentRegistry.Component c1 = cr.componentLookup.get("c1");
ComponentRegistry.Component c2 = cr.componentLookup.get("c2");
Modified: core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2008-01-08 15:01:40 UTC
(rev 5064)
+++ core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2008-01-08 15:13:15 UTC
(rev 5065)
@@ -518,7 +518,7 @@
// This will replace the previous interceptor chain in the component registry
// as well as update dependencies!
- cr.registerComponent(Interceptor.class.getName(), interceptor);
+ cr.registerComponent(Interceptor.class.getName(), interceptor, Interceptor.class);
}
/**
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2008-01-08
15:01:40 UTC (rev 5064)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -40,11 +40,11 @@
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
- cr.registerComponent(interceptor);
+ cr.registerComponent(interceptor, OptimisticCreateIfNotExistsInterceptor.class);
Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
- cr.registerComponent(nodeInterceptor);
+ cr.registerComponent(nodeInterceptor, OptimisticNodeInterceptor.class);
dummy = new MockInterceptor();
- cr.registerComponent(dummy);
+ cr.registerComponent(dummy, MockInterceptor.class);
interceptor.setNext(nodeInterceptor);
nodeInterceptor.setNext(dummy);
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/CorruptedFileCacheLoader.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/CorruptedFileCacheLoader.java 2008-01-08
15:01:40 UTC (rev 5064)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/CorruptedFileCacheLoader.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -1,6 +1,9 @@
package org.jboss.cache.statetransfer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.loader.FileCacheLoader;
import java.io.IOException;
@@ -8,8 +11,23 @@
public class CorruptedFileCacheLoader extends FileCacheLoader
{
+ private Log log = LogFactory.getLog(CorruptedFileCacheLoader.class);
+ private CacheLoaderConfig.IndividualCacheLoaderConfig cfg;
@Override
+ public void setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
+ {
+ this.cfg = base;
+ super.setConfig(base);
+ }
+
+ @Override
+ public CacheLoaderConfig.IndividualCacheLoaderConfig getConfig()
+ {
+ return cfg;
+ }
+
+ @Override
public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
{
throw new IOException("see
StateTransfer200Test#testCacheLoaderFailure()");
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2008-01-08
15:01:40 UTC (rev 5064)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -61,9 +61,9 @@
// inject our own message listener and re-wire deps
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
- cr.unregisterComponent(CacheMessageListener.class);
- cr.registerComponent(new SecretiveStateCacheMessageListener());
- cr.updateDependencies();
+// cr.unregisterComponent(CacheMessageListener.class);
+ cr.registerComponent(CacheMessageListener.class.getName(), new
SecretiveStateCacheMessageListener(), CacheMessageListener.class);
+// cr.updateDependencies();
cache.start();
@@ -80,9 +80,9 @@
// inject our own message listener and re-wire deps
cr = TestingUtil.extractComponentRegistry(recipient);
- cr.unregisterComponent(CacheMessageListener.class);
- cr.registerComponent(new SecretiveStateCacheMessageListener());
- cr.updateDependencies();
+ //cr.unregisterComponent(CacheMessageListener.class);
+ cr.registerComponent(CacheMessageListener.class.getName(), new
SecretiveStateCacheMessageListener(), CacheMessageListener.class);
+ //cr.updateDependencies();
try
{
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2008-01-08
15:01:40 UTC (rev 5064)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -93,7 +93,7 @@
@SuppressWarnings("null")
public void testCacheLoaderFailure() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false,
false, "org.jboss.cache.statetransfer.CorruptedFileCacheLoader", false, true);
+ CacheSPI<Object, Object> cache1 = createCache("cache1", false,
false, CorruptedFileCacheLoader.class.getName(), false, true);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2008-01-08
15:01:40 UTC (rev 5064)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2008-01-08
15:13:15 UTC (rev 5065)
@@ -134,7 +134,7 @@
}
if (cacheLoaderClass != null && cacheLoaderClass.length() > 0)
{
- configureCacheLoader(c, cacheLoaderClass, cacheID, useMarshalling,
cacheLoaderAsync);
+ configureCacheLoader(c, cacheLoaderClass, cacheID, cacheLoaderAsync);
}
// tree.setConfiguration(c);
//c.setLockAcquisitionTimeout(60000);
@@ -198,14 +198,13 @@
protected void configureCacheLoader(Configuration c,
String cacheID,
- boolean useExtended,
boolean async)
throws Exception
{
- configureCacheLoader(c, "org.jboss.cache.loader.FileCacheLoader",
cacheID, useExtended, async);
+ configureCacheLoader(c, "org.jboss.cache.loader.FileCacheLoader",
cacheID, async);
}
- protected void configureCacheLoader(Configuration c, String cacheloaderClass, String
cacheID, boolean useExtended,
+ protected void configureCacheLoader(Configuration c, String cacheloaderClass, String
cacheID,
boolean async) throws Exception
{
if (cacheloaderClass != null)