incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1357438 [2/5] - in /incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo: jdo-applib/ jdo-applib/src/ jdo-applib/src/main/ jdo-applib/src/main/java/ jdo-applib/src/main/resources/ jdo-applib/src/site/ jdo-applib/src/site/apt/ jdo-...
Date Wed, 04 Jul 2012 23:10:35 GMT
Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstaller.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstaller.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstaller.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,84 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus;
+
+import java.util.Map;
+
+import org.apache.isis.core.commons.components.Installer;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapterFactory;
+import org.apache.isis.core.metamodel.spec.SpecificationLookup;
+import org.apache.isis.runtimes.dflt.bytecode.identity.objectfactory.ObjectFactoryBasic;
+import org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.spi.DataNucleusIdentifierGenerator;
+import org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.spi.DataNucleusSimplePersistAlgorithm;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.PersistenceMechanismInstallerAbstract;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStore;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.IdentifierGenerator;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.ObjectFactory;
+
+/**
+ * Configuration files are read in the usual fashion (as per {@link Installer#getConfigurationResources()}, ie will consult all of:
+ * <ul>
+ * <li><tt>persistor_datanucleus.properties</tt>
+ * <li><tt>persistor.properties</tt>
+ * <li><tt>isis.properties</tt>
+ * </ul>
+ * 
+ * <p>
+ * With respect to configuration, all properties under <tt>isis.persistor.datanucleus.impl</tt> prefix are passed thru verbatim to the OpenDataNucleus runtime.
+ * For example:
+ * <table>
+ * <tr><th>Isis Property</th><th>DataNucleus Property</th></tr>
+ * <tr><td><tt>isis.persistor.datanucleus.impl.datanucleus.foo.Bar</tt></td><td><tt>datanucleus.foo.Bar</tt></td></tr>
+ * </table>
+ *
+ */
+public class DataNucleusPersistenceMechanismInstaller extends PersistenceMechanismInstallerAbstract {
+
+    public static final String NAME = "datanucleus";
+
+    private DataNucleusApplicationComponents applicationComponents = null;
+    
+    public DataNucleusPersistenceMechanismInstaller() {
+        super(NAME);
+    }
+
+    @Override
+    protected ObjectStore createObjectStore(IsisConfiguration configuration, ObjectAdapterFactory adapterFactory, AdapterManager adapterManager) {
+        createOpenJpaApplicationComponentsIfRequired(configuration);
+        return new DataNucleusObjectStore(configuration, adapterFactory, adapterManager, applicationComponents);
+    }
+
+    private void createOpenJpaApplicationComponentsIfRequired(IsisConfiguration configuration) {
+        if(applicationComponents != null) {
+            return;
+        }
+        
+        final IsisConfiguration dataNucleusConfig = configuration.createSubset("isis.persistor.datanucleus.impl");
+        final Map<String, String> props = dataNucleusConfig.asMap();
+        
+        applicationComponents = new DataNucleusApplicationComponents(props, getSpecificationLoader().allSpecifications());
+    }
+
+    @Override
+    protected IdentifierGenerator createIdentifierGenerator(IsisConfiguration configuration) {
+        return new DataNucleusIdentifierGenerator();
+    }
+
+
+    @Override
+    protected PersistAlgorithm createPersistAlgorithm(IsisConfiguration configuration) {
+        return new DataNucleusSimplePersistAlgorithm();
+    }
+    
+    @Override
+    protected ObjectFactory createObjectFactory(IsisConfiguration configuration) {
+        return new ObjectFactoryBasic();
+    }
+    
+    protected SpecificationLookup getSpecificationLoader() {
+        return IsisContext.getSpecificationLoader();
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/metamodel/facets/RemoveDataNucleusEnhancementTypesFacetFactory.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/metamodel/facets/RemoveDataNucleusEnhancementTypesFacetFactory.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/metamodel/facets/RemoveDataNucleusEnhancementTypesFacetFactory.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/metamodel/facets/RemoveDataNucleusEnhancementTypesFacetFactory.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.metamodel.facets;
+
+
+import org.apache.isis.core.progmodel.facets.object.ignore.javalang.AbstractRemoveMethodsFacetFactory;
+
+/**
+ * Removes all methods inherited from {@link Object}.
+ */
+public class RemoveDataNucleusEnhancementTypesFacetFactory extends AbstractRemoveMethodsFacetFactory {
+
+    public RemoveDataNucleusEnhancementTypesFacetFactory() {
+        super(javax.jdo.spi.PersistenceCapable.class);
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/metamodel/specloader/progmodelfacets/DataNucleusProgrammingModelFacets.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/metamodel/specloader/progmodelfacets/DataNucleusProgrammingModelFacets.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/metamodel/specloader/progmodelfacets/DataNucleusProgrammingModelFacets.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/metamodel/specloader/progmodelfacets/DataNucleusProgrammingModelFacets.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,43 @@
+/*
+ *  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.datanucleus.metamodel.specloader.progmodelfacets;
+
+
+import org.apache.isis.progmodels.dflt.ProgrammingModelFacetsJava5;
+import org.apache.isis.runtimes.dflt.objectstores.datanucleus.metamodel.facets.RemoveDataNucleusEnhancementTypesFacetFactory;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.specloader.progmodelfacets.JdoProgrammingModelFacets;
+
+/**
+ * As per the {@link ProgrammingModelFacetsJava5 Java 5 default programming
+ * model}, but also
+ * includes support for JPA.
+ * <p>
+ * Intended to be used by the {@link JpaJavaReflectorInstaller}, which
+ * additionally sets up other required components needed for JPA support.
+ */
+public class DataNucleusProgrammingModelFacets extends JdoProgrammingModelFacets {
+
+    public DataNucleusProgrammingModelFacets() {
+        addFactory(RemoveDataNucleusEnhancementTypesFacetFactory.class);
+    }
+
+}
+
+
+// Copyright (c) Naked Objects Group Ltd.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/IsisLifecycleListener.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/IsisLifecycleListener.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/IsisLifecycleListener.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/IsisLifecycleListener.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,370 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence;
+
+import java.text.MessageFormat;
+import java.util.Map;
+
+import javax.jdo.listener.AttachLifecycleListener;
+import javax.jdo.listener.ClearLifecycleListener;
+import javax.jdo.listener.CreateLifecycleListener;
+import javax.jdo.listener.DeleteLifecycleListener;
+import javax.jdo.listener.DetachLifecycleListener;
+import javax.jdo.listener.DirtyLifecycleListener;
+import javax.jdo.listener.InstanceLifecycleEvent;
+import javax.jdo.listener.LoadLifecycleListener;
+import javax.jdo.listener.StoreLifecycleListener;
+import javax.jdo.spi.PersistenceCapable;
+
+import com.google.common.collect.Maps;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackUtils;
+import org.apache.isis.core.metamodel.facets.object.callbacks.PersistedCallbackFacet;
+import org.apache.isis.core.metamodel.facets.object.callbacks.UpdatedCallbackFacet;
+import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerExtended;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionHydrator;
+
+public class IsisLifecycleListener implements AttachLifecycleListener, ClearLifecycleListener, CreateLifecycleListener, DeleteLifecycleListener, DetachLifecycleListener, DirtyLifecycleListener, LoadLifecycleListener, StoreLifecycleListener, SuspendableListener {
+
+    private static final Logger LOG = Logger.getLogger(IsisLifecycleListener.class);
+
+    private boolean suspended;
+
+    @Override
+    public void postCreate(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.POST, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void preAttach(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.PRE, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void postAttach(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.POST, event));
+        }
+
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void postLoad(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.POST, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+
+        ensureRootObject(event);
+
+        final Object pojo = persistenceCapableFor(event);
+
+        final OidGenerator oidGenerator = getOidGenerator();
+        final RootOid oid = oidGenerator.createPersistent(pojo, null);
+
+        PersistenceSessionHydrator hydrator = getPersistenceSession();
+        hydrator.recreateAdapter(oid, pojo);
+
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void preStore(InstanceLifecycleEvent event) {
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.PRE, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void postStore(InstanceLifecycleEvent event) {
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.POST, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+
+        ensureRootObject(event);
+
+        final PersistenceCapable pojo = persistenceCapableFor(event);
+        
+        final ObjectAdapter adapter = getAdapterManager().getAdapterFor(pojo);
+        if(!pojo.jdoIsPersistent()) {
+            final RootOid transientOid = (RootOid) adapter.getOid();
+            final RootOid persistentOid = getOidGenerator().createPersistent(pojo, transientOid);
+    
+            // most of the magic is here...
+            getAdapterManager().remapAsPersistent(adapter, persistentOid);
+    
+            clearDirtyFor(adapter);
+            CallbackUtils.callCallback(adapter, PersistedCallbackFacet.class);
+        } else {
+
+            clearDirtyFor(adapter);
+            CallbackUtils.callCallback(adapter, UpdatedCallbackFacet.class);
+        }
+
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void preDirty(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.PRE, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void postDirty(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.POST, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void preDelete(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.PRE, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void postDelete(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.POST, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void preClear(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.PRE, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void postClear(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.POST, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void preDetach(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.PRE, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    @Override
+    public void postDetach(InstanceLifecycleEvent event) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(logString(Phase.POST, event));
+        }
+        if (isSuspended()) {
+            LOG.debug(" [currently suspended - ignoring]");
+            return;
+        }
+        ensureRootObject(event);
+        ensureFrameworksInAgreement(event);
+    }
+
+    // /////////////////////////////////////////////////////////
+    // SuspendListener
+    // /////////////////////////////////////////////////////////
+
+    @Override
+    public boolean isSuspended() {
+        return suspended;
+    }
+
+    @Override
+    public void setSuspended(boolean suspended) {
+        this.suspended = suspended;
+    }
+
+    // /////////////////////////////////////////////////////////
+    // Helpers
+    // /////////////////////////////////////////////////////////
+
+    private void ensureFrameworksInAgreement(InstanceLifecycleEvent event) {
+        final PersistenceCapable pojo = persistenceCapableFor(event);
+        final ObjectAdapter adapter = getAdapterManager().getAdapterFor(pojo);
+        final Oid oid = adapter.getOid();
+
+        if(!pojo.jdoIsPersistent()) {
+            // make sure the adapter is transient
+            if (!adapter.getResolveState().isTransient()) {
+                throw new IsisException(MessageFormat.format("adapter is in invalid state; should be {0} but is {1}", ResolveState.TRANSIENT, adapter.getResolveState()));
+            }
+
+            // make sure the oid is transient
+            if (!oid.isTransient()) {
+                throw new IsisException(MessageFormat.format("Not transient: oid={0}, for {1}", oid, pojo));
+            }
+
+        } else {
+            // make sure the adapter is persistent
+            if (!adapter.getResolveState().isPersistent()) {
+                throw new IsisException(MessageFormat.format("adapter is in invalid state; should be in a persistent state but is {1}", ResolveState.RESOLVED, adapter.getResolveState()));
+            }
+
+            // make sure the oid is persistent
+            if (oid.isTransient()) {
+                throw new IsisException(MessageFormat.format("Transient: oid={0}, for {1}", oid, pojo));
+            }
+
+        }
+    }
+
+    // make sure the entity is a root
+    // TODO: will probably need to handle aggregated entities at some point...
+    private void ensureRootObject(InstanceLifecycleEvent event) {
+        final PersistenceCapable pojo2 = persistenceCapableFor(event);
+        final ObjectAdapter adapter2 = getAdapterManager().getAdapterFor(pojo2);
+        final Oid oid2 = adapter2.getOid();
+        if (!(oid2 instanceof RootOid)) {
+            throw new IsisException(MessageFormat.format("Not a RootOid: oid={0}, for {1}", oid2, pojo2));
+        }
+    }
+
+
+    
+    private enum Phase {
+        PRE, POST
+    }
+    
+    private static Map<Integer, LifecycleEventType> events = Maps.newHashMap();
+
+    private enum LifecycleEventType {
+        CREATE(0), LOAD(1), STORE(2), CLEAR(3), DELETE(4), DIRTY(5), DETACH(6), ATTACH(7);
+
+        private LifecycleEventType(int code) {
+            events.put(code, this);
+        }
+
+        public static LifecycleEventType lookup(int code) {
+            return events.get(code);
+        }
+    }
+
+    private static String logString(Phase phase, InstanceLifecycleEvent event) {
+        return phase + " " + LifecycleEventType.lookup(event.getEventType()) + ": pojo " + event.getSource();
+    }
+
+    private static void clearDirtyFor(final ObjectAdapter adapter) {
+        adapter.getSpecification().clearDirty(adapter);
+    }
+
+    private static PersistenceCapable persistenceCapableFor(InstanceLifecycleEvent event) {
+        return (PersistenceCapable)event.getSource();
+    }
+
+    @SuppressWarnings("unused")
+    private static Object jdoObjectIdFor(InstanceLifecycleEvent event) {
+        PersistenceCapable persistenceCapable = persistenceCapableFor(event);
+        Object jdoObjectId = persistenceCapable.jdoGetObjectId();
+        return jdoObjectId;
+    }
+
+    // /////////////////////////////////////////////////////////
+    // Dependencies (from context)
+    // /////////////////////////////////////////////////////////
+
+    protected AdapterManagerExtended getAdapterManager() {
+        return getPersistenceSession().getAdapterManager();
+    }
+
+    protected OidGenerator getOidGenerator() {
+        return getPersistenceSession().getOidGenerator();
+    }
+
+    protected PersistenceSession getPersistenceSession() {
+        return IsisContext.getPersistenceSession();
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/SuspendableListener.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/SuspendableListener.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/SuspendableListener.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/SuspendableListener.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,9 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence;
+
+public interface SuspendableListener {
+
+    boolean isSuspended();
+
+    void setSuspended(boolean suspend);
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/AbstractDataNucleusObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/AbstractDataNucleusObjectCommand.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/AbstractDataNucleusObjectCommand.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/AbstractDataNucleusObjectCommand.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,27 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.commands;
+
+import javax.jdo.PersistenceManager;
+import javax.persistence.EntityManager;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandAbstract;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
+
+public abstract class AbstractDataNucleusObjectCommand extends PersistenceCommandAbstract {
+    
+    private final PersistenceManager persistenceManager;
+
+    AbstractDataNucleusObjectCommand(final ObjectAdapter adapter,
+            final PersistenceManager persistenceManager) {
+        super(adapter);
+        this.persistenceManager = persistenceManager;
+        
+    }
+
+    protected PersistenceManager getPersistenceManager() {
+        return persistenceManager;
+    }
+    
+    public abstract void execute(final PersistenceCommandContext context);
+
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusCreateObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusCreateObjectCommand.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusCreateObjectCommand.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusCreateObjectCommand.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,37 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.commands;
+
+import javax.jdo.PersistenceManager;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
+
+public class DataNucleusCreateObjectCommand extends AbstractDataNucleusObjectCommand implements CreateObjectCommand {
+
+    private static final Logger LOG = Logger
+            .getLogger(DataNucleusCreateObjectCommand.class);
+
+    public DataNucleusCreateObjectCommand(ObjectAdapter adapter, PersistenceManager persistenceManager) {
+        super(adapter, persistenceManager);
+    }
+
+
+    @Override
+    public void execute(final PersistenceCommandContext context) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("create object - executing command for: " + onAdapter());
+        }
+        final ObjectAdapter adapter = onAdapter();
+        final Object domainObject = adapter.getObject();
+
+        getPersistenceManager().makePersistent(domainObject);
+    }
+
+    @Override
+    public String toString() {
+        return "CreateObjectCommand [adapter=" + onAdapter() + "]";
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusDeleteObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusDeleteObjectCommand.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusDeleteObjectCommand.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusDeleteObjectCommand.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,33 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.commands;
+
+import javax.jdo.PersistenceManager;
+import javax.persistence.EntityManager;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
+
+public class DataNucleusDeleteObjectCommand extends AbstractDataNucleusObjectCommand implements DestroyObjectCommand {
+
+    private static final Logger LOG = Logger.getLogger(DataNucleusDeleteObjectCommand.class);
+
+    public DataNucleusDeleteObjectCommand(ObjectAdapter adapter, PersistenceManager persistenceManager) {
+        super(adapter, persistenceManager);
+    }
+
+    @Override
+    public void execute(final PersistenceCommandContext context) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("destroy object - executing command for " + onAdapter());
+        }
+        getPersistenceManager().deletePersistent(onAdapter().getObject());
+    }
+
+    @Override
+    public String toString() {
+        return "DestroyObjectCommand [adapter=" + onAdapter() + "]";
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusUpdateObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusUpdateObjectCommand.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusUpdateObjectCommand.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/commands/DataNucleusUpdateObjectCommand.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,33 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.commands;
+
+import javax.jdo.PersistenceManager;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.SaveObjectCommand;
+
+public class DataNucleusUpdateObjectCommand extends AbstractDataNucleusObjectCommand implements SaveObjectCommand {
+    private static final Logger LOG = Logger
+            .getLogger(DataNucleusDeleteObjectCommand.class);
+
+    public DataNucleusUpdateObjectCommand(ObjectAdapter adapter, PersistenceManager persistenceManager) {
+        super(adapter, persistenceManager);
+    }
+
+    @Override
+    public void execute(final PersistenceCommandContext context) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("save object - executing command for: " + onAdapter());
+        }
+        
+        // TODO: this might be a no-op; JDO doesn't seem to have an equivalent of JPA's merge() ...
+        // getEntityManager().merge(onAdapter().getObject());
+    }
+
+    @Override
+    public String toString() {
+        return "SaveObjectCommand [adapter=" + onAdapter() + "]";
+    }
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindAllInstancesProcessor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindAllInstancesProcessor.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindAllInstancesProcessor.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindAllInstancesProcessor.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,35 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.queries;
+
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindAllInstances;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
+
+public class PersistenceQueryFindAllInstancesProcessor extends PersistenceQueryProcessorAbstract<PersistenceQueryFindAllInstances> {
+
+    private static final Logger LOG = Logger.getLogger(PersistenceQueryFindAllInstancesProcessor.class);
+
+    public PersistenceQueryFindAllInstancesProcessor(final AdapterManager adapterManager, final PersistenceManager persistenceManager) {
+        super(adapterManager, persistenceManager);
+    }
+
+    public List<ObjectAdapter> process(final PersistenceQueryFindAllInstances persistenceQuery) {
+
+        final ObjectSpecification specification = persistenceQuery.getSpecification();
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("getInstances: class=" + specification.getFullIdentifier());
+        }
+        final Query query = QueryUtil.createQuery(getPersistenceManager(), "o", null, specification, null);
+        final List<?> pojos = (List<?>) query.execute();
+        return loadAdapters(specification, pojos);
+    }
+}
+
+// Copyright (c) Naked Objects Group Ltd.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindByPatternProcessor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindByPatternProcessor.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindByPatternProcessor.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindByPatternProcessor.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,42 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.queries;
+
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+import javax.persistence.EntityManager;
+
+import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindByPattern;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
+
+public class PersistenceQueryFindByPatternProcessor extends
+        PersistenceQueryProcessorAbstract<PersistenceQueryFindByPattern> {
+
+    public PersistenceQueryFindByPatternProcessor(
+            final AdapterManager objectManager, final PersistenceManager persistenceManager) {
+        super(objectManager, persistenceManager);
+    }
+
+    public List<ObjectAdapter> process(
+            final PersistenceQueryFindByPattern persistenceQuery) {
+
+        
+
+        
+//        final Object pojoPattern = persistenceQuery.getPattern().getObject();
+//        
+//        final CriteriaBuilder criteriaBuilder = getEntityManager().getCriteriaBuilder();
+//        
+//        
+//        final CriteriaQuery<Object> criteriaQuery = criteriaBuilder.createQuery();
+//        
+//        final Query query = getEntityManager().createQuery(criteriaQuery);
+//        final List<?> results = query.getResultList();
+//        return loadAdapters(persistenceQuery.getSpecification(), results);
+        
+        throw new NotYetImplementedException();
+    }
+}
+
+// Copyright (c) Naked Objects Group Ltd.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindByTitleProcessor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindByTitleProcessor.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindByTitleProcessor.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindByTitleProcessor.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,45 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.queries;
+
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+
+import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindByTitle;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
+
+public class PersistenceQueryFindByTitleProcessor extends PersistenceQueryProcessorAbstract<PersistenceQueryFindByTitle> {
+
+    public PersistenceQueryFindByTitleProcessor(final AdapterManager adapterManager, final PersistenceManager persistenceManager) {
+        super(adapterManager, persistenceManager);
+    }
+
+    public List<ObjectAdapter> process(final PersistenceQueryFindByTitle persistenceQuery) {
+        final ObjectSpecification objectSpec = persistenceQuery.getSpecification();
+        final Class<?> correspondingClass = objectSpec.getCorrespondingClass();
+        return process(persistenceQuery, correspondingClass);
+    }
+
+    private <Z> List<ObjectAdapter> process(final PersistenceQueryFindByTitle persistenceQuery, Class<Z> correspondingClass) {
+        // TODO
+        throw new NotYetImplementedException();
+
+//        final CriteriaQuery<Z> criteriaQuery = getEntityManager().getCriteriaBuilder().createQuery(correspondingClass);
+//
+//        final ObjectSpecification objectSpec = persistenceQuery.getSpecification();
+//        final Root<Z> from = criteriaQuery.from(correspondingClass);
+//        
+//        final EntityType<Z> model = from.getModel();
+//        final SingularAttribute<? super Z, String> titleAttribute = model.getSingularAttribute("title", String.class);
+//        final Path<String> titlePath = from.get(titleAttribute);
+//        titlePath.equals(persistenceQuery.getTitle());
+//        
+//        final TypedQuery<Z> query = getPersistenceManager().createQuery(criteriaQuery);
+//        final List<Z> pojos = query.getResultList();
+//        return loadAdapters(objectSpec, pojos);
+    }
+}
+
+// Copyright (c) Naked Objects Group Ltd.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,88 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.queries;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.jdo.PersistenceManager;
+
+import com.google.common.collect.Maps;
+
+import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.services.container.query.QueryCardinality;
+import org.apache.isis.core.metamodel.spec.ObjectAdapterUtils;
+import org.apache.isis.runtimes.dflt.objectstores.datanucleus.DataNucleusObjectStore;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.facets.object.query.JdoNamedQuery;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindUsingApplibQueryDefault;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+
+public class PersistenceQueryFindUsingApplibQueryProcessor extends PersistenceQueryProcessorAbstract<PersistenceQueryFindUsingApplibQueryDefault> {
+    
+    public PersistenceQueryFindUsingApplibQueryProcessor(final AdapterManager objectManager, final PersistenceManager persistenceManager) {
+        super(objectManager, persistenceManager);
+    }
+
+    public List<ObjectAdapter> process(final PersistenceQueryFindUsingApplibQueryDefault persistenceQuery) {
+        final String queryName = persistenceQuery.getQueryName();
+        final Map<String, Object> map = unwrap(persistenceQuery.getArgumentsAdaptersByParameterName());
+        final QueryCardinality cardinality = persistenceQuery.getCardinality();
+        final List<?> results = getResults(queryName, map, cardinality);
+        return loadAdapters(persistenceQuery.getSpecification(), results);
+    }
+
+    public List<?> getResults(final String queryName, final Map<String, Object> argumentsByParameterName, final QueryCardinality cardinality) {
+        final JdoNamedQuery namedQuery = getNamedQuery(queryName);
+
+        throw new NotYetImplementedException();
+        
+//        final PersistenceManager persistenceManager = getJdoObjectStore().getPersistenceManager();
+//        final Query emQuery = persistenceManager.createNamedQuery(namedQuery.getName());
+//        
+//        for (final Map.Entry<String, Object> argumentByParameterName : argumentsByParameterName.entrySet()) {
+//            final String parameterName = argumentByParameterName.getKey();
+//            final Object argument = argumentByParameterName.getValue();
+//            emQuery.setParameter(parameterName, argument);
+//        }
+//
+//        if (cardinality == QueryCardinality.MULTIPLE) {
+//            return emQuery.getResultList();
+//        }
+//        if (cardinality == QueryCardinality.SINGLE) {
+//            final Object result = emQuery.getSingleResult();
+//            return result == null ? Collections.EMPTY_LIST : Arrays.asList(result);
+//        }
+//        // should never get here
+//        return Collections.EMPTY_LIST;
+    }
+
+    private JdoNamedQuery getNamedQuery(final String queryName) {
+        return getJdoObjectStore().getNamedQuery(queryName);
+    }
+
+    private static Map<String, Object> unwrap(final Map<String, ObjectAdapter> argumentAdaptersByParameterName) {
+        final Map<String, Object> argumentsByParameterName = Maps.newHashMap();
+        for (final String parameterName : argumentAdaptersByParameterName.keySet()) {
+            final ObjectAdapter argumentAdapter = argumentAdaptersByParameterName.get(parameterName);
+            final Object argument = ObjectAdapterUtils.unwrapObject(argumentAdapter);
+            argumentsByParameterName.put(parameterName, argument);
+        }
+        return argumentsByParameterName;
+    }
+
+    // /////////////////////////////////////////////////////////////
+    // Dependencies (from context)
+    // /////////////////////////////////////////////////////////////
+
+    private DataNucleusObjectStore getJdoObjectStore() {
+        return (DataNucleusObjectStore) getPersistenceSession().getObjectStore();
+    }
+
+    private PersistenceSession getPersistenceSession() {
+        return IsisContext.getPersistenceSession();
+    }
+
+}
+
+// Copyright (c) Naked Objects Group Ltd.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryProcessor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryProcessor.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryProcessor.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryProcessor.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,12 @@
+package org.apache.isis.runtimes.dflt.objectstores.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.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,66 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.queries;
+
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.metadata.TypeMetadata;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.Metamodel;
+
+import com.google.common.collect.Lists;
+
+import org.apache.isis.core.commons.ensure.Assert;
+import org.apache.isis.core.commons.ensure.Ensure;
+import org.apache.isis.core.commons.factory.InstanceUtil;
+import org.apache.isis.core.commons.lang.CastUtils;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceQuery;
+
+public abstract class PersistenceQueryProcessorAbstract<T extends PersistenceQuery>
+        implements PersistenceQueryProcessor<T> {
+
+    private final AdapterManager adapterManager;
+    private final PersistenceManager persistenceManager;
+
+    protected PersistenceQueryProcessorAbstract(
+            final AdapterManager objectManager , final PersistenceManager persistenceManager) {
+        this.adapterManager = objectManager;
+        this.persistenceManager = persistenceManager;
+    }
+
+    protected PersistenceManagerFactory getPersistenceManagerFactory() {
+        return getPersistenceManager().getPersistenceManagerFactory();
+    }
+
+    protected PersistenceManager getPersistenceManager() {
+        return persistenceManager;
+    }
+    
+    protected TypeMetadata getTypeMetadata(final String classFullName) {
+        return getPersistenceManagerFactory().getMetadata(classFullName);
+    }
+
+
+    protected List<ObjectAdapter> loadAdapters(
+            final ObjectSpecification specification, final List<?> pojos) {
+        final List<ObjectAdapter> adapters = Lists.newArrayList();
+        for (final Object pojo : pojos) {
+            ObjectAdapter adapter = adapterManager.getAdapterFor(pojo);
+            Assert.assertNotNull(adapter);
+            adapters.add( adapter );
+        }
+        return adapters;
+    }
+
+    protected AdapterManager getAdapterManager() {
+        return adapterManager;
+    }
+
+}
+
+// Copyright (c) Naked Objects Group Ltd.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/QueryUtil.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/QueryUtil.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/QueryUtil.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/queries/QueryUtil.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,69 @@
+package org.apache.isis.runtimes.dflt.objectstores.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 ").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.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,111 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus.persistence.spi;
+
+import java.util.UUID;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.persistence.PersistenceUnitUtil;
+
+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.map.AdapterMap;
+import org.apache.isis.core.metamodel.adapter.map.AdapterMapAware;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.SpecificationLookup;
+import org.apache.isis.core.metamodel.spec.SpecificationLookupAware;
+import org.apache.isis.runtimes.dflt.objectstores.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, AdapterMapAware, SpecificationLookupAware {
+
+    @SuppressWarnings("unused")
+    private static final Logger LOG = Logger.getLogger(DataNucleusIdentifierGenerator.class);
+    private AdapterMap adapterMap;
+    private SpecificationLookup specificationLookup;
+
+
+    // //////////////////////////////////////////////////////////////
+    // 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) {
+        
+        final Object identifier = getPersistenceManager().getObjectId(pojo);
+        
+        if(identifier == null) {
+            // is a service
+            return "1";
+        }
+
+        
+        
+        // for now, just using toString().  Suspect will need to review this
+        return identifier.toString();
+    }
+
+
+
+    // //////////////////////////////////////////////////////////////
+    // Debugging
+    // //////////////////////////////////////////////////////////////
+
+
+    public String debugTitle() {
+        return "OpenJpa Identifier Generator";
+    }
+
+    
+    @Override
+    public void debugData(DebugBuilder debug) {
+        
+    }
+
+
+    // //////////////////////////////////////////////////////////////
+    // Dependencies (injected by setter)
+    // //////////////////////////////////////////////////////////////
+
+    @Override
+    public void setAdapterMap(AdapterMap adapterMap) {
+        this.adapterMap = adapterMap;
+    }
+
+    @Override
+    public void setSpecificationLookup(SpecificationLookup specificationLookup) {
+        this.specificationLookup = specificationLookup;
+    }
+    
+    // //////////////////////////////////////////////////////////////
+    // Dependencies (from context)
+    // //////////////////////////////////////////////////////////////
+
+
+    protected PersistenceManager getPersistenceManager() {
+        final DataNucleusObjectStore objectStore = getObjectStore();
+        return objectStore.getPersistenceManager();
+    }
+
+
+    protected DataNucleusObjectStore getObjectStore() {
+        return (DataNucleusObjectStore) IsisContext.getPersistenceSession().getObjectStore();
+    }
+
+}
+// Copyright (c) Naked Objects Group Ltd.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/DataNucleusSimplePersistAlgorithm.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,62 @@
+package org.apache.isis.runtimes.dflt.objectstores.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
+    // ////////////////////////////////////////////////////////////////
+
+    /**
+     * @see NakedInsertPostEventListener#onPostInsert(org.hibernate.event.PostInsertEvent)
+     */
+    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.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/ResolveStateUtil.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/ResolveStateUtil.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/ResolveStateUtil.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/main/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/persistence/spi/ResolveStateUtil.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,105 @@
+package org.apache.isis.runtimes.dflt.objectstores.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.getResolveState().isResolving()) { // either RESOLVING or
+            // PART_RESOLVING
+            adapter.changeState(ResolveState.RESOLVED);
+
+        } else if (adapter.getResolveState().isResolved()) {
+            // nothing to do.
+
+        } else if (adapter.getResolveState().isPartlyResolved()) {
+            adapter.changeState(ResolveState.RESOLVED);
+
+        } else if (adapter.getResolveState().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.getResolveState().isNew()) {
+            adapter.changeState(ResolveState.GHOST);
+            adapter.changeState(ResolveState.RESOLVING);
+
+        } else if (adapter.getResolveState().isGhost()) {
+            adapter.changeState(ResolveState.RESOLVING);
+        }
+    }
+
+    public static void markAsGhost(final ObjectAdapter adapter) {
+
+        if (adapter.getResolveState().isValue()) {
+            // TODO: what should we do here? throw exception?
+        }
+        if (adapter.getResolveState().isDestroyed()) {
+            // TODO: what should we do here? throw exception?
+        }
+
+        if (adapter.isTransient()) {
+            adapter.changeState(ResolveState.RESOLVED);
+            adapter.changeState(ResolveState.GHOST);
+
+        } else if (adapter.getResolveState().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.getResolveState().isResolving()) {
+            adapter.changeState(ResolveState.RESOLVED);
+            adapter.changeState(ResolveState.GHOST);
+
+        } else if (adapter.getResolveState().isUpdating()) {
+            adapter.changeState(ResolveState.RESOLVED);
+            adapter.changeState(ResolveState.GHOST);
+
+        } else if (adapter.getResolveState().isResolved()) {
+            adapter.changeState(ResolveState.GHOST);
+
+        } else if (adapter.getResolveState().isGhost()) {
+            // nothing to do.
+        }
+    }
+
+
+    public static void markAsUpdating(final ObjectAdapter adapter) {
+
+        if (adapter.getResolveState() == ResolveState.TRANSIENT) {
+            adapter.changeState(ResolveState.RESOLVED);
+        }
+        if (adapter.getResolveState() == ResolveState.RESOLVED) {
+            adapter.changeState(ResolveState.UPDATING);
+        }
+    }
+
+}
+
+
+// Copyright (c) Naked Objects Group Ltd.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/apt/index.apt?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/apt/index.apt (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/apt/index.apt Wed Jul  4 23:10:27 2012
@@ -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.

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/apt/jottings.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/apt/jottings.apt?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/apt/jottings.apt (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/apt/jottings.apt Wed Jul  4 23:10:27 2012
@@ -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. 
+ 

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/site.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/site.xml?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/site.xml (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/site/site.xml Wed Jul  4 23:10:27 2012
@@ -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>

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_getName.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,30 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.runtimes.dflt.objectstores.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"));
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_persist.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_persist.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_persist.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_persist.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,95 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus;
+
+import static org.hamcrest.CoreMatchers.is;
+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.ResolveState;
+import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
+import org.apache.isis.tck.dom.scalars.PrimitiveValuedEntity;
+import org.apache.isis.tck.dom.scalars.PrimitiveValuedEntityRepository;
+
+public class DataNucleusPersistenceMechanismInstallerTest_persist {
+
+    private PrimitiveValuedEntityRepository repo = new PrimitiveValuedEntityRepository();
+    
+    @Rule
+    public IsisSystemWithFixtures iswf = Utils.systemBuilder()
+        .with(Utils.listenerToDeleteFrom("PRIMITIVEVALUEDENTITY"))
+        .withServices(repo)
+        .build();
+
+    @Test
+    public void emptyList() {
+        iswf.beginTran();
+        final List<PrimitiveValuedEntity> list = repo.list();
+        assertThat(list.size(), is(0));
+        iswf.commitTran();
+    }
+
+    @Test
+    public void retrieveWithoutBouncing() throws Exception {
+        iswf.beginTran();
+        PrimitiveValuedEntity entity = repo.newEntity();
+        entity.setId(1);
+        entity = repo.newEntity();
+        entity.setId(2);
+        iswf.commitTran();
+
+        // don't bounce
+        iswf.beginTran();
+        List<PrimitiveValuedEntity> list = repo.list();
+        assertThat(list.size(), is(2));
+        iswf.commitTran();
+    }
+
+    @Test
+    public void retrieveAfterBouncingSystem() throws Exception {
+        iswf.beginTran();
+        PrimitiveValuedEntity entity = repo.newEntity();
+        entity.setId(1);
+        entity = repo.newEntity();
+        entity.setId(2);
+        iswf.commitTran();
+
+        iswf.bounceSystem();
+        
+        iswf.beginTran();
+        List<PrimitiveValuedEntity> list = repo.list();
+        assertThat(list.size(), is(2));
+        iswf.commitTran();
+    }
+
+    @Test
+    public void adapterResolveStateChanges() throws Exception {
+        iswf.beginTran();
+        PrimitiveValuedEntity entity = repo.newEntity();
+        ObjectAdapter adapter = iswf.adapterFor(entity);
+        
+        assertThat(adapter.isTransient(), is(true));
+        assertThat(adapter.getResolveState(), is(ResolveState.TRANSIENT));
+        assertThat(adapter.getOid().isTransient(), is(true));
+        
+        entity.setId(1);
+        iswf.commitTran();
+        
+        iswf.bounceSystem();
+        
+        iswf.beginTran();
+        final List<PrimitiveValuedEntity> list = repo.list();
+        assertThat(list.size(), is(1));
+        
+        adapter = iswf.adapterFor(list.get(0));
+        assertThat(adapter.getResolveState(), is(ResolveState.GHOST));
+        assertThat(adapter.isTransient(), is(false));
+        assertThat(adapter.getOid().enString(), is("PRMV:1"));
+
+        iswf.commitTran();
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/DataNucleusPersistenceMechanismInstallerTest_services.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,44 @@
+package org.apache.isis.runtimes.dflt.objectstores.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"))));
+    }
+    
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/Utils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/Utils.java?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/Utils.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-datanucleus/src/test/java/org/apache/isis/runtimes/dflt/objectstores/datanucleus/Utils.java Wed Jul  4 23:10:27 2012
@@ -0,0 +1,64 @@
+package org.apache.isis.runtimes.dflt.objectstores.datanucleus;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationDefault;
+import org.apache.isis.runtimes.dflt.objectstores.datanucleus.DataNucleusObjectStore;
+import org.apache.isis.runtimes.dflt.objectstores.datanucleus.DataNucleusPersistenceMechanismInstaller;
+import org.apache.isis.runtimes.dflt.objectstores.datanucleus.metamodel.specloader.progmodelfacets.DataNucleusProgrammingModelFacets;
+import org.apache.isis.runtimes.dflt.objectstores.jdo.metamodel.specloader.validator.JdoMetaModelValidator;
+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(configurationForDataNucleusOverHsqlDb())
+        .with(new DataNucleusProgrammingModelFacets())
+        .with(new JdoMetaModelValidator())
+        .with(new DataNucleusPersistenceMechanismInstaller());
+    }
+
+    public static IsisSystemWithFixtures.Listener listenerToDeleteFrom(final String... tables) {
+        return new IsisSystemWithFixtures.ListenerAdapter(){
+
+            @Override
+            public void postSetupSystem(boolean firstTime) throws Exception {
+                final Statement statement = createStatement();
+                for(String table: tables) {
+                    statement.executeUpdate("DELETE FROM " + table);
+                }
+            }
+
+            private Statement createStatement() throws SQLException {
+                final DataNucleusObjectStore objectStore = (DataNucleusObjectStore) IsisContext.getPersistenceSession().getObjectStore();
+                Connection connection = objectStore.getJavaSqlConnection();
+                return connection.createStatement();
+            }
+        };
+    }
+
+    public static IsisConfiguration configurationForDataNucleusOverHsqlDb() {
+        final IsisConfigurationDefault configuration = new IsisConfigurationDefault();
+        Properties props = new Properties();
+        props.put("isis.persistor.datanucleus.impl.openjpa.jdbc.SynchronizeMappings", "buildSchema");
+        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.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", "");
+        props.put("isis.persistor.datanucleus.impl.datanucleus.autoCreateSchema", "true");
+        props.put("isis.persistor.datanucleus.impl.datanucleus.validateTables", "false");
+        props.put("isis.persistor.datanucleus.impl.datanucleus.validateConstraints", "false");
+        configuration.add(props);
+        return configuration;
+    }
+
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/NOTICE
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/NOTICE?rev=1357438&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/NOTICE (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/jdo/jdo-metamodel/NOTICE Wed Jul  4 23:10:27 2012
@@ -0,0 +1,7 @@
+Apache Isis
+Copyright 2010-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+



Mime
View raw message