[jbosscache-commits] JBoss Cache SVN: r4887 - in core/trunk/src: main/java/org/jboss/cache/factories and 3 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Dec 19 21:11:58 EST 2007
Author: manik.surtani at jboss.com
Date: 2007-12-19 21:11:58 -0500 (Wed, 19 Dec 2007)
New Revision: 4887
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/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
Log:
Fixed cache loading issues
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-12-19 21:51:57 UTC (rev 4886)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-12-20 02:11:58 UTC (rev 4887)
@@ -850,6 +850,8 @@
}
disp = null;
transactionManager = null;
+
+ componentRegistry.reset();
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2007-12-19 21:51:57 UTC (rev 4886)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2007-12-20 02:11:58 UTC (rev 4887)
@@ -143,7 +143,6 @@
// 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.class.getName(), spi);
}
public Cache<K, V> createCache(InputStream is) throws ConfigurationException
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2007-12-19 21:51:57 UTC (rev 4886)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2007-12-20 02:11:58 UTC (rev 4887)
@@ -120,12 +120,17 @@
Component c = new Component(name, component);
componentLookup.put(name, c);
+ addComponentDependencies(c);
+ c.changeState(overallState == null ? CONSTRUCTED : overallState);
+ }
+
+ protected void addComponentDependencies(Component c)
+ {
// build any dependent components if necessary
for (Dependency d : c.dependencies)
{
getOrCreateComponent(d.name, d.type);
}
- c.changeState(overallState);
}
public <T> T getComponent(Class<T> c)
@@ -475,8 +480,25 @@
*/
public void reset()
{
+ // the bootstrap classes
+ Component spi = componentLookup.get(CacheSPI.class.getName());
+ Component impl = componentLookup.get(CacheImpl.class.getName());
+ Component conf = componentLookup.get(Configuration.class.getName());
+ Component cr = componentLookup.get(ComponentRegistry.class.getName());
+
componentLookup.clear();
- overallState = CONSTRUCTED;
+
+ spi.changeState(CONSTRUCTED);
+ impl.changeState(CONSTRUCTED);
+ conf.changeState(CONSTRUCTED);
+ cr.changeState(CONSTRUCTED);
+
+ componentLookup.put(Configuration.class.getName(), conf);
+ componentLookup.put(ComponentRegistry.class.getName(), cr);
+ componentLookup.put(CacheImpl.class.getName(), impl);
+ componentLookup.put(CacheSPI.class.getName(), spi);
+
+ overallState = null;
}
/**
@@ -505,6 +527,12 @@
void moveComponentsToState(State state)
{
+ if (overallState == null)
+ {
+ // we have been destroyed! Need to bootstrap again.
+ bootstrap();
+ }
+
for (Component c : componentLookup.values())
{
c.changeState(state);
@@ -513,11 +541,27 @@
}
/**
+ * Always assumes that the 4 core bootstrap components are in the registry. Will now attempt to make sure their dependencies are built.
+ */
+ void bootstrap()
+ {
+ // the bootstrap classes
+ Component spi = componentLookup.get(CacheSPI.class.getName());
+ Component impl = componentLookup.get(CacheImpl.class.getName());
+ Component conf = componentLookup.get(Configuration.class.getName());
+ Component cr = componentLookup.get(ComponentRegistry.class.getName());
+ addComponentDependencies(spi);
+ addComponentDependencies(impl);
+ addComponentDependencies(conf);
+ addComponentDependencies(cr);
+ }
+
+ /**
* Represents the state of a component
*/
enum State
{
- STOPPED, CONSTRUCTED, WIRED, STARTED;
+ DESTROYED, STOPPED, CONSTRUCTED, WIRED, STARTED;
/**
* Tests whether the current state is "greater" than the state passed in
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2007-12-19 21:51:57 UTC (rev 4886)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2007-12-20 02:11:58 UTC (rev 4887)
@@ -195,7 +195,6 @@
{
if (!inTransaction())
{
- loader.remove(fqn, key);
Object returnValue = loader.remove(fqn, key);
nextInterceptor(ctx);
return returnValue;
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2007-12-19 21:51:57 UTC (rev 4886)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2007-12-20 02:11:58 UTC (rev 4887)
@@ -76,6 +76,20 @@
this.lockTable = lockTable;
}
+ private void reset()
+ {
+ this.stateTransferManager = null;
+ this.cacheLoaderManager = null;
+ this.notifier = null;
+ this.transactionManager = null;
+ this.buddyManager = null;
+ this.transactionTable = null;
+ this.rpcManager = null;
+ this.regionManager = null;
+ this.marshaller = null;
+ this.lockTable = null;
+ }
+
@Override
public String toString()
{
@@ -259,6 +273,7 @@
public void destroy()
{
+ reset();
cache.destroy();
}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2007-12-19 21:51:57 UTC (rev 4886)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2007-12-20 02:11:58 UTC (rev 4887)
@@ -52,7 +52,7 @@
public void setChildrenLoaded(boolean loaded)
{
- node.setChildrenLoaded(true);
+ node.setChildrenLoaded(loaded);
}
public boolean isDataLoaded()
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2007-12-19 21:51:57 UTC (rev 4886)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2007-12-20 02:11:58 UTC (rev 4887)
@@ -419,7 +419,6 @@
keys = cache.getNode("/a/b/c").getKeys();
assertNotNull(keys);
assertEquals(1, keys.size());
- keys.add("myKey");
}
@@ -519,7 +518,7 @@
{
cache.put("/a/b/c", null);
}
- Set children = cache.getRoot().getChildrenNames();
+ Set children = cache.getChildrenNames((Fqn<String>) null);
assertTrue(children.isEmpty());
}
catch (Exception e)
@@ -754,9 +753,6 @@
cache.evict(Fqn.fromString("/a/b"));
cache.evict(Fqn.fromString("/a"));
- // now load the children - this set childrenLoaded in /a/b to true
-// cache.getNode("/a/b").getChildrenNames();
-
NodeSPI n = (NodeSPI) cache.getNode("/a/b");
assert !n.isChildrenLoaded();
@@ -966,7 +962,7 @@
cache.removeNode("/x");
assertNull(cache.get(key, "keyA"));
addDelay();
- Set keys = cache.getNode(key).getKeys();
+ Set keys = cache.getKeys(key);
assertNull("got keys " + keys, keys);
cache.removeNode("/x");
}
@@ -1094,8 +1090,8 @@
assertEquals(null, cache.get("/one/two/three/four", "key2"));
addDelay();
assertNull("Loader does not have node /one/two/three", loader.get(Fqn.fromString("/one/two/three")));
- assertEquals("Cache does not have node /one/two/three", null, cache.getNode("/one/two/three").getKeys());
- Set<?> children = cache.getNode("/one").getChildrenNames();
+ assertNull("Cache does not have node /one/two/three", cache.getKeys("/one/two/three"));
+ Set<?> children = cache.getChildrenNames("/one");
assertEquals("Cache has no children under /one", 0, children.size());
children = loader.getChildrenNames(Fqn.fromString("/one"));
assertEquals("Loader has no children under /one", null, children);
More information about the jbosscache-commits
mailing list