[jbosscache-commits] JBoss Cache SVN: r4850 - in core/trunk/src: main/java/org/jboss/cache/factories and 5 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Thu Dec 13 12:30:43 EST 2007


Author: manik.surtani at jboss.com
Date: 2007-12-13 12:30:43 -0500 (Thu, 13 Dec 2007)
New Revision: 4850

Modified:
   core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
   core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
   core/trunk/src/main/java/org/jboss/cache/RegionManager.java
   core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.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/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
   core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
   core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
Log:
reduced failure count

Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java	2007-12-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -580,7 +580,7 @@
       setUseReplQueue(configuration.isUseReplQueue());
       setIsolationLevel(configuration.getIsolationLevel());
 
-      createEvictionPolicy();
+      //createEvictionPolicy();
 
       regionManager.setDefaultInactive(configuration.isInactiveOnStartup());
 
@@ -693,6 +693,13 @@
       // start all internal components
       componentRegistry.startComponents();
 
+      // create a new root temporarily.
+      NodeSPI tempRoot = nodeFactory.createRootDataNode();
+      // if we don't already have a root or the new (temp) root is of a different class (optimistic vs pessimistic) to
+      // the current root, then we use the new one.  Helps preserve data between cache restarts.
+      if (root == null || !root.getClass().equals(tempRoot.getClass()))
+         root = tempRoot;
+
 //      createTransactionManager();
 
       // cache loaders should be initialised *before* any state transfers take place to prevent
@@ -1047,21 +1054,6 @@
 
    /* ----------------------- End of buddy replication specific methods ------------*/
 
-   protected void createEvictionPolicy()
-   {
-      if (configuration.getEvictionConfig() != null
-            && configuration.getEvictionConfig().isValidConfig())
-      {
-         regionManager.setEvictionConfig(configuration.getEvictionConfig());
-         regionManager.setUsingEvictions(true);
-      }
-      else
-      {
-         regionManager.setUsingEvictions(false);
-         log.debug("Not using an EvictionPolicy");
-      }
-   }
-
    /**
     * Loads the indicated Fqn, plus all parents recursively from the
     * CacheLoader. If no CacheLoader is present, this is a no-op

Modified: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java	2007-12-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -10,6 +10,7 @@
 import org.jboss.cache.factories.ComponentFactory;
 import org.jboss.cache.factories.ComponentRegistry;
 import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.factories.annotations.Start;
 import org.jboss.cache.invocation.NodeInvocationDelegate;
 import org.jboss.cache.optimistic.TransactionWorkspace;
 import org.jboss.cache.optimistic.WorkspaceNode;
@@ -59,12 +60,12 @@
       this.cache = cache;
       this.configuration = configuration;
       this.componentRegistry = componentRegistry;
-      init();
    }
 
    /**
     * Initialises the node factory with the configuration from the cache.
     */
+   @Start
    public void init()
    {
       optimistic = configuration.isNodeLockingOptimistic();

Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java	2007-12-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -5,12 +5,14 @@
 import org.apache.commons.logging.LogFactory;
 import static org.jboss.cache.Region.Type.*;
 import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.ConfigurationException;
 import org.jboss.cache.config.EvictionConfig;
 import org.jboss.cache.config.EvictionRegionConfig;
 import org.jboss.cache.eviction.EvictionTimerTask;
 import org.jboss.cache.eviction.RegionNameConflictException;
 import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.factories.annotations.Start;
 import org.jboss.cache.lock.NodeLock;
 import org.jgroups.Address;
 
@@ -51,6 +53,7 @@
    private EvictionTimerTask evictionTimerTask = new EvictionTimerTask();
 
    protected final Set<Fqn> activationChangeNodes = Collections.synchronizedSet(new HashSet<Fqn>());
+   protected Configuration configuration;
 
    /**
     * Constructs a new instance not attached to a cache.
@@ -64,11 +67,28 @@
    }
 
    @Inject
-   private void injectDependencies(CacheSPI cache)
+   private void injectDependencies(CacheSPI cache, Configuration configuration)
    {
       this.cache = cache;
+      this.configuration = configuration;
    }
 
+   @Start
+   protected void createEvictionPolicy()
+   {
+      if (configuration.getEvictionConfig() != null
+            && configuration.getEvictionConfig().isValidConfig())
+      {
+         setEvictionConfig(configuration.getEvictionConfig());
+         setUsingEvictions(true);
+      }
+      else
+      {
+         setUsingEvictions(false);
+         log.debug("Not using an EvictionPolicy");
+      }
+   }
+
    /**
     * Returns true if evictions are being processed.
     */

Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java	2007-12-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -12,7 +12,6 @@
 import org.jboss.cache.factories.annotations.DefaultFactoryFor;
 import org.jboss.cache.interceptors.*;
 import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.util.Util;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -69,14 +68,6 @@
       return first;
    }
 
-
-   @SuppressWarnings("unchecked")
-   private Interceptor createInterceptor(String classname) throws ClassNotFoundException, IllegalAccessException, InstantiationException
-   {
-      Class<Interceptor> clazz = Util.loadClass(classname);
-      return createInterceptor(clazz);
-   }
-
    private Interceptor createInterceptor(Class<? extends Interceptor> clazz) throws IllegalAccessException, InstantiationException
    {
       Interceptor i = clazz.newInstance();
@@ -85,7 +76,6 @@
       return i;
    }
 
-
    /**
     * Adds an interceptor at the end of the chain
     */

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java	2007-12-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -7,11 +7,11 @@
 package org.jboss.cache.interceptors;
 
 import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeFactory;
 import org.jboss.cache.NodeSPI;
+import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.notifications.Notifier;
 import org.jboss.cache.optimistic.DataVersion;
 import org.jboss.cache.optimistic.DefaultDataVersion;
@@ -40,11 +40,10 @@
     */
    private NodeFactory nodeFactory;
 
-   public void setCache(CacheSPI cache)
+   @Inject
+   private void injectDependencies(NodeFactory nodeFactory)
    {
-      super.setCache(cache);
-      // set a reference to the node factory
-      nodeFactory = cache.getConfiguration().getRuntimeConfig().getNodeFactory();
+      this.nodeFactory = nodeFactory;
    }
 
    protected Object handlePutDataMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Map data, boolean createUndoOps) throws Throwable
@@ -143,135 +142,135 @@
       synchronized (workspace)
       {
 */
-         DataVersion version = null;
-         if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
-         {
-            version = ctx.getOptionOverrides().getDataVersion();
-            workspace.setVersioningImplicit(false);
-         }
+      DataVersion version = null;
+      if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
+      {
+         version = ctx.getOptionOverrides().getDataVersion();
+         workspace.setVersioningImplicit(false);
+      }
 
-         // start with the ROOT node and then work our way down to the node necessary, creating nodes along the way.
-         workspaceNode = workspace.getNode(Fqn.ROOT);
-         if (debug) log.debug("GlobalTransaction: " + gtx + "; Root: " + workspaceNode);
+      // start with the ROOT node and then work our way down to the node necessary, creating nodes along the way.
+      workspaceNode = workspace.getNode(Fqn.ROOT);
+      if (debug) log.debug("GlobalTransaction: " + gtx + "; Root: " + workspaceNode);
 
-         // we do not have the root in the workspace!  Put it into thr workspace now.
-         if (workspaceNode == null)
-         {
-            NodeSPI node = cache.getRoot();
-            workspaceNode = nodeFactory.createWorkspaceNode(node, workspace);
-            workspace.addNode(workspaceNode);
-            log.debug("Created root node in workspace.");
-         }
-         else
-         {
-            log.debug("Found root node in workspace.");
-         }
+      // we do not have the root in the workspace!  Put it into thr workspace now.
+      if (workspaceNode == null)
+      {
+         NodeSPI node = cache.getRoot();
+         workspaceNode = nodeFactory.createWorkspaceNode(node, workspace);
+         workspace.addNode(workspaceNode);
+         log.debug("Created root node in workspace.");
+      }
+      else
+      {
+         log.debug("Found root node in workspace.");
+      }
 
-         // iterate through the target Fqn's elements.
-         int targetFqnSize = targetFqn.size(), currentDepth = 1;
-         for (Object childName : targetFqn.peekElements())
-         {
-            boolean isTargetFqn = (currentDepth == targetFqnSize);
-            currentDepth++;
+      // iterate through the target Fqn's elements.
+      int targetFqnSize = targetFqn.size(), currentDepth = 1;
+      for (Object childName : targetFqn.peekElements())
+      {
+         boolean isTargetFqn = (currentDepth == targetFqnSize);
+         currentDepth++;
 
-            // current workspace node canot be null.
-            // try and get the child of current node
+         // current workspace node canot be null.
+         // try and get the child of current node
 
-            if (debug) log.debug("Attempting to get child " + childName);
-            NodeSPI currentNode = workspaceNode.getNode().getChildDirect(childName);
+         if (debug) log.debug("Attempting to get child " + childName);
+         NodeSPI currentNode = workspaceNode.getNode().getChildDirect(childName);
 
-            if (currentNode == null)
+         if (currentNode == null)
+         {
+            // first test that it exists in the workspace and has been created in thix tx!
+            WorkspaceNode peekInWorkspace = workspace.getNode(new Fqn(workspaceNode.getFqn(), childName));
+            if (peekInWorkspace != null && peekInWorkspace.isCreated())
             {
-               // first test that it exists in the workspace and has been created in thix tx!
-               WorkspaceNode peekInWorkspace = workspace.getNode(new Fqn(workspaceNode.getFqn(), childName));
-               if (peekInWorkspace != null && peekInWorkspace.isCreated())
+               // exists in workspace and has just been created.
+               currentNode = peekInWorkspace.getNode();
+               if (peekInWorkspace.isDeleted())
                {
-                  // exists in workspace and has just been created.
-                  currentNode = peekInWorkspace.getNode();
-                  if (peekInWorkspace.isDeleted())
-                  {
-                     peekInWorkspace.markAsDeleted(false);
-                     // add in parent again
-                     workspaceNode.addChild(peekInWorkspace);
-                  }
+                  peekInWorkspace.markAsDeleted(false);
+                  // add in parent again
+                  workspaceNode.addChild(peekInWorkspace);
                }
             }
+         }
 
-            if (currentNode == null)
+         if (currentNode == null)
+         {
+            // no child exists with this name; create it in the underlying data structure and then add it to the workspace.
+            if (trace) log.trace("Creating new child, since it doesn't exist in the cache.");
+            // we put the parent node into the workspace as we are changing it's children.
+            // at this point "workspaceNode" refers to the parent of the current node.  It should never be null if
+            // you got this far!
+            if (workspaceNode.isDeleted())
             {
-               // no child exists with this name; create it in the underlying data structure and then add it to the workspace.
-               if (trace) log.trace("Creating new child, since it doesn't exist in the cache.");
-               // we put the parent node into the workspace as we are changing it's children.
-               // at this point "workspaceNode" refers to the parent of the current node.  It should never be null if
-               // you got this far!
-               if (workspaceNode.isDeleted())
-               {
-                  //add a new one or overwrite an existing one that has been deleted
-                  if (trace)
-                     log.trace("Parent node doesn't exist in workspace or has been deleted.  Adding to workspace.");
-                  workspace.addNode(workspaceNode);
-                  if (!(workspaceNode.getVersion() instanceof DefaultDataVersion))
-                     workspaceNode.setVersioningImplicit(false);
-               }
-               else
-               {
-                  if (trace) log.trace("Parent node exists: " + workspaceNode);
-               }
-
-               // get the version passed in, if we need to use explicit versioning.
-               DataVersion versionToPassIn = null;
-               if (isTargetFqn && !workspace.isVersioningImplicit()) versionToPassIn = version;
-
-               NodeSPI newUnderlyingChildNode = workspaceNode.createChild(childName, workspaceNode.getNode(), cache, versionToPassIn);
-
-               // now assign "workspaceNode" to the new child created.
-               workspaceNode = nodeFactory.createWorkspaceNode(newUnderlyingChildNode, workspace);
-               workspaceNode.setVersioningImplicit(versionToPassIn == null || !isTargetFqn);
+               //add a new one or overwrite an existing one that has been deleted
                if (trace)
-                  log.trace("setting versioning of " + workspaceNode.getFqn() + " to be " + (workspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
-
-               // now add the wrapped child node into the transaction space
+                  log.trace("Parent node doesn't exist in workspace or has been deleted.  Adding to workspace.");
                workspace.addNode(workspaceNode);
-               workspaceNode.markAsCreated();
-               // save in list so we can broadcast our created nodes outside
-               // the synch block
-               nodesCreated.add(workspaceNode.getFqn());
+               if (!(workspaceNode.getVersion() instanceof DefaultDataVersion))
+                  workspaceNode.setVersioningImplicit(false);
             }
             else
             {
-               // node does exist but might not be in the workspace
-               workspaceNode = workspace.getNode(currentNode.getFqn());
-               // wrap it up so we can put it in later if we need to
-               if (workspaceNode == null || workspaceNode.isDeleted())
-               {
-                  if (trace)
-                     log.trace("Child node " + currentNode.getFqn() + " doesn't exist in workspace or has been deleted.  Adding to workspace in gtx " + gtx);
+               if (trace) log.trace("Parent node exists: " + workspaceNode);
+            }
 
-                  workspaceNode = nodeFactory.createWorkspaceNode(currentNode, workspace);
+            // get the version passed in, if we need to use explicit versioning.
+            DataVersion versionToPassIn = null;
+            if (isTargetFqn && !workspace.isVersioningImplicit()) versionToPassIn = version;
 
-                  // if the underlying node is a tombstone then mark the workspace node as newly created
-                  if (!currentNode.isValid()) workspaceNode.markAsCreated();
+            NodeSPI newUnderlyingChildNode = workspaceNode.createChild(childName, workspaceNode.getNode(), cache, versionToPassIn);
 
-                  if (isTargetFqn && !workspace.isVersioningImplicit())
-                  {
-                     workspaceNode.setVersion(version);
-                     workspaceNode.setVersioningImplicit(false);
-                  }
-                  else
-                  {
-                     workspaceNode.setVersioningImplicit(true);
-                  }
-                  if (trace)
-                     log.trace("setting versioning of " + workspaceNode.getFqn() + " to be " + (workspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
-                  workspace.addNode(workspaceNode);
+            // now assign "workspaceNode" to the new child created.
+            workspaceNode = nodeFactory.createWorkspaceNode(newUnderlyingChildNode, workspace);
+            workspaceNode.setVersioningImplicit(versionToPassIn == null || !isTargetFqn);
+            if (trace)
+               log.trace("setting versioning of " + workspaceNode.getFqn() + " to be " + (workspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
+
+            // now add the wrapped child node into the transaction space
+            workspace.addNode(workspaceNode);
+            workspaceNode.markAsCreated();
+            // save in list so we can broadcast our created nodes outside
+            // the synch block
+            nodesCreated.add(workspaceNode.getFqn());
+         }
+         else
+         {
+            // node does exist but might not be in the workspace
+            workspaceNode = workspace.getNode(currentNode.getFqn());
+            // wrap it up so we can put it in later if we need to
+            if (workspaceNode == null || workspaceNode.isDeleted())
+            {
+               if (trace)
+                  log.trace("Child node " + currentNode.getFqn() + " doesn't exist in workspace or has been deleted.  Adding to workspace in gtx " + gtx);
+
+               workspaceNode = nodeFactory.createWorkspaceNode(currentNode, workspace);
+
+               // if the underlying node is a tombstone then mark the workspace node as newly created
+               if (!currentNode.isValid()) workspaceNode.markAsCreated();
+
+               if (isTargetFqn && !workspace.isVersioningImplicit())
+               {
+                  workspaceNode.setVersion(version);
+                  workspaceNode.setVersioningImplicit(false);
                }
                else
                {
-                  if (trace) log.trace("Found child node in the workspace: " + currentNode);
-
+                  workspaceNode.setVersioningImplicit(true);
                }
+               if (trace)
+                  log.trace("setting versioning of " + workspaceNode.getFqn() + " to be " + (workspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
+               workspace.addNode(workspaceNode);
             }
+            else
+            {
+               if (trace) log.trace("Found child node in the workspace: " + currentNode);
+
+            }
          }
+      }
 
       //}// end sync block
 

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java	2007-12-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -6,16 +6,16 @@
  */
 package org.jboss.cache.interceptors;
 
+import org.apache.commons.logging.Log;
 import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
+import org.jboss.cache.factories.annotations.Inject;
 import org.jboss.cache.optimistic.TransactionWorkspace;
 import org.jboss.cache.transaction.GlobalTransaction;
 import org.jboss.cache.transaction.OptimisticTransactionEntry;
 import org.jboss.cache.transaction.TransactionTable;
-import org.apache.commons.logging.Log;
 
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
@@ -32,17 +32,18 @@
    protected TransactionTable txTable = null;
    protected boolean trace;
 
-   public void setCache(CacheSPI cache)
+   protected Log getLog()
    {
-      super.setCache(cache);
-      txManager = cache.getTransactionManager();
-      txTable = cache.getTransactionTable();
-      trace = log != null && log.isTraceEnabled();
+      return null;
    }
 
-   protected Log getLog()
+   @Inject
+   private void injectDependencies(TransactionManager txManager, TransactionTable txTable)
    {
-      return null;
+      this.txManager = txManager;
+      this.txTable = txTable;
+      trace = log != null && log.isTraceEnabled();
+
    }
 
    protected TransactionWorkspace getTransactionWorkspace(GlobalTransaction gtx) throws CacheException

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2007-12-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -8,7 +8,6 @@
 
 import org.apache.commons.logging.Log;
 import org.jboss.cache.CacheImpl;
-import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.Node;
@@ -60,21 +59,14 @@
    private long lock_acquisition_timeout;
 
    @Inject
-   public void injectDependencies(@ComponentName("LockTable")Map<Thread, List<NodeLock>> lockTable, Configuration configuration, CacheImpl cacheImpl)
+   public void injectDependencies(@ComponentName("LockTable")Map<Thread, List<NodeLock>> lockTable, Configuration configuration, CacheImpl cacheImpl, TransactionTable txTable)
    {
       this.lock_table = lockTable;
       lock_acquisition_timeout = configuration.getLockAcquisitionTimeout();
       this.cacheImpl = cacheImpl;
+      this.tx_table = txTable;
    }
 
-   public void setCache(CacheSPI cache)
-   {
-      super.setCache(cache);
-      tx_table = cache.getTransactionTable();
-      //lock_table = cache.getLockTable();
-      //lock_acquisition_timeout = cache.getConfiguration().getLockAcquisitionTimeout();
-   }
-
    protected Log getLog()
    {
       return log;
@@ -172,12 +164,10 @@
       else
       {
          Iterator removedNodes = entry.getRemovedNodes().iterator();
-         CacheImpl cacheImpl = (CacheImpl) cache;
          while (removedNodes.hasNext())
          {
             Fqn f = (Fqn) removedNodes.next();
             cacheImpl.realRemove(f, false);
-
          }
          // 1. Revert the modifications by running the undo-op list in reverse. This *cannot* throw any exceptions !
          entry.undoOperations(cache);
@@ -560,7 +550,6 @@
 
       // first remove nodes that should be deleted.
       Iterator removedNodes = entry.getRemovedNodes().iterator();
-      CacheImpl cacheImpl = (CacheImpl) cache;
       while (removedNodes.hasNext())
       {
          Fqn f = (Fqn) removedNodes.next();

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-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -564,4 +564,9 @@
    {
       return getChildrenNames(Fqn.fromString(fqn));
    }
+
+   public CacheImpl getImpl()
+   {
+      return cache;
+   }
 }

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-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -34,6 +34,11 @@
       this.node = node;
    }
 
+   public UnversionedNode getUnversionedNode()
+   {
+      return node;
+   }
+
    @Inject
    private void injectDependencies(CacheSPI spi)
    {
@@ -236,7 +241,7 @@
    public Set<Object> getChildrenNames()
    {
       assertValid();
-      return cache.getChildrenNames(getFqn());
+      return spi.getChildrenNames(getFqn());
    }
 
    public Map<K, V> getData()
@@ -270,13 +275,13 @@
    public boolean removeChild(Fqn<?> f)
    {
       assertValid();
-      return cache.removeNode(new Fqn(getFqn(), f));
+      return spi.removeNode(new Fqn(getFqn(), f));
    }
 
    public boolean removeChild(Object childName)
    {
       assertValid();
-      return cache.removeNode(new Fqn(getFqn(), childName));
+      return spi.removeNode(new Fqn(getFqn(), childName));
    }
 
    public Node<K, V> getChild(Fqn<?> f)

Modified: core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java	2007-12-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -15,6 +15,7 @@
 import org.jboss.cache.NodeFactory;
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.VersionedNode;
+import org.jboss.cache.invocation.NodeInvocationDelegate;
 import org.jboss.cache.transaction.GlobalTransaction;
 
 import java.util.ArrayList;
@@ -53,9 +54,10 @@
     */
    public WorkspaceNodeImpl(NodeSPI<K, V> node, TransactionWorkspace workspace)
    {
-      if (!(node instanceof VersionedNode))
+      NodeInvocationDelegate delegate = (NodeInvocationDelegate) node;
+      if (!(delegate.getUnversionedNode() instanceof VersionedNode))
       {
-         throw new IllegalArgumentException("node " + node + " not VersionedNode");
+         throw new IllegalArgumentException("node " + delegate.getUnversionedNode() + " not VersionedNode");
       }
       this.node = node;
       this.workspace = workspace;
@@ -145,11 +147,11 @@
       }
 
       Set<Object> names = new HashSet<Object>(optimisticChildNodeMap.keySet());
-      
+
       // process deltas
       for (Fqn child : childrenAdded) names.add(child.getLastElement());
       for (Fqn child : childrenRemoved) names.remove(child.getLastElement());
-      
+
       return names;
    }
 
@@ -194,11 +196,11 @@
       // if not we need to create it
 //      if (child == null)
 //      {
-         NodeFactory<K, V> factory = cache.getConfiguration().getRuntimeConfig().getNodeFactory();
-         NodeSPI<K, V> child = (NodeSPI<K, V>) factory.createNodeOfType(parent, child_name, parent, null);
+      NodeFactory<K, V> factory = cache.getConfiguration().getRuntimeConfig().getNodeFactory();
+      NodeSPI<K, V> child = (NodeSPI<K, V>) factory.createNodeOfType(parent, child_name, parent, null);
 //         optimisticChildNodeMap.put(child_name, child);
-         childrenAdded.add(child.getFqn());
-         childrenRemoved.remove(child.getFqn());
+      childrenAdded.add(child.getFqn());
+      childrenRemoved.remove(child.getFqn());
 //      }
       childrenModified = true;
       return child;
@@ -294,22 +296,22 @@
       else
       {
          // recursively create children
-         Node<K,V> currentParent = this;
+         Node<K, V> currentParent = this;
          for (Object o : f.peekElements())
          {
             if (currentParent instanceof WorkspaceNode)
             {
-               newNode = ((WorkspaceNode<K,V>) currentParent).getNode().getOrCreateChild(o, gtx);
+               newNode = ((WorkspaceNode<K, V>) currentParent).getNode().getOrCreateChild(o, gtx);
             }
             else
             {
                if (currentParent instanceof WorkspaceNode)
                {
-                  newNode = ((WorkspaceNode<K,V>) currentParent).getNode().getOrCreateChild(o, gtx);
+                  newNode = ((WorkspaceNode<K, V>) currentParent).getNode().getOrCreateChild(o, gtx);
                }
                else
                {
-                  newNode = ((NodeSPI<K,V>) currentParent).getOrCreateChild(o, gtx);
+                  newNode = ((NodeSPI<K, V>) currentParent).getOrCreateChild(o, gtx);
                }
             }
             currentParent = newNode;
@@ -318,7 +320,7 @@
       return newNode;
    }
 
-   public void addChild(WorkspaceNode<K,V> child)
+   public void addChild(WorkspaceNode<K, V> child)
    {
 //      optimisticChildNodeMap.put(child.getFqn().getLastElement(), child.getNode());
       childrenAdded.add(child.getFqn());
@@ -409,10 +411,10 @@
       Fqn childFqn = new Fqn(getFqn(), childName);
       /*if (n != null)
       {*/
-         childrenRemoved.add(childFqn);
-         childrenAdded.remove(childFqn);
-         childrenModified = true;
-         return node.getChildDirect(childName) != null;
+      childrenRemoved.add(childFqn);
+      childrenAdded.remove(childFqn);
+      childrenModified = true;
+      return node.getChildDirect(childName) != null;
       /*}
       else
       {

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java	2007-12-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -10,10 +10,12 @@
 import net.jcip.annotations.ThreadSafe;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheImpl;
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.Modification;
 import org.jboss.cache.config.Option;
+import org.jboss.cache.invocation.CacheInvocationDelegate;
 import org.jboss.cache.lock.IdentityLock;
 import org.jboss.cache.lock.NodeLock;
 import org.jboss.cache.marshall.MethodCall;
@@ -338,14 +340,15 @@
       {
          l = new ArrayList<MethodCall>(undo_list);
       }
+      CacheImpl ci = ((CacheInvocationDelegate) cache).getImpl();
       for (ListIterator<MethodCall> i = l.listIterator(l.size()); i.hasPrevious();)
       {
          MethodCall undo_op = i.previous();
-         undo(undo_op, cache);
+         undo(undo_op, ci);
       }
    }
 
-   private void undo(MethodCall undo_op, CacheSPI cache)
+   private void undo(MethodCall undo_op, CacheImpl cache)
    {
       try
       {

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java	2007-12-13 14:15:28 UTC (rev 4849)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java	2007-12-13 17:30:43 UTC (rev 4850)
@@ -7,7 +7,7 @@
 
 package org.jboss.cache.marshall;
 
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.Region;
@@ -31,7 +31,7 @@
 public class ActiveInactiveTest
 {
    RegionManager rman;
-   CacheImpl c;
+   CacheSPI c;
    Fqn<String> A = Fqn.fromString("/a");
    Fqn<String> I = Fqn.fromString("/i");
    Fqn<String> A_B = new Fqn<String>(A, "b");
@@ -39,7 +39,7 @@
    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception
    {
-      c = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
+      c = (CacheSPI) DefaultCacheFactory.getInstance().createCache(false);
       c.getConfiguration().setUseRegionBasedMarshalling(true);
       c.getConfiguration().setFetchInMemoryState(false);
       c.start();
@@ -49,9 +49,12 @@
    @AfterMethod(alwaysRun = true)
    public void tearDown() throws Exception
    {
-      c.stop();
-      c = null;
-      rman = null;
+      if (c != null)
+      {
+         c.stop();
+         c = null;
+         rman = null;
+      }
    }
 
    public void testDefaultActive() throws Exception




More information about the jbosscache-commits mailing list