[dna-commits] DNA SVN: r778 - in trunk: dna-common/src/main/java/org/jboss/dna/common/util and 3 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Tue Mar 17 11:43:09 EDT 2009


Author: rhauch
Date: 2009-03-17 11:43:09 -0400 (Tue, 17 Mar 2009)
New Revision: 778

Added:
   trunk/dna-common/src/main/java/org/jboss/dna/common/collection/EmptyIterator.java
   trunk/dna-common/src/main/java/org/jboss/dna/common/collection/ReadOnlyIterator.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChildNode.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/Children.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/EmptyChildren.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableChildren.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableNodeInfo.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NodeInfo.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/PropertyInfo.java
Removed:
   trunk/dna-common/src/main/java/org/jboss/dna/common/util/EmptyIterator.java
Modified:
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrChildNodeIterator.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrPropertyTest.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrChildNodeIteratorTest.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrMultiValuePropertyTest.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSingleValuePropertyTest.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/SessionCacheTest.java
Log:
DNA-194 Implement update JCR capability

Changed SessionCache to use immutable versions of the node, child and property representations, in preparation for mutable ones in the "changed cache".

Copied: trunk/dna-common/src/main/java/org/jboss/dna/common/collection/EmptyIterator.java (from rev 776, trunk/dna-common/src/main/java/org/jboss/dna/common/util/EmptyIterator.java)
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/collection/EmptyIterator.java	                        (rev 0)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/collection/EmptyIterator.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -0,0 +1,61 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors. 
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.common.collection;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * @author jverhaeg
+ * @param <T> some type
+ */
+public final class EmptyIterator<T> implements Iterator<T> {
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Iterator#hasNext()
+     */
+    public boolean hasNext() {
+        return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Iterator#next()
+     */
+    public T next() {
+        throw new NoSuchElementException();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Iterator#remove()
+     */
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+}


Property changes on: trunk/dna-common/src/main/java/org/jboss/dna/common/collection/EmptyIterator.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/dna-common/src/main/java/org/jboss/dna/common/collection/ReadOnlyIterator.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/collection/ReadOnlyIterator.java	                        (rev 0)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/collection/ReadOnlyIterator.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -0,0 +1,70 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * Unless otherwise indicated, all code in JBoss DNA is licensed
+ * to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.common.collection;
+
+import java.util.Iterator;
+
+/**
+ * An {@link Iterator} implementation that only allows reading elements, used as a wrapper around another iterator to make the
+ * contents appear to be immutable.
+ * 
+ * @param <T> the type that is being iterated over
+ */
+public final class ReadOnlyIterator<T> implements Iterator<T> {
+
+    private final Iterator<T> delegate;
+
+    public ReadOnlyIterator( Iterator<T> delegate ) {
+        this.delegate = delegate;
+        assert this.delegate != null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Iterator#hasNext()
+     */
+    public boolean hasNext() {
+        return delegate.hasNext();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Iterator#next()
+     */
+    public T next() {
+        return delegate.next();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Iterator#remove()
+     */
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+
+}


Property changes on: trunk/dna-common/src/main/java/org/jboss/dna/common/collection/ReadOnlyIterator.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: trunk/dna-common/src/main/java/org/jboss/dna/common/util/EmptyIterator.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/util/EmptyIterator.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/EmptyIterator.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -1,61 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of 
- * individual contributors. 
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.common.util;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * @author jverhaeg
- * @param <T> some type
- */
-public final class EmptyIterator<T> implements Iterator<T> {
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see java.util.Iterator#hasNext()
-     */
-    public boolean hasNext() {
-        return false;
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see java.util.Iterator#next()
-     */
-    public T next() {
-        throw new NoSuchElementException();
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see java.util.Iterator#remove()
-     */
-    public void remove() {
-        throw new UnsupportedOperationException();
-    }
-}

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -56,14 +56,14 @@
 import org.jboss.dna.graph.property.NamespaceRegistry;
 import org.jboss.dna.graph.property.Path;
 import org.jboss.dna.graph.property.ValueFormatException;
-import org.jboss.dna.jcr.SessionCache.ChildNode;
-import org.jboss.dna.jcr.SessionCache.Children;
-import org.jboss.dna.jcr.SessionCache.NodeInfo;
+import org.jboss.dna.jcr.cache.ChildNode;
+import org.jboss.dna.jcr.cache.Children;
+import org.jboss.dna.jcr.cache.NodeInfo;
 
 /**
  * An abstract implementation of the JCR {@link Node} interface. Instances of this class are created and managed by the
- * {@link SessionCache}. Each instance references the {@link SessionCache.NodeInfo node information} also managed by the
- * SessionCache, and finds and operates against this information with each method call.
+ * {@link SessionCache}. Each instance references the {@link NodeInfo node information} also managed by the SessionCache, and
+ * finds and operates against this information with each method call.
  */
 @Immutable
 abstract class AbstractJcrNode extends AbstractJcrItem implements Node {
@@ -266,7 +266,7 @@
      * @see javax.jcr.Node#hasProperties()
      */
     public final boolean hasProperties() throws RepositoryException {
-        return nodeInfo().getProperties().size() > 0;
+        return nodeInfo().hasProperties();
     }
 
     /**

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -37,7 +37,7 @@
 import org.jboss.dna.common.util.CheckArg;
 import org.jboss.dna.graph.property.Name;
 import org.jboss.dna.graph.property.Path;
-import org.jboss.dna.jcr.SessionCache.PropertyInfo;
+import org.jboss.dna.jcr.cache.PropertyInfo;
 
 /**
  * @author jverhaeg

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrChildNodeIterator.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrChildNodeIterator.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrChildNodeIterator.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -29,7 +29,7 @@
 import javax.jcr.RepositoryException;
 import net.jcip.annotations.Immutable;
 import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.jcr.SessionCache.ChildNode;
+import org.jboss.dna.jcr.cache.ChildNode;
 
 /**
  */

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -25,15 +25,14 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.ListIterator;
 import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
 import javax.jcr.Item;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.Node;
@@ -45,8 +44,6 @@
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.PropertyDefinition;
-import net.jcip.annotations.Immutable;
-import net.jcip.annotations.NotThreadSafe;
 import net.jcip.annotations.ThreadSafe;
 import org.jboss.dna.graph.ExecutionContext;
 import org.jboss.dna.graph.Graph;
@@ -63,9 +60,13 @@
 import org.jboss.dna.graph.property.ValueFactories;
 import org.jboss.dna.graph.property.ValueFactory;
 import org.jboss.dna.graph.property.ValueFormatException;
+import org.jboss.dna.jcr.cache.ChildNode;
+import org.jboss.dna.jcr.cache.Children;
+import org.jboss.dna.jcr.cache.ImmutableChildren;
+import org.jboss.dna.jcr.cache.ImmutableNodeInfo;
+import org.jboss.dna.jcr.cache.NodeInfo;
+import org.jboss.dna.jcr.cache.PropertyInfo;
 import com.google.common.base.ReferenceType;
-import com.google.common.collect.LinkedListMultimap;
-import com.google.common.collect.ListMultimap;
 import com.google.common.collect.ReferenceMap;
 
 /**
@@ -247,10 +248,10 @@
     public Collection<AbstractJcrProperty> findJcrPropertiesFor( UUID nodeUuid )
         throws ItemNotFoundException, RepositoryException {
         NodeInfo info = findNodeInfo(nodeUuid);
-        Map<Name, PropertyInfo> properties = info.getProperties();
-        Collection<AbstractJcrProperty> result = new ArrayList<AbstractJcrProperty>(properties.size());
-        for (PropertyInfo propertyInfo : properties.values()) {
-            result.add(findJcrProperty(propertyInfo.getPropertyId()));
+        Set<Name> propertyNames = info.getPropertyNames();
+        Collection<AbstractJcrProperty> result = new ArrayList<AbstractJcrProperty>(propertyNames.size());
+        for (Name propertyName : propertyNames) {
+            result.add(findJcrProperty(new PropertyId(nodeUuid, propertyName)));
         }
         return result;
     }
@@ -377,22 +378,6 @@
         return new JcrSingleValueProperty(this, info.getPropertyId());
     }
 
-    // public AbstractJcrProperty findJcrProperty( Path propertyPath ) throws PathNotFoundException, RepositoryException {
-    // if (propertyPath.isRoot()) return null;
-    // Path nodePath = propertyPath.getParent();
-    // NodeInfo nodeInfo = findNodeInfo(nodePath);
-    // Name propertyName = propertyPath.getLastSegment().getName();
-    // PropertyInfo info = nodeInfo.getProperty(propertyName);
-    //
-    // // Look for an existing JCR Property object ...
-    // PropertyId propertyId = info.getPropertyId();
-    // AbstractJcrProperty property = jcrProperties.get(propertyId);
-    // if (property != null) return property;
-    //
-    // // Now create the appropriate JCR Property object ...
-    // return createAndCacheJcrPropertyFor(info);
-    // }
-
     /**
      * Find the information for the node given by the UUID of the node. This is often the fastest way to find information,
      * especially after the information has been cached. Note, however, that this method first checks the cache, and if the
@@ -617,9 +602,7 @@
             NodeInfo parentInfo = findNodeInfo(parent);
             ChildNode child = parentInfo.getChildren().getChild(info.getUuid());
             if (child == null) break;
-            Path.Segment segment = pathFactory.createSegment(child.getName(), child.getSnsIndex());
-
-            segments.addFirst(segment);
+            segments.addFirst(child.getSegment());
             info = parentInfo;
         }
         return pathFactory.createAbsolutePath(segments);
@@ -826,17 +809,6 @@
             }
         }
 
-        // Create the node information ...
-        NodeInfo info = new NodeInfo(location, primaryTypeName, definition.getId());
-        if (parentInfo != null) {
-            info.setParent(parentInfo.getUuid());
-        }
-
-        // --------------------------------------------------
-        // Set the node's children ...
-        // --------------------------------------------------
-        info.setChildren(graphNode.getChildren());
-
         // ------------------------------------------------------
         // Set the node's properties ...
         // ------------------------------------------------------
@@ -894,6 +866,7 @@
         }
 
         // Now create the JCR property object wrappers around the other properties ...
+        Map<Name, PropertyInfo> props = new HashMap<Name, PropertyInfo>();
         for (org.jboss.dna.graph.property.Property dnaProp : graphProperties.values()) {
             Name name = dnaProp.getName();
 
@@ -958,7 +931,9 @@
 
             // Record the property in the node information ...
             PropertyId propId = new PropertyId(uuid, name);
-            info.setProperty(propId, (JcrPropertyDefinition)propertyDefinition, propertyType, dnaProp);
+            JcrPropertyDefinition defn = (JcrPropertyDefinition)propertyDefinition;
+            PropertyInfo propInfo = new PropertyInfo(propId, defn.getId(), propertyType, dnaProp, defn.isMultiple());
+            props.put(name, propInfo);
         }
 
         // Now add the "jcr:uuid" property if and only if referenceable ...
@@ -966,15 +941,21 @@
             // We know that this property is single-valued
             PropertyDefinition propertyDefinition = svPropertyDefinitionsByPropertyName.get(JcrLexicon.UUID);
             PropertyId propId = new PropertyId(uuid, JcrLexicon.UUID);
-            info.setProperty(propId, (JcrPropertyDefinition)propertyDefinition, PropertyType.STRING, uuidProperty);
+            JcrPropertyDefinition defn = (JcrPropertyDefinition)propertyDefinition;
+            PropertyInfo propInfo = new PropertyInfo(propId, defn.getId(), PropertyType.STRING, uuidProperty, defn.isMultiple());
+            props.put(JcrLexicon.UUID, propInfo);
         } else {
             // Make sure there is NOT a "jcr:uuid" property ...
-            info.removeProperty(JcrLexicon.UUID);
+            props.remove(JcrLexicon.UUID);
         }
         // Make sure the "dna:uuid" property did not get in there ...
-        info.removeProperty(DnaLexicon.UUID);
+        props.remove(DnaLexicon.UUID);
 
-        return info;
+        // Create the node information ...
+        UUID parentUuid = parentInfo != null ? parentInfo.getUuid() : null;
+        Children children = new ImmutableChildren(parentUuid, graphNode.getChildren());
+        props = Collections.unmodifiableMap(props);
+        return new ImmutableNodeInfo(location, primaryTypeName, definition.getId(), parentUuid, children, props);
     }
 
     /**
@@ -1001,583 +982,4 @@
         // TODO: should this also check the mixins?
         return primaryType.findBestNodeDefinitionForChild(childName, primaryTypeOfChild);
     }
-
-    /**
-     * The information that describes a node. This is the information that is kept in the {@link SessionCache#cachedNodes cache}
-     * and in the record of {@link SessionCache#changedNodes changes} made by the session but not yet commited/saved.
-     */
-    @NotThreadSafe
-    protected class NodeInfo {
-        private final Location originalLocation;
-        private final UUID uuid;
-        private UUID parent;
-        private final Name primaryTypeName;
-        private final NodeDefinitionId definition;
-        private final Children children;
-        private final Map<Name, PropertyInfo> properties;
-
-        protected NodeInfo( Location originalLocation,
-                            Name primaryTypeName,
-                            NodeDefinitionId definition ) {
-            this.originalLocation = originalLocation;
-            this.primaryTypeName = primaryTypeName;
-            this.definition = definition;
-            this.uuid = this.originalLocation.getUuid();
-            this.children = new Children(this.uuid);
-            this.properties = new HashMap<Name, PropertyInfo>();
-            assert this.uuid != null;
-            assert this.definition != null;
-            assert this.primaryTypeName != null;
-        }
-
-        /**
-         * @return location
-         */
-        public Location getOriginalLocation() {
-            return originalLocation;
-        }
-
-        /**
-         * @return uuid
-         */
-        public UUID getUuid() {
-            return uuid;
-        }
-
-        /**
-         * @return parent
-         */
-        public UUID getParent() {
-            return parent;
-        }
-
-        /**
-         * @param parent Sets parent to the specified value.
-         */
-        protected void setParent( UUID parent ) {
-            this.parent = parent;
-        }
-
-        /**
-         * @return primaryTypeName
-         */
-        public Name getPrimaryTypeName() {
-            return primaryTypeName;
-        }
-
-        /**
-         * @return definition
-         */
-        public NodeDefinitionId getDefinitionId() {
-            return definition;
-        }
-
-        /**
-         * Get the children for this node.
-         * 
-         * @return the children; never null but possibly empty
-         */
-        public Children getChildren() {
-            return children;
-        }
-
-        /**
-         * @param children Sets children to the specified value.
-         * @return the children information; never null
-         */
-        public Children setChildren( List<Location> children ) {
-            this.children.append(SessionCache.this, children, true);
-            return this.children;
-        }
-
-        /**
-         * Get the map of information for each property.
-         * 
-         * @return the information for each property; never null but possibly (though unlikely) empty
-         */
-        public Map<Name, PropertyInfo> getProperties() {
-            return this.properties; // never null
-        }
-
-        public PropertyInfo getProperty( Name name ) {
-            return this.properties.get(name);
-        }
-
-        public PropertyInfo setProperty( PropertyId id,
-                                         JcrPropertyDefinition definition,
-                                         int propertyType,
-                                         Property dnaProperty ) {
-            // Initialize the map if required (this never replaces it, though) ...
-            PropertyInfo info = new PropertyInfo(id, definition.getId(), propertyType, dnaProperty, definition.isMultiple());
-            return this.properties.put(id.getPropertyName(), info);
-        }
-
-        public PropertyInfo removeProperty( Name name ) {
-            return this.properties.remove(name);
-        }
-    }
-
-    /**
-     * An immutable representation of the name and current value(s) for a property, along with the JCR metadata for the property,
-     * including the {@link PropertyInfo#getDefinitionId() property definition} and {@link PropertyInfo#getPropertyType() property
-     * type}.
-     * <p>
-     * This class is immutable, which means that clients should never hold onto an instance. Instead, clients can obtain an
-     * instance by using a {@link PropertyId}, quickly use the information in the instance, and then immediately discard their
-     * reference. This is because these instances are replaced and discarded whenever anything about the property changes.
-     * </p>
-     */
-    @Immutable
-    public static class PropertyInfo {
-        private final PropertyId propertyId;
-        private final PropertyDefinitionId definitionId;
-        private final Property dnaProperty;
-        private final int propertyType;
-        private final boolean multiValued;
-
-        protected PropertyInfo( PropertyId propertyId,
-                                PropertyDefinitionId definitionId,
-                                int propertyType,
-                                Property dnaProperty,
-                                boolean multiValued ) {
-            this.propertyId = propertyId;
-            this.definitionId = definitionId;
-            this.propertyType = propertyType;
-            this.dnaProperty = dnaProperty;
-            this.multiValued = multiValued;
-        }
-
-        /**
-         * Get the durable identifier for this property.
-         * 
-         * @return propertyId
-         */
-        public PropertyId getPropertyId() {
-            return propertyId;
-        }
-
-        /**
-         * Get the UUID of the node to which this property belongs.
-         * 
-         * @return the owner node's UUID; never null
-         */
-        public UUID getNodeUuid() {
-            return propertyId.getNodeId();
-        }
-
-        /**
-         * The identifier for the property definition.
-         * 
-         * @return the property definition ID; never null
-         */
-        public PropertyDefinitionId getDefinitionId() {
-            return definitionId;
-        }
-
-        /**
-         * Get the DNA Property, which contains the name and value(s)
-         * 
-         * @return the property; never null
-         */
-        public Property getProperty() {
-            return dnaProperty;
-        }
-
-        /**
-         * Get the property name.
-         * 
-         * @return the property name; never null
-         */
-        public Name getPropertyName() {
-            return dnaProperty.getName();
-        }
-
-        /**
-         * Get the JCR {@link PropertyType} for this property.
-         * 
-         * @return the property type
-         */
-        public int getPropertyType() {
-            return propertyType;
-        }
-
-        /**
-         * @return multiValued
-         */
-        public boolean isMultiValued() {
-            return multiValued;
-        }
-
-        /**
-         * {@inheritDoc}
-         * 
-         * @see java.lang.Object#hashCode()
-         */
-        @Override
-        public int hashCode() {
-            return propertyId.hashCode();
-        }
-
-        /**
-         * {@inheritDoc}
-         * 
-         * @see java.lang.Object#equals(java.lang.Object)
-         */
-        @Override
-        public boolean equals( Object obj ) {
-            if (obj == this) return true;
-            if (obj instanceof PropertyInfo) {
-                return propertyId.equals(((PropertyInfo)obj).getPropertyId());
-            }
-            return false;
-        }
-
-        /**
-         * {@inheritDoc}
-         * 
-         * @see java.lang.Object#toString()
-         */
-        @Override
-        public String toString() {
-            StringBuilder sb = new StringBuilder();
-            sb.append(propertyId);
-            sb.append(" defined by ").append(definitionId);
-            sb.append(" of type ").append(PropertyType.nameFromValue(propertyType));
-            if (dnaProperty.isSingle()) {
-                sb.append(" with value ");
-            } else {
-                sb.append(" with values ");
-            }
-            sb.append(dnaProperty.getValuesAsArray());
-            return sb.toString();
-        }
-    }
-
-    /**
-     * Class that maintains the ordered list of {@link ChildNode} instances. This class uses a {@link ListMultimap} to maintain
-     * insertion order of the child nodes, and to allow fast access to the children with a specified name.
-     */
-    @ThreadSafe
-    public final static class Children implements Iterable<ChildNode> {
-        private final UUID parentUuid;
-        private final Map<UUID, ChildNode> childrenByUuid;
-        private final ListMultimap<Name, ChildNode> childrenByName;
-        private final ReadWriteLock lock = new ReentrantReadWriteLock();
-
-        Children( UUID parentUuid ) {
-            this.parentUuid = parentUuid;
-            this.childrenByUuid = new HashMap<UUID, ChildNode>();
-            this.childrenByName = new LinkedListMultimap<Name, ChildNode>();
-        }
-
-        /**
-         * Get the number of children.
-         * 
-         * @return the number of children
-         */
-        public int size() {
-            try {
-                lock.readLock().lock();
-                return childrenByName.size();
-            } finally {
-                lock.readLock().unlock();
-            }
-        }
-
-        /**
-         * Get the children.
-         * 
-         * @return a copy of the list of children
-         */
-        public List<ChildNode> asList() {
-            try {
-                lock.readLock().lock();
-                return new ArrayList<ChildNode>(childrenByName.values());
-            } finally {
-                lock.readLock().unlock();
-            }
-        }
-
-        /**
-         * Get the children.
-         * 
-         * @return a copy of the list of children
-         */
-        public Iterator<ChildNode> iterator() {
-            return asList().iterator();
-        }
-
-        /**
-         * The UUID of the parent node.
-         * 
-         * @return the parent node's UUID
-         */
-        public UUID getParentUuid() {
-            return parentUuid;
-        }
-
-        /**
-         * Get the child with the given UUID.
-         * 
-         * @param uuid the UUID of the child node
-         * @return the child node, or null if there is no child with the supplied UUID
-         */
-        public ChildNode getChild( UUID uuid ) {
-            try {
-                lock.readLock().lock();
-                return this.childrenByUuid.get(uuid);
-            } finally {
-                lock.readLock().unlock();
-            }
-        }
-
-        /**
-         * Get the child given the path segment.
-         * 
-         * @param segment the path segment for the child, which includes the {@link Path.Segment#getName() name} and
-         *        {@link Path.Segment#getIndex() one-based same-name-sibling index}; may not be null
-         * @return the information for the child node, or null if no such child existed
-         */
-        public ChildNode getChild( Path.Segment segment ) {
-            try {
-                lock.readLock().lock();
-                List<ChildNode> childrenWithName = this.childrenByName.get(segment.getName());
-                int snsIndex = segment.getIndex();
-                if (childrenWithName.size() < snsIndex) return null;
-                return childrenWithName.get(snsIndex - 1);
-            } finally {
-                lock.readLock().unlock();
-            }
-        }
-
-        /**
-         * Get the same-name-sibling children that all share the supplied name.
-         * 
-         * @param name the name for the children; may not be null
-         * @return the children with the supplied name; never null
-         */
-        public List<ChildNode> getChildren( Name name ) {
-            try {
-                lock.readLock().lock();
-                return new ArrayList<ChildNode>(this.childrenByName.get(name));
-            } finally {
-                lock.readLock().unlock();
-            }
-        }
-
-        /**
-         * Remove the child with the given path segment.
-         * 
-         * @param segment the path segment for the child, which includes the {@link Path.Segment#getName() name} and
-         *        {@link Path.Segment#getIndex() one-based same-name-sibling index}; may not be null
-         * @return the information for the child node that was removed, or null if no such child existed
-         */
-        public ChildNode remove( Path.Segment segment ) {
-            try {
-                lock.writeLock().lock();
-                List<ChildNode> childrenWithName = this.childrenByName.get(segment.getName());
-                int snsIndex = segment.getIndex();
-                int numChildrenWithName = childrenWithName.size();
-                if (numChildrenWithName < snsIndex) return null;
-                ChildNode result = childrenWithName.remove(snsIndex);
-                this.childrenByUuid.remove(result.getUuid());
-                --numChildrenWithName;
-                if (numChildrenWithName > snsIndex) {
-                    // We need to reduce the SNS index of every child after the one that was just removed ...
-                    ListIterator<ChildNode> siblingIter = childrenWithName.listIterator(snsIndex);
-                    while (siblingIter.hasNext()) {
-                        // Remove the next child and replace with one having the correct SNS index ...
-                        ChildNode next = siblingIter.next();
-                        siblingIter.remove();
-                        siblingIter.set(next.withChangedSnsIndex(-1));
-                    }
-                }
-                return result;
-            } finally {
-                lock.writeLock().unlock();
-            }
-        }
-
-        /**
-         * Add a new child to the end of the list of existing children a new child with the supplied name and UUID. The
-         * same-name-sibling will be determined to be one more than the number of existing children with the same name.
-         * 
-         * @param cache the cache; may not be null
-         * @param name the name for the child to be appended; may not be null
-         * @param childUuid the UUID of the child; may not be null
-         * @return the information for the newly-added child; never null
-         */
-        public ChildNode append( SessionCache cache,
-                                 Name name,
-                                 UUID childUuid ) {
-            try {
-                lock.writeLock().lock();
-                List<ChildNode> childrenWithName = this.childrenByName.get(name);
-                ChildNode child = new ChildNode(childUuid, name, childrenWithName.size() + 1);
-                childrenWithName.add(child);
-                this.childrenByUuid.put(childUuid, child);
-                // Look for the child in the cache/changed nodes ...
-                NodeInfo childInfo = cache.findNodeInfoInCache(childUuid);
-                if (childInfo != null) childInfo.setParent(parentUuid);
-                return child;
-            } finally {
-                lock.writeLock().unlock();
-            }
-        }
-
-        /**
-         * Append the children described by the supplied Location objects, optionally removing all existing children first.
-         * 
-         * @param cache the cache; may not be null
-         * @param children a list containing a Location object for each child
-         * @param removeExistingFirst true if the existing children should be removed before these children are added, or false if
-         *        these children should be appended to the existing children
-         */
-        public void append( SessionCache cache,
-                            List<Location> children,
-                            boolean removeExistingFirst ) {
-            try {
-                lock.writeLock().lock();
-                if (removeExistingFirst && !this.childrenByName.isEmpty()) {
-                    for (ChildNode child : this.childrenByName.values()) {
-                        // Look for the child in the cache/changed nodes ...
-                        NodeInfo childInfo = cache.findNodeInfoInCache(child.getUuid());
-                        if (childInfo != null) childInfo.setParent(null);
-                        // TODO: These nodes are deleted and should be handled as deletes ...
-                    }
-                    this.childrenByUuid.clear();
-                    this.childrenByName.clear();
-                }
-                for (Location childLocation : children) {
-                    UUID childUuid = childLocation.getUuid();
-                    Path.Segment segment = childLocation.getPath().getLastSegment();
-                    Name name = segment.getName();
-                    ChildNode child = new ChildNode(childUuid, name, segment.getIndex());
-                    this.childrenByName.put(name, child);
-                    this.childrenByUuid.put(childUuid, child);
-                    // Look for the child in the cache/changed nodes ...
-                    NodeInfo childInfo = cache.findNodeInfoInCache(childUuid);
-                    if (childInfo != null) childInfo.setParent(parentUuid);
-                }
-            } finally {
-                lock.writeLock().unlock();
-            }
-        }
-
-        /**
-         * {@inheritDoc}
-         * 
-         * @see java.lang.Object#toString()
-         */
-        @Override
-        public String toString() {
-            StringBuilder sb = new StringBuilder();
-            try {
-                lock.readLock().lock();
-                boolean first = true;
-                for (ChildNode child : childrenByName.values()) {
-                    if (!first) sb.append(", ");
-                    else first = false;
-                    sb.append(child.getName()).append('[').append(child.getSnsIndex()).append(']');
-                }
-            } finally {
-                lock.readLock().unlock();
-            }
-            return sb.toString();
-        }
-    }
-
-    /**
-     * The information about a child node. This is designed to be found in the {@link Children}, used quickly, and discarded.
-     * Clients should not hold on to these objects, since any changes to the children involve discarding the old ChildNode objects
-     * and replacing them with new instances.
-     */
-    @Immutable
-    public final static class ChildNode {
-        private final UUID uuid;
-        private final Name name;
-        private final int snsIndex;
-
-        protected ChildNode( UUID uuid,
-                             Name name,
-                             int snsIndex ) {
-            this.uuid = uuid;
-            this.name = name;
-            this.snsIndex = snsIndex;
-            assert this.snsIndex > 0;
-        }
-
-        /**
-         * Get the UUID of the node.
-         * 
-         * @return the node's UUID; never null
-         */
-        public UUID getUuid() {
-            return uuid;
-        }
-
-        /**
-         * Get the name of the node.
-         * 
-         * @return the node's current name; never null
-         */
-        public Name getName() {
-            return name;
-        }
-
-        /**
-         * Get the same-name-sibling index of the node.
-         * 
-         * @return the node's SNS index; always positive
-         */
-        public int getSnsIndex() {
-            return snsIndex;
-        }
-
-        /**
-         * Return a new child node that has a changed SNS index.
-         * 
-         * @param delta the amount the change the SNS index, either positive to increase the value or negative to decrease the
-         *        value
-         * @return the copy of this, with a changed SNS index; never null
-         */
-        public ChildNode withChangedSnsIndex( int delta ) {
-            return new ChildNode(uuid, name, snsIndex + delta);
-        }
-
-        /**
-         * {@inheritDoc}
-         * 
-         * @see java.lang.Object#hashCode()
-         */
-        @Override
-        public int hashCode() {
-            return uuid.hashCode();
-        }
-
-        /**
-         * {@inheritDoc}
-         * 
-         * @see java.lang.Object#equals(java.lang.Object)
-         */
-        @Override
-        public boolean equals( Object obj ) {
-            if (obj == this) return true;
-            if (obj instanceof ChildNode) {
-                return this.uuid.equals(((ChildNode)obj).uuid);
-            }
-            return false;
-        }
-
-        /**
-         * {@inheritDoc}
-         * 
-         * @see java.lang.Object#toString()
-         */
-        @Override
-        public String toString() {
-            return uuid.toString() + " ( " + name + "[" + snsIndex + "] )";
-        }
-    }
-
 }

Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChildNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChildNode.java	                        (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChildNode.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -0,0 +1,133 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * Unless otherwise indicated, all code in JBoss DNA is licensed
+ * to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.cache;
+
+import java.util.UUID;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.Path;
+
+/**
+ * 
+ */
+/**
+ * The information about a child node. This is designed to be found in the {@link Children}, used quickly, and discarded. Clients
+ * should not hold on to these objects, since any changes to the children involve discarding the old ChildNode objects and
+ * replacing them with new instances.
+ */
+ at Immutable
+public final class ChildNode {
+
+    private final UUID uuid;
+    private final Path.Segment segment;
+
+    public ChildNode( UUID uuid,
+                      Path.Segment segment ) {
+        assert uuid != null;
+        assert segment != null;
+        this.uuid = uuid;
+        this.segment = segment;
+    }
+
+    /**
+     * Get the UUID of the node.
+     * 
+     * @return the node's UUID; never null
+     */
+    public UUID getUuid() {
+        return uuid;
+    }
+
+    /**
+     * Get the path segment for this node.
+     * 
+     * @return the path segment; never null
+     */
+    public Path.Segment getSegment() {
+        return segment;
+    }
+
+    /**
+     * Get the name of the node.
+     * 
+     * @return the node's current name; never null
+     */
+    public Name getName() {
+        return segment.getName();
+    }
+
+    /**
+     * Get the same-name-sibling index of the node.
+     * 
+     * @return the node's SNS index; always positive
+     */
+    public int getSnsIndex() {
+        return segment.getIndex();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        return uuid.hashCode();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals( Object obj ) {
+        if (obj == this) return true;
+        if (obj instanceof ChildNode) {
+            return this.uuid.equals(((ChildNode)obj).uuid);
+        }
+        return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return uuid.toString() + " ( " + getSegment() + " )";
+    }
+
+    /**
+     * Obtain a new instance that uses the same {@link #getUuid() UUID} but the supplied path segment.
+     * 
+     * @param newSegment the new segment; may not be null
+     * @return the new instance; never null
+     */
+    public ChildNode with( Path.Segment newSegment ) {
+        return new ChildNode(uuid, newSegment);
+    }
+
+}


Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChildNode.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/Children.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/Children.java	                        (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/Children.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -0,0 +1,88 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * Unless otherwise indicated, all code in JBoss DNA is licensed
+ * to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.cache;
+
+import java.util.Iterator;
+import java.util.UUID;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.PathFactory;
+
+/**
+ * Class that maintains the ordered list of {@link ChildNode} instances yet allows fast access to the children with a specified
+ * name.
+ */
+public interface Children extends Iterable<ChildNode> {
+
+    /**
+     * Get the number of children.
+     * 
+     * @return the number of children
+     */
+    int size();
+
+    /**
+     * The UUID of the parent node.
+     * 
+     * @return the parent node's UUID
+     */
+    UUID getParentUuid();
+
+    /**
+     * Get the child with the given UUID.
+     * 
+     * @param uuid the UUID of the child node
+     * @return the child node, or null if there is no child with the supplied UUID
+     */
+    ChildNode getChild( UUID uuid );
+
+    /**
+     * Get the child given the path segment.
+     * 
+     * @param segment the path segment for the child, which includes the {@link Path.Segment#getName() name} and
+     *        {@link Path.Segment#getIndex() one-based same-name-sibling index}; may not be null
+     * @return the information for the child node, or null if no such child existed
+     */
+    ChildNode getChild( Path.Segment segment );
+
+    /**
+     * Get the same-name-sibling children that all share the supplied name, in order of increasing SNS index.
+     * 
+     * @param name the name for the children; may not be null
+     * @return the children with the supplied name; never null
+     */
+    Iterator<ChildNode> getChildren( Name name );
+
+    /**
+     * Create another Children object that is equivalent to this node but with the supplied child added.
+     * 
+     * @param newChildName the name of the new child; may not be null
+     * @param newChildUuid the UUID of the new child; may not be null
+     * @param pathFactory the factory that can be used to create Path and/or Path.Segment instances.
+     * @return the new Children object; never null
+     */
+    Children with( Name newChildName,
+                   UUID newChildUuid,
+                   PathFactory pathFactory );
+}


Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/Children.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/EmptyChildren.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/EmptyChildren.java	                        (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/EmptyChildren.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -0,0 +1,117 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * Unless otherwise indicated, all code in JBoss DNA is licensed
+ * to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.cache;
+
+import java.util.Iterator;
+import java.util.UUID;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.collection.EmptyIterator;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.PathFactory;
+import org.jboss.dna.graph.property.Path.Segment;
+
+/**
+ * An immutable implementation of {@link Children}.
+ */
+ at Immutable
+public final class EmptyChildren implements Children {
+
+    private static final Iterator<ChildNode> EMPTY_ITERATOR = new EmptyIterator<ChildNode>();
+
+    private final UUID parentUuid;
+
+    public EmptyChildren( UUID parentUuid ) {
+        this.parentUuid = parentUuid;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.Children#size()
+     */
+    public int size() {
+        return 0;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.Iterable#iterator()
+     */
+    public Iterator<ChildNode> iterator() {
+        return EMPTY_ITERATOR;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.Children#getParentUuid()
+     */
+    public UUID getParentUuid() {
+        return parentUuid;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.Children#getChild(java.util.UUID)
+     */
+    public ChildNode getChild( UUID uuid ) {
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.Children#getChild(org.jboss.dna.graph.property.Path.Segment)
+     */
+    public ChildNode getChild( Segment segment ) {
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.Children#getChildren(org.jboss.dna.graph.property.Name)
+     */
+    public Iterator<ChildNode> getChildren( Name name ) {
+        return EMPTY_ITERATOR;
+    }
+
+    public ImmutableChildren with( Name newChildName,
+                                   UUID newChildUuid,
+                                   PathFactory pathFactory ) {
+        return new ImmutableChildren(this, newChildName, newChildUuid, pathFactory);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return "";
+    }
+}


Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/EmptyChildren.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableChildren.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableChildren.java	                        (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableChildren.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -0,0 +1,164 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * Unless otherwise indicated, all code in JBoss DNA is licensed
+ * to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.cache;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.collection.ReadOnlyIterator;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.PathFactory;
+import org.jboss.dna.graph.property.Path.Segment;
+import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.ListMultimap;
+
+/**
+ * An immutable implementation of {@link Children}.
+ */
+ at Immutable
+public final class ImmutableChildren implements Children {
+    private final UUID parentUuid;
+    private final Map<UUID, ChildNode> childrenByUuid;
+    private final ListMultimap<Name, ChildNode> childrenByName;
+
+    public ImmutableChildren( UUID parentUuid,
+                              Iterable<Location> children ) {
+        this.parentUuid = parentUuid;
+        this.childrenByUuid = new HashMap<UUID, ChildNode>();
+        this.childrenByName = new LinkedListMultimap<Name, ChildNode>();
+        for (Location childLocation : children) {
+            UUID childUuid = childLocation.getUuid();
+            Path.Segment segment = childLocation.getPath().getLastSegment();
+            Name name = segment.getName();
+            ChildNode child = new ChildNode(childUuid, segment);
+            this.childrenByName.put(name, child);
+            this.childrenByUuid.put(childUuid, child);
+        }
+    }
+
+    protected ImmutableChildren( Children original,
+                                 Name additionalChildName,
+                                 UUID childUuid,
+                                 PathFactory pathFactory ) {
+        this.parentUuid = original.getParentUuid();
+        this.childrenByUuid = new HashMap<UUID, ChildNode>();
+        this.childrenByName = new LinkedListMultimap<Name, ChildNode>();
+        Iterator<ChildNode> iter = original.iterator();
+        while (iter.hasNext()) {
+            ChildNode child = iter.next();
+            this.childrenByName.put(child.getName(), child);
+            this.childrenByUuid.put(child.getUuid(), child);
+        }
+        List<ChildNode> childrenWithName = this.childrenByName.get(additionalChildName);
+        Path.Segment segment = pathFactory.createSegment(additionalChildName, childrenWithName.size() + 1);
+        ChildNode additionalChild = new ChildNode(childUuid, segment);
+        this.childrenByName.put(additionalChildName, additionalChild);
+        this.childrenByUuid.put(childUuid, additionalChild);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.Children#size()
+     */
+    public int size() {
+        return childrenByName.size();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.Iterable#iterator()
+     */
+    public Iterator<ChildNode> iterator() {
+        return new ReadOnlyIterator<ChildNode>(this.childrenByName.values().iterator());
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.Children#getParentUuid()
+     */
+    public UUID getParentUuid() {
+        return parentUuid;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.Children#getChild(java.util.UUID)
+     */
+    public ChildNode getChild( UUID uuid ) {
+        return this.childrenByUuid.get(uuid);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.Children#getChild(org.jboss.dna.graph.property.Path.Segment)
+     */
+    public ChildNode getChild( Segment segment ) {
+        List<ChildNode> childrenWithName = this.childrenByName.get(segment.getName());
+        int snsIndex = segment.getIndex();
+        if (childrenWithName.size() < snsIndex) return null;
+        return childrenWithName.get(snsIndex - 1);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.Children#getChildren(org.jboss.dna.graph.property.Name)
+     */
+    public Iterator<ChildNode> getChildren( Name name ) {
+        return new ReadOnlyIterator<ChildNode>(this.childrenByName.get(name).iterator());
+    }
+
+    public ImmutableChildren with( Name newChildName,
+                                   UUID newChildUuid,
+                                   PathFactory pathFactory ) {
+        return new ImmutableChildren(this, newChildName, newChildUuid, pathFactory);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        boolean first = true;
+        for (ChildNode child : childrenByName.values()) {
+            if (!first) sb.append(", ");
+            else first = false;
+            sb.append(child.getName()).append('[').append(child.getSnsIndex()).append(']');
+        }
+        return sb.toString();
+    }
+}


Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableChildren.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableNodeInfo.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableNodeInfo.java	                        (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableNodeInfo.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -0,0 +1,155 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * Unless otherwise indicated, all code in JBoss DNA is licensed
+ * to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.cache;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.jcr.NodeDefinitionId;
+
+/**
+ * The information that describes a node. This is the information that is kept in the cache.
+ */
+ at Immutable
+public class ImmutableNodeInfo implements NodeInfo {
+    private final Location originalLocation;
+    private final UUID uuid;
+    private final UUID parent;
+    private final Name primaryTypeName;
+    private final NodeDefinitionId definition;
+    private final Children children;
+    private final Map<Name, PropertyInfo> properties;
+
+    /**
+     * Create an immutable NodeInfo instance.
+     * 
+     * @param originalLocation the original location
+     * @param primaryTypeName the name of the node's primary type
+     * @param definition the definition used when creating the node
+     * @param parent the parent
+     * @param children the immutable children
+     * @param properties the unmodifiable map of properties
+     */
+    public ImmutableNodeInfo( Location originalLocation,
+                              Name primaryTypeName,
+                              NodeDefinitionId definition,
+                              UUID parent,
+                              Children children,
+                              Map<Name, PropertyInfo> properties ) {
+        this.originalLocation = originalLocation;
+        this.primaryTypeName = primaryTypeName;
+        this.definition = definition;
+        this.parent = parent;
+        this.uuid = this.originalLocation.getUuid();
+        this.children = children;
+        this.properties = properties;
+        assert this.uuid != null;
+        assert this.definition != null;
+        assert this.primaryTypeName != null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.NodeInfo#getOriginalLocation()
+     */
+    public Location getOriginalLocation() {
+        return originalLocation;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.NodeInfo#getUuid()
+     */
+    public UUID getUuid() {
+        return uuid;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.NodeInfo#getParent()
+     */
+    public UUID getParent() {
+        return parent;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.NodeInfo#getPrimaryTypeName()
+     */
+    public Name getPrimaryTypeName() {
+        return primaryTypeName;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.NodeInfo#getDefinitionId()
+     */
+    public NodeDefinitionId getDefinitionId() {
+        return definition;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.NodeInfo#getChildren()
+     */
+    public Children getChildren() {
+        return children;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.NodeInfo#hasProperties()
+     */
+    public boolean hasProperties() {
+        return this.properties.size() != 0;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.NodeInfo#getPropertyNames()
+     */
+    public Set<Name> getPropertyNames() {
+        return this.properties.keySet();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.NodeInfo#getProperty(org.jboss.dna.graph.property.Name)
+     */
+    public PropertyInfo getProperty( Name name ) {
+        return this.properties.get(name);
+    }
+}


Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableNodeInfo.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NodeInfo.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NodeInfo.java	                        (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NodeInfo.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -0,0 +1,90 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * Unless otherwise indicated, all code in JBoss DNA is licensed
+ * to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.cache;
+
+import java.util.Set;
+import java.util.UUID;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.jcr.NodeDefinitionId;
+
+/**
+ * The information that describes a node. This is the information that is kept in the cache.
+ */
+public interface NodeInfo {
+
+    /**
+     * @return location
+     */
+    public Location getOriginalLocation();
+
+    /**
+     * @return uuid
+     */
+    public UUID getUuid();
+
+    /**
+     * @return parent
+     */
+    public UUID getParent();
+
+    /**
+     * @return primaryTypeName
+     */
+    public Name getPrimaryTypeName();
+
+    /**
+     * @return definition
+     */
+    public NodeDefinitionId getDefinitionId();
+
+    /**
+     * Get the children for this node.
+     * 
+     * @return the children; never null but possibly empty
+     */
+    public Children getChildren();
+
+    /**
+     * Return true of this node has at least one property.
+     * 
+     * @return true if there is at least one property, or false if there are none
+     */
+    public boolean hasProperties();
+
+    /**
+     * Get the names of the properties that are owned by this node.
+     * 
+     * @return the unmodifiable set of property names
+     */
+    public Set<Name> getPropertyNames();
+
+    /**
+     * Get this node's property that has the supplied name.
+     * 
+     * @param name the property name; may not be null
+     * @return the property information, or null if this node has no property with the supplied name
+     */
+    public PropertyInfo getProperty( Name name );
+}


Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NodeInfo.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/PropertyInfo.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/PropertyInfo.java	                        (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/PropertyInfo.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -0,0 +1,168 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * Unless otherwise indicated, all code in JBoss DNA is licensed
+ * to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.cache;
+
+import java.util.UUID;
+import javax.jcr.PropertyType;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.Property;
+import org.jboss.dna.jcr.PropertyDefinitionId;
+import org.jboss.dna.jcr.PropertyId;
+
+/**
+ * An immutable representation of the name and current value(s) for a property, along with the JCR metadata for the property,
+ * including the {@link PropertyInfo#getDefinitionId() property definition} and {@link PropertyInfo#getPropertyType() property
+ * type}.
+ * <p>
+ * This class is immutable, which means that clients should never hold onto an instance. Instead, clients can obtain an instance
+ * by using a {@link PropertyId}, quickly use the information in the instance, and then immediately discard their reference. This
+ * is because these instances are replaced and discarded whenever anything about the property changes.
+ * </p>
+ */
+ at Immutable
+public class PropertyInfo {
+    private final PropertyId propertyId;
+    private final PropertyDefinitionId definitionId;
+    private final Property dnaProperty;
+    private final int propertyType;
+    private final boolean multiValued;
+
+    public PropertyInfo( PropertyId propertyId,
+                         PropertyDefinitionId definitionId,
+                         int propertyType,
+                         Property dnaProperty,
+                         boolean multiValued ) {
+        this.propertyId = propertyId;
+        this.definitionId = definitionId;
+        this.propertyType = propertyType;
+        this.dnaProperty = dnaProperty;
+        this.multiValued = multiValued;
+    }
+
+    /**
+     * Get the durable identifier for this property.
+     * 
+     * @return propertyId
+     */
+    public PropertyId getPropertyId() {
+        return propertyId;
+    }
+
+    /**
+     * Get the UUID of the node to which this property belongs.
+     * 
+     * @return the owner node's UUID; never null
+     */
+    public UUID getNodeUuid() {
+        return propertyId.getNodeId();
+    }
+
+    /**
+     * The identifier for the property definition.
+     * 
+     * @return the property definition ID; never null
+     */
+    public PropertyDefinitionId getDefinitionId() {
+        return definitionId;
+    }
+
+    /**
+     * Get the DNA Property, which contains the name and value(s)
+     * 
+     * @return the property; never null
+     */
+    public Property getProperty() {
+        return dnaProperty;
+    }
+
+    /**
+     * Get the property name.
+     * 
+     * @return the property name; never null
+     */
+    public Name getPropertyName() {
+        return dnaProperty.getName();
+    }
+
+    /**
+     * Get the JCR {@link PropertyType} for this property.
+     * 
+     * @return the property type
+     */
+    public int getPropertyType() {
+        return propertyType;
+    }
+
+    /**
+     * @return multiValued
+     */
+    public boolean isMultiValued() {
+        return multiValued;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        return propertyId.hashCode();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals( Object obj ) {
+        if (obj == this) return true;
+        if (obj instanceof PropertyInfo) {
+            return propertyId.equals(((PropertyInfo)obj).getPropertyId());
+        }
+        return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(propertyId);
+        sb.append(" defined by ").append(definitionId);
+        sb.append(" of type ").append(PropertyType.nameFromValue(propertyType));
+        if (dnaProperty.isSingle()) {
+            sb.append(" with value ");
+        } else {
+            sb.append(" with values ");
+        }
+        sb.append(dnaProperty.getValuesAsArray());
+        return sb.toString();
+    }
+}


Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/PropertyInfo.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -33,7 +33,6 @@
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.List;
-import java.util.Map;
 import java.util.UUID;
 import javax.jcr.Item;
 import javax.jcr.ItemNotFoundException;
@@ -53,9 +52,10 @@
 import org.jboss.dna.graph.ExecutionContext;
 import org.jboss.dna.graph.property.Name;
 import org.jboss.dna.graph.property.Path;
-import org.jboss.dna.jcr.SessionCache.Children;
-import org.jboss.dna.jcr.SessionCache.NodeInfo;
-import org.jboss.dna.jcr.SessionCache.PropertyInfo;
+import org.jboss.dna.jcr.cache.Children;
+import org.jboss.dna.jcr.cache.EmptyChildren;
+import org.jboss.dna.jcr.cache.NodeInfo;
+import org.jboss.dna.jcr.cache.PropertyInfo;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -129,7 +129,7 @@
         node = new MockAbstractJcrNode(cache, uuid);
 
         // Create the children container for the node ...
-        children = new Children(uuid);
+        children = new EmptyChildren(uuid);
         stub(info.getChildren()).toReturn(children);
     }
 
@@ -149,6 +149,12 @@
         return new JcrValue(context.getValueFactories(), PropertyType.STRING, value);
     }
 
+    protected void addChild( Name childName,
+                             UUID childUuid ) {
+        children = children.with(childName, childUuid, context.getValueFactories().getPathFactory());
+        stub(info.getChildren()).toReturn(children);
+    }
+
     @Test
     public void shouldAllowVisitation() throws Exception {
         ItemVisitor visitor = Mockito.mock(ItemVisitor.class);
@@ -285,7 +291,7 @@
     public void shouldReturnChildNodeFromGetNodeWithValidName() throws Exception {
         AbstractJcrNode child = mock(AbstractJcrNode.class);
         UUID childUuid = UUID.randomUUID();
-        children.append(cache, name("child"), childUuid);
+        addChild(name("child"), childUuid);
         stub(cache.findJcrNode(childUuid)).toReturn(child);
         assertThat(node.getNode("child"), is((Node)child));
     }
@@ -337,7 +343,7 @@
     public void shouldProvideNodeIterator() throws Exception {
         AbstractJcrNode child = mock(AbstractJcrNode.class);
         UUID childUuid = UUID.randomUUID();
-        children.append(cache, name("child"), childUuid);
+        addChild(name("child"), childUuid);
         stub(cache.findJcrNode(childUuid)).toReturn(child);
         NodeIterator iter = node.getNodes();
         assertThat(iter, notNullValue());
@@ -517,10 +523,10 @@
 
     @Test
     public void shouldReturnTrueFromHasNodeIfChildWithNameExists() throws Exception {
-        children.append(cache, name("child"), UUID.randomUUID());
+        addChild(name("child"), UUID.randomUUID());
         assertThat(node.hasNode("child[1]"), is(true));
         assertThat(node.hasNode("child[2]"), is(false));
-        children.append(cache, name("child"), UUID.randomUUID());
+        addChild(name("child"), UUID.randomUUID());
         assertThat(node.hasNode("child[2]"), is(true));
         assertThat(node.hasNode("child[3]"), is(false));
     }
@@ -537,7 +543,7 @@
 
     @Test
     public void shouldReturnTrueFromHasNodesIfThereIsAtLeastOneChild() throws Exception {
-        children.append(cache, name("child"), UUID.randomUUID());
+        addChild(name("child"), UUID.randomUUID());
         assertThat(node.hasNodes(), is(true));
     }
 
@@ -593,20 +599,14 @@
     }
 
     @Test
-    @SuppressWarnings( "unchecked" )
     public void shouldReturnTrueFromHasPropertiesIfNodeHasAtLeastOneProperty() throws Exception {
-        Map<Name, PropertyInfo> properties = mock(Map.class);
-        stub(properties.size()).toReturn(5);
-        stub(info.getProperties()).toReturn(properties);
+        stub(info.hasProperties()).toReturn(true);
         assertThat(node.hasProperties(), is(true));
     }
 
     @Test
-    @SuppressWarnings( "unchecked" )
     public void shouldReturnFalseFromHasPropertiesIfNodeHasNoProperties() throws Exception {
-        Map<Name, PropertyInfo> properties = mock(Map.class);
-        stub(properties.size()).toReturn(0);
-        stub(info.getProperties()).toReturn(properties);
+        stub(info.hasProperties()).toReturn(false);
         assertThat(node.hasProperties(), is(false));
     }
 

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrPropertyTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrPropertyTest.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrPropertyTest.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -43,8 +43,8 @@
 import org.jboss.dna.graph.ExecutionContext;
 import org.jboss.dna.graph.property.Name;
 import org.jboss.dna.graph.property.Path;
-import org.jboss.dna.jcr.SessionCache.NodeInfo;
-import org.jboss.dna.jcr.SessionCache.PropertyInfo;
+import org.jboss.dna.jcr.cache.NodeInfo;
+import org.jboss.dna.jcr.cache.PropertyInfo;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrChildNodeIteratorTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrChildNodeIteratorTest.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrChildNodeIteratorTest.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -36,7 +36,8 @@
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import org.jboss.dna.graph.property.basic.BasicName;
-import org.jboss.dna.jcr.SessionCache.ChildNode;
+import org.jboss.dna.graph.property.basic.BasicPathSegment;
+import org.jboss.dna.jcr.cache.ChildNode;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;
@@ -60,7 +61,7 @@
         childNodes = new ArrayList<Node>();
         for (int i = 0; i != 10; ++i) {
             UUID uuid = UUID.randomUUID();
-            ChildNode child = new ChildNode(uuid, new BasicName("", "name"), i + 1);
+            ChildNode child = new ChildNode(uuid, new BasicPathSegment(new BasicName("", "name"), i + 1));
             AbstractJcrNode node = mock(AbstractJcrNode.class);
             stub(cache.findJcrNode(uuid)).toReturn(node);
             children.add(child);

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrMultiValuePropertyTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrMultiValuePropertyTest.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrMultiValuePropertyTest.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -34,7 +34,7 @@
 import javax.jcr.nodetype.PropertyDefinition;
 import org.jboss.dna.graph.ExecutionContext;
 import org.jboss.dna.graph.property.Name;
-import org.jboss.dna.jcr.SessionCache.PropertyInfo;
+import org.jboss.dna.jcr.cache.PropertyInfo;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -32,7 +32,7 @@
 import org.jboss.dna.graph.ExecutionContext;
 import org.jboss.dna.graph.property.Name;
 import org.jboss.dna.graph.property.Path;
-import org.jboss.dna.jcr.SessionCache.NodeInfo;
+import org.jboss.dna.jcr.cache.NodeInfo;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSingleValuePropertyTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSingleValuePropertyTest.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSingleValuePropertyTest.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -39,7 +39,7 @@
 import org.jboss.dna.graph.property.DateTime;
 import org.jboss.dna.graph.property.Name;
 import org.jboss.dna.graph.property.Path;
-import org.jboss.dna.jcr.SessionCache.PropertyInfo;
+import org.jboss.dna.jcr.cache.PropertyInfo;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/SessionCacheTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/SessionCacheTest.java	2009-03-16 22:50:09 UTC (rev 777)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/SessionCacheTest.java	2009-03-17 15:43:09 UTC (rev 778)
@@ -49,9 +49,9 @@
 import org.jboss.dna.graph.property.Name;
 import org.jboss.dna.graph.property.Path;
 import org.jboss.dna.graph.property.Property;
-import org.jboss.dna.jcr.SessionCache.Children;
-import org.jboss.dna.jcr.SessionCache.NodeInfo;
-import org.jboss.dna.jcr.SessionCache.PropertyInfo;
+import org.jboss.dna.jcr.cache.Children;
+import org.jboss.dna.jcr.cache.NodeInfo;
+import org.jboss.dna.jcr.cache.PropertyInfo;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;
@@ -212,7 +212,7 @@
         UUID uuid = dnaNode.getLocation().getUuid();
         assertThat(nodeInfo.getUuid(), is(uuid));
         assertThat(nodeInfo.getOriginalLocation().getUuid(), is(uuid));
-        Set<Name> propertyNames = nodeInfo.getProperties().keySet();
+        Set<Name> propertyNames = nodeInfo.getPropertyNames();
         for (Name propertyName : propertyNames) {
             PropertyInfo info = nodeInfo.getProperty(propertyName);
             assertThat(info.getNodeUuid(), is(uuid));
@@ -246,7 +246,7 @@
         assertThat(rootInfo.getPrimaryTypeName(), is(name("dna:root")));
         assertThat(rootInfo.getOriginalLocation().getPath().isRoot(), is(true));
         assertThat(rootInfo.getOriginalLocation().getUuid(), is(rootUuid));
-        Set<Name> rootProperties = rootInfo.getProperties().keySet();
+        Set<Name> rootProperties = rootInfo.getPropertyNames();
         assertThat(rootProperties, hasItems(name("jcr:primaryType")));
         assertSameProperties(rootInfo, root);
 




More information about the dna-commits mailing list