jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r932956 [1/2] - /jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/
Date Sun, 11 Apr 2010 17:49:04 GMT
Author: thomasm
Date: Sun Apr 11 17:49:03 2010
New Revision: 932956

URL: http://svn.apache.org/viewvc?rev=932956&view=rev
Log:
Some code for a Jackrabbit 3 prototype

Added:
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/BinaryImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyIteratorImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RangeIteratorImpl.java
Removed:
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Cache.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Change.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ChangeList.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/Constants.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ExceptionFactory.java
Modified:
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NamespaceRegistryImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeIteratorImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeState.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryFactoryImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/SessionImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueFactoryImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ValueImpl.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/WorkspaceImpl.java

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/BinaryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/BinaryImpl.java?rev=932956&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/BinaryImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/BinaryImpl.java Sun Apr 11 17:49:03 2010
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.j3;
+
+import java.io.IOException;
+import java.io.InputStream;
+import javax.jcr.Binary;
+import javax.jcr.RepositoryException;
+import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ */
+public class BinaryImpl implements Binary, LogObject {
+
+    private final Log log;
+    private final ValueFactoryImpl factory;
+    private final Val value;
+    private InputStream stream;
+
+    BinaryImpl(Val value, ValueFactoryImpl factory) {
+        this.factory = factory;
+        this.log = factory.getLog();
+        this.value = value;
+    }
+
+    public void dispose() {
+        log.code(this, "dispose");
+        if (stream != null) {
+            try {
+                stream.close();
+            } catch (IOException e) {
+                // TODO log
+            }
+        }
+    }
+
+    public long getSize() throws RepositoryException {
+        log.code(this, "getSize");
+        return ValueFactoryImpl.getLength(value, factory);
+    }
+
+    public InputStream getStream() throws RepositoryException {
+        log.code(this, "getStream");
+        stream = ValueFactoryImpl.getInputStream(value, factory);
+        return stream;
+    }
+
+    public int read(byte[] b, long position) throws IOException, RepositoryException {
+        log.code(this, "read", b, position);
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    Val getValue() {
+        return value;
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NamespaceRegistryImpl.java?rev=932956&r1=932955&r2=932956&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NamespaceRegistryImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NamespaceRegistryImpl.java Sun Apr 11 17:49:03 2010
@@ -17,18 +17,24 @@
 package org.apache.jackrabbit.j3;
 
 import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map.Entry;
 import javax.jcr.AccessDeniedException;
 import javax.jcr.NamespaceException;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
 
 /**
- * A namespace registry implementation.
+ * The implementation of the corresponding JCR interface.
  */
-public class NamespaceRegistryImpl implements NamespaceRegistry {
+public class NamespaceRegistryImpl implements NamespaceRegistry, LogObject {
 
-    public static final NamespaceRegistryImpl BUILT_IN = new NamespaceRegistryImpl(null);
+    public static final NamespaceRegistryImpl BUILT_IN = new NamespaceRegistryImpl(null, Log.DEFAULT);
 
     static {
         NamespaceRegistryImpl registry = BUILT_IN;
@@ -37,14 +43,17 @@ public class NamespaceRegistryImpl imple
         registry.register(PREFIX_MIX, NAMESPACE_MIX);
         registry.register(PREFIX_XML, NAMESPACE_XML);
         registry.register(PREFIX_EMPTY, NAMESPACE_EMPTY);
+        registry.register("rep", "internal");
     }
 
+    private final Log log;
     private final NamespaceRegistryImpl parent;
-    private HashMap<String, String> prefixToUri = new HashMap<String, String>();
+    private LinkedHashMap<String, String> prefixToUri = new LinkedHashMap<String, String>();
     private HashMap<String, String> uriToPrefix = new HashMap<String, String>();
     private boolean shareMapsWithParent;
 
-    private NamespaceRegistryImpl(NamespaceRegistryImpl parent) {
+    private NamespaceRegistryImpl(NamespaceRegistryImpl parent, Log log) {
+        this.log = log;
         this.parent = parent;
         if (parent != null) {
             prefixToUri = parent.prefixToUri;
@@ -53,25 +62,62 @@ public class NamespaceRegistryImpl imple
         }
     }
 
-    public static NamespaceRegistryImpl createLocalInstance() {
-        return new NamespaceRegistryImpl(BUILT_IN);
+    public static NamespaceRegistryImpl createLocalInstance(Log log) {
+        return new NamespaceRegistryImpl(BUILT_IN, log);
+    }
+
+    public String nameToString(Val name) {
+        if (name.getType() == Val.TYPE_MULTI_VALUE) {
+            Val[] namePair = name.getArray();
+            String uri = getPrefix(namePair[0].getString());
+            String localName = namePair[1].getString();
+            StringBuilder buff = new StringBuilder(uri.length() + 1 + localName.length());
+            buff.append(uri).append(':').append(localName);
+            return buff.toString();
+        }
+        return name.getString();
+    }
+
+    public Val parseName(String name) {
+        if (name.charAt(0) == '{') {
+            int index = name.indexOf('}');
+            Val namespace = Val.get(name.substring(1, index));
+            Val localName = Val.get(name.substring(index + 1));
+            return Val.get(namespace, localName);
+        }
+        int index = name.indexOf(':');
+        if (index < 0) {
+            return Val.get(name);
+        }
+        String prefix = name.substring(0, index);
+        String ns = getURI(prefix);
+        if (ns == null) {
+            throw ExceptionFactory.illegalArgument("Not URI found for prefix: {0}", prefix);
+        }
+        Val namespace = Val.get(ns);
+        Val localName = Val.get(name.substring(index + 1));
+        return Val.get(namespace, localName);
     }
 
     public String getPrefix(String uri) {
+        log.code(this, "getPrefix", uri);
         return uriToPrefix.get(uri);
     }
 
     public synchronized String[] getPrefixes() throws RepositoryException {
+        log.code(this, "getPrefixes");
         String[] prefixes = new String[prefixToUri.size()];
         prefixToUri.keySet().toArray(prefixes);
         return prefixes;
     }
 
     public String getURI(String prefix) {
+        log.code(this, "getURI", prefix);
         return prefixToUri.get(prefix);
     }
 
     public synchronized String[] getURIs() throws RepositoryException {
+        log.code(this, "getURIs");
         String[] uris = new String[uriToPrefix.size()];
         uriToPrefix.keySet().toArray(uris);
         return uris;
@@ -79,18 +125,20 @@ public class NamespaceRegistryImpl imple
 
     public void registerNamespace(String prefix, String uri) throws NamespaceException,
             UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
+        log.code(this, "registerNamespace", prefix, uri);
         if (parent.prefixToUri.containsKey(prefix) || parent.uriToPrefix.containsKey(uri)) {
-            throw new NamespaceException("Can not redefine a built-in prefix");
-        }
-        if (prefix.equalsIgnoreCase("xml")) {
-            throw new NamespaceException("Can not redefine an xml variant");
+            if (!parent.prefixToUri.get(prefix).equals(uri)) {
+                throw ExceptionFactory.namespace("Can not redefine built-in prefix: {0}", prefix);
+            }
+        } else if (prefix.equalsIgnoreCase("xml")) {
+            throw ExceptionFactory.namespace("Can not (re-)define an xml variant: {0}", prefix);
         }
         register(prefix, uri);
     }
 
     private synchronized void register(String prefix, String uri) {
         if (shareMapsWithParent) {
-            prefixToUri = new HashMap<String, String>(prefixToUri);
+            prefixToUri = new LinkedHashMap<String, String>(prefixToUri);
             uriToPrefix = new HashMap<String, String>(uriToPrefix);
             shareMapsWithParent = false;
         }
@@ -100,14 +148,27 @@ public class NamespaceRegistryImpl imple
 
     public synchronized void unregisterNamespace(String prefix) throws NamespaceException, UnsupportedRepositoryOperationException,
             AccessDeniedException, RepositoryException {
+        log.code(this, "unregisterNamespace", prefix);
         if (parent.prefixToUri.containsKey(prefix)) {
-            throw new NamespaceException("Can not unregister a built-in prefix");
+            throw ExceptionFactory.namespace("Can not unregister a built-in prefix: {0}", prefix);
         }
         if (!prefixToUri.containsKey(prefix)) {
-            throw new NamespaceException("Not registered");
+            throw ExceptionFactory.namespace("Not registered: {0}", prefix);
         }
         String uri = prefixToUri.remove(prefix);
         uriToPrefix.remove(uri);
     }
 
+    public String toString() {
+        StringBuilder buff = new StringBuilder();
+        for (Entry<String, String> e : prefixToUri.entrySet()) {
+            buff.append('<').append(e.getKey()).append('=').append(e.getValue()).append('>');
+        }
+        return buff.toString();
+    }
+
+    public Log getLog() {
+        return log;
+    }
+
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeImpl.java?rev=932956&r1=932955&r2=932956&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeImpl.java Sun Apr 11 17:49:03 2010
@@ -16,9 +16,6 @@
  */
 package org.apache.jackrabbit.j3;
 
-import org.apache.jackrabbit.j3.lock.LockImpl;
-import org.apache.jackrabbit.j3.mc.Val;
-import org.apache.jackrabbit.j3.security.PrivilegeImpl;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.util.Calendar;
@@ -39,7 +36,6 @@ import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
@@ -53,11 +49,25 @@ import javax.jcr.version.ActivityViolati
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionHistory;
+import org.apache.jackrabbit.j3.lock.LockImpl;
+import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.nodetype.NodeTypeImpl;
+import org.apache.jackrabbit.j3.nodetype.PropertyDefinitionImpl;
+import org.apache.jackrabbit.j3.observation.EventAddLock;
+import org.apache.jackrabbit.j3.observation.EventAddMixin;
+import org.apache.jackrabbit.j3.observation.EventAddNode;
+import org.apache.jackrabbit.j3.observation.EventAddProperty;
+import org.apache.jackrabbit.j3.observation.EventModifyProperty;
+import org.apache.jackrabbit.j3.observation.EventRemoveNode;
+import org.apache.jackrabbit.j3.security.PrivilegeImpl;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
 
 /**
- * A node implementation.
+ * The implementation of the corresponding JCR interface.
  */
-public class NodeImpl implements Node {
+public class NodeImpl implements Node, LogObject {
 
     private final NodeState state;
 
@@ -67,32 +77,51 @@ public class NodeImpl implements Node {
      */
     private NodeImpl parent;
     private int privilegesChecked;
+    protected final Log log;
 
-    NodeImpl(NodeImpl parent, NodeState state) {
+    protected NodeImpl(NodeImpl parent, NodeState state, Log log) {
         this.state = state;
         this.parent = parent;
+        this.log = log;
     }
 
     public NodeImpl addNode(String relPath, String primaryNodeTypeName) throws ItemExistsException, PathNotFoundException,
             NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException {
-        // TODO primaryNodeTypeName is incorrect
-        return addNode(relPath, NodeState.NT_UNSTRUCTURED);
+        NodeTypeImpl nt = state.getSession().getNodeTypeManager().getNodeType(primaryNodeTypeName);
+        NodeImpl n = addNode(relPath, nt);
+        log.codeAssign(n, this, "addNode", relPath, primaryNodeTypeName);
+        return n;
     }
 
-    private NodeImpl addNode(String relPath, Val primaryNodeType) throws RepositoryException {
+    private NodeImpl addNode(String relPath, NodeTypeImpl nt) throws RepositoryException {
         SessionImpl s = state.getSession();
-        ChangeAddNode change = new ChangeAddNode(s);
-        change.childName = Val.get(relPath);
-        ChangeAddProperty changePrimaryType = new ChangeAddProperty(s);
-        changePrimaryType.propertyName = NodeState.PROPERTY_PRIMARY_TYPE;
-        changePrimaryType.value = primaryNodeType;
         synchronized (s) {
             NodeImpl node = s.createNode(this, state.getId());
-            change.newNode = node;
-            changePrimaryType.node = node;
-            changePrimaryType.applyAndAddChange();
-            change.applyAndAddChange();
-            return change.newNode;
+            EventAddNode event = new EventAddNode(s, Val.get(relPath), node);
+            Val primaryNodeType;
+            if (nt == null) {
+                // TODO primaryNodeTypeName may be incorrect
+                primaryNodeType = NodeState.DEFAULT_PRIMARY_TYPE;
+            } else {
+                primaryNodeType = nt.getNameVal();
+            }
+            EventAddProperty eventSetPrimaryType = new EventAddProperty(s, node, NodeState.PROPERTY_PRIMARY_TYPE,  primaryNodeType);
+            eventSetPrimaryType.applyAndAdd();
+            event.applyAndAdd();
+            if (nt != null) {
+                nt.visit(node);
+            }
+            return node;
+        }
+    }
+
+    public void apply(PropertyDefinitionImpl p) throws RepositoryException {
+        SessionImpl s = state.getSession();
+        if (p.isAutoCreated()) {
+            Val propertyName = p.getNameVal();
+            Val value = p.getDefaultVal();
+            EventModifyProperty event = new EventModifyProperty(s, this, propertyName, value);
+            event.applyAndAdd();
         }
     }
 
@@ -103,46 +132,60 @@ public class NodeImpl implements Node {
 
     public NodeImpl addNode(String relPath) throws ItemExistsException, PathNotFoundException, VersionException,
             ConstraintViolationException, LockException, RepositoryException {
-        // TODO primaryNodeTypeName may be incorrect
-        return addNode(relPath, NodeState.NT_UNSTRUCTURED);
+        NodeImpl n = addNode(relPath, (NodeTypeImpl) null);
+        log.codeAssign(n, this, "addNode", relPath);
+        return n;
+    }
+
+    void log(String message) {
+    }
+
+    String format(String x, Object... args) {
+        return "";
+    }
+
+    boolean trace() {
+        return true;
     }
 
     public PropertyImpl setProperty(String name, String value) throws ValueFormatException, VersionException,
-    LockException, ConstraintViolationException, RepositoryException {
+            LockException, ConstraintViolationException, RepositoryException {
+        PropertyImpl p = setProperty(name, Val.get(value));
+        log.codeAssign(p, this, "setProperty", name, value);
+        return p;
+    }
+
+    private PropertyImpl setProperty(String name, Val value) throws RepositoryException {
         SessionImpl s = state.getSession();
-        ChangeModifyProperty change = new ChangeModifyProperty(s);
+        Val propertyName = Val.get(name);
+        EventModifyProperty event = new EventModifyProperty(s, this, propertyName, value);
         synchronized (s) {
-            change.node = this;
-            change.propertyName = Val.get(name);
-            change.value = Val.get(value);
-            change.applyAndAddChange();
-            PropertyImpl prop = new PropertyImpl(this, change.propertyName);
-            return prop;
+            event.applyAndAdd();
+            return new PropertyImpl(this, propertyName);
         }
     }
 
+
     public void doSetProperty(Val propertyName, Val value) throws LockException {
         checkAccess(PrivilegeImpl.MODIFY_PROPERTIES | PrivilegeImpl.LOCK_OK);
-        state.setPropertyValue(propertyName, value);
+        state.setPropertyInternal(propertyName, value);
     }
 
     public Property getProperty(String relPath) throws PathNotFoundException, RepositoryException {
         Val propertyName = Val.get(relPath);
         // just verify that the property exists for now
-        state.getPropertyValue(propertyName);
+        state.getPropertyInternal(propertyName);
         PropertyImpl prop = new PropertyImpl(this, propertyName);
+        log.codeAssign(prop, this, "getProperty", relPath);
         return prop;
     }
 
-    Value getPropertyValue(Val name) {
-        return new ValueImpl(state.getPropertyValue(name));
-    }
-
-    Val getPropertyVal(Val name) {
-        return state.getPropertyValue(name);
+    ValueImpl getPropertyValue(Val name) {
+        return getValueFactory().wrap(state.getPropertyInternal(name));
     }
 
     public NodeImpl getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException {
+        log.codeAssign(parent, this, "getParent");
         return parent;
     }
 
@@ -151,6 +194,7 @@ public class NodeImpl implements Node {
     }
 
     public String getPath() throws RepositoryException {
+        log.code(this, "getPath");
         SessionImpl s = state.getSession();
         synchronized (s) {
             StringBuilder buff = new StringBuilder();
@@ -171,28 +215,28 @@ public class NodeImpl implements Node {
         }
     }
 
-    public String toString() {
-        return "NodeImpl: " + (parent == null ? "" : "parent=" + parent.state.getId()) + " state=" + state;
-    }
-
     public String getIdentifier() throws RepositoryException {
+        log.code(this, "getIdentifier");
         return state.getIdentifier();
     }
 
-    public Node getNode(String relPath) throws PathNotFoundException, RepositoryException {
-        return getNodeImpl(relPath);
+    public NodeImpl getNode(String relPath) throws PathNotFoundException, RepositoryException {
+        NodeImpl n = getNodeImpl(relPath);
+        log.codeAssign(n, this, "getNode", relPath);
+        return n;
     }
 
     NodeImpl getNodeImpl(String relPath) throws PathNotFoundException, RepositoryException {
         Val childName = Val.get(relPath);
         Val childId = state.getNodeData().getChildId(childName);
         if (childId == null) {
-            throw new PathNotFoundException();
+            throw ExceptionFactory.pathNotFound("Path: {0}", relPath);
         }
         return state.getSession().getNode(this, childId);
     }
 
     public String getName() throws RepositoryException {
+        log.code(this, "getName");
         if (parent == null) {
             return "/";
         }
@@ -200,6 +244,7 @@ public class NodeImpl implements Node {
     }
 
     public boolean hasNode(String relPath) throws RepositoryException {
+        log.code(this, "hasNode", relPath);
         Val childName = Val.get(relPath);
         Val childId = state.getNodeData().getChildId(childName);
         return childId != null;
@@ -207,14 +252,14 @@ public class NodeImpl implements Node {
 
     public void remove() throws VersionException, LockException, ConstraintViolationException, AccessDeniedException,
             RepositoryException {
+        log.code(this, "remove");
         SessionImpl s = state.getSession();
-        ChangeRemoveNode change = new ChangeRemoveNode(s);
         if (parent == null) {
-            throw new RepositoryException("Can not remove the root node");
+            throw ExceptionFactory.repository("Can not remove the root node");
         }
         synchronized (s) {
-            change.node = this;
-            change.applyAndAddChange();
+            EventRemoveNode event = new EventRemoveNode(s, this);
+            event.applyAndAdd();
         }
     }
 
@@ -224,7 +269,7 @@ public class NodeImpl implements Node {
         getParentNode().state.removeChild(name);
     }
 
-    public Session getSession() {
+    public SessionImpl getSession() {
         return state.getSession();
     }
 
@@ -232,6 +277,10 @@ public class NodeImpl implements Node {
         if ((privilegesChecked & privilegeMask) == privilegeMask) {
             return;
         }
+        if (state.session.isAdmin()) {
+            privilegesChecked |= PrivilegeImpl.ALL;
+            return;
+        }
         // remove what was already checked
         privilegeMask &= ~privilegesChecked;
         if ((privilegeMask & PrivilegeImpl.LOCK_OK) != 0) {
@@ -255,41 +304,40 @@ public class NodeImpl implements Node {
 
     public void addMixin(String mixinName) throws NoSuchNodeTypeException, VersionException,
             ConstraintViolationException, LockException, RepositoryException {
+        log.code(this, "addMixin", mixinName);
         SessionImpl s = state.getSession();
-        ChangeAddMixin change = new ChangeAddMixin(s);
-        change.node = this;
-        change.mixin = Val.get(mixinName);
+        EventAddMixin event = new EventAddMixin(s, this, Val.get(mixinName));
         synchronized (s) {
-            change.applyAndAddChange();
+            event.applyAndAdd();
         }
     }
 
     public void doAddMixin(Val mixin) throws LockException {
         checkAccess(PrivilegeImpl.MODIFY_PROPERTIES | PrivilegeImpl.LOCK_OK);
-        Val oldList = state.getPropertyValue(NodeState.PROPERTY_MIXIN_TYPES);
+        Val oldList = state.getPropertyInternal(NodeState.PROPERTY_MIXIN_TYPES);
         Val newList;
         if (oldList == null) {
             newList = Val.get(mixin);
         } else {
             newList = oldList.addOrdered(mixin);
         }
-        state.setPropertyValue(NodeState.PROPERTY_MIXIN_TYPES, newList);
+        state.setPropertyInternal(NodeState.PROPERTY_MIXIN_TYPES, newList);
     }
 
     public LockImpl lock(boolean isDeep, boolean isSessionScoped) throws UnsupportedRepositoryOperationException,
             LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
         if (state.session.hasPendingChanges()) {
-            throw new InvalidItemStateException("Session has pending changes");
+            throw ExceptionFactory.invalidItemState("Session has pending changes");
         }
         SessionImpl s = state.getSession();
-        ChangeAddLock change = new ChangeAddLock(s);
         // TODO the lock token currently is the node id; this is not secure
         Val lockToken = state.getId();
         LockImpl lock = new LockImpl(this, lockToken, isDeep, isSessionScoped);
-        change.lock = lock;
+        EventAddLock event = new EventAddLock(s, lock);
         synchronized (s) {
-            change.applyAndAddChange();
+            event.applyAndAdd();
         }
+        log.codeAssign(lock, this, "lock", isDeep, isSessionScoped);
         return lock;
     }
 
@@ -304,398 +352,498 @@ public class NodeImpl implements Node {
         return state;
     }
 
-    public NodeType getPrimaryNodeType() throws RepositoryException {
-        Val pt = state.getPropertyValue(NodeState.PROPERTY_PRIMARY_TYPE);
-        return state.getSession().getNodeTypeManager().getNodeType(pt);
+    public NodeTypeImpl getPrimaryNodeType() throws RepositoryException {
+        Val pt = state.getPropertyInternal(NodeState.PROPERTY_PRIMARY_TYPE);
+        NodeTypeImpl nt = state.getSession().getNodeTypeManager().getNodeType(pt);
+        log.codeAssign(nt, this, "getPrimaryNodeType");
+        return nt;
+    }
+
+    public PropertyIteratorImpl getProperties() throws RepositoryException {
+        PropertyIteratorImpl p = new PropertyIteratorImpl(this);
+        log.codeAssign(p, this, "getProperties");
+        return p;
+    }
+
+    public NodeIterator getNodes() throws RepositoryException {
+        Val childId = state.getNextChildId(null);
+        NodeImpl first;
+        if (childId == null) {
+            first = null;
+        } else {
+            first = state.getSession().getNode(this, childId);
+        }
+        NodeIteratorImpl it = new NodeIteratorImpl(first, log);
+        log.codeAssign(it, this, "getNodes");
+        return it;
+    }
+
+    NodeImpl getNextSibling() throws RepositoryException {
+        Val childId = parent.state.getNextChildId(state);
+        if (childId == null) {
+            return null;
+        } else {
+            return state.getSession().getNode(parent, childId);
+        }
+    }
+
+    public Property setProperty(String name, Calendar value) throws ValueFormatException, VersionException,
+            LockException, ConstraintViolationException, RepositoryException {
+        PropertyImpl p = setProperty(name, getValueFactory().createVal(value));
+        log.codeAssign(p, this, "setProperty", value);
+        return p;
+    }
+
+    private ValueFactoryImpl getValueFactory() {
+        return state.getSession().getValueFactory();
+    }
+
+    public Property setProperty(String name, InputStream value) throws ValueFormatException, VersionException,
+            LockException, ConstraintViolationException, RepositoryException {
+        PropertyImpl p = setProperty(name, getValueFactory().createVal(value));
+        log.codeAssign(p, this, "setProperty", value);
+        return p;
+    }
+
+    public Property setProperty(String name, Binary value) throws ValueFormatException, VersionException,
+            LockException, ConstraintViolationException, RepositoryException {
+        PropertyImpl p = setProperty(name, getValueFactory().createVal(value));
+        log.codeAssign(p, this, "setProperty", value);
+        return p;
+    }
+
+    public Property setProperty(String name, boolean value) throws ValueFormatException, VersionException,
+            LockException, ConstraintViolationException, RepositoryException {
+        PropertyImpl p = setProperty(name, getValueFactory().createVal(value));
+        log.codeAssign(p, this, "setProperty", value);
+        return p;
+    }
+
+    public Property setProperty(String name, double value) throws ValueFormatException, VersionException,
+            LockException, ConstraintViolationException, RepositoryException {
+        PropertyImpl p = setProperty(name, getValueFactory().createVal(value));
+        log.codeAssign(p, this, "setProperty", value);
+        return p;
+    }
+
+    public Property setProperty(String name, BigDecimal value) throws ValueFormatException, VersionException,
+            LockException, ConstraintViolationException, RepositoryException {
+        PropertyImpl p = setProperty(name, getValueFactory().createVal(value));
+        log.codeAssign(p, this, "setProperty", value);
+        return p;
+    }
+
+    public Property setProperty(String name, long value) throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        PropertyImpl p = setProperty(name, getValueFactory().createVal(value));
+        log.codeAssign(p, this, "setProperty", value);
+        return p;
+    }
+
+    public Property setProperty(String name, Node value) throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        PropertyImpl p = setProperty(name, getValueFactory().createVal(value));
+        log.codeAssign(p, this, "setProperty", value);
+        return p;
+    }
+
+    public Property setProperty(String name, String value, int type) throws ValueFormatException, VersionException,
+            LockException, ConstraintViolationException, RepositoryException {
+        PropertyImpl p = setProperty(name, getValueFactory().createVal(value, type));
+        log.codeAssign(p, this, "setProperty", value);
+        return p;
+    }
+
+    public Log getLog() {
+        return log;
+    }
+
+    public Item getPrimaryItem() throws ItemNotFoundException, RepositoryException {
+        log.code(this, "getPrimaryItem");
+        // TODO
+        return null;
     }
 
     public boolean canAddMixin(String mixinName) throws NoSuchNodeTypeException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "canAddMixin", mixinName);
+        // TODO
         return false;
     }
 
     public void cancelMerge(Version version) throws VersionException, InvalidItemStateException,
             UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "cancelMerge", version);
+        // TODO
 
     }
 
     public Version checkin() throws VersionException, UnsupportedRepositoryOperationException,
             InvalidItemStateException, LockException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "checkin");
+        // TODO
         return null;
     }
 
     public void checkout() throws UnsupportedRepositoryOperationException, LockException, ActivityViolationException,
             RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "checkout");
+        // TODO
 
     }
 
     public void doneMerge(Version version) throws VersionException, InvalidItemStateException,
             UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "doneMerge", version);
+        // TODO
 
     }
 
     public void followLifecycleTransition(String transition) throws UnsupportedRepositoryOperationException,
             InvalidLifecycleTransitionException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "followLifecycleTransition", transition);
+        // TODO
 
     }
 
     public String[] getAllowedLifecycleTransistions() throws UnsupportedRepositoryOperationException,
             RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getAllowedLifecycleTransistions");
+        // TODO
         return null;
     }
 
     public Version getBaseVersion() throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getBaseVersion");
+        // TODO
         return null;
     }
 
     public String getCorrespondingNodePath(String workspaceName) throws ItemNotFoundException,
             NoSuchWorkspaceException, AccessDeniedException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getCorrespondingNodePath", workspaceName);
+        // TODO
         return null;
     }
 
     public NodeDefinition getDefinition() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getDefinition");
+        // TODO
         return null;
     }
 
     public int getIndex() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getIndex");
+        // TODO
         return 0;
     }
 
     public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException,
             RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getLock");
+        // TODO
         return null;
     }
 
     public NodeType[] getMixinNodeTypes() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public NodeIterator getNodes() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getMixinNodeTypes");
+        // TODO
         return null;
     }
 
     public NodeIterator getNodes(String namePattern) throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getNodes", namePattern);
+        // TODO
         return null;
     }
 
     public NodeIterator getNodes(String[] nameGlobs) throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Item getPrimaryItem() throws ItemNotFoundException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public PropertyIterator getProperties() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getNodes", (Object) nameGlobs);
+        // TODO
         return null;
     }
 
     public PropertyIterator getProperties(String namePattern) throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getProperties", namePattern);
+        // TODO
         return null;
     }
 
     public PropertyIterator getProperties(String[] nameGlobs) throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getProperties", (Object) nameGlobs);
+        // TODO
         return null;
     }
 
     public PropertyIterator getReferences() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getReferences");
+        // TODO
         return null;
     }
 
     public PropertyIterator getReferences(String name) throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getReferences", name);
+        // TODO
         return null;
     }
 
     public NodeIterator getSharedSet() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getSharedSet");
+        // TODO
         return null;
     }
 
     public String getUUID() throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getUUID");
+        // TODO
         return null;
     }
 
     public VersionHistory getVersionHistory() throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getVersionHistory");
+        // TODO
         return null;
     }
 
     public PropertyIterator getWeakReferences() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getWeakReferences");
+        // TODO
         return null;
     }
 
     public PropertyIterator getWeakReferences(String name) throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getWeakReferences", name);
+        // TODO
         return null;
     }
 
     public boolean hasNodes() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "hasNodes");
+        // TODO
         return false;
     }
 
     public boolean hasProperties() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "hasProperties");
+        // TODO
         return false;
     }
 
     public boolean hasProperty(String relPath) throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "hasProperty", relPath);
+        // TODO
         return false;
     }
 
     public boolean holdsLock() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "holdsLock");
+        // TODO
         return false;
     }
 
     public boolean isCheckedOut() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "isCheckedOut");
+        // TODO
         return false;
     }
 
     public boolean isLocked() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "isLocked");
+        // TODO
         return false;
     }
 
     public boolean isNodeType(String nodeTypeName) throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "isNodeType", nodeTypeName);
+        // TODO
         return false;
     }
 
     public NodeIterator merge(String srcWorkspace, boolean bestEffort) throws NoSuchWorkspaceException,
             AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "merge", srcWorkspace, bestEffort);
+        // TODO
         return null;
     }
 
     public void orderBefore(String srcChildRelPath, String destChildRelPath)
             throws UnsupportedRepositoryOperationException, VersionException, ConstraintViolationException,
             ItemNotFoundException, LockException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "orderBefore", srcChildRelPath, destChildRelPath);
+        // TODO
 
     }
 
     public void removeMixin(String mixinName) throws NoSuchNodeTypeException, VersionException,
             ConstraintViolationException, LockException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "removeMixin", mixinName);
+        // TODO
 
     }
 
     public void removeShare() throws VersionException, LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "removeShare");
+        // TODO
 
     }
 
     public void removeSharedSet() throws VersionException, LockException, ConstraintViolationException,
             RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "removeSharedSet");
+        // TODO
 
     }
 
     public void restore(String versionName, boolean removeExisting) throws VersionException, ItemExistsException,
             UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "restore", versionName, removeExisting);
+        // TODO
 
     }
 
     public void restore(Version version, boolean removeExisting) throws VersionException, ItemExistsException,
             InvalidItemStateException, UnsupportedRepositoryOperationException, LockException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "restore", version, removeExisting);
+        // TODO
 
     }
 
     public void restore(Version version, String relPath, boolean removeExisting) throws PathNotFoundException,
             ItemExistsException, VersionException, ConstraintViolationException,
             UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "restore", version, relPath, removeExisting);
+        // TODO
 
     }
 
     public void restoreByLabel(String versionLabel, boolean removeExisting) throws VersionException,
             ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException,
             RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "restoreByLabel", versionLabel, removeExisting);
+        // TODO
 
     }
 
     public void setPrimaryType(String nodeTypeName) throws NoSuchNodeTypeException, VersionException,
             ConstraintViolationException, LockException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setPrimaryType", nodeTypeName);
+        // TODO
 
     }
 
     public Property setProperty(String name, Value value) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setProperty", name, value);
+        // TODO
         return null;
     }
 
     public Property setProperty(String name, Value[] values) throws ValueFormatException, VersionException,
             LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setProperty", name, values);
+        // TODO
         return null;
     }
 
     public Property setProperty(String name, String[] values) throws ValueFormatException, VersionException,
             LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Property setProperty(String name, InputStream value) throws ValueFormatException, VersionException,
-            LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Property setProperty(String name, Binary value) throws ValueFormatException, VersionException,
-            LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Property setProperty(String name, boolean value) throws ValueFormatException, VersionException,
-            LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Property setProperty(String name, double value) throws ValueFormatException, VersionException,
-            LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Property setProperty(String name, BigDecimal value) throws ValueFormatException, VersionException,
-            LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Property setProperty(String name, long value) throws ValueFormatException, VersionException, LockException,
-            ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Property setProperty(String name, Calendar value) throws ValueFormatException, VersionException,
-            LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Property setProperty(String name, Node value) throws ValueFormatException, VersionException, LockException,
-            ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setProperty", name, values);
+        // TODO
         return null;
     }
 
     public Property setProperty(String name, Value value, int type) throws ValueFormatException, VersionException,
             LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setProperty", name, value, type);
+        // TODO
         return null;
     }
 
     public Property setProperty(String name, Value[] values, int type) throws ValueFormatException, VersionException,
             LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setProperty", name, values, type);
+        // TODO
         return null;
     }
 
     public Property setProperty(String name, String[] values, int type) throws ValueFormatException, VersionException,
             LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Property setProperty(String name, String value, int type) throws ValueFormatException, VersionException,
-            LockException, ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setProperty", name, values, type);
+        // TODO
         return null;
     }
 
     public void unlock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException,
             InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "unlock");
+        // TODO
 
     }
 
     public void update(String srcWorkspace) throws NoSuchWorkspaceException, AccessDeniedException, LockException,
             InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "update", srcWorkspace);
+        // TODO
 
     }
 
     public void accept(ItemVisitor visitor) throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "accept", visitor);
+        // TODO
 
     }
 
     public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getAncestor", depth);
+        // TODO
         return null;
     }
 
     public int getDepth() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getDepth");
+        // TODO
         return 0;
     }
 
     public boolean isModified() {
-        // TODO Auto-generated method stub
+        log.code(this, "isModified");
+        // TODO
         return false;
     }
 
     public boolean isNew() {
-        // TODO Auto-generated method stub
+        log.code(this, "isNew");
+        // TODO
         return false;
     }
 
     public boolean isNode() {
-        // TODO Auto-generated method stub
+        log.code(this, "isNode");
+        // TODO
         return false;
     }
 
     public boolean isSame(Item otherItem) throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "isSame", otherItem);
+        // TODO
         return false;
     }
 
     public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "refresh", keepChanges);
+        // TODO
 
     }
 
     public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException,
             InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException,
             NoSuchNodeTypeException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "save");
+        // TODO
 
     }
 
+    public String toString() {
+        return "NodeImpl: " + (parent == null ? "" : "parent=" + parent.state.getId()) + " state=" + state;
+    }
+
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeIteratorImpl.java?rev=932956&r1=932955&r2=932956&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeIteratorImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeIteratorImpl.java Sun Apr 11 17:49:03 2010
@@ -16,47 +16,70 @@
  */
 package org.apache.jackrabbit.j3;
 
-import javax.jcr.Node;
 import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
 
 /**
- * A node iterator implementation.
+ * The implementation of the corresponding JCR interface.
  */
-public class NodeIteratorImpl implements NodeIterator {
+public class NodeIteratorImpl implements NodeIterator, LogObject {
 
-    public Node nextNode() {
-        // TODO Auto-generated method stub
-        return null;
+    private final Log log;
+    private NodeImpl next;
+    private long pos;
+
+    NodeIteratorImpl(NodeImpl first, Log log) {
+        this.log = log;
+        this.next = first;
+    }
+
+    public NodeImpl nextNode() {
+        NodeImpl n = next;
+        if (n == null) {
+            throw ExceptionFactory.noSuchElement();
+        }
+        pos++;
+        try {
+            next = n.getNextSibling();
+        } catch (RepositoryException e) {
+            throw ExceptionFactory.runtime(e);
+        }
+        log.codeAssign(n, this, "nextNode");
+        return n;
     }
 
     public long getPosition() {
-        // TODO Auto-generated method stub
-        return 0;
+        log.code(this, "getPosition");
+        return pos;
     }
 
     public long getSize() {
-        // TODO Auto-generated method stub
-        return 0;
+        log.code(this, "getSize");
+        return -1;
     }
 
     public void skip(long skipNum) {
-        // TODO Auto-generated method stub
-
+        log.code(this, "skip", skipNum);
+        while (skipNum > 0) {
+            nextNode();
+        }
     }
 
     public boolean hasNext() {
-        // TODO Auto-generated method stub
-        return false;
+        log.code(this, "hasNext");
+        return next != null;
     }
 
     public Object next() {
-        // TODO Auto-generated method stub
-        return null;
+        return nextNode();
     }
 
     public void remove() {
-        // TODO Auto-generated method stub
-
+        log.code(this, "remove");
+        throw ExceptionFactory.unsupportedOperation();
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeState.java?rev=932956&r1=932955&r2=932956&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeState.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/NodeState.java Sun Apr 11 17:49:03 2010
@@ -20,6 +20,7 @@ import javax.jcr.NamespaceRegistry;
 import javax.jcr.lock.LockException;
 import org.apache.jackrabbit.j3.mc.NodeData;
 import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
 
 /**
  * There is one node state for each session and instance of shareable node. That
@@ -38,29 +39,37 @@ public class NodeState {
 
     final SessionImpl session;
     private NodeData data;
-    private boolean modified;
+    private int modCount;
     private SessionImpl lockOwner;
 
-    NodeState(SessionImpl session, NodeData data, boolean modified) {
+    NodeState(SessionImpl session, NodeData data, int modCount) {
         this.session = session;
         this.data = data;
-        this.modified = modified;
+        this.modCount = modCount;
     }
 
     void modify() {
-        if (!modified) {
+        if (modCount++ == 0) {
             data = data.createCopy();
             session.modify(this);
-            modified = true;
         }
     }
 
     void reset(NodeData data) {
-        modified = false;
+        modCount = 0;
         this.data = data;
     }
 
-    void setPropertyValue(Val name, Val value) {
+    /**
+     * Set the property.
+     *
+     * The system properties jcr:primaryType
+     * and jcr:mixinTypes are in the array format.
+     *
+     * @param name the property name
+     * @param value the value
+     */
+    void setPropertyInternal(Val name, Val value) {
         modify();
         if (name.equals(NodeState.PROPERTY_PRIMARY_TYPE)) {
             if (value.equals(DEFAULT_PRIMARY_TYPE)) {
@@ -73,7 +82,16 @@ public class NodeState {
         }
     }
 
-    Val getPropertyValue(Val name) {
+    /**
+     * Get the internal property value.
+     *
+     * The system properties jcr:primaryType
+     * and jcr:mixinTypes are in the name format.
+     *
+     * @param name the property name
+     * @param value the value
+     */
+    Val getPropertyInternal(Val name) {
         if (name.equals(NodeState.PROPERTY_PRIMARY_TYPE)) {
             Val pt = data.getPrimaryType();
             return pt == null ? DEFAULT_PRIMARY_TYPE : pt;
@@ -81,6 +99,31 @@ public class NodeState {
         return data.getPropertyValue(name);
     }
 
+    /**
+     * Get the external property value.
+     *
+     * The system properties jcr:primaryType
+     * and jcr:mixinTypes are converted to strings.
+     *
+     * @param name the property name
+     * @param value the value
+     */
+    Val getPropertyExternal(Val name) {
+        Val v = getPropertyInternal(name);
+        if (name.equals(NodeState.PROPERTY_PRIMARY_TYPE)) {
+            v = Val.get(session.nameToString(v));
+        } else if (name.equals(NodeState.PROPERTY_MIXIN_TYPES)) {
+            Val[] array = v.getArray();
+            Val[] nameArray = new Val[array.length];
+            for (int i = 0; i < array.length; i++) {
+                Val a = array[i];
+                nameArray[i] = Val.get(session.nameToString(a));
+            }
+            v = Val.get(array);
+        }
+        return v;
+    }
+
     Val getId() {
         return data.getId();
     }
@@ -108,12 +151,12 @@ public class NodeState {
         return data.getName(parent.data);
     }
 
-    String nameToString(Val name) {
+    public String nameToString(Val name) {
         return session.nameToString(name);
     }
 
     public String toString() {
-        return (modified ? "(mod) " : "") + data;
+        return (modCount > 0 ? "(mod) " : "") + data;
     }
 
     NodeData getNodeData() {
@@ -143,7 +186,15 @@ public class NodeState {
         if (session.getLockManager().hasLockToken(lockToken)) {
             lockOwner = session;
         }
-        throw new LockException("Node is locked");
+        throw ExceptionFactory.lock("Node is locked");
+    }
+
+    int getModCount() {
+        return modCount;
+    }
+
+    Val getNextChildId(NodeState last) {
+        return data.getNextChildId(last == null ? null : last.data);
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyImpl.java?rev=932956&r1=932955&r2=932956&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyImpl.java Sun Apr 11 17:49:03 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.j3;
 
-import org.apache.jackrabbit.j3.mc.Val;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.util.Calendar;
@@ -31,7 +30,6 @@ import javax.jcr.Node;
 import javax.jcr.Property;
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
 import javax.jcr.lock.LockException;
@@ -39,245 +37,292 @@ import javax.jcr.nodetype.ConstraintViol
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.version.VersionException;
+import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
 
 /**
- * The property implementation.
+ * The implementation of the corresponding JCR interface.
  */
-public class PropertyImpl implements Property {
+public class PropertyImpl implements Property, LogObject {
 
     private final NodeImpl node;
+    private final Log log;
     private final Val name;
 
     PropertyImpl(NodeImpl node, Val name) {
         this.node = node;
+        this.log = node.getLog();
         this.name = name;
     }
 
-    public Value getValue() throws ValueFormatException, RepositoryException {
-        return node.getPropertyValue(name);
+    public ValueImpl getValue() throws ValueFormatException, RepositoryException {
+        ValueImpl v = node.getPropertyValue(name);
+        log.codeAssign(v, this, "getValue");
+        return v;
+    }
+
+    private Val getVal() {
+        return node.getNodeState().getPropertyExternal(name);
     }
 
     public String getString() throws ValueFormatException, RepositoryException {
-        return node.getPropertyVal(name).getString();
+        log.code(this, "getString");
+        return ValueFactoryImpl.getString(getVal(), node.getSession().getValueFactory());
+    }
+
+    public SessionImpl getSession() throws RepositoryException {
+        return node.getSession();
+    }
+
+    public boolean isNode() {
+        log.code(this, "isNode");
+        return false;
     }
 
     public Binary getBinary() throws ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        BinaryImpl b = new BinaryImpl(getVal(), getValueFactory());
+        log.codeAssign(b, this, "getBinary");
+        return b;
+    }
+
+    private ValueFactoryImpl getValueFactory() {
+        return node.getSession().getValueFactory();
     }
 
     public boolean getBoolean() throws ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
+        log.code(this, "getBoolean");
+        return ValueFactoryImpl.getBoolean(getVal());
     }
 
     public Calendar getDate() throws ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getDate");
+        return ValueFactoryImpl.getDate(getVal());
     }
 
     public BigDecimal getDecimal() throws ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        log.code(this, "getDecimal");
+        return ValueFactoryImpl.getDecimal(getVal());
     }
 
-    public PropertyDefinition getDefinition() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+    public double getDouble() throws ValueFormatException, RepositoryException {
+        log.code(this, "getDouble");
+        return ValueFactoryImpl.getDouble(getVal());
     }
 
-    public double getDouble() throws ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
-        return 0;
+    public String getName() throws RepositoryException {
+        log.code(this, "getName");
+        return node.getSession().nameToString(name);
     }
 
     public long getLength() throws ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
-        return 0;
+        log.code(this, "getLength");
+        return ValueFactoryImpl.getLength(getVal(), node.getSession().getValueFactory());
     }
 
-    public long[] getLengths() throws ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
+    public long getLong() throws ValueFormatException, RepositoryException {
+        log.code(this, "getLong");
+        return ValueFactoryImpl.getLong(getVal());
+    }
+
+    public NodeImpl getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException {
+        log.code(this, "getParent");
+        return node;
+    }
+
+    public NodeImpl getNode() throws ItemNotFoundException, ValueFormatException, RepositoryException {
+        log.code(this, "getNode");
+        // TODO
+        // for reference properties
         return null;
     }
 
-    public long getLong() throws ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
-        return 0;
+    public PropertyDefinition getDefinition() throws RepositoryException {
+        log.code(this, "getDefinition");
+        // TODO
+        return null;
     }
 
-    public Node getNode() throws ItemNotFoundException, ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
+    public long[] getLengths() throws ValueFormatException, RepositoryException {
+        log.code(this, "getLengths");
+        // TODO
         return null;
     }
 
     public Property getProperty() throws ItemNotFoundException, ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getProperty");
+        // TODO
         return null;
     }
 
     public InputStream getStream() throws ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getStream");
+        // TODO
         return null;
     }
 
     public int getType() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getType");
+        // TODO
         return 0;
     }
 
     public Value[] getValues() throws ValueFormatException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getValues");
+        // TODO
         return null;
     }
 
     public boolean isMultiple() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "isMultiple");
+        // TODO
         return false;
     }
 
     public void setValue(Value value) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", value);
+        // TODO
 
     }
 
     public void setValue(Value[] values) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", (Object) values);
+        // TODO
 
     }
 
     public void setValue(String value) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", value);
+        // TODO
 
     }
 
     public void setValue(String[] values) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", (Object) values);
+        // TODO
 
     }
 
     public void setValue(InputStream value) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", value);
+        // TODO
 
     }
 
     public void setValue(Binary value) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", value);
+        // TODO
 
     }
 
     public void setValue(long value) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", value);
+        // TODO
 
     }
 
     public void setValue(double value) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", value);
+        // TODO
 
     }
 
     public void setValue(BigDecimal value) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", value);
+        // TODO
 
     }
 
     public void setValue(Calendar value) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", value);
+        // TODO
 
     }
 
     public void setValue(boolean value) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", value);
+        // TODO
 
     }
 
     public void setValue(Node value) throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "setValue", value);
+        // TODO
 
     }
 
     public void accept(ItemVisitor visitor) throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "accept", visitor);
+        // TODO
 
     }
 
     public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getAncestor", depth);
+        // TODO
         return null;
     }
 
     public int getDepth() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getDepth");
+        // TODO
         return 0;
     }
 
-    public String getName() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     public String getPath() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Session getSession() throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "getPath");
+        // TODO
         return null;
     }
 
     public boolean isModified() {
-        // TODO Auto-generated method stub
+        log.code(this, "isModified");
+        // TODO
         return false;
     }
 
     public boolean isNew() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public boolean isNode() {
-        // TODO Auto-generated method stub
+        log.code(this, "isNew");
+        // TODO
         return false;
     }
 
     public boolean isSame(Item otherItem) throws RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "isSame", otherItem);
+        // TODO
         return false;
     }
 
     public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "refresh", keepChanges);
+        // TODO
 
     }
 
     public void remove() throws VersionException, LockException, ConstraintViolationException, AccessDeniedException,
             RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "remove");
+        // TODO
 
     }
 
     public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException,
             InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException,
             NoSuchNodeTypeException, RepositoryException {
-        // TODO Auto-generated method stub
+        log.code(this, "save");
+        // TODO
 
     }
 

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyIteratorImpl.java?rev=932956&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyIteratorImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/PropertyIteratorImpl.java Sun Apr 11 17:49:03 2010
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.j3;
+
+import javax.jcr.PropertyIterator;
+import org.apache.jackrabbit.j3.mc.NodeData;
+import org.apache.jackrabbit.j3.mc.Val;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ *
+ * If properties are modified while iterating, a
+ * ConcurrentModificationException is thrown.
+ */
+public class PropertyIteratorImpl implements PropertyIterator, LogObject {
+
+    private final Log log;
+    private final NodeImpl node;
+    private final NodeData nodeData;
+    private final int modCount;
+    private final int size;
+    private Val propertyName;
+
+    /**
+     * Index 0 means the primary type of the node.
+     * There is always at least this one property.
+     */
+    private int index;
+
+    PropertyIteratorImpl(NodeImpl node) {
+        this.log = node.getLog();
+        this.node = node;
+        this.nodeData = node.getNodeState().getNodeData();
+        this.modCount = node.getNodeState().getModCount();
+        this.size = nodeData.getPropertyCount();
+    }
+
+    public PropertyImpl nextProperty() {
+        PropertyImpl result;
+        if (index == 0) {
+            result = new PropertyImpl(node, NodeState.PROPERTY_PRIMARY_TYPE);
+        } else {
+            if (propertyName == null) {
+                throw ExceptionFactory.noSuchElement();
+            }
+            result = new PropertyImpl(node, propertyName);
+        }
+        go();
+        log.codeAssign(result, this, "nextNode");
+        return result;
+    }
+
+    void go() {
+        NodeState state = node.getNodeState();
+        if (state.getModCount() != modCount || state.getNodeData() != nodeData) {
+            throw ExceptionFactory.concurrentModification();
+        }
+        if (index > size) {
+            throw ExceptionFactory.noSuchElement();
+        }
+        while (true) {
+            propertyName = nodeData.getPropertyName(index++);
+            if (propertyName == null) {
+                break;
+            }
+            if (skip()) {
+                continue;
+            }
+            break;
+        }
+    }
+
+    private boolean skip() {
+        log.code(this, "skip");
+        return false;
+    }
+
+    public long getPosition() {
+        log.code(this, "getPosition");
+        return index;
+    }
+
+    public long getSize() {
+        log.code(this, "getSize");
+        return size;
+    }
+
+    public void skip(long skipNum) {
+        log.code(this, "skip", skipNum);
+        index += skipNum;
+    }
+
+    public boolean hasNext() {
+        log.code(this, "hasNext");
+        return index <= size;
+    }
+
+    public Object next() {
+        return nextProperty();
+    }
+
+    public void remove() {
+        log.code(this, "remove");
+        throw ExceptionFactory.unsupportedOperation();
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RangeIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RangeIteratorImpl.java?rev=932956&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RangeIteratorImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RangeIteratorImpl.java Sun Apr 11 17:49:03 2010
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.j3;
+
+import java.util.Iterator;
+import javax.jcr.RangeIterator;
+import javax.jcr.RepositoryException;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
+import org.apache.jackrabbit.j3.util.Log;
+import org.apache.jackrabbit.j3.util.LogObject;
+
+/**
+ * The implementation of the corresponding JCR interface.
+ *
+ * @param <T> the type
+ */
+public abstract class RangeIteratorImpl<T> implements RangeIterator, LogObject {
+
+    protected final Log log;
+    private final Iterator<T> iterator;
+    private T next;
+    private long size;
+    private long pos;
+
+    protected RangeIteratorImpl(Iterator<T> iterator, long size, Log log) {
+        this.iterator = iterator;
+        this.size = size;
+        this.log = log;
+        go();
+    }
+
+    public boolean skip(T x) throws RepositoryException {
+        return false;
+    }
+
+    void go() {
+        try {
+            while (true) {
+                if (!iterator.hasNext()) {
+                    next = null;
+                    break;
+                }
+                next = iterator.next();
+                if (skip(next)) {
+                    continue;
+                }
+                break;
+            }
+        } catch (RepositoryException e) {
+            throw ExceptionFactory.runtime(e);
+        }
+    }
+
+    public Object next() {
+        return goNext();
+    }
+
+    public T goNext() {
+        pos++;
+        T result = next;
+        if (result == null) {
+            throw ExceptionFactory.noSuchElement();
+        }
+        go();
+        return result;
+    }
+
+    public long getPosition() {
+        log.code(this, "getPosition");
+        return pos;
+    }
+
+    public long getSize() {
+        log.code(this, "getSize");
+        return size;
+    }
+
+    public void skip(long skipNum) {
+        log.code(this, "skip", skipNum);
+        for (int i = 0; i < skipNum; i++) {
+            go();
+        }
+    }
+
+    public boolean hasNext() {
+        log.code(this, "hasNext");
+        return next != null;
+    }
+
+    public void remove() {
+        log.code(this, "remove");
+        throw ExceptionFactory.unsupportedOperation();
+    }
+
+}

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryFactoryImpl.java?rev=932956&r1=932955&r2=932956&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryFactoryImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryFactoryImpl.java Sun Apr 11 17:49:03 2010
@@ -17,18 +17,33 @@
 package org.apache.jackrabbit.j3;
 
 import java.util.Map;
-import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.RepositoryFactory;
+import org.apache.jackrabbit.j3.util.Constants;
+import org.apache.jackrabbit.j3.util.Log;
 
 /**
- * The repository factory implementation.
+ * The implementation of the corresponding JCR interface.
  */
 public class RepositoryFactoryImpl implements RepositoryFactory {
 
     @SuppressWarnings("unchecked")
-    public Repository getRepository(Map parameters) throws RepositoryException {
-        return new RepositoryImpl(parameters);
+    public RepositoryImpl getRepository(Map parameters) throws RepositoryException {
+        String url;
+        Object o = parameters.get("url");
+        if (o == null) {
+            url = Constants.DEFAULT_URL;
+        } else {
+            url = o.toString();
+        }
+        Log log = new Log();
+        if (url.endsWith("&log=debug")) {
+            url = url.substring(0, url.length() - "&log=debug".length());
+            log.debug = true;
+        }
+        RepositoryImpl  rep = new RepositoryImpl(url, log);
+        log.codeAssign(rep, null, "new " + RepositoryFactoryImpl.class.getName() + "().getRepository", parameters);
+        return rep;
     }
 
 }



Mime
View raw message