jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r961687 - in /jackrabbit/sandbox/jackrabbit-j3/src: main/java/org/apache/jackrabbit/j3/ main/java/org/apache/jackrabbit/j3/api/observation/ main/java/org/apache/jackrabbit/j3/mc/ main/java/org/apache/jackrabbit/j3/mc/jdbc/ main/java/org/apa...
Date Thu, 08 Jul 2010 10:21:35 GMT
Author: thomasm
Date: Thu Jul  8 10:21:34 2010
New Revision: 961687

URL: http://svn.apache.org/viewvc?rev=961687&view=rev
Log:
Orderable child nodes

Added:
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestRepositoryLock.java
Modified:
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ChangeSet.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/NodeState.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/api/observation/SynchronousEventListener.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/McException.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/NodeData.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Storage.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorage.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorageSession.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorage.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorageSession.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventConsumer.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventFilter.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/query/ParserSQL2.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/Cache.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/CacheSimple.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/ExceptionFactory.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/Log.java
    jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/LogObject.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestAll.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBase.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestConcurrentWrite.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestEventJournal.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestObservation.java
    jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/xa/UserTransactionImpl.java

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ChangeSet.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ChangeSet.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ChangeSet.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/ChangeSet.java Thu Jul  8 10:21:34 2010
@@ -41,8 +41,8 @@ public class ChangeSet {
     private final LinkedHashMap<Val, NodeState> nodes = new LinkedHashMap<Val, NodeState>();
     private final LinkedList<EventImpl> events = new LinkedList<EventImpl>();
     private final int maxMemorySize;
-    private final SessionImpl session;
-    private final StorageSession storageSession;
+    final SessionImpl session;
+    final StorageSession storageSession;
     private final Log log;
     private final boolean unlimited;
     private String userId;
@@ -51,7 +51,7 @@ public class ChangeSet {
     private String userData;
     private int nodeMemoryUsed;
     private int nodesCountTotal;
-    private boolean persistEvents = true;
+    private final boolean persistEvents;
 
     /**
      * A bloom filter to quickly check if an entry might be in the backend storage.
@@ -62,6 +62,7 @@ public class ChangeSet {
     public ChangeSet(SessionImpl session, StorageSession storageSession, int maxMemorySize) {
         this.session = session;
         this.storageSession = storageSession;
+        this.persistEvents = storageSession == null ? false : storageSession.supportsEventJournal();
         this.maxMemorySize = maxMemorySize;
         this.log = session.getLog();
         this.userId = session.getUserId();

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=961687&r1=961686&r2=961687&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 Thu Jul  8 10:21:34 2010
@@ -141,17 +141,6 @@ public class NodeImpl implements Node, L
         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 {
         PropertyImpl p = setProperty(name, Val.get(value));

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=961687&r1=961686&r2=961687&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 Thu Jul  8 10:21:34 2010
@@ -34,6 +34,7 @@ public class NodeState {
     static final Val PROPERTY_LOCK_IS_DEEP = Val.get(JCR, Val.get("lockIsDeep"));
     static final Val PROPERTY_LOCK_OWNER = Val.get(JCR, Val.get("lockOwner"));
     static final Val PROPERTY_PRIMARY_TYPE = Val.get(JCR, Val.get("primaryType"));
+    static final Val PROPERTY_CHILD_ORDER = Val.get(JCR, Val.get("childOrder"));
     static final Val NT_UNSTRUCTURED = Val.get(NT, Val.get("unstructured"));
     static final Val DEFAULT_PRIMARY_TYPE = NT_UNSTRUCTURED;
 
@@ -202,6 +203,24 @@ public class NodeState {
         if (data.getHiddenChildNodes()) {
 
         }
+        int childCount = data.getChildCount();
+        if (childCount > 0) {
+            Val order = data.getPropertyValue(PROPERTY_CHILD_ORDER);
+            if (order != null) {
+                order = order.addUnordered(childName);
+                data.setPropertyValue(PROPERTY_CHILD_ORDER, order);
+            } else {
+                Val lastChildName = data.getChildName(childCount - 1);
+                if (childName.compareTo(lastChildName) < 0) {
+                    Val[] orderList = new Val[childCount + 1];
+                    for (int i = 0; i < childCount; i++) {
+                        orderList[i] = data.getChildName(i);
+                    }
+                    orderList[childCount] = childName;
+                    data.setPropertyValue(PROPERTY_CHILD_ORDER, Val.get(orderList));
+                }
+            }
+        }
         data.addChild(childName, id);
         modifyEnd();
     }
@@ -213,6 +232,16 @@ public class NodeState {
 
         } else {
             data.removeChild(childName);
+            Val order = data.getChildId(PROPERTY_CHILD_ORDER);
+            if (order != null) {
+                if (order.getArray().length == 1) {
+                    order = null;
+                } else {
+                    order = order.addUnordered(childName);
+                    // TODO check if the list is now ordered - if yes remove it
+                }
+                data.setPropertyValue(PROPERTY_CHILD_ORDER, order);
+            }
         }
         modifyEnd();
     }
@@ -242,7 +271,25 @@ public class NodeState {
         if (data.getHiddenChildNodes()) {
 
         }
-        return data.getNextChildId(last == null ? null : last.data);
+        Val order = data.getPropertyValue(PROPERTY_CHILD_ORDER);
+        if (order == null) {
+            return data.getNextChildId(last == null ? null : last.data);
+        }
+        Val[] orderList = order.getArray();
+        if (last == null) {
+            return data.getChildId(orderList[0]);
+        }
+        Val lastName = last.getName(this);
+        int i = 0;
+        for (; i < orderList.length; i++) {
+            if (orderList[i].equals(lastName)) {
+                break;
+            }
+        }
+        if (i >= orderList.length - 1) {
+            return null;
+        }
+        return data.getChildId(orderList[i + 1]);
     }
 
 }

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=961687&r1=961686&r2=961687&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 Thu Jul  8 10:21:34 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.j3;
 
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
@@ -30,6 +32,15 @@ import org.apache.jackrabbit.j3.util.Log
  */
 public class RepositoryFactoryImpl implements JackrabbitRepositoryFactory {
 
+    /**
+     * Open a new repository. Only the parameter "url" is supported. If not
+     * specified, repository URL "mem:" is used. The repository URL has the
+     * following format: prefix ':' [ name ] [ '?' param '=' value [ '&' param '=' value ]* ].
+     * Supported options are log=debug and eventJournal=true|false (default is enabled if possible).
+     * Examples: jdbc:h2:~/test, jdbc:h2:~/test?log=debug
+     *
+     * @param parameters the parameters
+     */
     @SuppressWarnings("unchecked")
     public RepositoryImpl getRepository(Map parameters) throws RepositoryException {
         String url;
@@ -39,12 +50,29 @@ public class RepositoryFactoryImpl imple
         } else {
             url = o.toString();
         }
+        int queryStart = url.lastIndexOf('?');
+        Map<String, String> q;
+        if (queryStart < 0) {
+            q = Collections.emptyMap();
+        } else {
+            q = new HashMap<String, String>();
+            String query = url.substring(queryStart + 1);
+            while (true) {
+                int next = query.indexOf('&');
+                String pv = next < 0 ? query : query.substring(0, next);
+                int idx = pv.indexOf('=');
+                q.put(pv.substring(0, idx), pv.substring(idx + 1));
+                if (next < 0) {
+                    break;
+                }
+                query = query.substring(next + 1);
+            }
+        }
         Log log = new Log();
-        if (url.endsWith("&log=debug")) {
-            url = url.substring(0, url.length() - "&log=debug".length());
+        if ("debug".equals(q.get("log"))) {
             log.debug = true;
         }
-        RepositoryImpl  rep = new RepositoryImpl(this, url, log);
+        RepositoryImpl  rep = new RepositoryImpl(this, url, q, log);
         log.codeAssign(rep, null, "new " + RepositoryFactoryImpl.class.getName() + "().getRepository", parameters);
         return rep;
     }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryImpl.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/RepositoryImpl.java Thu Jul  8 10:21:34 2010
@@ -18,6 +18,8 @@ package org.apache.jackrabbit.j3;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
 import java.util.TreeSet;
 import java.util.WeakHashMap;
 import javax.jcr.Credentials;
@@ -28,12 +30,11 @@ import javax.jcr.Value;
 import org.apache.jackrabbit.j3.api.JackrabbitRepository;
 import org.apache.jackrabbit.j3.data.DataStore;
 import org.apache.jackrabbit.j3.lock.LockSystem;
+import org.apache.jackrabbit.j3.mc.McException;
 import org.apache.jackrabbit.j3.mc.NodeData;
 import org.apache.jackrabbit.j3.mc.Storage;
 import org.apache.jackrabbit.j3.mc.StorageSession;
 import org.apache.jackrabbit.j3.mc.Val;
-import org.apache.jackrabbit.j3.mc.jdbc.JdbcStorage;
-import org.apache.jackrabbit.j3.mc.mem.MemStorage;
 import org.apache.jackrabbit.j3.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.j3.query.qom.QueryObjectModelFactoryImpl;
 import org.apache.jackrabbit.j3.util.Cache;
@@ -67,17 +68,27 @@ public class RepositoryImpl implements J
     private boolean closed;
     private LockSystem lockSystem;
 
-    public RepositoryImpl(RepositoryFactoryImpl factory, String url, Log log) {
+    public RepositoryImpl(RepositoryFactoryImpl factory, String url, Map<String, String> params, Log log) {
         this.factory = factory;
         this.log = log;
         this.url = url;
-        if (url.startsWith("jdbc:")) {
-            storage = new JdbcStorage(url);
-        } else if (url.startsWith("mem:")) {
-            storage = new MemStorage();
-        } else {
+        int idx = url.indexOf(':');
+        if (idx < 0 || url.length() < 2) {
             throw ExceptionFactory.mcException("Unsupported url: {0}", url);
         }
+        String prefix = url.substring(0, idx);
+        StringBuilder buff = new StringBuilder();
+        buff.append(Storage.class.getPackage().getName()).append('.');
+        buff.append(prefix).append('.');
+        buff.append(prefix.substring(0, 1).toUpperCase(Locale.US)).append(prefix.substring(1));
+        buff.append("Storage");
+        String className = buff.toString();
+        try {
+            storage = (Storage) Class.forName(className).newInstance();
+        } catch (Exception e) {
+            throw ExceptionFactory.mcException(e, "Unsupported url: {0}", url);
+        }
+        storage.init(url, params);
         valueFactory = new ValueFactoryImpl(lobStore, NamespaceRegistryImpl.BUILT_IN, log);
         descriptors.put("url", valueFactory.createValue(url));
         qomFactory = new QueryObjectModelFactoryImpl(log);
@@ -118,7 +129,12 @@ public class RepositoryImpl implements J
         }
         SimpleCredentials sc = (SimpleCredentials) credentials;
         String userId = sc.getUserID();
-        StorageSession storageSession = storage.openSession(userId, sc.getPassword());
+        StorageSession storageSession;
+        try {
+            storageSession = storage.openSession(userId, sc.getPassword());
+        } catch (McException e) {
+            throw ExceptionFactory.repository(e, null);
+        }
         SessionImpl session = new SessionImpl(this, sc, storageSession, workspaceName, log);
         initRepository(storageSession);
         sessions.put(session, this);

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/SessionImpl.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/SessionImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/SessionImpl.java Thu Jul  8 10:21:34 2010
@@ -50,7 +50,6 @@ import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 import org.apache.jackrabbit.j3.api.JackrabbitSession;
-import org.apache.jackrabbit.j3.data.DataStore;
 import org.apache.jackrabbit.j3.lock.LockManagerImpl;
 import org.apache.jackrabbit.j3.mc.McException;
 import org.apache.jackrabbit.j3.mc.NodeData;

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/api/observation/SynchronousEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/api/observation/SynchronousEventListener.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/api/observation/SynchronousEventListener.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/api/observation/SynchronousEventListener.java Thu Jul  8 10:21:34 2010
@@ -32,4 +32,6 @@ import javax.jcr.observation.EventListen
  */
 public interface SynchronousEventListener extends EventListener {
 
+    // marker interface
+
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/McException.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/McException.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/McException.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/McException.java Thu Jul  8 10:21:34 2010
@@ -21,6 +21,8 @@ package org.apache.jackrabbit.j3.mc;
  */
 public class McException extends RuntimeException {
 
+    private static final long serialVersionUID = 1L;
+
     public McException(String message) {
         super(message);
     }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/NodeData.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/NodeData.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/NodeData.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/NodeData.java Thu Jul  8 10:21:34 2010
@@ -38,11 +38,8 @@ public class NodeData implements CacheEl
     private long version;
     private Val primaryType;
     private Val lockToken;
-    private Val childNameFirst, childNameLast;
-    // TODO maybe combine all pairs into one array
     private Val[] propertyValuePairs;
     private Val[] childNameIdPairs;
-    private Val[] childNamePrevNextPairs;
     private int cachedParentIndex;
     private int memoryCache;
     private boolean hiddenChildNodes;
@@ -57,11 +54,8 @@ public class NodeData implements CacheEl
         NodeData copy = new NodeData(id, primaryParentId, version);
         copy.primaryType = primaryType;
         copy.lockToken = lockToken;
-        copy.childNameFirst = childNameFirst;
-        copy.childNameLast = childNameLast;
         copy.propertyValuePairs = propertyValuePairs;
         copy.childNameIdPairs = childNameIdPairs;
-        copy.childNamePrevNextPairs = childNamePrevNextPairs;
         copy.cachedParentIndex = cachedParentIndex;
         copy.memoryCache = memoryCache;
         copy.hiddenChildNodes = hiddenChildNodes;
@@ -101,6 +95,14 @@ public class NodeData implements CacheEl
         if (childNameIdPairs == null || index >= childNameIdPairs.length) {
             return null;
         }
+        return childNameIdPairs[index + 1];
+    }
+
+    public Val getChildName(int index) {
+        index += index;
+        if (childNameIdPairs == null || index >= childNameIdPairs.length) {
+            return null;
+        }
         return childNameIdPairs[index];
     }
 
@@ -109,40 +111,9 @@ public class NodeData implements CacheEl
             throw ExceptionFactory.mcException("Duplicate node {0}", childName);
         }
         childNameIdPairs = updatePair(childNameIdPairs, childName, childId);
-        if (childNamePrevNextPairs != null) {
-            int index = search(childName, childNameIdPairs);
-            int newLength = childNameIdPairs.length;
-            Val[] newPrevNext = new Val[newLength];
-            if (newLength == 2) {
-                childNameFirst = childName;
-                childNameLast = childName;
-            } else {
-                System.arraycopy(childNamePrevNextPairs, 0, newPrevNext, 0, index);
-                System.arraycopy(childNamePrevNextPairs, index, newPrevNext, index + 2, newLength - 2 - index);
-                newPrevNext[index] = childNameLast;
-                int lastIndex = search(childNameLast, childNameIdPairs);
-                newPrevNext[lastIndex + 1] = childName;
-                childNameLast = childName;
-            }
-            childNamePrevNextPairs = newPrevNext;
-        }
     }
 
     public void removeChild(Val childName) {
-        if (childNamePrevNextPairs != null) {
-            int index = search(childName, childNameIdPairs);
-            int newLength = childNameIdPairs.length - 2;
-            Val[] newPrevNext = new Val[newLength];
-            System.arraycopy(childNamePrevNextPairs, 0, newPrevNext, 0, index);
-            System.arraycopy(childNamePrevNextPairs, index + 2, newPrevNext, index, newLength - index);
-            if (childNameFirst.equals(childName)) {
-                childNameFirst = childNamePrevNextPairs[index + 1];
-            }
-            if (childNameLast.equals(childName)) {
-                childNameLast = childNamePrevNextPairs[index];
-            }
-
-        }
         childNameIdPairs = updatePair(childNameIdPairs, childName, null);
     }
 
@@ -406,8 +377,6 @@ public class NodeData implements CacheEl
         if ((flags & BIT_CHILDREN) != 0) {
             int count = bundle.readVarInt();
             data.childNameIdPairs = readArray(bundle, count * 2);
-            // TODO child order
-            data.childNamePrevNextPairs = new Val[count * 2];
         }
         if ((flags & BIT_PROPERTIES) != 0) {
             int count = bundle.readVarInt();

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Storage.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Storage.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Storage.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Storage.java Thu Jul  8 10:21:34 2010
@@ -16,11 +16,17 @@
  */
 package org.apache.jackrabbit.j3.mc;
 
+import java.util.Map;
+
 /**
  * The storage interface.
  */
 public interface Storage {
 
+    String EVENT_JOURNAL = "eventJournal";
+
+    void init(String url, Map<String, String> params);
+
     StorageSession openSession(String user, char[] password);
 
     void close();

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/Val.java Thu Jul  8 10:21:34 2010
@@ -295,7 +295,10 @@ public class Val implements Comparable<V
                 if (i++ > 0) {
                     buff.append(", ");
                 }
-                buff.append(v.toString());
+                // should in theory never be null (unless there is a bug)
+                if (v != null) {
+                    buff.append(v.toString());
+                }
             }
             return buff.append(" ]").toString();
         }
@@ -404,6 +407,31 @@ public class Val implements Comparable<V
         return Integer.signum(data1.length - data2.length);
     }
 
+    public Val addUnordered(Val x) {
+        Val[] oldArray = getArray();
+        Val[] newArray = new Val[oldArray.length + 1];
+        System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
+        newArray[oldArray.length] = x;
+        return Val.get(newArray);
+    }
+
+    public Val removeUnordered(Val x) {
+        Val[] oldArray = getArray();
+        int pos;
+        for (pos = 0; pos < oldArray.length; pos++) {
+            if (oldArray[pos].equals(x)) {
+                break;
+            }
+        }
+        if (pos >= oldArray.length) {
+            return this;
+        }
+        Val[] newArray = new Val[oldArray.length - 1];
+        System.arraycopy(oldArray, 0, newArray, 0, pos);
+        System.arraycopy(oldArray, pos + 1, newArray, pos, oldArray.length - pos - 1);
+        return Val.get(newArray);
+    }
+
     public Val addOrdered(Val x) {
         // if this is a performance problem,
         // use java.util.TreeMap<Val, Integer> where the value is the count

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorage.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorage.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorage.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorage.java Thu Jul  8 10:21:34 2010
@@ -21,6 +21,8 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.sql.Timestamp;
+import java.util.Map;
 import javax.jcr.RepositoryException;
 import org.apache.jackrabbit.j3.data.DataStore;
 import org.apache.jackrabbit.j3.data.FileDataStore;
@@ -43,7 +45,7 @@ public class JdbcStorage implements Stor
     private static final String VERSION_WRITE = "1";
     private static final int NODE_ID_INCREMENT = 32;
 
-    private final String url;
+    private String url;
     private boolean initDone;
     private static final Val rootNodeId = Val.get(0);
     private long nextBaseNodeId;
@@ -56,14 +58,20 @@ public class JdbcStorage implements Stor
 
     private DataStore dataStore;
 
-    public JdbcStorage(String url) {
+    private boolean supportsEventJournal = true;
+
+    public void init(String url, Map<String, String> params) {
         this.url = url;
+        String s = params.get(EVENT_JOURNAL);
+        if (s != null) {
+            supportsEventJournal = Boolean.parseBoolean(s);
+        }
     }
 
     public synchronized StorageSession openSession(String user, char[] password) {
         try {
             Connection conn = JdbcUtils.getConnection(null, url, user, new String(password));
-            JdbcStorageSession session = new JdbcStorageSession(this, conn, nextSessionId++);
+            JdbcStorageSession session = new JdbcStorageSession(this, conn, nextSessionId++, supportsEventJournal);
             if (connControl == null) {
                 connLock =  JdbcUtils.getConnection(null, url, user, new String(password));
                 connControl = JdbcUtils.getConnection(null, url, user, new String(password));
@@ -118,7 +126,7 @@ public class JdbcStorage implements Stor
                 // could switch to read-only now
                 throw ExceptionFactory.mcException("Invalid write version: {0}", write);
             }
-            stat.execute("create table if not exists lock(id int primary key)");
+            stat.execute("create table if not exists lock(id int primary key, comment varchar(255))");
             lock();
             stat.execute("create table if not exists nodes(id bigint primary key, version bigint, data binary)");
             stat.execute("create table if not exists nodes_temp(id bigint, sessionId bigint, block int, version int, data binary, primary key(id, sessionId))");
@@ -152,11 +160,17 @@ public class JdbcStorage implements Stor
 
     private void lock() {
         try {
-            connLock.setAutoCommit(false);
             Statement lock = connLock.createStatement();
-            lock.execute("insert into lock values(1)");
+            lock.execute("delete from lock");
+            PreparedStatement prep = connLock.prepareStatement("insert into lock values(0, ?)");
+            prep.setString(1, new Timestamp(System.currentTimeMillis()).toString());
+            prep.execute();
+            connLock.setAutoCommit(false);
+            // using insert / update / delete prevents the transaction log
+            // from shrinking (tested in the H2 database and Apache Derby)
+            lock.execute("select * from lock for update");
         } catch (SQLException e) {
-            throw ExceptionFactory.mcException("Repository is already in use", e);
+            throw ExceptionFactory.mcException(e, ExceptionFactory.getMessage(ExceptionFactory.REPOSITORY_ALREADY_OPEN));
         }
     }
 
@@ -200,4 +214,8 @@ public class JdbcStorage implements Stor
         return dataStore;
     }
 
+    boolean supportsEventJournal() {
+        return supportsEventJournal;
+    }
+
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorageSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorageSession.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorageSession.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/jdbc/JdbcStorageSession.java Thu Jul  8 10:21:34 2010
@@ -40,14 +40,16 @@ public class JdbcStorageSession implemen
     private final HashMap<String, PreparedStatement> prepared = new HashMap<String, PreparedStatement>();
     private final Bundle bundle = Bundle.create(512);
     private final long sessionId;
+    private final boolean supportsEventJournal;
     private int tempNodeBlocks;
     private int tempEventBlocks;
     private long nextEventId;
 
-    JdbcStorageSession(JdbcStorage storage, Connection conn, long sessionId) {
+    JdbcStorageSession(JdbcStorage storage, Connection conn, long sessionId, boolean supportsEventJournal) {
         this.storage = storage;
         this.conn = conn;
         this.sessionId = sessionId;
+        this.supportsEventJournal = supportsEventJournal;
     }
 
     private PreparedStatement prepare(String sql) throws SQLException {
@@ -259,7 +261,7 @@ public class JdbcStorageSession implemen
     }
 
     public boolean supportsEventJournal() {
-        return true;
+        return supportsEventJournal;
     }
 
     public boolean supportsTemp() {

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorage.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorage.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorage.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorage.java Thu Jul  8 10:21:34 2010
@@ -21,6 +21,7 @@ import org.apache.jackrabbit.j3.mc.NodeD
 import org.apache.jackrabbit.j3.mc.Storage;
 import org.apache.jackrabbit.j3.mc.StorageSession;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
 
 /**
@@ -32,12 +33,13 @@ public class MemStorage implements Stora
     private final HashMap<Val, NodeData> content = new HashMap<Val, NodeData>();
     private AtomicLong nextBaseNodeId = new AtomicLong(1);
 
-    public MemStorage() {
+    public void init(String url, Map<String, String> params) {
         NodeData root = new NodeData(rootNodeId, null, 0);
         content.put(rootNodeId, root);
     }
 
     public void close() {
+        // nothing to do
     }
 
     public StorageSession openSession(String user, char[] password) {

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorageSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorageSession.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorageSession.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/mc/mem/MemStorageSession.java Thu Jul  8 10:21:34 2010
@@ -39,6 +39,7 @@ public class MemStorageSession implement
     }
 
     public void close() {
+        // nothing to do
     }
 
     public NodeData getNode(Val nodeId) {

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventConsumer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventConsumer.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventConsumer.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventConsumer.java Thu Jul  8 10:21:34 2010
@@ -32,7 +32,7 @@ public class EventConsumer {
 
     private final EventListener listener;
     private final SessionImpl session;
-    private final EventFilter filter;
+    final EventFilter filter;
 
     EventConsumer(SessionImpl session, EventListener listener, EventFilter filter) {
         this.session = session;

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventFilter.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventFilter.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/observation/EventFilter.java Thu Jul  8 10:21:34 2010
@@ -27,7 +27,7 @@ import org.apache.jackrabbit.j3.util.Exc
  * A filter for event iterators.
  */
 public class EventFilter {
-    private final SessionImpl session;
+    final SessionImpl session;
     private final int eventTypes;
     private final String absPath;
     private final boolean isDeep;

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/query/ParserSQL2.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/query/ParserSQL2.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/query/ParserSQL2.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/query/ParserSQL2.java Thu Jul  8 10:21:34 2010
@@ -979,10 +979,10 @@ public class ParserSQL2 {
      * Represents a column or a wildcard in a SQL expression.
      * This class is temporarily used during parsing.
      */
-    private static class ColumnOrWildcard {
-        private String selectorName;
-        private String propertyName;
-        private String columnName;
+    static class ColumnOrWildcard {
+        String selectorName;
+        String propertyName;
+        String columnName;
     }
 
     /**

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/Cache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/Cache.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/Cache.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/Cache.java Thu Jul  8 10:21:34 2010
@@ -11,6 +11,7 @@ import java.util.Map;
  */
 public class Cache<K, V extends CacheElement> extends LinkedHashMap<K, V> {
 
+    private static final long serialVersionUID = 1L;
     private final int maxMemory;
     private long memoryUsed;
 

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/CacheSimple.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/CacheSimple.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/CacheSimple.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/CacheSimple.java Thu Jul  8 10:21:34 2010
@@ -27,6 +27,7 @@ import java.util.Map;
  */
 public class CacheSimple<K, V> extends LinkedHashMap<K, V> {
 
+    private static final long serialVersionUID = 1L;
     private final int maxSize;
 
     public CacheSimple(int maxSize) {

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/ExceptionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/ExceptionFactory.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/ExceptionFactory.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/ExceptionFactory.java Thu Jul  8 10:21:34 2010
@@ -35,6 +35,7 @@ import org.apache.jackrabbit.j3.mc.McExc
  */
 public class ExceptionFactory {
 
+    public static final int REPOSITORY_ALREADY_OPEN = 1002;
     static final int CLOSED_0 = 1000;
     static final int CONCURRENT_UPDATE_1 = 1001;
 
@@ -43,13 +44,24 @@ public class ExceptionFactory {
 
     static {
         MESSAGE_MAP.put(CLOSED_0, "The repository is closed");
+        MESSAGE_MAP.put(REPOSITORY_ALREADY_OPEN, "The repository is already open");
+    }
+
+    public static int getErrorCode(Exception e) {
+        String message = e.getMessage();
+        int open = message.lastIndexOf('[');
+        int dash = message.lastIndexOf('-');
+        if (dash < 0 || open < 0 || dash < open) {
+            return 0;
+        }
+        return Integer.parseInt(message.substring(open + 1, dash));
     }
 
     public static RepositoryException get(int errorCode, String... params) {
         return new RepositoryException(getMessage(errorCode, params));
     }
 
-    static String getMessage(int errorCode, String... params) {
+    public static String getMessage(int errorCode, String... params) {
         String message = MESSAGE_MAP.get(errorCode);
         message = MessageFormat.format(message, (Object[]) params);
         return message + " [" + errorCode + "-" + Constants.FULL_VERSION + "]";
@@ -62,18 +74,18 @@ public class ExceptionFactory {
         return message + " [" + Constants.FULL_VERSION + "]";
     }
 
-    public static <E extends Exception> E exception(Class<E> e, Throwable cause, String message, Object... params) throws E {
-        String msg;
+    public static <E extends Exception> E exception(Class<E> e, Throwable cause, String msg, Object... params) throws E {
+        String message;
         if (params != null && params.length > 0) {
-            msg = format(message, params);
+            message = format(msg, params);
         } else {
-            msg = message;
+            message = msg == null ? cause.getMessage() : msg;
         }
         E i;
         try {
-            i = e.getConstructor(String.class).newInstance(msg);
+            i = e.getConstructor(String.class).newInstance(message);
         } catch (Exception e1) {
-            throw new RuntimeException("Error building " + e + ": " + msg, cause);
+            throw new RuntimeException("Error building " + e + ": " + message, cause);
         }
         if (cause != null) {
             i.initCause(cause);
@@ -141,6 +153,10 @@ public class ExceptionFactory {
         throw exception(McException.class, null, message, params);
     }
 
+    public static McException mcException(Exception cause, String message, Object... params) throws McException {
+        throw exception(McException.class, cause, message, params);
+    }
+
     public static LoginException login() throws LoginException {
         throw exception(LoginException.class, null, "");
     }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/Log.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/Log.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/Log.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/Log.java Thu Jul  8 10:21:34 2010
@@ -21,7 +21,6 @@ import java.util.HashMap;
 import java.util.Map;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.observation.EventListener;
-import org.apache.jackrabbit.j3.SessionImpl;
 
 /**
  * The method call logger utility.
@@ -126,7 +125,7 @@ public class Log {
                 return c.getSimpleName();
             }
         }
-        throw ExceptionFactory.illegalArgument("Not a javax.jcr class", obj);
+        throw ExceptionFactory.illegalArgument("Not a javax.jcr class: {0}", obj);
     }
 
     private String format(LogObject obj, String method, Object... args) {

Modified: jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/LogObject.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/LogObject.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/LogObject.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/main/java/org/apache/jackrabbit/j3/util/LogObject.java Thu Jul  8 10:21:34 2010
@@ -17,8 +17,10 @@
 package org.apache.jackrabbit.j3.util;
 
 /**
- * A class that implements this interface can log method calls.
+ * A class that implements this marker interface can log method calls.
  */
 public interface LogObject {
 
+    // no methods
+
 }

Modified: jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestAll.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestAll.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestAll.java Thu Jul  8 10:21:34 2010
@@ -37,14 +37,12 @@ public class TestAll extends TestCase {
 
         int todo;
 
-        // ability to disable the even journal (for a repo, for each session)
-
         // many child nodes
 
-        // unsorted / sort child sortedChildNodeNames
-
         // sns
 
+        // large transactions shouldn't block read operations
+
         // integrated lob storage
         // database data store: should use the session to access the binary
         // (like this we can also restrict on temporary storage per session)
@@ -64,6 +62,8 @@ public class TestAll extends TestCase {
         // ability to auto-delete old event journal entries
         // node id: try supporting path as the node id
         // node id: store neighbor nodes together, use { idOfBaseNode, localNodeId }
+        // lazy hasNode (should not read the node data)
+        // possibly lazy NodeImpl (sometimes reading the node is not required, only the path)
 
         // events: save space for n=addNode+n.setProperty+... or n.setProperty+n.setProperty+...
 
@@ -74,13 +74,14 @@ public class TestAll extends TestCase {
         // make namespace registry global
         // NodeIterators: support Iterable
         // somehow support getValue for multi-value properties
+        // orderable child nodes shouldn't be the default
 
         suite.addTestSuite(TestBundle.class);
         suite.addTestSuite(TestCache.class);
         suite.addTestSuite(TestCreateNodesTraverse.class);
         suite.addTestSuite(TestEventJournal.class);
         suite.addTestSuite(TestLargeObject.class);
-        // suite.addTestSuite(TestOrderableChildNodes.class);
+        suite.addTestSuite(TestOrderableChildNodes.class);
         suite.addTestSuite(TestNamespaceRegistry.class);
         suite.addTestSuite(TestNodeTypeRegistry.class);
         suite.addTestSuite(TestSecurity.class);
@@ -90,6 +91,7 @@ public class TestAll extends TestCase {
             suite.addTestSuite(TestConcurrentWrite.class);
             suite.addTestSuite(TestLock.class);
             suite.addTestSuite(TestObservation.class);
+            suite.addTestSuite(TestRepositoryLock.class);
             suite.addTestSuite(TestSessionGC.class);
             suite.addTestSuite(TestSimple.class);
 

Modified: jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBase.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBase.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestBase.java Thu Jul  8 10:21:34 2010
@@ -27,6 +27,7 @@ import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 import junit.framework.TestCase;
 import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.j3.api.JackrabbitRepositoryFactory;
 
 /**
  * The base class for the tests.
@@ -36,13 +37,14 @@ public abstract class TestBase extends T
     protected static int configurationId;
 
     public static final String[] URL = new String[] {
-        // "jdbc:h2:target/repos/test&log=debug",
+         "jdbc:h2:target/repos/test?eventJournal=false",
         // "jdbc:h2:target/repos/test;TRACE_LEVEL_SYSTEM_OUT=2",
         "jdbc:h2:target/repos/test",
         "mem:",
         "jdbc:h2:mem:test",
     };
 
+    protected Map<String, String> parameters;
     protected RepositoryFactory repositoryFactory;
     protected Repository repository;
     protected Session session;
@@ -51,16 +53,26 @@ public abstract class TestBase extends T
         FileUtils.deleteDirectory(new File("target/repos"));
         String factoryClass = "org.apache.jackrabbit.j3.RepositoryFactoryImpl";
         String url = URL[configurationId];
+        url += getUrlSuffix();
         repositoryFactory = (RepositoryFactory) Class.forName(factoryClass).newInstance();
-        Map<String, String> parameters = new HashMap<String, String>();
+        parameters = new HashMap<String, String>();
         parameters.put("url", url);
-        repository = repositoryFactory.getRepository(parameters);
+        repository = openRepository();
 
         session = openSession();
     }
 
+    protected String getUrlSuffix() {
+        return "";
+    }
+
+    protected Repository openRepository() throws RepositoryException {
+        return repositoryFactory.getRepository(parameters);
+    }
+
     protected void tearDown() throws Exception {
         session.logout();
+        ((JackrabbitRepositoryFactory) repositoryFactory).getRepositoryManager(repository).stop();
     }
 
     protected Session openSession() throws LoginException, RepositoryException {

Modified: jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestConcurrentWrite.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestConcurrentWrite.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestConcurrentWrite.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestConcurrentWrite.java Thu Jul  8 10:21:34 2010
@@ -30,8 +30,8 @@ import javax.jcr.Session;
  */
 public class TestConcurrentWrite extends TestBase {
 
-   private String parentUUID;
-   private boolean stop;
+   String parentUUID;
+   boolean stop;
 
    public void test() throws Exception {
 

Modified: jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestEventJournal.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestEventJournal.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestEventJournal.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestEventJournal.java Thu Jul  8 10:21:34 2010
@@ -26,6 +26,10 @@ import javax.jcr.observation.EventJourna
  */
 public class TestEventJournal extends TestBase {
 
+    protected String getUrlSuffix() {
+        return "&eventJournal=true";
+    }
+
     public void test() throws Exception {
         Node n = session.getRootNode().addNode("testEventJournal");
         session.getWorkspace().getObservationManager().setUserData("userData");

Modified: jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestObservation.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestObservation.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestObservation.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestObservation.java Thu Jul  8 10:21:34 2010
@@ -29,8 +29,8 @@ import javax.jcr.observation.EventListen
  */
 public class TestObservation extends TestBase {
 
-    private ArrayList<String> eventList = new ArrayList<String>();
-    private boolean ownEvent;
+    ArrayList<String> eventList = new ArrayList<String>();
+    boolean ownEvent;
 
     public void test() throws Exception {
         session.getRootNode().addNode("t");

Added: jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestRepositoryLock.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestRepositoryLock.java?rev=961687&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestRepositoryLock.java (added)
+++ jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/TestRepositoryLock.java Thu Jul  8 10:21:34 2010
@@ -0,0 +1,28 @@
+package org.apache.jackrabbit.j3;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import org.apache.jackrabbit.j3.util.ExceptionFactory;
+
+/**
+ * Tests repository locking.
+ */
+public class TestRepositoryLock extends TestBase {
+
+    public void test() throws Exception {
+        if (parameters.get("url").startsWith("mem:")) {
+            // each in-memory repository is unique
+            return;
+        }
+        try {
+            // the repository is already open at this point
+            Repository r2 = openRepository();
+            r2.login(getCredentials());
+            fail(parameters.toString());
+        } catch (RepositoryException e) {
+            // expected
+            assertEquals(ExceptionFactory.REPOSITORY_ALREADY_OPEN, ExceptionFactory.getErrorCode(e));
+        }
+    }
+
+}
\ No newline at end of file

Modified: jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/xa/UserTransactionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/xa/UserTransactionImpl.java?rev=961687&r1=961686&r2=961687&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/xa/UserTransactionImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-j3/src/test/java/org/apache/jackrabbit/j3/xa/UserTransactionImpl.java Thu Jul  8 10:21:34 2010
@@ -44,7 +44,7 @@ public class UserTransactionImpl impleme
     /**
      * The XAResources map
      */
-    private Map<XAResource, XidImpl> xaResources = new HashMap<XAResource, XidImpl>();
+    Map<XAResource, XidImpl> xaResources = new HashMap<XAResource, XidImpl>();
 
     private int status = Status.STATUS_NO_TRANSACTION;
 



Mime
View raw message