You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by st...@apache.org on 2011/04/08 17:45:11 UTC

svn commit: r1090303 - in /jackrabbit/sandbox/microkernel: ./ src/main/java/org/apache/jackrabbit/mk/ src/main/java/org/apache/jackrabbit/mk/api/ src/main/java/org/apache/jackrabbit/mk/store/ src/main/java/org/apache/jackrabbit/mk/store/git/ src/main/j...

Author: stefan
Date: Fri Apr  8 15:45:10 2011
New Revision: 1090303

URL: http://svn.apache.org/viewvc?rev=1090303&view=rev
Log:
MicroKernel prototype (WIP)

Added:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
      - copied, changed from r1085319, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernel.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernelException.java
      - copied, changed from r1080594, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelException.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Blob.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Commit.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Constants.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/DataStore.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNode.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNodePart.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Node.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeTree.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/ObjectStore.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/StoredObject.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/GitStore.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/MicroKernelRepository.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/ObjectDb.java
    jackrabbit/sandbox/microkernel/src/main/java/org/eclipse/
    jackrabbit/sandbox/microkernel/src/main/java/org/eclipse/jgit/
    jackrabbit/sandbox/microkernel/src/main/java/org/eclipse/jgit/storage/
    jackrabbit/sandbox/microkernel/src/main/java/org/eclipse/jgit/storage/file/
    jackrabbit/sandbox/microkernel/src/main/java/org/eclipse/jgit/storage/file/ObjectDbInserter.java
Removed:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernel.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelException.java
Modified:
    jackrabbit/sandbox/microkernel/pom.xml

Modified: jackrabbit/sandbox/microkernel/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/pom.xml?rev=1090303&r1=1090302&r2=1090303&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/pom.xml (original)
+++ jackrabbit/sandbox/microkernel/pom.xml Fri Apr  8 15:45:10 2011
@@ -21,24 +21,37 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                              http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
+    <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.apache.jackrabbit</groupId>
-  <artifactId>microkernel</artifactId>
-  <version>0.1-SNAPSHOT</version>
-  <name>MicroKernel</name>
-  <description>Hierarchical MVCC-based persistence store</description>
-
-  <dependencies>
-
-    <!--Test Dependencies-->
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.5</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
+    <groupId>org.apache.jackrabbit</groupId>
+    <artifactId>microkernel</artifactId>
+    <version>0.1-SNAPSHOT</version>
+    <name>MicroKernel</name>
+    <description>Hierarchical MVCC-based persistence store</description>
+
+    <repositories>
+        <repository>
+        <id>jgit-repository</id>
+        <url>http://download.eclipse.org/jgit/maven</url>
+        </repository>
+    </repositories>
+
+    <dependencies>
+        <!-- core jgit library -->
+        <dependency>
+            <groupId>org.eclipse.jgit</groupId>
+            <artifactId>org.eclipse.jgit</artifactId>
+            <version>0.10.1</version>
+        </dependency>
+
+        <!--Test Dependencies-->
+        <dependency>
+           <groupId>junit</groupId>
+           <artifactId>junit</artifactId>
+           <version>4.5</version>
+           <scope>test</scope>
+         </dependency>
+    </dependencies>
 
   <build>
     <plugins>

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,155 @@
+package org.apache.jackrabbit.mk;
+
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.api.MicroKernelException;
+
+import java.io.InputStream;
+
+/**
+ *
+ */
+public class MicroKernelImpl implements MicroKernel {
+
+    protected Repository rep;
+
+    public MicroKernelImpl(String homeDir) throws MicroKernelException {
+        init(homeDir);
+    }
+
+    protected void init(String homeDir) throws MicroKernelException {
+        rep = new Repository(homeDir);
+        try {
+            rep.init();
+        } catch (Exception e) {
+            throw new MicroKernelException(e);
+        }
+    }
+
+    public void dispose() {
+        if (rep != null) {
+            try {
+                rep.shutDown();
+            } catch (Exception ignore) {
+                // fail silently
+            }
+            rep = null;
+        }
+    }
+
+    public String getHeadRevision() throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        try {
+            return rep.getHeadRevision();
+        } catch (Exception e) {
+            throw new MicroKernelException(e);
+        }
+    }
+
+    public String getRevisions(long since, int maxEntries) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        // todo implement
+
+        return null;
+    }
+
+    public String getJournal(String fromRevisionId, String toRevisionId) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        // todo implement
+
+        return null;
+    }
+
+    public boolean nodeExists(String idOrPath, String revisionId) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        try {
+            rep.getNode(idOrPath, revisionId);
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    public String getNodes(String idOrPath, int depth, String revisionId) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        // todo implement
+
+        return null;
+    }
+
+    public String getChildNodes(String idOrPath, long offset, long count, int depth, String revisionId) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        // todo implement
+
+        return null;
+    }
+
+    public long getChildNodeCount(String idOrPath, String revisionId) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        try {
+            return rep.getNode(idOrPath, revisionId).getChildNodeEntries().size();
+        } catch (Exception e) {
+            throw new MicroKernelException(e);
+        }
+    }
+
+    public String commit(String idOrPath, String jsonDiff, String revisionId) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        // todo implement
+
+        return null;
+    }
+
+    public long getLength(String blobId) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        // todo implement
+
+        return 0;
+    }
+
+    public int read(String blobId, byte[] buf, int off, int length) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        // todo implement
+
+        return 0;
+    }
+
+    public String write(InputStream in) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        // todo implement
+
+        return null;
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,96 @@
+/*
+ * 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.mk;
+
+import org.apache.jackrabbit.mk.store.Commit;
+import org.apache.jackrabbit.mk.store.Node;
+import org.apache.jackrabbit.mk.store.ObjectStore;
+import java.io.File;
+
+/**
+ *
+ */
+public class Repository {
+
+    final String homeDir;
+    boolean initialized;
+
+    final ObjectStore store;
+
+    public Repository(String homeDir) {
+        this.homeDir = homeDir == null ? "." : homeDir;
+        store = new ObjectStore();
+        initialized = false;
+    }
+
+    public void init() throws Exception {
+        if (initialized) {
+            return;
+        }
+
+        store.initialize(new File(homeDir));
+
+        initialized = true;
+    }
+
+    public void shutDown() throws Exception {
+        if (! initialized) {
+            return;
+        }
+
+        store.close();
+
+        initialized = false;
+    }
+
+    public Node getNode(String revId, String path) throws Exception {
+        if (! initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+
+        String[] ids = resolvePath(revId, path);
+        return store.getNode(ids[ids.length - 1]);
+    }
+
+    public String getHeadRevision() throws Exception {
+        if (! initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+        return store.getHeadCommit().getId();
+    }
+
+    String[] /* array of node id's */ resolvePath(String revId, String path) throws Exception {
+        if (path == null || path.length() == 0 || path.charAt(0) != '/') {
+            throw new IllegalArgumentException("illegal path");
+        }
+
+        Commit commit = store.getCommit(revId);
+
+        String[] names = path.split("/");
+        String[] ids = new String[names.length + 1];
+
+        // get root node
+        ids[0] = commit.getRootNodeId();
+        Node parent = store.getNode(ids[0]);
+        // traverse path and store id of each element
+        for (int i = 1; i <= names.length; i++) {
+            ids[i] = parent.getChildNodeEntries().get(names[i]);
+            parent = store.getNode(ids[i]);
+        }
+        return ids;
+    }
+}

Copied: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java (from r1085319, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernel.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java?p2=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java&p1=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernel.java&r1=1085319&r2=1090303&rev=1090303&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernel.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java Fri Apr  8 15:45:10 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mk;
+package org.apache.jackrabbit.mk.api;
 
 import java.io.InputStream;
 
@@ -98,8 +98,9 @@ public interface MicroKernel {
      * Return the id of the current head revision.
      *
      * @return id of head revision
+     * @throws MicroKernelException if an error occurs
      */
-    String getHeadRevision();
+    String getHeadRevision() throws MicroKernelException;
 
     /**
      * Returns a chronological list of all revisions since a specific point
@@ -251,7 +252,7 @@ public interface MicroKernel {
     /**
      * Returns the number of child nodes of the specified parent node.
      *
-     * @todo if we represent the number as child nodes as a special property on the parent(":childNodeCount") there's probably no need for specific api method (TBD)
+     * @todo if we represent the number of child nodes as a special property on the parent (":childNodeCount") there's probably no need for a specific api method (TBD)
      *
      * @param idOrPath identifier or path denoting parent node
      * @param revisionId revision

Copied: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernelException.java (from r1080594, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelException.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernelException.java?p2=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernelException.java&p1=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelException.java&r1=1080594&r2=1090303&rev=1090303&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelException.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/api/MicroKernelException.java Fri Apr  8 15:45:10 2011
@@ -14,10 +14,26 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mk;
+package org.apache.jackrabbit.mk.api;
 
 /**
  * Exception thrown by methods of the <code>MicroKernel</code> API
  */
 public class MicroKernelException extends Exception {
+
+    public MicroKernelException() {
+        super();
+    }
+
+    public MicroKernelException(String message) {
+        super(message);
+    }
+
+    public MicroKernelException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public MicroKernelException(Throwable cause) {
+        super(cause);
+    }
 }

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Blob.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Blob.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Blob.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Blob.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,27 @@
+/*
+ * 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.mk.store;
+
+/**
+ * Immutable BLOB ...
+ */
+public class Blob extends StoredObject {
+
+     public Blob(String id) {
+        super(id);
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Commit.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Commit.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Commit.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Commit.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,44 @@
+/*
+ * 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.mk.store;
+
+/**
+ * Immutable Commit object...
+ */
+public class Commit extends StoredObject {
+
+    // id's of parent commits
+    final String[] parentIds;
+
+    // id of root node associated with this commit
+    final String rootNodeId;
+
+    public Commit(String id, String rootNodeId, String[] parentIds) {
+        super(id);
+
+        this.rootNodeId = rootNodeId;
+        this.parentIds = parentIds;
+    }
+
+    public String getRootNodeId() {
+        return rootNodeId;
+    }
+
+    public String[] getParentIds() {
+        return parentIds;
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Constants.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Constants.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Constants.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Constants.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,33 @@
+/*
+ * 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.mk.store;
+
+/**
+ *
+ */
+public interface Constants {
+
+    static String[] TYPE_NAMES = { "node", "nodetree", "fatnode", "fatnodepart", "commit", "blob" };
+
+    static int ANY = -1;
+    static int NODE = 0;
+    static int NODE_TREE = 1;
+    static int FAT_NODE = 2;
+    static int FAT_NODE_PART = 3;
+    static int COMMIT = 4;
+    static int BLOB = 5;
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/DataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/DataStore.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/DataStore.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/DataStore.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,28 @@
+/*
+ * 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.mk.store;
+
+/**
+ * <code>DataStore</code> represents a simple, <i>content-addressable</i>
+ * data store.
+ */
+public interface DataStore {
+
+    byte[] get(String id, int typeHint) throws Exception;
+
+    String /* id */ put(int type, byte[] data) throws Exception;
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNode.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNode.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNode.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.mk.store;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Immutable 'Fat Node' object...
+ */
+public class FatNode extends Node {
+
+    final String nextPartId; // refers to next FatNodePart
+
+    public FatNode(String id,
+                   Map<String, String> properties,
+                   List<ChildNodeEntry> children,
+                   String nextPartId) {
+        super(id, properties, children);
+
+        this.nextPartId = nextPartId;
+    }
+
+    public String getNextPartId() {
+        return nextPartId;
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNodePart.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNodePart.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNodePart.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNodePart.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,42 @@
+/*
+ * 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.mk.store;
+
+import org.eclipse.jgit.lib.AnyObjectId;
+import org.eclipse.jgit.lib.ObjectId;
+
+import java.util.List;
+
+/**
+ * Immutable 'Fat Node Part' object...
+ */
+public class FatNodePart extends StoredObject {
+
+    final ObjectId nextPartId;
+
+    public FatNodePart(String id,
+                       List<Node.ChildNodeEntry> children,
+                       ObjectId nextPartId) {
+        super(id);
+
+        this.nextPartId = nextPartId;
+    }
+
+    public ObjectId getNextPartId() {
+        return nextPartId;
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Node.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Node.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Node.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Node.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,77 @@
+/*
+ * 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.mk.store;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Immutable Node object...
+ */
+public class Node extends StoredObject {
+
+    final Map<String, String> properties;
+    final LinkedHashMap<String, String> childEntries;
+
+    public Node(String id,
+                Map<String, String> properties,
+                List<ChildNodeEntry> children) {
+        super(id);
+        this.properties = new HashMap<String, String>();
+        this.properties.putAll(properties);
+        childEntries = new LinkedHashMap<String, String>(children.size());
+        for (ChildNodeEntry cne : children) {
+            childEntries.put(cne.getName(), cne.getId());
+        }
+    }
+
+    public Map<String, String> getProperties() {
+        return Collections.unmodifiableMap(properties);
+    }
+
+    /**
+     * Returns a map of names and id's which keeps insertion order.
+     *
+     * @return
+     */
+    public Map<String, String> getChildNodeEntries() {
+        return Collections.unmodifiableMap(childEntries);
+    }
+
+    //--------------------------------------------------------< inner classes >
+    public static class ChildNodeEntry {
+
+        final String name;
+        final String id;
+
+        public ChildNodeEntry(String name, String id) {
+            this.name = name;
+            this.id = id;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public String getId() {
+            return id;
+        }
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeTree.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeTree.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeTree.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,45 @@
+/*
+ * 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.mk.store;
+
+/**
+ * Immutable 'Node Tree' object...
+ */
+public class NodeTree extends StoredObject {
+
+    public NodeTree(String id) {
+        super(id);
+    }
+
+    //--------------------------------------------------------< inner classes >
+
+    public static interface ChildNodeEntryTarget {
+    }
+
+    public static class EmbeddedNode implements ChildNodeEntryTarget {
+
+    }
+
+    public static class NodeId implements ChildNodeEntryTarget {
+
+        final String targetId;
+
+        protected NodeId(String targetId) {
+            this.targetId = targetId;
+        }
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/ObjectStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/ObjectStore.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/ObjectStore.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/ObjectStore.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,73 @@
+/*
+ * 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.mk.store;
+
+import org.apache.jackrabbit.mk.store.git.GitStore;
+
+import java.io.File;
+
+/**
+ *
+ */
+public class ObjectStore implements Constants {
+
+    boolean initialized;
+    GitStore store;
+
+    public ObjectStore() {
+        initialized = false;
+    }
+
+    public void initialize(File homeDir) throws Exception {
+        if (initialized) {
+            throw new IllegalStateException("already initialized");
+        }
+
+        store = new GitStore();
+        store.initialize(homeDir);
+
+        initialized = true;
+    }
+
+    public void close() {
+        if (!initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+        store.close();
+        store = null;
+        initialized = false;
+    }
+
+    public Node getNode(String id) throws Exception {
+        byte[] data = store.get(id, NODE);
+        // todo deserialize Node object
+        Node node = null;
+        return node;
+    }
+
+    public Commit getCommit(String id) throws Exception {
+        byte[] data = store.get(id, COMMIT);
+        // todo deserialize Commit object
+        Commit commit = null;
+        return commit;
+    }
+
+    public Commit getHeadCommit() throws Exception {
+        return getCommit(store.getHeadCommitId());
+    }
+
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/StoredObject.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/StoredObject.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/StoredObject.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/StoredObject.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,34 @@
+/*
+ * 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.mk.store;
+
+
+/**
+ *
+ */
+public abstract class StoredObject {
+
+    final String id;
+
+    protected StoredObject(String id) {
+        this.id = id;
+    }
+
+    public String getId() {
+        return id;
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/GitStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/GitStore.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/GitStore.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/GitStore.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,108 @@
+/*
+ * 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.mk.store.git;
+
+import org.apache.jackrabbit.mk.store.Constants;
+import org.apache.jackrabbit.mk.store.DataStore;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.ObjectInserter;
+import org.eclipse.jgit.lib.RefUpdate;
+
+import java.io.File;
+
+/**
+ *
+ */
+public class GitStore implements DataStore, Constants {
+
+    MicroKernelRepository rep;
+    boolean initialized;
+
+    public GitStore() {
+        initialized = false;
+    }
+
+    public void initialize(File homeDir) throws Exception {
+        if (initialized) {
+            throw new IllegalStateException("already initialized");
+        }
+
+        File dir = new File(homeDir, ".git");
+        rep = new MicroKernelRepository(dir);
+        if (! dir.exists()) {
+            rep.create(true);
+        }
+
+        initialized = true;
+    }
+
+    public void close() {
+        if (!initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+        rep.close();
+        rep = null;
+        initialized = false;
+    }
+
+    public String getHeadCommitId() throws Exception {
+        if (!initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+        return rep.getRefDatabase().getRef("HEAD").getObjectId().name();
+    }
+
+    public void setHeadCommitId(String commitId) throws Exception {
+        if (!initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+        RefUpdate refUpd = rep.getRefDatabase().newUpdate("HEAD", false);
+        refUpd.setNewObjectId(ObjectId.fromString(commitId));
+        RefUpdate.Result result = refUpd.update();
+    }
+
+    //------------------------------------------------------------< DataStore >
+    public byte[] get(String id) throws Exception {
+        return get(id, ANY);
+    }
+
+    public byte[] get(String id, int typeHint) throws Exception {
+        if (!initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+        return rep.getObjectDb().newReader().open(ObjectId.fromString(id), typeHint).getBytes();
+    }
+
+    public String put(int type, byte[] data) throws Exception {
+        if (!initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+        if (type < 0 || type >= TYPE_NAMES.length) {
+            throw new IllegalArgumentException("invalid type");
+        }
+        ObjectInserter inserter = rep.getObjectDb().newInserter();
+        ObjectId id;
+        try {
+            id = inserter.insert(type, data);
+            inserter.flush();
+        } finally {
+            inserter.release();
+        }
+
+        return id.name();
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/MicroKernelRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/MicroKernelRepository.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/MicroKernelRepository.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/MicroKernelRepository.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,56 @@
+/*
+ * 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.mk.store.git;
+
+import org.eclipse.jgit.lib.BaseRepositoryBuilder;
+import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ *
+ */
+public class MicroKernelRepository extends FileRepository {
+
+    ObjectDb db;
+
+    public MicroKernelRepository(File gitDir) throws IOException {
+        this(new FileRepositoryBuilder().setGitDir(gitDir).setup());
+    }
+
+    public MicroKernelRepository(BaseRepositoryBuilder options) throws IOException {
+        super(options);
+
+        db = new ObjectDb(getConfig(),
+                options.getObjectDirectory(),
+		options.getAlternateObjectDirectories(),
+		getFS());
+    }
+
+    @Override
+    public void create(boolean bare) throws IOException {
+        super.create(bare);
+        db.create();
+    }
+
+    public ObjectDb getObjectDb() {
+        return db;
+    }
+
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/ObjectDb.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/ObjectDb.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/ObjectDb.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/git/ObjectDb.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,55 @@
+/*
+ * 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.mk.store.git;
+
+import org.eclipse.jgit.lib.Config;
+import org.eclipse.jgit.storage.file.ObjectDirectory;
+import org.eclipse.jgit.storage.file.ObjectDbInserter;
+import org.eclipse.jgit.util.FS;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ *
+ */
+public class ObjectDb extends ObjectDirectory {
+
+    Config cfg;
+
+    /**
+     * Initialize a reference to an on-disk object directory.
+     *
+     * @param cfg            configuration this directory consults for write settings.
+     * @param dir            the location of the <code>objects</code> directory.
+     * @param alternatePaths a list of alternate object directories
+     * @param fs             the file system abstraction which will be necessary to perform
+     *                       certain file system operations.
+     * @throws java.io.IOException an alternate object cannot be opened.
+     */
+    public ObjectDb(Config cfg, File dir, File[] alternatePaths, FS fs) throws IOException {
+        super(cfg, dir, alternatePaths, fs);
+        this.cfg = cfg;
+    }
+
+    @Override
+    public ObjectDbInserter newInserter() {
+        return new ObjectDbInserter(this, cfg);
+    }
+
+
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/eclipse/jgit/storage/file/ObjectDbInserter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/eclipse/jgit/storage/file/ObjectDbInserter.java?rev=1090303&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/eclipse/jgit/storage/file/ObjectDbInserter.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/eclipse/jgit/storage/file/ObjectDbInserter.java Fri Apr  8 15:45:10 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.eclipse.jgit.storage.file;
+
+import org.apache.jackrabbit.mk.store.Constants;
+import org.eclipse.jgit.lib.Config;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ *
+ */
+public class ObjectDbInserter extends ObjectDirectoryInserter {
+
+    public ObjectDbInserter(FileObjectDatabase dest, Config cfg) {
+        super(dest, cfg);
+    }
+
+    @Override
+    void writeHeader(OutputStream out, int type, long len) throws IOException {
+        out.write(Constants.TYPE_NAMES[type].getBytes());
+        out.write((byte) ' ');
+        out.write(Long.toString(len).getBytes());
+        out.write((byte) 0);
+    }
+}