isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject [15/51] [partial] ISIS-188: moving components into correct directories.
Date Thu, 06 Dec 2012 11:09:55 GMT
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/PersistenceQueryProcessor.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/PersistenceQueryProcessor.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/PersistenceQueryProcessor.java
new file mode 100644
index 0000000..7e1c768
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/PersistenceQueryProcessor.java
@@ -0,0 +1,30 @@
+/*
+ *  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.jdo.datanucleus.persistence.queries;
+
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceQuery;
+
+public interface PersistenceQueryProcessor<T extends PersistenceQuery> {
+	List<ObjectAdapter> process(T query);
+}
+
+// Copyright (c) Naked Objects Group Ltd.

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
new file mode 100644
index 0000000..db4cd46
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
@@ -0,0 +1,107 @@
+/*
+ *  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.jdo.datanucleus.persistence.queries;
+
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.listener.InstanceLifecycleEvent;
+import javax.jdo.metadata.TypeMetadata;
+import javax.jdo.spi.PersistenceCapable;
+
+import com.google.common.collect.Lists;
+
+import org.apache.isis.core.commons.ensure.Assert;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.DataNucleusObjectStore;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.FrameworkSynchronizer;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.FrameworkSynchronizer.CalledFrom;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.IsisLifecycleListener;
+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.Persistor;
+
+public abstract class PersistenceQueryProcessorAbstract<T extends PersistenceQuery>
+        implements PersistenceQueryProcessor<T> {
+
+    private final PersistenceManager persistenceManager;
+    private final FrameworkSynchronizer frameworkSynchronizer;
+
+    protected PersistenceQueryProcessorAbstract(final PersistenceManager persistenceManager, final FrameworkSynchronizer frameworkSynchronizer) {
+        this.persistenceManager = persistenceManager;
+        this.frameworkSynchronizer = frameworkSynchronizer;
+    }
+
+    protected PersistenceManager getPersistenceManager() {
+        return persistenceManager;
+    }
+    
+    
+    // /////////////////////////////////////////////////////////////
+    // helpers for subclasses
+    // /////////////////////////////////////////////////////////////
+
+    protected PersistenceManagerFactory getPersistenceManagerFactory() {
+        return getPersistenceManager().getPersistenceManagerFactory();
+    }
+    
+    protected TypeMetadata getTypeMetadata(final String classFullName) {
+        return getPersistenceManagerFactory().getMetadata(classFullName);
+    }
+    
+    /**
+     * Traversing the provided list causes (or should cause) the
+     * {@link IsisLifecycleListener#postLoad(InstanceLifecycleEvent) {
+     * to be called.
+     */
+    protected List<ObjectAdapter> loadAdapters(
+            final ObjectSpecification specification, final List<?> pojos) {
+        final List<ObjectAdapter> adapters = Lists.newArrayList();
+        for (final Object pojo : pojos) {
+        	// ought not to be necessary, however for some queries it seems that the 
+        	// lifecycle listener is not called
+        	frameworkSynchronizer.postLoadProcessingFor((PersistenceCapable) pojo, CalledFrom.OS_QUERY);
+            ObjectAdapter adapter = getAdapterManager().getAdapterFor(pojo);
+            Assert.assertNotNull(adapter);
+            adapters.add(adapter);
+        }
+        return adapters;
+    }
+
+    // /////////////////////////////////////////////////////////////
+    // Dependencies (from context)
+    // /////////////////////////////////////////////////////////////
+
+    protected Persistor getPersistenceSession() {
+        return IsisContext.getPersistenceSession();
+    }
+
+    protected AdapterManager getAdapterManager() {
+        return IsisContext.getPersistenceSession().getAdapterManager();
+    }
+
+    protected DataNucleusObjectStore getJdoObjectStore() {
+        return (DataNucleusObjectStore) IsisContext.getPersistenceSession().getObjectStore();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/QueryUtil.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/QueryUtil.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/QueryUtil.java
new file mode 100644
index 0000000..e27f95a
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/queries/QueryUtil.java
@@ -0,0 +1,89 @@
+/*
+ *  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.jdo.datanucleus.persistence.queries;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public final class QueryUtil {
+
+    private static final Logger LOG = Logger.getLogger(QueryUtil.class);
+
+    private QueryUtil() {}
+
+    public static Query createQuery(
+            final PersistenceManager persistenceManager,
+            final String alias,
+            final String select,
+            final ObjectSpecification specification,
+            final String whereClause) {
+
+        final StringBuilder buf = new StringBuilder(128);
+        appendSelect(buf, select, alias);
+        appendFrom(buf, specification, alias);
+        appendWhere(buf, whereClause);
+
+        final String queryString = buf.toString();
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("creating query: " + queryString);
+        }
+
+        return persistenceManager.newQuery(queryString);
+    }
+
+    private static StringBuilder appendSelect(
+            final StringBuilder buf,
+            final String select, 
+            String alias) {
+        if (select != null) {
+            buf.append(select);
+        } else {
+            buf.append("select ");
+            // not required in JDOQL (cf JPA QL)
+            // buf.append(alias);
+        }
+        buf.append(" ");
+        return buf;
+    }
+
+    private static void appendWhere(StringBuilder buf, String whereClause) {
+        if(whereClause == null) {
+            return;
+        }
+        buf.append(" where ").append(whereClause);
+    }
+
+
+    private static StringBuilder appendFrom(
+            final StringBuilder buf,
+            final ObjectSpecification specification,
+            final String alias) {
+        return buf.append("from ")
+                .append(specification.getFullIdentifier())
+                .append(" as ")
+                .append(alias);
+    }
+}
+
+
+// Copyright (c) Naked Objects Group Ltd.

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java
new file mode 100644
index 0000000..eb2b4d5
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java
@@ -0,0 +1,106 @@
+/*
+ *  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.jdo.datanucleus.persistence.spi;
+
+import java.util.UUID;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.spi.PersistenceCapable;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.DataNucleusObjectStore;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.IdentifierGenerator;
+
+public class DataNucleusIdentifierGenerator implements IdentifierGenerator {
+
+    @SuppressWarnings("unused")
+    private static final Logger LOG = Logger.getLogger(DataNucleusIdentifierGenerator.class);
+    
+
+
+    // //////////////////////////////////////////////////////////////
+    // main api
+    // //////////////////////////////////////////////////////////////
+
+    @Override
+    public String createTransientIdentifierFor(ObjectSpecId objectSpecId, Object pojo) {
+        return UUID.randomUUID().toString();
+    }
+
+
+    @Override
+    public String createAggregateLocalId(ObjectSpecId objectSpecId, Object pojo, ObjectAdapter parentAdapter) {
+        return UUID.randomUUID().toString();
+    }
+
+
+    @Override
+    public String createPersistentIdentifierFor(ObjectSpecId objectSpecId, Object pojo, RootOid transientRootOid) {
+        
+        // hack to deal with services
+        if(!(pojo instanceof PersistenceCapable)) {
+            return "1";
+        }
+        
+        final Object jdoOid = getJdoPersistenceManager().getObjectId(pojo);
+        
+        return JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+    }
+
+
+
+    // //////////////////////////////////////////////////////////////
+    // Debugging
+    // //////////////////////////////////////////////////////////////
+
+
+    public String debugTitle() {
+        return "DataNucleus Identifier Generator";
+    }
+
+    
+    @Override
+    public void debugData(DebugBuilder debug) {
+        
+    }
+
+    
+    // //////////////////////////////////////////////////////////////
+    // Dependencies (from context)
+    // //////////////////////////////////////////////////////////////
+
+
+    protected PersistenceManager getJdoPersistenceManager() {
+        final DataNucleusObjectStore objectStore = getDataNucleusObjectStore();
+        return objectStore.getPersistenceManager();
+    }
+
+
+    protected DataNucleusObjectStore getDataNucleusObjectStore() {
+        return (DataNucleusObjectStore) IsisContext.getPersistenceSession().getObjectStore();
+    }
+
+}
+// Copyright (c) Naked Objects Group Ltd.

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java
new file mode 100644
index 0000000..eb2fd53
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java
@@ -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.isis.runtimes.dflt.objectstores.jdo.datanucleus.persistence.spi;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.lang.ToString;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackUtils;
+import org.apache.isis.core.metamodel.facets.object.callbacks.PersistingCallbackFacet;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.PersistAlgorithmAbstract;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.ToPersistObjectSet;
+
+
+/**
+ * A {@link PersistAlgorithm} which simply saves the object made persistent.
+ */
+public class DataNucleusSimplePersistAlgorithm extends PersistAlgorithmAbstract {
+    
+    private static final Logger LOG = Logger
+            .getLogger(DataNucleusSimplePersistAlgorithm.class);
+
+
+    // ////////////////////////////////////////////////////////////////
+    // name
+    // ////////////////////////////////////////////////////////////////
+
+    public String name() {
+        return "SimplePersistAlgorithm";
+    }
+
+
+    // ////////////////////////////////////////////////////////////////
+    // makePersistent
+    // ////////////////////////////////////////////////////////////////
+
+    public void makePersistent(final ObjectAdapter adapter,
+            final ToPersistObjectSet toPersistObjectSet) {
+        if (alreadyPersistedOrNotPersistable(adapter)) {
+            return;
+        }
+        if (LOG.isInfoEnabled()) {
+            LOG.info("persist " + adapter);
+        }
+        CallbackUtils.callCallback(adapter, PersistingCallbackFacet.class);
+        toPersistObjectSet.addCreateObjectCommand(adapter);
+    }
+
+
+    // ////////////////////////////////////////////////////////////////
+    // toString
+    // ////////////////////////////////////////////////////////////////
+
+    @Override
+    public String toString() {
+        final ToString toString = new ToString(this);
+        return toString.toString();
+    }
+}
+// Copyright (c) Naked Objects Group Ltd.

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransaction.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransaction.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransaction.java
new file mode 100644
index 0000000..fa0a3ae
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransaction.java
@@ -0,0 +1,92 @@
+/*
+ *  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.jdo.datanucleus.persistence.spi;
+
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.isis.applib.clock.Clock;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.applib.AuditService;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.auditable.AuditableFacet;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.TransactionalResource;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.MessageBroker;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.UpdateNotifier;
+
+public class DataNucleusTransaction extends IsisTransaction {
+
+    private final AuditService auditService;
+    
+    public DataNucleusTransaction(
+                final IsisTransactionManager transactionManager, 
+                final MessageBroker messageBroker, 
+                final UpdateNotifier updateNotifier, 
+                final TransactionalResource objectStore, 
+                final AuditService auditService) {
+        super(transactionManager, messageBroker, updateNotifier, objectStore);
+        this.auditService = auditService;
+    }
+
+    @Override
+    protected void doAudit(final Set<Entry<AdapterAndProperty, PreAndPostValues>> auditEntries) {
+        if(auditService == null) {
+            super.doAudit(auditEntries);
+            return;
+        }
+        final String currentUser = getAuthenticationSession().getUserName();
+        final long currentTimestampEpoch = currentTimestampEpoch();
+        for (Entry<AdapterAndProperty, PreAndPostValues> auditEntry : auditEntries) {
+            audit(currentUser, currentTimestampEpoch, auditEntry);
+        }
+    }
+
+    private long currentTimestampEpoch() {
+        return Clock.getTime();
+    }
+
+    private void audit(final String currentUser, final long currentTimestampEpoch, final Entry<AdapterAndProperty, PreAndPostValues> auditEntry) {
+        final AdapterAndProperty aap = auditEntry.getKey();
+        final ObjectAdapter adapter = aap.getAdapter();
+        if(!adapter.getSpecification().containsFacet(AuditableFacet.class)) {
+            return;
+        }
+        final RootOid oid = (RootOid) adapter.getOid();
+        final String objectType = oid.getObjectSpecId().asString();
+        final String identifier = oid.getIdentifier();
+        final PreAndPostValues papv = auditEntry.getValue();
+        final String preValue = asString(papv.getPre());
+        final String postValue = asString(papv.getPost());
+        auditService.audit(currentUser, currentTimestampEpoch, objectType, identifier, preValue, postValue);
+    }
+
+    private static String asString(Object object) {
+        return object != null? object.toString(): null;
+    }
+
+
+    protected AuthenticationSession getAuthenticationSession() {
+        return IsisContext.getAuthenticationSession();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransactionManager.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransactionManager.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransactionManager.java
new file mode 100644
index 0000000..ca81a8e
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/DataNucleusTransactionManager.java
@@ -0,0 +1,46 @@
+/*
+ *  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.jdo.datanucleus.persistence.spi;
+
+import org.apache.isis.runtimes.dflt.objectstores.jdo.applib.AuditService;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.TransactionalResource;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.EnlistedObjectDirtying;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.MessageBroker;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.UpdateNotifier;
+
+public class DataNucleusTransactionManager extends IsisTransactionManager {
+    
+    private final AuditService auditService;
+
+    public DataNucleusTransactionManager(
+            final EnlistedObjectDirtying objectPersistor, 
+            final TransactionalResource objectStore, 
+            final AuditService auditService) {
+        super(objectPersistor, objectStore);
+        this.auditService = auditService;
+    }
+    
+    @Override
+    protected IsisTransaction createTransaction(final MessageBroker messageBroker, final UpdateNotifier updateNotifier) {
+        return new DataNucleusTransaction(this, messageBroker, updateNotifier, getTransactionalResource(), auditService);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java
new file mode 100644
index 0000000..b27e63d
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializer.java
@@ -0,0 +1,150 @@
+/*
+ *  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.jdo.datanucleus.persistence.spi;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.jdo.identity.IntIdentity;
+import javax.jdo.identity.LongIdentity;
+import javax.jdo.identity.StringIdentity;
+
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.datanucleus.identity.OID;
+
+public final class JdoObjectIdSerializer {
+    
+    private static final char SEPARATOR = '_';
+
+    private JdoObjectIdSerializer(){}
+
+    public static class Exception extends RuntimeException {
+        private static final long serialVersionUID = 1L;
+
+        public Exception(java.lang.Exception ex) {
+            super(ex);
+        }
+    }
+
+    public static String toOidIdentifier(Object jdoOid) {
+        if(jdoOid instanceof javax.jdo.identity.IntIdentity) {
+            return "i" + SEPARATOR + jdoOid; 
+        }
+        if(jdoOid instanceof javax.jdo.identity.StringIdentity) {
+            return "s" + SEPARATOR + jdoOid; 
+        }
+        if(jdoOid instanceof javax.jdo.identity.LongIdentity) {
+            return "l" + SEPARATOR + jdoOid; 
+        }
+        if(jdoOid instanceof OID) {
+            OID dnOid = (OID) jdoOid;
+            Object keyValue = dnOid.getKeyValue();
+            
+            // prettier handling of these common cases
+            if(keyValue instanceof String) {
+                return "S" + SEPARATOR + keyValue; 
+            }
+
+            if(keyValue instanceof Long) {
+                return "L" + SEPARATOR + keyValue; 
+            }
+
+            if(keyValue instanceof BigInteger) {
+                return "B" + SEPARATOR + keyValue; 
+            }
+
+            if(keyValue instanceof Integer) {
+                return "I" + SEPARATOR + keyValue; 
+            }
+
+        }
+        
+        // the JDO spec (5.4.3) requires that OIDs are serializable toString and 
+        // recreatable through the constructor
+        return jdoOid.getClass().getName().toString() + SEPARATOR + jdoOid.toString();
+    }
+
+    private static List<String> dnPrefixes = Arrays.asList("S", "I", "L", "B");
+    
+    public static Object toJdoObjectId(RootOid oid) {
+    	String idStr = oid.getIdentifier();
+        final int colonIdx = idStr.indexOf(SEPARATOR);
+        final String keyStr = idStr.substring(colonIdx+1);
+        
+        final String firstPart = idStr.substring(0, colonIdx);
+
+        if("s".equals(firstPart)) {
+        	return new StringIdentity(objectTypeClassFor(oid), keyStr);
+        }
+
+        if("i".equals(firstPart)) {
+        	return new IntIdentity(objectTypeClassFor(oid), keyStr);
+        }
+
+        if("l".equals(firstPart)) {
+        	return new LongIdentity(objectTypeClassFor(oid), keyStr);
+        }
+
+        if(dnPrefixes.contains(firstPart)) {
+            ObjectSpecId objectSpecId = oid.getObjectSpecId();
+            ObjectSpecification spec = getSpecificationLoader().lookupBySpecId(objectSpecId);
+			return keyStr + "[OID]" + spec.getFullIdentifier(); 
+        }
+        
+        final String clsName = firstPart;
+        try {
+            final Class<?> cls = Thread.currentThread().getContextClassLoader().loadClass(clsName);
+            final Constructor<?> cons = cls.getConstructor(String.class);
+            final Object dnOid = cons.newInstance(keyStr);
+            return dnOid.toString();
+        } catch (ClassNotFoundException e) {
+            throw new JdoObjectIdSerializer.Exception(e);
+        } catch (IllegalArgumentException e) {
+            throw new JdoObjectIdSerializer.Exception(e);
+        } catch (InstantiationException e) {
+            throw new JdoObjectIdSerializer.Exception(e);
+        } catch (IllegalAccessException e) {
+            throw new JdoObjectIdSerializer.Exception(e);
+        } catch (InvocationTargetException e) {
+            throw new JdoObjectIdSerializer.Exception(e);
+        } catch (SecurityException e) {
+            throw new JdoObjectIdSerializer.Exception(e);
+        } catch (NoSuchMethodException e) {
+            throw new JdoObjectIdSerializer.Exception(e);
+        }
+    }
+
+	private static Class<?> objectTypeClassFor(RootOid oid) {
+		final ObjectSpecId objectSpecId = oid.getObjectSpecId();
+		final ObjectSpecification spec = getSpecificationLoader().lookupBySpecId(objectSpecId);
+		final Class<?> correspondingClass = spec.getCorrespondingClass();
+		return correspondingClass;
+	}
+
+	private static SpecificationLoaderSpi getSpecificationLoader() {
+		return IsisContext.getSpecificationLoader();
+	}
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/ResolveStateUtil.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/ResolveStateUtil.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/ResolveStateUtil.java
new file mode 100644
index 0000000..47e0329
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/ResolveStateUtil.java
@@ -0,0 +1,122 @@
+/*
+ *  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.jdo.datanucleus.persistence.spi;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+
+public final class ResolveStateUtil {
+
+    private ResolveStateUtil() {}
+
+
+    public static void moveToResolving(final ObjectAdapter adapter) {
+
+        moveUpToResolving(adapter);
+    }
+
+    public static void markAsResolved(final ObjectAdapter adapter) {
+
+        moveUpToResolving(adapter);
+
+        // move to ResolveState.RESOLVED;
+
+        if (adapter.isResolving()) { 
+            adapter.changeState(ResolveState.RESOLVED);
+
+        } else if (adapter.isResolved()) {
+            // nothing to do.
+
+//        } else if (adapter.getResolveState().isPartlyResolved()) {
+//            adapter.changeState(ResolveState.RESOLVED);
+
+        } else if (adapter.isUpdating()) {
+            adapter.changeState(ResolveState.RESOLVED);
+        }
+    }
+
+
+    private static void moveUpToResolving(final ObjectAdapter adapter) {
+        // move these on so we can get to part_resolved or resolved.
+        if (adapter.isTransient()) {
+            adapter.changeState(ResolveState.RESOLVED);
+            adapter.changeState(ResolveState.GHOST);
+            adapter.changeState(ResolveState.RESOLVING);
+
+        } else if (adapter.isNew()) {
+            adapter.changeState(ResolveState.GHOST);
+            adapter.changeState(ResolveState.RESOLVING);
+
+        } else if (adapter.isGhost()) {
+            adapter.changeState(ResolveState.RESOLVING);
+        }
+    }
+
+    public static void markAsGhost(final ObjectAdapter adapter) {
+
+        if (adapter.isValue()) {
+            // TODO: what should we do here? throw exception?
+        }
+        if (adapter.isDestroyed()) {
+            // TODO: what should we do here? throw exception?
+        }
+
+        if (adapter.isTransient()) {
+            adapter.changeState(ResolveState.RESOLVED);
+            adapter.changeState(ResolveState.GHOST);
+
+        } else if (adapter.isNew()) {
+            adapter.changeState(ResolveState.GHOST);
+
+//        } else if (adapter.getResolveState().isPartlyResolved()) {
+//            adapter.changeState(ResolveState.RESOLVING);
+//            adapter.changeState(ResolveState.RESOLVED);
+//            adapter.changeState(ResolveState.GHOST);
+
+        } else if (adapter.isResolving()) {
+            adapter.changeState(ResolveState.RESOLVED);
+            adapter.changeState(ResolveState.GHOST);
+
+        } else if (adapter.isUpdating()) {
+            adapter.changeState(ResolveState.RESOLVED);
+            adapter.changeState(ResolveState.GHOST);
+
+        } else if (adapter.isResolved()) {
+            adapter.changeState(ResolveState.GHOST);
+
+        } else if (adapter.isGhost()) {
+            // nothing to do.
+        }
+    }
+
+
+    public static void markAsUpdating(final ObjectAdapter adapter) {
+
+        if (adapter.isTransient()) {
+            adapter.changeState(ResolveState.RESOLVED);
+        }
+        if (adapter.isResolved()) {
+            adapter.changeState(ResolveState.UPDATING);
+        }
+    }
+
+}
+
+
+// Copyright (c) Naked Objects Group Ltd.

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobConverter.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobConverter.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobConverter.java
new file mode 100644
index 0000000..aadd5fc
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobConverter.java
@@ -0,0 +1,27 @@
+package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.value.Blob;
+import org.apache.isis.core.progmodel.facets.value.blobs.BlobValueSemanticsProvider;
+import org.datanucleus.store.types.converters.TypeConverter;
+
+public class IsisBlobConverter implements TypeConverter<Blob, String>{
+
+    private static final long serialVersionUID = 1L;
+    private EncoderDecoder<Blob> encoderDecoder;
+
+    public IsisBlobConverter() {
+        encoderDecoder = new BlobValueSemanticsProvider().getEncoderDecoder();
+    }
+    
+    @Override
+    public String toDatastoreType(Blob memberValue) {
+        return encoderDecoder.toEncodedString(memberValue);
+    }
+
+    @Override
+    public Blob toMemberType(String datastoreValue) {
+        return encoderDecoder.fromEncodedString(datastoreValue);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobMapping.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobMapping.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobMapping.java
new file mode 100644
index 0000000..02d50ee
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisBlobMapping.java
@@ -0,0 +1,88 @@
+package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
+
+import org.apache.isis.applib.value.Blob;
+import org.datanucleus.ClassLoaderResolver;
+import org.datanucleus.ClassNameConstants;
+import org.datanucleus.NucleusContext;
+import org.datanucleus.metadata.AbstractMemberMetaData;
+import org.datanucleus.store.ExecutionContext;
+import org.datanucleus.store.mapped.DatastoreContainerObject;
+import org.datanucleus.store.mapped.MappedStoreManager;
+import org.datanucleus.store.mapped.mapping.SingleFieldMultiMapping;
+
+public class IsisBlobMapping extends SingleFieldMultiMapping {
+
+    public IsisBlobMapping() {
+    }
+    
+    @Override
+    public Class<?> getJavaType() {
+        return org.apache.isis.applib.value.Blob.class;
+    }
+
+    public void initialize(AbstractMemberMetaData mmd, DatastoreContainerObject container, ClassLoaderResolver clr)
+    {
+        super.initialize(mmd, container, clr);
+        addDatastoreFields();
+    }
+
+    public void initialize(MappedStoreManager storeMgr, String type)
+    {
+        super.initialize(storeMgr, type);
+        addDatastoreFields();
+    }
+
+    protected void addDatastoreFields()
+    {
+        addDatastoreField(ClassNameConstants.JAVA_LANG_STRING); // name
+        addDatastoreField(ClassNameConstants.JAVA_LANG_STRING); // mime type
+        addDatastoreField(ClassNameConstants.JAVA_LANG_BYTE_ARRAY); // bytes
+    }
+
+    public Object getValueForDatastoreMapping(NucleusContext nucleusCtx, int index, Object value)
+    {
+        Blob blob = ((Blob)value);
+        switch (index) {
+            case 0: return blob.getName();
+            case 1: return blob.getMimeType().getBaseType();
+            case 2: return blob.getBytes();
+        }
+        throw new IndexOutOfBoundsException();
+    }
+
+    public void setObject(ExecutionContext ec, Object preparedStmt, int[] exprIndex, Object value)
+    {
+        Blob blob = ((Blob)value);
+        if (blob == null) {
+            getDatastoreMapping(0).setObject(preparedStmt, exprIndex[0], null);
+            getDatastoreMapping(1).setObject(preparedStmt, exprIndex[1], null);
+            getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], null);
+        } else {
+            getDatastoreMapping(0).setString(preparedStmt, exprIndex[0], blob.getName());
+            getDatastoreMapping(1).setString(preparedStmt, exprIndex[1], blob.getMimeType().getBaseType());
+            getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], blob.getBytes());
+        }
+    }
+    
+    public Object getObject(ExecutionContext ec, Object resultSet, int[] exprIndex)
+    {
+        try
+        {
+            // Check for null entries
+            if (getDatastoreMapping(0).getObject(resultSet, exprIndex[0]) == null)
+            {
+                return null;
+            }
+        }
+        catch (Exception e)
+        {
+            // Do nothing
+        }
+
+        String name = getDatastoreMapping(0).getString(resultSet, exprIndex[0]); 
+        String mimeTypeBase = getDatastoreMapping(1).getString(resultSet, exprIndex[1]); 
+        byte[] bytes = (byte[]) getDatastoreMapping(2).getObject(resultSet,exprIndex[2]); 
+        return new Blob(name, mimeTypeBase, bytes);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobConverter.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobConverter.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobConverter.java
new file mode 100644
index 0000000..024b619
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobConverter.java
@@ -0,0 +1,27 @@
+package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.value.Clob;
+import org.apache.isis.core.progmodel.facets.value.clobs.ClobValueSemanticsProvider;
+import org.datanucleus.store.types.converters.TypeConverter;
+
+public class IsisClobConverter implements TypeConverter<Clob, String>{
+
+    private static final long serialVersionUID = 1L;
+    private EncoderDecoder<Clob> encoderDecoder;
+
+    public IsisClobConverter() {
+        encoderDecoder = new ClobValueSemanticsProvider().getEncoderDecoder();
+    }
+    
+    @Override
+    public String toDatastoreType(Clob memberValue) {
+        return encoderDecoder.toEncodedString(memberValue);
+    }
+
+    @Override
+    public Clob toMemberType(String datastoreValue) {
+        return encoderDecoder.fromEncodedString(datastoreValue);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobMapping.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobMapping.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobMapping.java
new file mode 100644
index 0000000..5ab97fa
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisClobMapping.java
@@ -0,0 +1,88 @@
+package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.valuetypes;
+
+import org.apache.isis.applib.value.Blob;
+import org.apache.isis.applib.value.Clob;
+import org.datanucleus.ClassLoaderResolver;
+import org.datanucleus.ClassNameConstants;
+import org.datanucleus.NucleusContext;
+import org.datanucleus.metadata.AbstractMemberMetaData;
+import org.datanucleus.store.ExecutionContext;
+import org.datanucleus.store.mapped.DatastoreContainerObject;
+import org.datanucleus.store.mapped.MappedStoreManager;
+import org.datanucleus.store.mapped.mapping.SingleFieldMultiMapping;
+
+public class IsisClobMapping extends SingleFieldMultiMapping {
+
+    public IsisClobMapping() {
+    }
+    
+    @Override
+    public Class<?> getJavaType() {
+        return org.apache.isis.applib.value.Clob.class;
+    }
+
+    public void initialize(AbstractMemberMetaData mmd, DatastoreContainerObject container, ClassLoaderResolver clr)
+    {
+        super.initialize(mmd, container, clr);
+        addDatastoreFields();
+    }
+
+    public void initialize(MappedStoreManager storeMgr, String type)
+    {
+        super.initialize(storeMgr, type);
+        addDatastoreFields();
+    }
+
+    protected void addDatastoreFields()
+    {
+        addDatastoreField(ClassNameConstants.JAVA_LANG_STRING); // name
+        addDatastoreField(ClassNameConstants.JAVA_LANG_STRING); // mime type
+        addDatastoreField(ClassNameConstants.JAVA_LANG_CHARACTER_ARRAY); // chars
+    }
+
+    public Object getValueForDatastoreMapping(NucleusContext nucleusCtx, int index, Object value)
+    {
+        Clob clob = ((Clob)value);
+        switch (index) {
+            case 0: return clob.getName();
+            case 1: return clob.getMimeType().getBaseType();
+            case 2: return clob.getChars();
+        }
+        throw new IndexOutOfBoundsException();
+    }
+
+    public void setObject(ExecutionContext ec, Object preparedStmt, int[] exprIndex, Object value)
+    {
+        Clob clob = ((Clob)value);
+        if (clob == null) {
+            getDatastoreMapping(0).setObject(preparedStmt, exprIndex[0], null);
+            getDatastoreMapping(1).setObject(preparedStmt, exprIndex[1], null);
+            getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], null);
+        } else {
+            getDatastoreMapping(0).setString(preparedStmt, exprIndex[0], clob.getName());
+            getDatastoreMapping(1).setString(preparedStmt, exprIndex[1], clob.getMimeType().getBaseType());
+            getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], clob.getChars());
+        }
+    }
+    
+    public Object getObject(ExecutionContext ec, Object resultSet, int[] exprIndex)
+    {
+        try
+        {
+            // Check for null entries
+            if (getDatastoreMapping(0).getObject(resultSet, exprIndex[0]) == null)
+            {
+                return null;
+            }
+        }
+        catch (Exception e)
+        {
+            // Do nothing
+        }
+
+        String name = getDatastoreMapping(0).getString(resultSet, exprIndex[0]); 
+        String mimeTypeBase = getDatastoreMapping(1).getString(resultSet, exprIndex[1]); 
+        char[] chars = (char[]) getDatastoreMapping(2).getObject(resultSet,exprIndex[2]); 
+        return new Clob(name, mimeTypeBase, chars);
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateConverter.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateConverter.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateConverter.java
new file mode 100644
index 0000000..4723286
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateConverter.java
@@ -0,0 +1,68 @@
+/*
+ *  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.jdo.datanucleus.valuetypes;
+
+import org.apache.isis.applib.value.Date;
+import org.datanucleus.store.types.converters.TypeConverter;
+
+public class IsisDateConverter implements TypeConverter<Date, Long>{
+
+    private static final long serialVersionUID = 1L;
+
+    public IsisDateConverter() {
+        
+    }
+    
+//    @Override
+//    public Long toLong(Date object) {
+//        if(object == null) {
+//            return null;
+//        }
+//
+//        Date d = (Date)object;
+//        return d.getMillisSinceEpoch();
+//    }
+//
+//    @Override
+//    public Date toObject(Long value) {
+//        if(value == null) {
+//            return null;
+//        }
+//        return new Date(value);
+//    }
+
+    @Override
+    public Long toDatastoreType(Date memberValue) {
+        if(memberValue == null) {
+            return null;
+        }
+
+        Date d = (Date)memberValue;
+        return d.getMillisSinceEpoch();
+    }
+
+    @Override
+    public Date toMemberType(Long datastoreValue) {
+        if(datastoreValue == null) {
+            return null;
+        }
+        return new Date(datastoreValue);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateMapping.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateMapping.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateMapping.java
new file mode 100644
index 0000000..7063d2b
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateMapping.java
@@ -0,0 +1,48 @@
+/*
+ *  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.jdo.datanucleus.valuetypes;
+
+import org.datanucleus.store.mapped.mapping.ObjectAsLongMapping;
+
+import org.apache.isis.applib.value.Date;
+
+public class IsisDateMapping extends ObjectAsLongMapping {
+
+    private final IsisDateConverter dateConverter = new IsisDateConverter();
+    
+    public IsisDateMapping() {
+        
+    }
+    
+    @Override
+    public Class<?> getJavaType() {
+        return org.apache.isis.applib.value.Date.class;
+    }
+
+    @Override
+    protected Long objectToLong(Object object) {
+        return dateConverter.toDatastoreType((Date) object);
+    }
+
+    @Override
+    protected Object longToObject(Long datastoreValue) {
+        return dateConverter.toMemberType(datastoreValue);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeConverter.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeConverter.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeConverter.java
new file mode 100644
index 0000000..7e7cb29
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeConverter.java
@@ -0,0 +1,50 @@
+/*
+ *  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.jdo.datanucleus.valuetypes;
+
+import org.apache.isis.applib.value.DateTime;
+import org.datanucleus.store.types.converters.TypeConverter;
+
+public class IsisDateTimeConverter implements TypeConverter<DateTime, Long>{
+
+    private static final long serialVersionUID = 1L;
+
+    public IsisDateTimeConverter() {
+        
+    }
+    
+    @Override
+    public Long toDatastoreType(DateTime memberValue) {
+        if(memberValue == null) {
+            return null;
+        }
+
+        DateTime d = (DateTime)memberValue;
+        return d.getMillisSinceEpoch();
+    }
+
+    @Override
+    public DateTime toMemberType(Long datastoreValue) {
+        if(datastoreValue == null) {
+            return null;
+        }
+        return new DateTime(datastoreValue);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeMapping.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeMapping.java b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeMapping.java
new file mode 100644
index 0000000..44d9bbf
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/valuetypes/IsisDateTimeMapping.java
@@ -0,0 +1,48 @@
+/*
+ *  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.jdo.datanucleus.valuetypes;
+
+import org.datanucleus.store.mapped.mapping.ObjectAsLongMapping;
+
+import org.apache.isis.applib.value.DateTime;
+
+public class IsisDateTimeMapping extends ObjectAsLongMapping {
+
+    private final IsisDateTimeConverter dateConverter = new IsisDateTimeConverter();
+    
+    public IsisDateTimeMapping() {
+        
+    }
+    
+    @Override
+    public Class<?> getJavaType() {
+        return org.apache.isis.applib.value.DateTime.class;
+    }
+
+    @Override
+    protected Long objectToLong(Object object) {
+        return dateConverter.toDatastoreType((DateTime) object);
+    }
+
+    @Override
+    protected Object longToObject(Long datastoreValue) {
+        return dateConverter.toMemberType(datastoreValue);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/site/apt/index.apt b/framework/objectstore/jdo/jdo-datanucleus/src/site/apt/index.apt
new file mode 100644
index 0000000..2141916
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/site/apt/index.apt
@@ -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.
+
+
+
+DataNucleus
+
+  The <datanucleus> module is an implementation of the Isis object store
+  using the DataNucleus as its underlying ORM.
+  
+  This objectstore can optionally be used with the JPA applib and JPA metamodel.
+  
+  In the future, the intention is for the objectstore to support both JPA and also 
+  a JDO applib/metamodel.

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/site/apt/jottings.apt
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/site/apt/jottings.apt b/framework/objectstore/jdo/jdo-datanucleus/src/site/apt/jottings.apt
new file mode 100644
index 0000000..c5d1200
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/site/apt/jottings.apt
@@ -0,0 +1,24 @@
+~~  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.
+
+
+
+Jottings
+ 
+  This page is to capture any random jottings relating to this module prior 
+  to being moved into formal documentation. 
+ 

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/site/site.xml
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/site/site.xml b/framework/objectstore/jdo/jdo-datanucleus/src/site/site.xml
new file mode 100644
index 0000000..3020e82
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/site/site.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project name="${project.name}">
+	<body>
+		<breadcrumbs>
+			<item name="DataNucleus" href="index.html"/>
+		</breadcrumbs>
+
+		<menu name="DataNucleus">
+			<item name="About" href="index.html" />
+            <item name="Jottings" href="jottings.html" />
+		</menu>
+
+		<menu name="Maven Reports" ref="reports" />
+	</body>
+</project>

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java b/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java
new file mode 100644
index 0000000..0276f64
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java
@@ -0,0 +1,48 @@
+/*
+ *  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.jdo.datanucleus;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
+
+public class DataNucleusPersistenceMechanismInstallerTest_getName {
+
+    private DataNucleusPersistenceMechanismInstaller installer;
+
+    @Before
+    public void setUp() throws Exception {
+        installer = new DataNucleusPersistenceMechanismInstaller();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    public void isSet() {
+        assertThat(installer.getName(), is("datanucleus"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java b/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java
new file mode 100644
index 0000000..0474440
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java
@@ -0,0 +1,62 @@
+/*
+ *  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.jdo.datanucleus;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
+import org.apache.isis.tck.dom.scalars.PrimitiveValuedEntityRepository;
+
+public class DataNucleusPersistenceMechanismInstallerTest_services {
+
+    private PrimitiveValuedEntityRepository repo = new PrimitiveValuedEntityRepository();
+    
+    @Rule
+    public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+        .withServices(repo)
+        .build();
+
+    @Test
+    public void servicesBootstrapped() {
+        final List<Object> services = IsisContext.getServices();
+        assertThat(services.size(), is(1));
+        assertThat(services.get(0), is((Object)repo));
+        
+        final ObjectAdapter serviceAdapter = IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(repo);
+        assertThat(serviceAdapter, is(not(nullValue())));
+        
+        assertThat(serviceAdapter.getOid(), is(equalTo((Oid)RootOidDefault.create(ObjectSpecId.of("PrimitiveValuedEntities"), "1"))));
+    }
+    
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/Utils.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/Utils.java b/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/Utils.java
new file mode 100644
index 0000000..75d7b07
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/Utils.java
@@ -0,0 +1,124 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.joda.time.LocalDate;
+import org.joda.time.LocalDateTime;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationDefault;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
+
+public class Utils {
+
+    private Utils(){}
+
+    public static IsisSystemWithFixtures.Builder systemBuilder() {
+        return IsisSystemWithFixtures.builder()
+        .with(configurationForDataNucleusDb())
+        .with(new DataNucleusPersistenceMechanismInstaller());
+    }
+
+    public static IsisSystemWithFixtures.Listener listenerToDeleteFrom(final String... tables) {
+        return new IsisSystemWithFixtures.ListenerAdapter(){
+
+            @Override
+            public void postSetupSystem(boolean firstTime) throws Exception {
+                Connection connection = getConnection();
+                try {
+                    final Statement statement = connection.createStatement();
+                    for(String table: tables) {
+                        statement.executeUpdate("DELETE FROM " + table);
+                    }
+                } catch(Exception ex) {
+                    connection.rollback();
+                    throw ex;
+                } finally {
+                    connection.commit();
+                }
+            }
+
+            private Connection getConnection() {
+                final DataNucleusObjectStore objectStore = (DataNucleusObjectStore) IsisContext.getPersistenceSession().getObjectStore();
+                return objectStore.getJavaSqlConnection();
+            }
+        };
+    }
+
+    public static IsisConfiguration configurationForDataNucleusDb() {
+        final IsisConfigurationDefault configuration = new IsisConfigurationDefault();
+        Properties props = new Properties();
+        
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.PersistenceManagerFactoryClass", "org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
+
+        // last one wins!
+        configureHsqlDbFileBased(props);
+        configureForMsSqlServer(props);
+        configureHsqlDbInMemory(props);
+
+        props.put("isis.persistor.datanucleus.impl.datanucleus.autoCreateSchema", "true");
+        props.put("isis.persistor.datanucleus.impl.datanucleus.validateTables", "true");
+        props.put("isis.persistor.datanucleus.impl.datanucleus.validateConstraints", "true");
+        
+        props.put("isis.persistor.datanucleus.impl.datanucleus.cache.level2.type", "none");
+
+        configuration.add(props);
+        return configuration;
+    }
+
+
+    private static void configureHsqlDbInMemory(Properties props) {
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName", "org.hsqldb.jdbcDriver");
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL", "jdbc:hsqldb:mem:test");
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName", "sa");
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword", "");
+    }
+
+    private static void configureHsqlDbFileBased(Properties props) {
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName", "org.hsqldb.jdbcDriver");
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL", "jdbc:hsqldb:file:hsql-db/test;hsqldb.write_delay=false;shutdown=true");
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName", "sa");
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword", "");
+    }
+
+    private static void configureForMsSqlServer(Properties props) {
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL", "jdbc:sqlserver://127.0.0.1:1433;instance=SQLEXPRESS;databaseName=jdo;");
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName", "jdo");
+        props.put("isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword", "jdopass");
+    }
+
+    
+
+    public static long toMillis(int year, int monthOfYear, int dayOfMonth) {
+        LocalDate d = new LocalDate(year, monthOfYear, dayOfMonth);
+        return d.toDateMidnight().getMillis();
+    }
+
+    public static long toMillis(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute) {
+        LocalDateTime d = new LocalDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute);
+        return d.toDateTime().getMillis();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.java b/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.java
new file mode 100644
index 0000000..0a73e2b
--- /dev/null
+++ b/framework/objectstore/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/jdo/datanucleus/persistence/spi/JdoObjectIdSerializerTest.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.runtimes.dflt.objectstores.jdo.datanucleus.persistence.spi;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.math.BigInteger;
+import java.util.Date;
+
+import org.apache.isis.applib.annotation.ObjectType;
+import org.apache.isis.core.commons.matchers.IsisMatchers;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
+import org.datanucleus.identity.OIDImpl;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class JdoObjectIdSerializerTest {
+
+	@ObjectType("CUS")
+	public static class Customer {}
+	
+	public static class CustomerRepository {
+		public void foo(Customer x) {}
+	}
+	
+    @Rule
+    public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
+        .withServices(new CustomerRepository())
+        .build();
+    
+    
+    
+    @Test
+    public void whenJavaxJdoIntIdentity() throws Exception {
+        Object jdoObjectId = new javax.jdo.identity.IntIdentity(Customer.class, 123);
+        String id = JdoObjectIdSerializer.toOidIdentifier(jdoObjectId);
+        assertThat(id, is("i_123"));
+        
+        RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+        Object jdoObjectIdRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+        
+        assertThat(jdoObjectIdRecreated, is(jdoObjectId));
+    }
+
+
+    @Test
+    public void whenJavaxJdoStringIdentity() throws Exception {
+        Object jdoObjectId = new javax.jdo.identity.StringIdentity(Customer.class, "123");
+        String id = JdoObjectIdSerializer.toOidIdentifier(jdoObjectId);
+        assertThat(id, is("s_123"));
+        
+        RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+        Object jdoObjectIdRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+        
+        assertThat(jdoObjectIdRecreated, is(jdoObjectId));
+    }
+
+    
+    @Test
+    public void whenJavaxJdoLongIdentity() throws Exception {
+        Object jdoObjectId = new javax.jdo.identity.LongIdentity(Customer.class, 123L);
+        String id = JdoObjectIdSerializer.toOidIdentifier(jdoObjectId);
+        assertThat(id, is("l_123"));
+        
+        RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+        Object jdoObjectIdRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+        
+        assertThat(jdoObjectIdRecreated, is(jdoObjectId));
+    }
+
+
+    @Test
+    public void whenLong() throws Exception {
+        Object jdoOid = new OIDImpl(Customer.class.getName(), 123L);
+        String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+        assertThat(id, is("L_123"));
+        
+        RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+        Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+        assertThat(jdoOidRecreated, is((Object)("123"+ "[OID]" + Customer.class.getName())));
+    }
+
+    @Test
+    public void whenDataNucleusOidAndLong() throws Exception {
+        Object jdoOid = new OIDImpl(Customer.class.getName(), 123L);
+        String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+        assertThat(id, is("L_123"));
+        
+        RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+        Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+        assertThat(jdoOidRecreated, is((Object)("123"+ "[OID]" + Customer.class.getName())));
+    }
+
+    @Test
+    public void whenDataNucleusOidAndBigInteger() throws Exception {
+        Object jdoOid = new OIDImpl(Customer.class.getName(), new BigInteger("123"));
+        String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+        assertThat(id, is("B_123"));
+        
+        RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+        Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+        
+        assertThat(jdoOidRecreated, is(((Object)("123"+ "[OID]" + Customer.class.getName()))));
+    }
+
+    @Test
+    public void whenDataNucleusOidAndString() throws Exception {
+        Object jdoOid = new OIDImpl(Customer.class.getName(), "456");
+        String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+        assertThat(id, is("S_456"));
+        
+        RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+        Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+        
+        assertThat(jdoOidRecreated, is((Object)("456" + "[OID]" + Customer.class.getName())));
+    }
+
+    @Test
+    public void whenDataNucleusOidAndOtherKeyValue() throws Exception {
+        Date key = new Date();
+		Object jdoOid = new OIDImpl(Customer.class.getName(), key);
+        String id = JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+        assertThat(id, IsisMatchers.startsWith(OIDImpl.class.getName() + "_" + key.toString()));
+        
+        RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("CUS"), id);
+        Object jdoOidRecreated = JdoObjectIdSerializer.toJdoObjectId(oid);
+
+        assertThat(jdoOidRecreated, is((Object)(key.toString() + "[OID]" + Customer.class.getName())));
+    }
+
+}


Mime
View raw message