[jboss-cvs] JBossCache/src/org/jboss/cache/optimistic ...

Manik Surtani msurtani at jboss.com
Thu Jan 4 00:35:41 EST 2007


  User: msurtani
  Date: 07/01/04 00:35:41

  Modified:    src/org/jboss/cache/optimistic   WorkspaceNodeImpl.java
                        WorkspaceNode.java
  Log:
  Major changes around nodes, and the way they interact with the interceptor stack.
  Also removed redundant methods in NodeSPI and removed the need for casting to NodeSPI in most cases.
  
  Revision  Changes    Path
  1.40      +33 -31    JBossCache/src/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WorkspaceNodeImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/optimistic/WorkspaceNodeImpl.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -b -r1.39 -r1.40
  --- WorkspaceNodeImpl.java	2 Jan 2007 19:19:05 -0000	1.39
  +++ WorkspaceNodeImpl.java	4 Jan 2007 05:35:41 -0000	1.40
  @@ -14,7 +14,6 @@
   import org.jboss.cache.GlobalTransaction;
   import org.jboss.cache.Node;
   import org.jboss.cache.NodeSPI;
  -import org.jboss.cache.UnversionedNode;
   import org.jboss.cache.VersionedNode;
   
   import java.util.Collections;
  @@ -55,12 +54,16 @@
         }
         this.node = node;
         this.workspace = workspace;
  -      optimisticDataMap = new HashMap<Object, Object>(node.getRawData());
  +      optimisticDataMap = new HashMap<Object, Object>(node.getDataDirect());
         Map<Object, Node> childrenMap = node.getChildrenMap();
         if (childrenMap == null)
  +      {
            optimisticChildNodeMap = new ConcurrentHashMap<Object, NodeSPI>();
  +      }
         else
  +      {
            optimisticChildNodeMap = new ConcurrentHashMap(childrenMap);
  +      }
         this.version = node.getVersion();
         if (version == null)
         {
  @@ -168,7 +171,7 @@
         versioningImplicit = b;
      }
   
  -   public Node getChild(Object childName)
  +   public NodeSPI getChild(Object childName)
      {
         //see if in the the transaction map
         return optimisticChildNodeMap.get(childName);
  @@ -231,13 +234,7 @@
   
      public Node addChild(Fqn f)
      {
  -      if (log.isTraceEnabled())
  -      {
  -         log.trace("Adding child " + f + " to " + getFqn());
  -      }
         CacheSPI cache = getCache();
  -      if (cache.getInvocationContext().getOptionOverrides().isBypassInterceptorChain())
  -      {
            Node newNode = this;
            GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
   
  @@ -252,33 +249,38 @@
               for (Object o : f.peekElements())
               {
                  if (currentParent instanceof WorkspaceNode)
  +            {
                     newNode = ((WorkspaceNode) currentParent).getNode().getOrCreateChild(o, gtx);
  -               else
  -                  newNode = currentParent.getNodeSPI().getOrCreateChild(o, gtx);
  -               currentParent = newNode;
               }
  -         }
  -
  -         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(false);
  -         return newNode;
  +            else
  +            {
  +               if (currentParent instanceof WorkspaceNode)
  +               {
  +                  newNode = ((WorkspaceNode) currentParent).getNode().getOrCreateChild(o, gtx);
         }
         else
         {
  -         Fqn nf = new Fqn(getFqn(), f);
  -         cache.put(nf, Collections.emptyMap());
  -         return getChild(f);
  +                  newNode = ((NodeSPI) currentParent).getOrCreateChild(o, gtx);
  +               }
         }
  +            currentParent = newNode;
  +         }
  +      }
  +      return newNode;
      }
   
      public void clearData()
      {
  +      dirty = true;
         optimisticDataMap.clear();
      }
   
  -   public Node getChild(Fqn f)
  +   public NodeSPI getChild(Fqn f)
      {
         if (f.size() > 1)
  +      {
            throw new UnsupportedOperationException("Workspace node does not support fetching indirect children");
  +      }
         return getChild(f.getLastElement());
      }
   
  @@ -320,6 +322,6 @@
   
      protected CacheSPI getCache()
      {
  -      return ((UnversionedNode) node).getCache();
  +      return node.getCache();
      }
   }
  
  
  
  1.21      +17 -0     JBossCache/src/org/jboss/cache/optimistic/WorkspaceNode.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WorkspaceNode.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/optimistic/WorkspaceNode.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -b -r1.20 -r1.21
  --- WorkspaceNode.java	2 Jan 2007 17:15:30 -0000	1.20
  +++ WorkspaceNode.java	4 Jan 2007 05:35:41 -0000	1.21
  @@ -7,6 +7,7 @@
   package org.jboss.cache.optimistic;
   
   import org.jboss.cache.CacheSPI;
  +import org.jboss.cache.Fqn;
   import org.jboss.cache.Node;
   import org.jboss.cache.NodeSPI;
   
  @@ -137,4 +138,20 @@
       * @param recursive if true, child nodes (and their children) are marked as well.
       */
      void markAsDeleted(boolean marker, boolean recursive);
  +
  +   /**
  +    * Overrides {@link Node#getChild(Object)} to return a {@link org.jboss.cache.NodeSPI} rather than a {@link org.jboss.cache.Node}
  +    *
  +    * @param o node name
  +    * @return a child node
  +    */
  +   NodeSPI getChild(Object o);
  +
  +   /**
  +    * Overrides {@link Node#getChild(Fqn)} to return a {@link org.jboss.cache.NodeSPI} rather than a {@link org.jboss.cache.Node}
  +    *
  +    * @param f node fqn
  +    * @return a child node
  +    */
  +   NodeSPI getChild(Fqn f);
   }
  
  
  



More information about the jboss-cvs-commits mailing list