[jbosscache-commits] JBoss Cache SVN: r5813 - in core/trunk/src: main/java/org/jboss/cache/commands/remote and 4 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Thu May 8 12:36:55 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-05-08 12:36:55 -0400 (Thu, 08 May 2008)
New Revision: 5813

Modified:
   core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
   core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
   core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java
   core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
   core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java
   core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
   core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
   core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
   core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
   core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
Log:
Fixed breakages

Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2008-05-08 16:36:55 UTC (rev 5813)
@@ -8,7 +8,6 @@
 
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.BootstrapFactory;
 import org.jboss.cache.factories.ComponentFactory;
 import org.jboss.cache.factories.ComponentRegistry;
 import org.jboss.cache.factories.XmlConfigurationParser;
@@ -126,14 +125,10 @@
    private void bootstrap(CacheSPI spi, Configuration configuration)
    {
       // injection bootstrap stuff
-      componentRegistry = new ComponentRegistry(configuration);
+      componentRegistry = new ComponentRegistry(configuration, spi);
       componentRegistry.registerDefaultClassLoader(defaultClassLoader);
       this.configuration = configuration;
-      BootstrapFactory bf = new BootstrapFactory(spi, configuration, componentRegistry);
-      componentRegistry.registerComponent(bf, BootstrapFactory.class);
 
-      // make sure we set the CacheLifecycleManager and CacheSPI instance in the component registry.
-      //componentRegistry.registerComponent(lifecycleManager, LifecycleManager.class);
       componentRegistry.registerComponent(spi, CacheSPI.class);
       componentRegistry.wire();
    }

Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java	2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java	2008-05-08 16:36:55 UTC (rev 5813)
@@ -36,7 +36,7 @@
    private static final Log log = LogFactory.getLog(ClusteredGetCommand.class);
    private static boolean trace = log.isTraceEnabled();
 
-   public ClusteredGetCommand(Boolean searchBackupSubtrees, DataCommand dataCommand)
+   public ClusteredGetCommand(boolean searchBackupSubtrees, DataCommand dataCommand)
    {
       this.searchBackupSubtrees = searchBackupSubtrees;
       this.dataCommand = dataCommand;

Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java	2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java	2008-05-08 16:36:55 UTC (rev 5813)
@@ -3,6 +3,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
 import org.jboss.cache.CacheStatus;
 import org.jboss.cache.Version;
 import org.jboss.cache.config.Configuration;
@@ -93,7 +94,7 @@
     *
     * @param configuration configuration with which this is created
     */
-   public ComponentRegistry(Configuration configuration)
+   public ComponentRegistry(Configuration configuration, CacheSPI cache)
    {
       try
       {
@@ -101,6 +102,7 @@
          registerDefaultClassLoader(null);
          registerComponent(this, ComponentRegistry.class);
          registerComponent(configuration, Configuration.class);
+         registerComponent(new BootstrapFactory(cache, configuration, this), BootstrapFactory.class);
       }
       catch (Exception e)
       {
@@ -186,11 +188,8 @@
     */
    public void registerComponent(Object component, Class type)
    {
-      Component c = new Component();
+
       String name = type.getName();
-      c.name = name;
-      c.nonVolatile = component.getClass().isAnnotationPresent(NonVolatile.class);
-      c.instance = component;
       Component old = componentLookup.get(name);
 
       if (old != null)
@@ -204,17 +203,24 @@
          }
       }
 
-      if (trace) log.trace("Registering component " + c + " under name " + name);
-
+      Component c;
       if (old != null)
       {
-         if (trace) log.trace("Replacing old component " + old);
+         if (trace) log.trace("Replacing old component " + old + " with new instance " + component);
          old.instance = component;
+         c = old;
+
+         if (state == CacheStatus.STARTED) populateLifecycleMethods();
       }
       else
       {
+         c = new Component();
+         c.name = name;
+         c.instance = component;
+         if (trace) log.trace("Registering component " + c + " under name " + name);
          componentLookup.put(name, c);
       }
+      c.nonVolatile = component.getClass().isAnnotationPresent(NonVolatile.class);
       addComponentDependencies(c);
       // inject dependencies for this component
       c.injectDependencies();
@@ -229,7 +235,7 @@
    {
       Class type = c.instance.getClass();
       List<CachedMethod> methods = ReflectionUtil.getAllCachedMethods(type, Inject.class);
-
+      c.injectionMethods.clear();
       for (CachedMethod m : methods) c.injectionMethods.add(m);
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java	2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java	2008-05-08 16:36:55 UTC (rev 5813)
@@ -181,7 +181,7 @@
       catch (Exception e)
       {
          throw new CacheException("Unable to invoke method " + method + " on object instance " + instance +
-               (parameters != null ? " with parameters " + Arrays.asList(parameters) : ""));
+               (parameters != null ? " with parameters " + Arrays.asList(parameters) : ""), e);
       }
    }
 

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-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java	2008-05-08 16:36:55 UTC (rev 5813)
@@ -12,6 +12,7 @@
 import org.jboss.cache.commands.ReplicableCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.factories.ComponentRegistry;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
 import org.jboss.cache.lock.NodeLock;
 import org.jboss.cache.misc.TestingUtil;
@@ -172,7 +173,9 @@
       List<Address> memberList = originalRpcManager.getMembers();
       expect(rpcManager.getMembers()).andReturn(memberList).anyTimes();
       // inject a mock RPC manager so that we can test whether calls made are sync or async.
-      TestingUtil.extractComponentRegistry(cache1).registerComponent(rpcManager, RPCManager.class);
+      ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache1);
+      cr.registerComponent(rpcManager, RPCManager.class);
+      cr.rewire();
 
       // invalidations will not trigger any rpc call sfor PFER
       if (!isUsingInvalidation())

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java	2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java	2008-05-08 16:36:55 UTC (rev 5813)
@@ -3,7 +3,6 @@
 import org.jboss.cache.CacheStatus;
 import org.jboss.cache.RegionManager;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.CommandsFactory;
 import org.jboss.cache.factories.ComponentRegistry;
 
 /**
@@ -23,15 +22,14 @@
 
    protected VersionAwareMarshaller createVAMandRestartCache(RegionManager rm)
    {
-      cr.registerComponent(rm, RegionManager.class);
-      VersionAwareMarshaller vam = (VersionAwareMarshaller) cr.getComponent(Marshaller.class);
       if (cr.getState() == CacheStatus.STARTED) cr.stop();
-
-      CommandsFactory cf = cr.getComponent(CommandsFactory.class);
-      if (cf == null) cf = new CommandsFactory();
-      cr.registerComponent(cf, CommandsFactory.class);
-
-      cr.start();
-      return vam;
+      cr.registerComponent(rm, RegionManager.class);
+      cr.create();
+      cr.rewire();
+      // force cache mode
+      VersionAwareMarshaller m = (VersionAwareMarshaller) cr.getComponent(Marshaller.class);
+      m.init();
+      m.initReplicationVersions();
+      return m;
    }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java	2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java	2008-05-08 16:36:55 UTC (rev 5813)
@@ -10,7 +10,6 @@
 import org.jboss.cache.Region;
 import org.jboss.cache.RegionManager;
 import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.factories.ComponentRegistry;
 import org.testng.annotations.Test;
 
 import java.io.ByteArrayInputStream;
@@ -87,9 +86,8 @@
       final CacheMarshaller200 cm200 = new CacheMarshaller200();
       c.setInactiveOnStartup(false);
       c.setUseRegionBasedMarshalling(true);
-      ComponentRegistry cr = new ComponentRegistry(c);
       cr.registerComponent(cm200, CacheMarshaller200.class);
-      cr.start();
+      cr.rewire();
 
       RegionManager rm = cr.getComponent(RegionManager.class);
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -97,7 +95,7 @@
       final Fqn region = Fqn.fromString("/hello");
       Region r = rm.getRegion(region, true);
       r.registerContextClassLoader(this.getClass().getClassLoader());
-      cm200.objectToObjectStream(new ClusteredGetCommand(null, null), oos, region);
+      cm200.objectToObjectStream(new ClusteredGetCommand(false, null), oos, region);
       oos.close();
 
       final byte[] stream = baos.toByteArray();
@@ -180,7 +178,7 @@
                      byte magic = in.readByte();
 
                      assert magic != CacheMarshaller200.MAGICNUMBER_FQN : "The stream should NOT start with an Fqn!";
-                     assert magic == CacheMarshaller200.MAGICNUMBER_NULL : "Should start with a NULL";
+                     assert magic == CacheMarshaller200.MAGICNUMBER_NULL : "Should start with a NULL.  Instead, was " + magic;
                      assert in.readByte() == CacheMarshaller200.MAGICNUMBER_BOOLEAN : "Should have a boolean magic number before the boolean value";
                      assert in.readBoolean() : "The boolean written to the stream should be true";
 

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java	2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java	2008-05-08 16:36:55 UTC (rev 5813)
@@ -13,6 +13,7 @@
 import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.invocation.CacheInvocationDelegate;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertTrue;
 import org.testng.annotations.AfterMethod;
@@ -35,14 +36,13 @@
    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception
    {
-      regionManager = new RegionManager();
       c = new Configuration();
       c.setUseRegionBasedMarshalling(false);
       c.setInactiveOnStartup(false);
       c.setReplVersionString(currentVersion);
-      cr = new ComponentRegistry(c);
-      //c.setUseReferenceCounting(true);
-      marshaller = createVAMandRestartCache(regionManager);
+      cr = new ComponentRegistry(c, new CacheInvocationDelegate());
+      marshaller = createVAMandRestartCache(new RegionManager());
+      regionManager = cr.getComponent(RegionManager.class);
    }
 
    @AfterMethod(alwaysRun = true)

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java	2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java	2008-05-08 16:36:55 UTC (rev 5813)
@@ -13,6 +13,7 @@
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
 import org.jboss.cache.interceptors.MarshalledValueInterceptor;
 import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.CacheInvocationDelegate;
 import org.jboss.cache.loader.DummyInMemoryCacheLoader;
 import org.jboss.cache.misc.TestingUtil;
 import org.jboss.cache.notifications.annotation.CacheListener;
@@ -217,7 +218,7 @@
       MarshalledValue mv = new MarshalledValue(pojo);
 
       Configuration c = new Configuration();
-      ComponentRegistry cr = new ComponentRegistry(c);
+      ComponentRegistry cr = new ComponentRegistry(c, new CacheInvocationDelegate());
 
       Marshaller marshaller = new CacheMarshaller210();
       cr.registerComponent(marshaller, Marshaller.class);

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java	2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java	2008-05-08 16:36:55 UTC (rev 5813)
@@ -4,9 +4,7 @@
 import org.jboss.cache.commands.ReversibleCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
 import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.CommandsFactory;
-import org.jboss.cache.factories.ComponentRegistry;
 import static org.testng.AssertJUnit.assertEquals;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -46,7 +44,6 @@
       prepareComand = new PrepareCommand(null, list, null, true);
 
       CacheMarshaller210 cm210 = new CacheMarshaller210();
-      ComponentRegistry registry = new ComponentRegistry(new Configuration());
       CommandsFactory factory = new CommandsFactory();
       cm210.injectCommandsFactory(factory);
 

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java	2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java	2008-05-08 16:36:55 UTC (rev 5813)
@@ -9,6 +9,7 @@
 import org.jboss.cache.Version;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.invocation.CacheInvocationDelegate;
 import org.jboss.util.stream.MarshalledValueInputStream;
 import static org.testng.AssertJUnit.assertEquals;
 import org.testng.annotations.AfterMethod;
@@ -29,7 +30,7 @@
    @BeforeMethod
    public void setUp()
    {
-      cr = new ComponentRegistry(new Configuration());
+      cr = new ComponentRegistry(new Configuration(), new CacheInvocationDelegate());
    }
 
    @AfterMethod




More information about the jbosscache-commits mailing list