You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/12/13 08:30:04 UTC

[40/58] [partial] ISIS-188: renaming packages in line with groupId:artifactId

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManager.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManager.java b/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManager.java
new file mode 100644
index 0000000..43c835b
--- /dev/null
+++ b/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/data/xml/XmlDataManager.java
@@ -0,0 +1,559 @@
+/*
+ *  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.isis.objectstore.xml.internal.data.xml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Vector;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.ensure.Assert;
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.commons.xml.ContentWriter;
+import org.apache.isis.core.commons.xml.XmlFile;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
+import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.objectstore.xml.internal.data.CollectionData;
+import org.apache.isis.objectstore.xml.internal.data.Data;
+import org.apache.isis.objectstore.xml.internal.data.DataManager;
+import org.apache.isis.objectstore.xml.internal.data.ListOfRootOid;
+import org.apache.isis.objectstore.xml.internal.data.ObjectData;
+import org.apache.isis.objectstore.xml.internal.data.ObjectDataVector;
+import org.apache.isis.objectstore.xml.internal.data.PersistorException;
+import org.apache.isis.objectstore.xml.internal.version.FileVersion;
+
+public class XmlDataManager implements DataManager {
+    private final XmlFile xmlFile;
+
+    public XmlDataManager(final XmlFile xmlFile) {
+        this.xmlFile = xmlFile;
+    }
+
+    // ////////////////////////////////////////////////////////
+    // shutdown
+    // ////////////////////////////////////////////////////////
+
+    @Override
+    public void shutdown() {
+    }
+
+    // ////////////////////////////////////////////////////////
+    // SAX Handlers
+    // ////////////////////////////////////////////////////////
+
+    // TODO the following methods are being called repeatedly - is there no
+    // caching? See the print statements
+    private class DataHandler extends DefaultHandler {
+        
+        final StringBuilder data = new StringBuilder();
+        CollectionData collection;
+        String fieldName;
+        ObjectData object;
+
+        @Override
+        public void characters(final char[] ch, final int start, final int end) throws SAXException {
+            data.append(new String(ch, start, end));
+        }
+
+        @Override
+        public void endElement(final String ns, final String name, final String tagName) throws SAXException {
+            if (object != null) {
+                if (tagName.equals("value")) {
+                    final String value = data.toString();
+                    object.set(fieldName, value);
+                }
+            }
+        }
+
+        @Override
+        public void startElement(final String ns, final String name, final String tagName, final Attributes attributes) throws SAXException {
+            if (object != null) {
+                if (tagName.equals("value")) {
+                    fieldName = attributes.getValue("field");
+                    data.setLength(0);
+                } else if (tagName.equals("association")) {
+                    object.set(attributes.getValue("field"), oidFrom(attributes));
+                } else if (tagName.equals("element")) {
+                    object.addElement(fieldName, oidFrom(attributes));
+                } else if (tagName.equals("multiple-association")) {
+                    fieldName = attributes.getValue("field");
+                    object.initCollection(fieldName);
+                }
+            } else if (collection != null) {
+                if (tagName.equals("element")) {
+                    
+                    collection.addElement(oidFrom(attributes));
+                }
+            } else {
+                if (tagName.equals("isis")) {
+                    final RootOidDefault oid = oidFrom(attributes);
+                    final Version fileVersion = fileVersionFrom(attributes);
+                    
+                    object = new ObjectData(oid, fileVersion);
+                } else if (tagName.equals("collection")) {
+                    
+                    final RootOidDefault oid = oidFrom(attributes);
+                    final Version fileVersion = fileVersionFrom(attributes);
+                    
+                    collection = new CollectionData(oid, fileVersion);
+                } else {
+                    throw new SAXException("Invalid data");
+                }
+            }
+        }
+    }
+
+    private static RootOidDefault oidFrom(final Attributes attributes) {
+        final String oid = attributes.getValue("oid");
+        return RootOidDefault.deString(oid, getOidMarshaller());
+    }
+
+    private static Version fileVersionFrom(final Attributes attributes) {
+        final String user = attributes.getValue("user");
+        final long version = Long.valueOf(attributes.getValue("ver"), 16).longValue();
+        final Version fileVersion = FileVersion.create(user, version);
+        return fileVersion;
+    }
+
+
+    private class InstanceHandler extends DefaultHandler {
+        Vector<RootOid> instances = new Vector<RootOid>();
+
+        @Override
+        public void characters(final char[] arg0, final int arg1, final int arg2) throws SAXException {
+        }
+
+        @Override
+        public void startElement(final String ns, final String name, final String tagName, final Attributes attrs) throws SAXException {
+            if (tagName.equals("instance")) {
+                
+                final String oidStr = attrs.getValue("oid");
+                final RootOidDefault oid = RootOidDefault.deString(oidStr, getOidMarshaller());
+                
+                instances.addElement(oid);
+            }
+        }
+    }
+
+    private class NumberHandler extends DefaultHandler {
+        boolean captureValue = false;
+        long value = 0;
+
+        @Override
+        public void characters(final char[] arg0, final int arg1, final int arg2) throws SAXException {
+            if (captureValue) {
+                final String string = new String(arg0, arg1, arg2);
+                value = Long.valueOf(string, 16).longValue();
+            }
+        }
+
+        @Override
+        public void startElement(final String ns, final String name, final String tagName, final Attributes attrs) throws SAXException {
+            captureValue = tagName.equals("number");
+        }
+
+        public ContentWriter writer(final long nextId) {
+            return new ContentWriter() {
+                @Override
+                public void write(final Writer writer) throws IOException {
+                    writer.write("<number>");
+                    final String nextIdHex = Long.toString(nextId, 16);
+                    writer.append("" + nextIdHex);
+                    writer.append("</number>");
+                    writer.flush();
+                }
+            };
+        }
+        
+        
+    }
+
+    // ////////////////////////////////////////////////////////
+    // fixtures
+    // ////////////////////////////////////////////////////////
+
+    @Override
+    public boolean isFixturesInstalled() {
+        return xmlFile.isFixturesInstalled();
+    }
+
+    // ////////////////////////////////////////////////////////
+    // loadData
+    // ////////////////////////////////////////////////////////
+
+    @Override
+    public Data loadData(final RootOid oid) {
+        final DataHandler handler = new DataHandler();
+        xmlFile.parse(handler, filename(oid));
+
+        if (handler.object != null) {
+            return handler.object;
+        } else {
+            return handler.collection;
+        }
+    }
+
+    // ////////////////////////////////////////////////////////
+    // getInstances, numberOfInstances
+    // ////////////////////////////////////////////////////////
+
+    @Override
+    public ObjectDataVector getInstances(final ObjectData pattern) {
+        
+        final Vector<RootOid> instances = loadInstances(pattern.getSpecification(getSpecificationLoader()));
+
+        if (instances == null) {
+            return new ObjectDataVector();
+        }
+
+        final ObjectDataVector matches = new ObjectDataVector();
+        for (final RootOid oid : instances) {
+            final ObjectData instanceData = (ObjectData) loadData(oid);
+            // TODO check loader first
+            if (instanceData == null) {
+                throw new IsisException("No data found for " + oid + " (possible missing file)");
+            }
+            if (matchesPattern(pattern, instanceData)) {
+                matches.addElement(instanceData);
+            }
+        }
+        return matches;
+    }
+
+    @Override
+    public int numberOfInstances(final ObjectData pattern) {
+        return getInstances(pattern).size();
+    }
+
+    private Vector<RootOid> loadInstances(final ObjectSpecification noSpec) {
+        final InstanceHandler handler = new InstanceHandler();
+        parseSpecAndSubclasses(handler, noSpec);
+        return handler.instances;
+    }
+
+    private void parseSpecAndSubclasses(final InstanceHandler handler, final ObjectSpecification noSpec) {
+        parseIfNotAbstract(noSpec, handler);
+        for (final ObjectSpecification subSpec : noSpec.subclasses()) {
+            parseSpecAndSubclasses(handler, subSpec);
+        }
+    }
+
+    private void parseIfNotAbstract(final ObjectSpecification noSpec, final InstanceHandler handler) {
+        if (noSpec.isAbstract()) {
+            return;
+        }
+        xmlFile.parse(handler, noSpec.getFullIdentifier());
+    }
+
+    /**
+     * A helper that determines if two sets of data match. A match occurs when
+     * the types are the same and any field in the pattern also occurs in the
+     * data set under test.
+     */
+    // TODO we need to be able to find collection instances as well
+    protected boolean matchesPattern(final ObjectData patternData, final ObjectData candidateData) {
+        if (patternData == null || candidateData == null) {
+            throw new NullPointerException("Can't match on nulls " + patternData + " " + candidateData);
+        }
+
+        if (!candidateData.getSpecification(getSpecificationLoader()).isOfType(patternData.getSpecification(getSpecificationLoader()))) {
+            return false;
+        }
+
+        for (final String field : patternData.fields()) {
+            final Object patternFieldValue = patternData.get(field);
+            final Object candidateFieldValue = candidateData.get(field);
+
+            if (candidateFieldValue instanceof ListOfRootOid) {
+                final ListOfRootOid patternElements = (ListOfRootOid) patternFieldValue;
+                for (int i = 0; i < patternElements.size(); i++) {
+                    final RootOid requiredElement = patternElements.elementAt(i); // must have this element
+                    boolean requiredFound = false;
+                    final ListOfRootOid testElements = ((ListOfRootOid) candidateFieldValue);
+                    for (int j = 0; j < testElements.size(); j++) {
+                        if (requiredElement.equals(testElements.elementAt(j))) {
+                            requiredFound = true;
+                            break;
+                        }
+                    }
+                    if (!requiredFound) {
+                        return false;
+                    }
+                }
+            } else {
+                if (!patternFieldValue.equals(candidateFieldValue)) {
+                    return false;
+                }
+            }
+
+        }
+
+        return true;
+    }
+
+    /**
+     * Read in the next unique number for the object identifier.
+     */
+    protected long nextId() throws PersistorException {
+        final NumberHandler handler = new NumberHandler();
+        xmlFile.parse(handler, "oid");
+
+        final long nextId = handler.value + 1;
+        xmlFile.writeXml("oid", handler.writer(nextId));
+
+        return nextId;
+    }
+
+    // ////////////////////////////////////////////////////////
+    // insertObject, remove
+    // ////////////////////////////////////////////////////////
+
+    /**
+     * Save the data for an object and adds the reference to a list of instances
+     */
+    @Override
+    public final void insertObject(final ObjectData data) {
+        if (data.getRootOid() == null) {
+            throw new IllegalArgumentException("Oid must be non-null");
+        }
+
+        writeInstanceToItsDataFile(data);
+        final ObjectSpecification objSpec = data.getSpecification(getSpecificationLoader());
+        addReferenceToInstancesFile(data.getRootOid(), objSpec);
+    }
+
+    private void addReferenceToInstancesFile(final RootOid oid, final ObjectSpecification noSpec) {
+        final Vector<RootOid> instances = loadInstances(noSpec);
+        instances.addElement(oid);
+        writeInstanceFile(noSpec, instances);
+    }
+
+    // ////////////////////////////////////////////////////////
+    // remove
+    // ////////////////////////////////////////////////////////
+
+    @Override
+    public final void remove(final RootOid oid) throws ObjectNotFoundException, ObjectPersistenceException {
+        final Data data = loadData(oid);
+        removeReferenceFromInstancesFile(oid, data.getSpecification(getSpecificationLoader()));
+        deleteData(oid);
+    }
+
+    /**
+     * Delete the data for an existing instance.
+     */
+    private void deleteData(final RootOid oid) {
+        xmlFile.delete(filename(oid));
+    }
+
+    private void removeReferenceFromInstancesFile(final RootOid oid, final ObjectSpecification noSpec) {
+        final Vector<RootOid> instances = loadInstances(noSpec);
+        instances.removeElement(oid);
+        writeInstanceFile(noSpec, instances);
+    }
+
+    // ////////////////////////////////////////////////////////
+    // helpers (used by both add & remove)
+    // ////////////////////////////////////////////////////////
+
+    private void writeInstanceFile(final ObjectSpecification noSpec, final Vector<RootOid> instances) {
+        writeInstanceFile(noSpec.getFullIdentifier(), instances);
+    }
+
+    private void writeInstanceFile(final String name, final Vector<RootOid> instances) {
+        xmlFile.writeXml(name, new ContentWriter() {
+            @Override
+            public void write(final Writer writer) throws IOException {
+                writer.write("<instances");
+                Utils.appendAttribute(writer, "name", name);
+                writer.append(">\n");
+
+                for (final RootOid elementAt : instances) {
+                    writer.append("  <instance");
+                    Utils.appendAttribute(writer, "oid", elementAt.enString(getOidMarshaller()));
+                    writer.append("/>\n");
+                }
+                writer.append("</instances>");
+                writer.flush();
+            }
+        });
+    }
+
+    // ////////////////////////////////////////////////////////
+    // save
+    // ////////////////////////////////////////////////////////
+
+    /**
+     * Save the data for latter retrieval.
+     */
+    @Override
+    public final void save(final Data data) {
+        writeInstanceToItsDataFile(data);
+    }
+
+    private void writeInstanceToItsDataFile(final Data data) {
+        xmlFile.writeXml(filename(data.getRootOid()), new ContentWriter() {
+            @Override
+            public void write(final Writer writer) throws IOException {
+                final boolean isObject = data instanceof ObjectData;
+                final String tag = isObject ? "isis" : "collection";
+                writer.write("<");
+                writer.write(tag);
+                final RootOid oid = data.getRootOid();
+                Utils.appendAttribute(writer, "oid", oid.enString(getOidMarshaller()));
+                Utils.appendAttribute(writer, "user", "" + getAuthenticationSession().getUserName());
+
+                final long sequence = data.getVersion().getSequence();
+                final String sequenceString = Long.toHexString(sequence).toUpperCase();
+                Utils.appendAttribute(writer, "ver", "" + sequenceString);
+
+                writer.append(">\n");
+
+                if (isObject) {
+                    writeObject(data, writer);
+                } else {
+                    writeCollection(data, writer);
+                }
+
+                writer.append("</" + tag + ">\n");
+                writer.flush();
+            }
+
+        });
+    }
+
+    private void writeObject(final Data data, final Writer writer) throws IOException {
+        final ObjectData object = (ObjectData) data;
+        for (final String field : object.fields()) {
+            writeField(writer, object, field);
+        }
+    }
+
+    private void writeField(final Writer writer, final ObjectData object, final String field) throws IOException {
+        final Object entry = object.get(field);
+
+        if (entry instanceof RootOidDefault) {
+            writeAssociationField(writer, field, entry);
+        } else if (entry instanceof ListOfRootOid) {
+            writeMultipleAssociationField(writer, field, entry);
+        } else {
+            writeValueField(writer, field, entry);
+        }
+    }
+
+    private void writeAssociationField(final Writer writer, final String field, final Object entry) throws IOException {
+        final Oid rootOidDefault = (Oid)entry;
+        Assert.assertFalse(rootOidDefault.isTransient());
+        writer.append("  <association");
+        Utils.appendAttribute(writer, "field", field);
+        Utils.appendAttribute(writer, "oid", rootOidDefault.enString(getOidMarshaller()));
+        writer.append("/>\n");
+    }
+
+    private void writeMultipleAssociationField(final Writer writer, final String field, final Object entry) throws IOException {
+        final ListOfRootOid references = (ListOfRootOid) entry;
+        final int size = references.size();
+
+        if (size > 0) {
+            writer.append("  <multiple-association field=\"" + field + "\" ");
+            writer.append(">\n");
+            for (int i = 0; i < size; i++) {
+                final Object oid = references.elementAt(i);
+                final RootOidDefault rootOidDefault = (RootOidDefault) oid;
+                if (rootOidDefault.isTransient()) {
+                    throw new ObjectPersistenceException("Can't add tranisent OID (" + oid + ") to " + field + " element.");
+                }
+                writer.append("    <element ");
+                Utils.appendAttribute(writer, "oid", rootOidDefault.enString(getOidMarshaller()));
+                writer.append("/>\n");
+            }
+            writer.append("  </multiple-association>\n");
+            writer.flush();
+        }
+    }
+
+    private static void writeValueField(final Writer writer, final String field, final Object entry) throws IOException {
+        writer.append("  <value");
+        Utils.appendAttribute(writer, "field", field);
+        writer.append(">");
+        writer.append(XmlFile.getValueWithSpecialsEscaped(entry.toString()));
+        writer.append("</value>\n");
+    }
+
+    private static void writeCollection(final Data data, final Writer writer) throws IOException {
+        final CollectionData collection = (CollectionData) data;
+        final ListOfRootOid refs = collection.references();
+        for (int i = 0; i < refs.size(); i++) {
+            final Object oid = refs.elementAt(i);
+            writer.append("  <element");
+            final RootOid rootOid = (RootOid) oid;
+            Utils.appendAttribute(writer, "oid", rootOid.enString(getOidMarshaller()));
+            writer.append("/>\n");
+        }
+    }
+
+    
+    private static String filename(final RootOid oid) {
+        return oid.getObjectSpecId() + File.separator + oid.getIdentifier();
+    }
+
+
+
+    // ////////////////////////////////////////////////////////
+    // Debugging
+    // ////////////////////////////////////////////////////////
+
+    @Override
+    public String getDebugData() {
+        return "Data directory " + xmlFile.getDirectory();
+    }
+
+    
+    // ////////////////////////////////////////////////////////
+    // dependencies (from context)
+    // ////////////////////////////////////////////////////////
+
+    protected static OidMarshaller getOidMarshaller() {
+		return IsisContext.getOidMarshaller();
+	}
+
+    protected AuthenticationSession getAuthenticationSession() {
+        return IsisContext.getAuthenticationSession();
+    }
+
+    protected SpecificationLoaderSpi getSpecificationLoader() {
+        return IsisContext.getSpecificationLoader();
+    }
+
+    
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/services/ServiceManager.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/services/ServiceManager.java b/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/services/ServiceManager.java
new file mode 100644
index 0000000..e15088a
--- /dev/null
+++ b/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/services/ServiceManager.java
@@ -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.isis.objectstore.xml.internal.services;
+
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+
+public interface ServiceManager {
+
+    void loadServices();
+
+    void registerService(RootOid rootOid);
+
+    RootOid getOidForService(ObjectSpecId objectSpecId);
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/services/xml/XmlServiceManager.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/services/xml/XmlServiceManager.java b/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/services/xml/XmlServiceManager.java
new file mode 100644
index 0000000..882b959
--- /dev/null
+++ b/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/services/xml/XmlServiceManager.java
@@ -0,0 +1,152 @@
+/*
+ *  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.isis.objectstore.xml.internal.services.xml;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.apache.isis.core.commons.ensure.Assert;
+import org.apache.isis.core.commons.xml.ContentWriter;
+import org.apache.isis.core.commons.xml.XmlFile;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.objectstore.xml.internal.data.xml.Utils;
+import org.apache.isis.objectstore.xml.internal.services.ServiceManager;
+
+
+public class XmlServiceManager implements ServiceManager {
+    private static final String SERVICES_FILE_NAME = "services";
+    private List<ServiceElement> services;
+    private final XmlFile xmlFile;
+
+    public XmlServiceManager(final XmlFile xmlFile) {
+        this.xmlFile = xmlFile;
+    }
+
+    @Override
+    public RootOid getOidForService(final ObjectSpecId objectSpecId) {
+        for (final ServiceElement element: services) {
+            if (element.oid.getObjectSpecId().equals(objectSpecId)) {
+                return element.oid;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public void loadServices() {
+        final ServiceHandler handler = new ServiceHandler();
+        xmlFile.parse(handler, SERVICES_FILE_NAME);
+        services = handler.services;
+    }
+
+    @Override
+    public void registerService(final RootOid rootOid) {
+        final RootOidDefault soid = (RootOidDefault) rootOid;
+        final ServiceElement element = new ServiceElement(soid);
+        services.add(element);
+        saveServices();
+    }
+
+    public final void saveServices() {
+        xmlFile.writeXml(SERVICES_FILE_NAME, new ContentWriter() {
+            @Override
+            public void write(final Writer writer) throws IOException {
+                final String tag = SERVICES_FILE_NAME;
+                writer.append("<" + tag + ">\n");
+                for (final ServiceElement element: services) {
+                    writer.append("  <service");
+//                    Utils.appendAttribute(writer, "type", element.oid.getObjectSpecId());
+//                    Utils.appendAttribute(writer, "id", element.oid.getIdentifier());
+
+                  Utils.appendAttribute(writer, "oid", element.oid.enString(getOidMarshaller()));
+
+                    writer.append("/>\n");
+                }
+                writer.append("</" + tag + ">\n");
+            }
+        });
+    }
+    
+    
+    ////////////////////////////////////////////////////
+    // dependencies (from context)
+    ////////////////////////////////////////////////////
+    
+    protected OidMarshaller getOidMarshaller() {
+		return IsisContext.getOidMarshaller();
+	}
+}
+
+class ServiceElement {
+    final RootOid oid;
+
+    public ServiceElement(final RootOid oid) {
+        Assert.assertNotNull("oid", oid.enString(getOidMarshaller()));
+        this.oid = oid;
+    }
+
+    
+    /////////////////////////////////////////////////////
+    // dependencies (from context)
+    /////////////////////////////////////////////////////
+    
+    protected OidMarshaller getOidMarshaller() {
+		return IsisContext.getOidMarshaller();
+	}
+
+}
+
+class ServiceHandler extends DefaultHandler {
+    List<ServiceElement> services = Lists.newArrayList();
+
+    @Override
+    public void startElement(final String ns, final String name, final String tagName, final Attributes attrs) throws SAXException {
+        if (tagName.equals("service")) {
+//            final String objectType = attrs.getValue("type");
+//            final String identifier = attrs.getValue("id");
+//             final RootOid rootOid = RootOidDefault.create(objectType, identifier);
+            
+            final String oidStr = attrs.getValue("oid");
+            RootOid rootOid = getOidMarshaller().unmarshal(oidStr, RootOid.class);
+            final ServiceElement service = new ServiceElement(rootOid);
+            services.add(service);
+        }
+    }
+
+    
+    ///////////////////////////////////////////////////////
+    // dependencies (from context)
+    ///////////////////////////////////////////////////////
+    
+    protected OidMarshaller getOidMarshaller() {
+        return IsisContext.getOidMarshaller();
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/utils/CopyXmlObjectStore.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/utils/CopyXmlObjectStore.java b/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/utils/CopyXmlObjectStore.java
new file mode 100644
index 0000000..fc96669
--- /dev/null
+++ b/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/utils/CopyXmlObjectStore.java
@@ -0,0 +1,87 @@
+/*
+ *  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.isis.objectstore.xml.internal.utils;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+
+public class CopyXmlObjectStore {
+    public static void main(final String[] args) {
+        final String workingDirectory = args[0];
+        final String testDirectory = args[1];
+
+        copyAllFiles(testDirectory, workingDirectory);
+    }
+
+    private static void copyAllFiles(final String testDirectory, final String workingDirectory) {
+        final File from = new File(testDirectory);
+        final File to = new File(workingDirectory);
+
+        if (!to.exists()) {
+            to.mkdirs();
+        }
+        if (to.isFile()) {
+            throw new IsisException("To directory is actually a file " + to.getAbsolutePath());
+        }
+
+        final String list[] = from.list();
+        for (final String element : list) {
+            copyFile(new File(from, element), new File(to, element));
+        }
+    }
+
+    private static void copyFile(final File from, final File to) {
+        BufferedInputStream bis = null;
+        BufferedOutputStream bos = null;
+        try {
+            bis = new BufferedInputStream(new FileInputStream(from));
+            bos = new BufferedOutputStream(new FileOutputStream(to));
+
+            final byte buffer[] = new byte[2048];
+
+            int len = 0;
+            while ((len = bis.read(buffer)) > 0) {
+                bos.write(buffer, 0, len);
+            }
+        } catch (final IOException e) {
+            throw new IsisException("Error copying file " + from.getAbsolutePath() + " to " + to.getAbsolutePath(), e);
+        } finally {
+            if (bis != null) {
+                try {
+                    bis.close();
+                } catch (final IOException ignore) {
+                }
+            }
+            if (bos != null) {
+                try {
+                    bos.close();
+                } catch (final IOException ignore) {
+                }
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/version/FileVersion.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/version/FileVersion.java b/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/version/FileVersion.java
new file mode 100644
index 0000000..c1c5489
--- /dev/null
+++ b/component/objectstore/xml/src/main/java/org/apache/isis/objectstore/xml/internal/version/FileVersion.java
@@ -0,0 +1,40 @@
+/*
+ *  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.isis.objectstore.xml.internal.version;
+
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.objectstore.xml.internal.clock.Clock;
+
+public class FileVersion {
+    
+    private static Clock clock;
+    public static void setClock(final Clock clock) {
+        FileVersion.clock = clock;
+    }
+
+    public static Version create(String user) {
+        return create(user, clock.getTime());
+    }
+    
+    public static Version create(final String user, final long time) {
+        return Version.create(time, user, time);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStore.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStore.java b/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStore.java
deleted file mode 100644
index 4b83acd..0000000
--- a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStore.java
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- *  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.isis.runtimes.dflt.objectstores.xml;
-
-import java.text.MessageFormat;
-import java.util.List;
-
-import com.google.common.collect.Lists;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.config.ConfigurationConstants;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.ensure.Assert;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.commons.xml.XmlFile;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.ResolveState;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
-import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock.Clock;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.commands.XmlCreateObjectCommand;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.commands.XmlDestroyObjectCommand;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.commands.XmlUpdateObjectCommand;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.CollectionData;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.Data;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.DataManager;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.ListOfRootOid;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.ObjectData;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.ObjectDataVector;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.xml.XmlDataManager;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.xml.Utils;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.services.ServiceManager;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.services.xml.XmlServiceManager;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectNotFoundException;
-import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectPersistenceException;
-import org.apache.isis.runtimes.dflt.runtime.persistence.PersistorUtil;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStoreSpi;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.SaveObjectCommand;
-import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryBuiltIn;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManagerSpi;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceQuery;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
-
-public class XmlObjectStore implements ObjectStoreSpi {
-
-    private static final Logger LOG = Logger.getLogger(XmlObjectStore.class);
-    private static final String XMLOS_DIR = ConfigurationConstants.ROOT + "xmlos.dir";
-    private final DataManager dataManager;
-    private final ServiceManager serviceManager;
-    private boolean isFixturesInstalled;
-
-    public XmlObjectStore(final IsisConfiguration configuration) {
-        final String charset = Utils.lookupCharset(configuration);
-        final String directory = configuration.getString(XMLOS_DIR, "xml/objects");
-        final XmlFile xmlFile = new XmlFile(charset, directory);
-        dataManager = new XmlDataManager(xmlFile);
-        serviceManager = new XmlServiceManager(xmlFile);
-        serviceManager.loadServices();
-    }
-
-    public XmlObjectStore(final DataManager dataManager, final ServiceManager serviceManager) {
-        this.dataManager = dataManager;
-        this.serviceManager = serviceManager;
-        serviceManager.loadServices();
-    }
-
-    // /////////////////////////////////////////////////////////
-    // name
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public String name() {
-        return "XML";
-    }
-
-    // /////////////////////////////////////////////////////////
-    // close
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public void close() {
-        LOG.info("close " + this);
-    }
-
-    // /////////////////////////////////////////////////////////
-    // reset
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public void reset() {
-    }
-
-    // /////////////////////////////////////////////////////////
-    // init, shutdown, finalize
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public boolean hasInstances(final ObjectSpecification cls) {
-        LOG.debug("checking instance of " + cls);
-        final ObjectData data = new ObjectData(RootOidDefault.create(cls.getSpecId(), "---dummy-value-never-used---"), null);
-        return dataManager.numberOfInstances(data) > 0;
-    }
-
-    @Override
-    public void open() throws ObjectPersistenceException {
-        isFixturesInstalled = dataManager.isFixturesInstalled();
-    }
-
-    @Override
-    public boolean isFixturesInstalled() {
-        return isFixturesInstalled;
-    }
-
-    private void initObject(final ObjectAdapter adapter, final ObjectData data) {
-        if (!adapter.canTransitionToResolving()) {
-            return;
-        } 
-        try {
-            PersistorUtil.startResolving(adapter);
-            final List<ObjectAssociation> fields = adapter.getSpecification().getAssociations();
-            for (int i = 0; i < fields.size(); i++) {
-                final ObjectAssociation field = fields.get(i);
-                if (field.isNotPersisted()) {
-                    continue;
-                }
-
-                final ObjectSpecification fieldSpecification = field.getSpecification();
-                if (fieldSpecification.isEncodeable()) {
-                    final EncodableFacet encoder = fieldSpecification.getFacet(EncodableFacet.class);
-                    ObjectAdapter value;
-                    final String valueData = data.value(field.getId());
-                    if (valueData != null) {
-                        if (valueData.equals("NULL")) {
-                            value = null;
-                        } else {
-                            value = encoder.fromEncodedString(valueData);
-                        }
-                        ((OneToOneAssociation) field).initAssociation(adapter, value);
-                    }
-                } else if (field.isOneToManyAssociation()) {
-                    initObjectSetupCollection(adapter, data, field);
-                } else if (field.isOneToOneAssociation()) {
-                    initObjectSetupReference(adapter, data, field);
-                }
-            }
-            adapter.setVersion(data.getVersion());
-        } finally {
-            PersistorUtil.toEndState(adapter);
-        }
-    }
-
-    private void initObjectSetupReference(final ObjectAdapter object, final ObjectData data, final ObjectAssociation field) {
-    	
-        final RootOid referencedOid = (RootOidDefault) data.get(field.getId());
-        if(LOG.isDebugEnabled()) {
-            LOG.debug("setting up field " + field + " with " + referencedOid);
-        }
-        if (referencedOid == null) {
-            return;
-        }
-
-        final Data fieldData = dataManager.loadData(referencedOid);
-
-        final ObjectAdapter referencedAdapter = getAdapterManager().adapterFor(referencedOid);
-        if (fieldData == null) {
-            if (!referencedAdapter.isDestroyed()) {
-                referencedAdapter.changeState(ResolveState.DESTROYED);
-            }
-            LOG.warn("No data found for " + referencedOid + " so field '" + field.getName() + "' not set in object '" + object.titleString() + "'");
-        }
-        ((OneToOneAssociation) field).initAssociation(object, referencedAdapter);
-
-        // REVIEW: what was this commented out code for?
-        /*
-         * if (loadedObjects().isLoaded(referenceOid)) { ObjectAdapter
-         * loadedObject = loadedObjects().getLoadedObject(referenceOid);
-         * LOG.debug("using loaded object " + loadedObject);
-         * object.initAssociation((OneToOneAssociation) field, loadedObject); }
-         * else { ObjectAdapter fieldObject; Data fieldData = (Data)
-         * dataManager.loadData((SerialOid) referenceOid);
-         * 
-         * if (fieldData != null) { fieldObject = (ObjectAdapter)
-         * specFor(fieldData).acquireInstance(); } else { fieldObject =
-         * (ObjectAdapter) field.getSpecification().acquireInstance(); }
-         * 
-         * fieldObject.setOid(referenceOid);
-         * 
-         * if (fieldObject instanceof CollectionAdapter) {
-         * fieldObject.setResolved(); }
-         * 
-         * loadedObjects().loaded(fieldObject);
-         * object.initAssociation((OneToOneAssociation) field, fieldObject); }
-         */
-    }
-
-    private void initObjectSetupCollection(final ObjectAdapter objectAdapter, final ObjectData data, final ObjectAssociation field) {
-        /*
-         * The internal collection is already a part of the object, and
-         * therefore cannot be recreated, but its oid must be set
-         */
-        final ListOfRootOid refs = (ListOfRootOid) data.get(field.getId());
-        
-        final ObjectAdapter collectionAdapter = field.get(objectAdapter);
-        if (!collectionAdapter.canTransitionToResolving()) {
-            return;
-        } 
-        
-        try {
-            PersistorUtil.startResolving(collectionAdapter);
-            final int size = refs == null ? 0 : refs.size();
-            final ObjectAdapter[] elements = new ObjectAdapter[size];
-            for (int j = 0; j < size; j++) {
-                final RootOid elementOid = refs.elementAt(j);
-                ObjectAdapter adapter;
-                adapter = getAdapterManager().getAdapterFor(elementOid);
-                if (adapter == null) {
-                    adapter = loadInstanceAndAdapt(elementOid);
-                }
-                elements[j] = adapter;
-            }
-            final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collectionAdapter);
-            facet.init(collectionAdapter, elements);
-        } finally {
-            PersistorUtil.toEndState(collectionAdapter);
-        }
-    }
-
-    // /////////////////////////////////////////////////////////
-    // Transaction Management
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public void startTransaction() {
-        LOG.debug("start transaction");
-    }
-
-    @Override
-    public void endTransaction() {
-        LOG.debug("end transaction");
-    }
-
-    @Override
-    public void abortTransaction() {
-        LOG.debug("transaction aborted");
-    }
-
-    // /////////////////////////////////////////////////////////
-    // createXxxCommands
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public CreateObjectCommand createCreateObjectCommand(final ObjectAdapter object) {
-        return new XmlCreateObjectCommand(object, dataManager);
-    }
-
-    @Override
-    public SaveObjectCommand createSaveObjectCommand(final ObjectAdapter object) {
-        return new XmlUpdateObjectCommand(object, dataManager);
-    }
-
-    @Override
-    public DestroyObjectCommand createDestroyObjectCommand(final ObjectAdapter object) {
-        return new XmlDestroyObjectCommand(object, dataManager);
-    }
-
-    // /////////////////////////////////////////////////////////
-    // execute, flush
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public void execute(final List<PersistenceCommand> commands) {
-        LOG.debug("start execution of transaction");
-        for (final PersistenceCommand command : commands) {
-            command.execute(null);
-        }
-        LOG.debug("end execution");
-    }
-
-    // /////////////////////////////////////////////////////////
-    // getObject, resolveImmediately, resolveField
-    // /////////////////////////////////////////////////////////
-
-
-    @Override
-    public ObjectAdapter loadInstanceAndAdapt(final TypedOid oid) {
-        LOG.debug("getObject " + oid);
-        final Data data = dataManager.loadData((RootOidDefault) oid);
-        LOG.debug("  data read " + data);
-
-        ObjectAdapter object;
-
-        if (data instanceof ObjectData) {
-            object = recreateAdapter((ObjectData) data);
-        } else if (data instanceof CollectionData) {
-            throw new IsisException();
-        } else {
-            throw new ObjectNotFoundException(oid);
-        }
-        return object;
-    }
-
-    @Override
-    public void resolveField(final ObjectAdapter object, final ObjectAssociation field) {
-        final ObjectAdapter reference = field.get(object);
-        resolveImmediately(reference);
-    }
-
-    @Override
-    public void resolveImmediately(final ObjectAdapter object) {
-        final ObjectData data = (ObjectData) dataManager.loadData((RootOidDefault) object.getOid());
-        Assert.assertNotNull("Not able to read in data during resolve", object, data);
-        initObject(object, data);
-    }
-
-    /*
-     * The ObjectData holds all references for internal collections, so the
-     * object should haves its internal collection populated by this method.
-     */
-    private ObjectAdapter recreateAdapter(final ObjectData data) {
-        final RootOid oid = data.getRootOid();
-        final ObjectAdapter adapter = getAdapterManager().adapterFor(oid);
-        initObject(adapter, data);
-        return adapter;
-    }
-
-    // /////////////////////////////////////////////////////////
-    // getInstances, allInstances
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public List<ObjectAdapter> loadInstancesAndAdapt(final PersistenceQuery persistenceQuery) {
-
-        if (!(persistenceQuery instanceof PersistenceQueryBuiltIn)) {
-            throw new IllegalArgumentException(MessageFormat.format("Provided PersistenceQuery not supported; was {0}; " + "the XML object store only supports {1}", persistenceQuery.getClass().getName(), PersistenceQueryBuiltIn.class.getName()));
-        }
-        final PersistenceQueryBuiltIn builtIn = (PersistenceQueryBuiltIn) persistenceQuery;
-
-        final ObjectSpecification objSpec = builtIn.getSpecification();
-        LOG.debug("getInstances of " + objSpec + " where " + builtIn);
-        final RootOid oid = RootOidDefault.create(objSpec.getSpecId(), "dummy");
-        final ObjectData patternData = new ObjectData(oid, null);
-        return getInstances(patternData, builtIn);
-    }
-
-    private List<ObjectAdapter> getInstances(final ObjectData patternData, final PersistenceQueryBuiltIn persistenceQuery) {
-        final ObjectDataVector data = dataManager.getInstances(patternData);
-        final List<ObjectAdapter> instances = Lists.newArrayList();
-        
-        for (int i = 0; i < data.size(); i++) {
-            final ObjectData instanceData = data.element(i);
-            if(LOG.isDebugEnabled()) {
-                LOG.debug("instance data " + instanceData);
-            }
-
-            final RootOid oid = instanceData.getRootOid();
-
-            final ObjectAdapter adapter = getAdapterManager().adapterFor(oid);
-            if(LOG.isDebugEnabled()) {
-                LOG.debug("recreated instance " + adapter);
-            }
-            initObject(adapter, instanceData);
-
-            if (persistenceQuery == null || persistenceQuery.matches(adapter)) {
-                instances.add(adapter);
-            }
-        }
-        return instances;
-    }
-
-    // /////////////////////////////////////////////////////////
-    // services
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public RootOid getOidForService(ObjectSpecification serviceSpec) {
-        return serviceManager.getOidForService(serviceSpec.getSpecId());
-    }
-
-    @Override
-    public void registerService(final RootOid rootOid) {
-        serviceManager.registerService(rootOid);
-    }
-
-    // /////////////////////////////////////////////////////////
-    // debugging
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public void debugData(final DebugBuilder debug) {
-        debug.appendTitle("Business Objects");
-        debug.appendln(dataManager.getDebugData());
-    }
-
-    @Override
-    public String debugTitle() {
-        return "XML Object Store";
-    }
-
-    // /////////////////////////////////////////////////////////
-    // Dependencies (injected)
-    // /////////////////////////////////////////////////////////
-
-    /**
-     * Set the clock used to generate sequence numbers and last changed dates
-     * for version objects.
-     */
-    public void setClock(final Clock clock) {
-        FileVersion.setClock(clock);
-    }
-
-    // /////////////////////////////////////////////////////////
-    // Dependencies (from singleton)
-    // /////////////////////////////////////////////////////////
-
-    protected SpecificationLoaderSpi getSpecificationLookup() {
-        return IsisContext.getSpecificationLoader();
-    }
-
-    private AdapterManager getAdapterManager() {
-        return getPersistenceSession().getAdapterManager();
-    }
-
-    protected PersistenceSession getPersistenceSession() {
-        return IsisContext.getPersistenceSession();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstaller.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstaller.java b/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstaller.java
deleted file mode 100644
index 7588c1e..0000000
--- a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstaller.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- *  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.isis.runtimes.dflt.objectstores.xml;
-
-import java.util.Date;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapterFactory;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.clock.DefaultClock;
-import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.PersistenceMechanismInstallerAbstract;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStoreSpi;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManagerSpi;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.IdentifierGenerator;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.IdentifierGeneratorDefault;
-
-public class XmlPersistenceMechanismInstaller extends PersistenceMechanismInstallerAbstract {
-
-    public static final String NAME = "xml";
-    
-    private XmlObjectStore objectStore;
-
-    public XmlPersistenceMechanismInstaller() {
-        super(NAME);
-    }
-
-    @Override
-    protected ObjectStoreSpi createObjectStore(final IsisConfiguration configuration, final ObjectAdapterFactory objectFactory, final AdapterManagerSpi adapterManager) {
-        if (objectStore == null) {
-            objectStore = new XmlObjectStore(configuration);
-            objectStore.setClock(new DefaultClock());
-        }
-        return objectStore;
-    }
-
-    @Override
-    public IdentifierGenerator createIdentifierGenerator(final IsisConfiguration configuration) {
-        final long currentTime = new Date().getTime();
-        return new IdentifierGeneratorDefault(currentTime);
-    }
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/Clock.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/Clock.java b/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/Clock.java
deleted file mode 100644
index e8588a0..0000000
--- a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/Clock.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *  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.isis.runtimes.dflt.objectstores.xml.internal.clock;
-
-public interface Clock {
-
-    long getTime();
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClock.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClock.java b/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClock.java
deleted file mode 100644
index eb64670..0000000
--- a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClock.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *  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.isis.runtimes.dflt.objectstores.xml.internal.clock;
-
-public class DefaultClock implements Clock {
-    @Override
-    public long getTime() {
-        return System.currentTimeMillis();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/AbstractXmlPersistenceCommand.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/AbstractXmlPersistenceCommand.java b/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/AbstractXmlPersistenceCommand.java
deleted file mode 100644
index 096d52d..0000000
--- a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/AbstractXmlPersistenceCommand.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- *  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.isis.runtimes.dflt.objectstores.xml.internal.commands;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.DataManager;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.ObjectData;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandAbstract;
-
-abstract class AbstractXmlPersistenceCommand extends PersistenceCommandAbstract {
-    private static final Logger LOG = Logger.getLogger(AbstractXmlPersistenceCommand.class);
-
-    private final DataManager dataManager;
-
-    public AbstractXmlPersistenceCommand(final ObjectAdapter adapter, final DataManager dataManager) {
-        super(adapter);
-        this.dataManager = dataManager;
-    }
-
-    protected DataManager getDataManager() {
-        return dataManager;
-    }
-
-    protected ObjectData createObjectData(final ObjectAdapter adapter, final boolean ensurePersistent) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("compiling object data for " + adapter);
-        }
-
-        final ObjectSpecification adapterSpec = adapter.getSpecification();
-        final ObjectData data = new ObjectData((RootOidDefault) adapter.getOid(), adapter.getVersion());
-
-        final List<ObjectAssociation> associations = adapterSpec.getAssociations();
-        for (final ObjectAssociation association : associations) {
-            if (association.isNotPersisted()) {
-                continue;
-            }
-
-            final ObjectAdapter associatedObject = association.get(adapter);
-            final boolean isEmpty = association.isEmpty(adapter);
-            final String associationId = association.getId();
-
-            if (association.isOneToManyAssociation()) {
-                saveCollection(associationId, data, associatedObject, ensurePersistent);
-            } else if (association.getSpecification().isEncodeable()) {
-                saveEncoded(data, associationId, associatedObject, isEmpty);
-            } else if (association.isOneToOneAssociation()) {
-                saveReference(data, associationId, associatedObject, ensurePersistent);
-            }
-        }
-
-        return data;
-    }
-
-    private void saveReference(final ObjectData data, final String associationId, final ObjectAdapter associatedObject, final boolean ensurePersistent) {
-        data.addAssociation(associatedObject, associationId, ensurePersistent);
-    }
-
-    private void saveCollection(final String associationId, final ObjectData data, final ObjectAdapter associatedObject, final boolean ensurePersistent) {
-        data.addInternalCollection(associatedObject, associationId, ensurePersistent);
-    }
-
-    private void saveEncoded(final ObjectData data, final String associationId, final ObjectAdapter associatedObject, final boolean isEmpty) {
-        if (associatedObject == null || isEmpty) {
-            data.saveValue(associationId, isEmpty, null);
-        } else {
-            final EncodableFacet facet = associatedObject.getSpecification().getFacet(EncodableFacet.class);
-            final String encodedValue = facet.toEncodedString(associatedObject);
-            data.saveValue(associationId, isEmpty, encodedValue);
-        }
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlCreateObjectCommand.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlCreateObjectCommand.java b/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlCreateObjectCommand.java
deleted file mode 100644
index 62baebe..0000000
--- a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlCreateObjectCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *  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.isis.runtimes.dflt.objectstores.xml.internal.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.DataManager;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.ObjectData;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectPersistenceException;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
-
-public final class XmlCreateObjectCommand extends AbstractXmlPersistenceCommand implements CreateObjectCommand {
-    private static final Logger LOG = Logger.getLogger(XmlCreateObjectCommand.class);
-
-    public XmlCreateObjectCommand(final ObjectAdapter adapter, final DataManager dataManager) {
-        super(adapter, dataManager);
-    }
-
-    @Override
-    public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("  create object " + onAdapter());
-        }
-        final String user = getAuthenticationSession().getUserName();
-        onAdapter().setVersion(FileVersion.create(user));
-        final ObjectData data = createObjectData(onAdapter(), true);
-        getDataManager().insertObject(data);
-    }
-
-    @Override
-    public String toString() {
-        return "CreateObjectCommand [object=" + onAdapter() + "]";
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlDestroyObjectCommand.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlDestroyObjectCommand.java b/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlDestroyObjectCommand.java
deleted file mode 100644
index 2462fd5..0000000
--- a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlDestroyObjectCommand.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *  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.isis.runtimes.dflt.objectstores.xml.internal.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.DataManager;
-import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectPersistenceException;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
-
-public final class XmlDestroyObjectCommand extends AbstractXmlPersistenceCommand implements DestroyObjectCommand {
-    private static final Logger LOG = Logger.getLogger(XmlDestroyObjectCommand.class);
-
-    public XmlDestroyObjectCommand(final ObjectAdapter adapter, final DataManager dataManager) {
-        super(adapter, dataManager);
-    }
-
-    @Override
-    public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("  destroy object " + onAdapter());
-        }
-        final RootOidDefault oid = (RootOidDefault) onAdapter().getOid();
-        getDataManager().remove(oid);
-        onAdapter().setVersion(null);
-    }
-
-    @Override
-    public String toString() {
-        return "DestroyObjectCommand [object=" + onAdapter() + "]";
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlUpdateObjectCommand.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlUpdateObjectCommand.java b/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlUpdateObjectCommand.java
deleted file mode 100644
index 509af95..0000000
--- a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlUpdateObjectCommand.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- *  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.isis.runtimes.dflt.objectstores.xml.internal.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.Data;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.data.DataManager;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectPersistenceException;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.SaveObjectCommand;
-
-public final class XmlUpdateObjectCommand extends AbstractXmlPersistenceCommand implements SaveObjectCommand {
-
-    private static final Logger LOG = Logger.getLogger(XmlUpdateObjectCommand.class);
-
-    public XmlUpdateObjectCommand(final ObjectAdapter adapter, final DataManager dataManager) {
-        super(adapter, dataManager);
-    }
-
-    @Override
-    public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("  save object " + onAdapter());
-        }
-        final String user = getAuthenticationSession().getUserName();
-        onAdapter().setVersion(FileVersion.create(user));
-
-        final Data data = createObjectData(onAdapter(), true);
-        getDataManager().save(data);
-    }
-
-    @Override
-    public String toString() {
-        return "SaveObjectCommand [object=" + onAdapter() + "]";
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/CollectionData.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/CollectionData.java b/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/CollectionData.java
deleted file mode 100644
index 9814c9b..0000000
--- a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/CollectionData.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *  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.isis.runtimes.dflt.objectstores.xml.internal.data;
-
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-
-/**
- * A logical collection of elements of a specified type
- */
-public class CollectionData extends Data {
-    private final ListOfRootOid elements = new ListOfRootOid();
-
-    public CollectionData(final RootOid oid, final Version version) {
-        super(oid, version);
-    }
-
-    public void addElement(final RootOid elementOid) {
-        elements.add(elementOid);
-    }
-
-    public void removeElement(final RootOid elementOid) {
-        elements.remove(elementOid);
-    }
-
-    public ListOfRootOid references() {
-        return elements;
-    }
-
-    @Override
-    public String toString() {
-        return "CollectionData[type=" + getObjectSpecId() + ",elements=" + elements + "]";
-    }
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Data.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Data.java b/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Data.java
deleted file mode 100644
index 778f840..0000000
--- a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Data.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *  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.isis.runtimes.dflt.objectstores.xml.internal.data;
-
-import com.google.common.base.Objects;
-
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-import org.apache.isis.runtimes.dflt.objectstores.xml.internal.version.FileVersion;
-
-public abstract class Data {
-    
-    private final RootOid oid;
-    private final Version version;
-
-    Data(final RootOid oid, final Version version) {
-        this.oid = oid;
-        this.version = version;
-    }
-
-    public RootOid getRootOid() {
-        return oid;
-    }
-
-    public Version getVersion() {
-        return version;
-    }
-
-    public ObjectSpecification getSpecification(SpecificationLoader specificationLookup) {
-        final ObjectSpecId objectSpecId = oid.getObjectSpecId();
-        return specificationLookup.lookupBySpecId(objectSpecId);
-    }
-
-    public ObjectSpecId getObjectSpecId() {
-        return getRootOid().getObjectSpecId();
-    }
-
-    @Override
-    public boolean equals(final Object obj) {
-        if (obj == this) {
-            return true;
-        }
-
-        if (obj instanceof Data) {
-            final Data data = (Data) obj;
-            return Objects.equal(data.getObjectSpecId(), getObjectSpecId()) && Objects.equal(data.oid, oid);
-        }
-
-        return false;
-    }
-
-    @Override
-    public int hashCode() {
-        int h = 17;
-        h = 37 * h + getObjectSpecId().hashCode();
-        h = 37 * h + oid.hashCode();
-        return h;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/DataManager.java
----------------------------------------------------------------------
diff --git a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/DataManager.java b/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/DataManager.java
deleted file mode 100644
index c14f44b..0000000
--- a/component/objectstore/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/DataManager.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- *  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.isis.runtimes.dflt.objectstores.xml.internal.data;
-
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectNotFoundException;
-import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectPersistenceException;
-
-public interface DataManager {
-
-    void shutdown();
-
-    /**
-     * Return data for all instances that match the pattern.
-     */
-    public ObjectDataVector getInstances(final ObjectData pattern);
-
-    /**
-     * Return the number of instances that match the specified data
-     */
-    public int numberOfInstances(final ObjectData pattern);
-
-    public Data loadData(final RootOid oid);
-
-    /**
-     * Save the data for an object and adds the reference to a list of instances
-     */
-    void insertObject(ObjectData data);
-
-    void remove(RootOid oid) throws ObjectNotFoundException, ObjectPersistenceException;
-
-    /**
-     * Save the data for latter retrieval.
-     */
-    void save(Data data);
-
-    String getDebugData();
-
-    boolean isFixturesInstalled();
-}