You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/10/30 14:59:24 UTC

[8/8] git commit: ISIS-939: PojoRecreatorUnified and IdentifierGeneratorUnified.

ISIS-939: PojoRecreatorUnified and IdentifierGeneratorUnified.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/e523166f
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/e523166f
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/e523166f

Branch: refs/heads/master
Commit: e523166f7fef54b6152306fb4b946567d3c117d5
Parents: 898c604
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Oct 30 12:20:47 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Oct 30 12:20:47 2014 +0000

----------------------------------------------------------------------
 .../InMemoryPersistenceSessionFactory.java      |  11 +-
 .../core/runtime/PersistorImplementation.java   |   7 +
 .../PersistenceMechanismInstallerAbstract.java  |  48 +------
 .../PersistenceSessionFactoryDelegate.java      |   7 -
 .../PersistenceSessionFactoryDelegating.java    |  26 ----
 .../adaptermanager/AdapterManagerDefault.java   |   3 +-
 .../adaptermanager/PojoRecreatorDefault.java    |   2 +-
 .../PojoRecreatorForDataNucleus.java            |  60 ++++++++
 .../adaptermanager/PojoRecreatorUnified.java    |  45 ++++++
 .../persistence/objectfactory/MethodUtils.java  |  42 ------
 .../objectfactory/ObjectChanger.java            |  26 ----
 .../objectfactory/ObjectResolver.java           |  26 ----
 .../algorithm/PersistAlgorithmUnified.java      |   2 +-
 .../system/persistence/IdentifierGenerator.java |   5 +-
 .../persistence/IdentifierGeneratorDefault.java |  24 ++--
 .../IdentifierGeneratorForDataNucleus.java      | 143 +++++++++++++++++++
 .../persistence/IdentifierGeneratorUnified.java |  64 +++++++++
 .../system/persistence/OidGenerator.java        |   4 -
 .../system/persistence/PersistenceSession.java  |   3 +-
 .../persistence/PersistenceSessionFactory.java  |   3 -
 ...ataNucleusPersistenceMechanismInstaller.java |  11 --
 .../DataNucleusPojoRecreator.java               |  62 --------
 .../spi/DataNucleusIdentifierGenerator.java     | 137 ------------------
 .../PersistenceSessionObjectStoreTest.java      |   4 +-
 .../PersistorSessionHydratorTest.java           |   7 +-
 25 files changed, 351 insertions(+), 421 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceSessionFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceSessionFactory.java b/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceSessionFactory.java
index b1a38b6..3dc4ed1 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceSessionFactory.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceSessionFactory.java
@@ -49,8 +49,8 @@ public class InMemoryPersistenceSessionFactory extends PersistenceSessionFactory
         if (persistedObjects != null) {
             final OidGenerator oidGenerator = persistenceSession.getOidGenerator();
             final IdentifierGenerator identifierGenerator = oidGenerator.getIdentifierGenerator();
-            if (identifierGenerator instanceof IdentifierGeneratorDefault) {
-                final IdentifierGeneratorDefault identifierGeneratorDefault = (IdentifierGeneratorDefault) identifierGenerator;
+            final IdentifierGeneratorDefault identifierGeneratorDefault = identifierGenerator.underlying(IdentifierGeneratorDefault.class);
+            if(identifierGeneratorDefault != null) {
                 identifierGeneratorDefault.resetTo(persistedObjects.getOidGeneratorMemento());
             }
         }
@@ -73,10 +73,13 @@ public class InMemoryPersistenceSessionFactory extends PersistenceSessionFactory
     public void attach(final PersistenceSession persistenceSession, final ObjectStorePersistedObjects persistedObjects) {
         final OidGenerator oidGenerator = persistenceSession.getOidGenerator();
         final IdentifierGenerator identifierGenerator = oidGenerator.getIdentifierGenerator();
-        if (identifierGenerator instanceof IdentifierGeneratorDefault) {
-            final IdentifierGeneratorDefault identifierGeneratorDefault = (IdentifierGeneratorDefault) identifierGenerator;
+
+        final IdentifierGeneratorDefault identifierGeneratorDefault = identifierGenerator.underlying(IdentifierGeneratorDefault.class);
+        if(identifierGeneratorDefault != null) {
+            identifierGeneratorDefault.resetTo(persistedObjects.getOidGeneratorMemento());
             persistedObjects.saveOidGeneratorMemento(identifierGeneratorDefault.getMemento());
         }
+
         this.persistedObjects = persistedObjects;
     }
 

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/PersistorImplementation.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/PersistorImplementation.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/PersistorImplementation.java
index c022a1e..e30e0aa 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/PersistorImplementation.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/PersistorImplementation.java
@@ -27,4 +27,11 @@ public enum PersistorImplementation {
         final String persistor = configuration.getString("isis.persistor", "datanucleus");
         return "datanucleus".equalsIgnoreCase(persistor)? DATANUCLEUS: INMEMORY;
     }
+
+    public boolean isDataNucleus() {
+        return this == DATANUCLEUS;
+    }
+    public boolean isInMemory() {
+        return this == INMEMORY;
+    }
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java
index 57cb7d9..e702e36 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java
@@ -39,11 +39,10 @@ import org.apache.isis.core.runtime.persistence.PersistenceSessionFactoryDelegat
 import org.apache.isis.core.runtime.persistence.adapter.PojoAdapterFactory;
 import org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDefault;
 import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreator;
-import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreatorDefault;
+import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreatorUnified;
 import org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession;
 import org.apache.isis.core.runtime.persistence.objectstore.IsisObjectStoreLogger;
 import org.apache.isis.core.runtime.persistence.objectstore.ObjectStoreSpi;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.TransactionalResource;
 import org.apache.isis.core.runtime.system.DeploymentType;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 import org.apache.isis.core.runtime.system.persistence.*;
@@ -107,8 +106,7 @@ public abstract class PersistenceMechanismInstallerAbstract extends InstallerAbs
         }
 
         ObjectAdapterFactory adapterFactory = persistenceSessionFactory.getAdapterFactory();
-        PojoRecreator pojoRecreator = persistenceSessionFactory.getPojoRecreator();
-        IdentifierGenerator identifierGenerator = persistenceSessionFactory.getIdentifierGenerator();
+        PojoRecreator pojoRecreator = new PojoRecreatorUnified(getConfiguration());
         ServicesInjectorSpi servicesInjector = persistenceSessionFactory.getServicesInjector();
         
         final AdapterManagerDefault adapterManager = new AdapterManagerDefault(pojoRecreator);
@@ -123,12 +121,9 @@ public abstract class PersistenceMechanismInstallerAbstract extends InstallerAbs
         }
         
         final PersistenceSession persistenceSession = 
-                new PersistenceSession(persistenceSessionFactory, adapterFactory, servicesInjector, identifierGenerator, adapterManager, objectStore, getConfiguration());
-        
-        final IsisTransactionManager transactionManager = createTransactionManager(persistenceSession, objectStore, servicesInjector);
-        
-        ensureThatArg(persistenceSession, is(not(nullValue())));
-        ensureThatArg(transactionManager, is(not(nullValue())));
+                new PersistenceSession(persistenceSessionFactory, adapterFactory, servicesInjector, adapterManager, objectStore, getConfiguration());
+
+        final IsisTransactionManager transactionManager = new IsisTransactionManager(persistenceSession, objectStore, servicesInjector);
         
         persistenceSession.setDirtiableSupport(true);
         persistenceSession.setTransactionManager(transactionManager);
@@ -152,19 +147,6 @@ public abstract class PersistenceMechanismInstallerAbstract extends InstallerAbs
     // Optional hook methods
     // ///////////////////////////////////////////
 
-    /**
-     * Hook method to return an {@link IsisTransactionManager}.
-     * 
-     * <p>
-     * By default returns a {@link IsisTransactionManager}.
-     */
-    protected IsisTransactionManager createTransactionManager(
-            final PersistenceSession persistenceSession,
-            final TransactionalResource transactionalResource,
-            final ServicesInjectorSpi servicesInjectorSpi) {
-        return new IsisTransactionManager(persistenceSession, transactionalResource,  servicesInjectorSpi);
-    }
-
 
     /**
      * Hook method to refine the {@link ProgrammingModel}.
@@ -214,26 +196,6 @@ public abstract class PersistenceMechanismInstallerAbstract extends InstallerAbs
         return new ServicesInjectorDefault();
     }
 
-    /**
-     * Hook method to allow subclasses to specify a different implementation of
-     * {@link IdentifierGenerator}
-     * 
-     * <p>
-     * By default, returns {@link IdentifierGeneratorDefault}.
-     */
-    public IdentifierGenerator createIdentifierGenerator(final IsisConfiguration configuration) {
-        return new IdentifierGeneratorDefault();
-    }
-
-    /**
-     * Hook method to return {@link PojoRecreator}.
-     * 
-     * <p>
-     * By default, returns {@link PojoRecreatorDefault}.
-     */
-    public PojoRecreator createPojoRecreator(final IsisConfiguration configuration) {
-        return new PojoRecreatorDefault();
-    }
 
     // ///////////////////////////////////////////
     // Non overridable.

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/PersistenceSessionFactoryDelegate.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/PersistenceSessionFactoryDelegate.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/PersistenceSessionFactoryDelegate.java
index 9cbc2e0..9da2585 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/PersistenceSessionFactoryDelegate.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/PersistenceSessionFactoryDelegate.java
@@ -25,9 +25,6 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapterFactory;
 import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
 import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
 import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
-import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreator;
-import org.apache.isis.core.runtime.system.persistence.IdentifierGenerator;
-import org.apache.isis.core.runtime.system.persistence.ObjectFactory;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
 
@@ -42,12 +39,8 @@ public interface PersistenceSessionFactoryDelegate extends IsisConfigurationBuil
     // singleton threadsafe components created during init
     ///////////////////////////////////////////////////////////////////////////
     
-    PojoRecreator createPojoRecreator(IsisConfiguration configuration);
-
     ObjectAdapterFactory createAdapterFactory(IsisConfiguration configuration);
 
-    IdentifierGenerator createIdentifierGenerator(IsisConfiguration configuration);
-
     ServicesInjectorSpi createServicesInjector(IsisConfiguration configuration);
 
     RuntimeContext createRuntimeContext(IsisConfiguration configuration);

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/PersistenceSessionFactoryDelegating.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/PersistenceSessionFactoryDelegating.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/PersistenceSessionFactoryDelegating.java
index 45284cc..c0902f7 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/PersistenceSessionFactoryDelegating.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/PersistenceSessionFactoryDelegating.java
@@ -29,10 +29,8 @@ import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
 import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
 import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
 import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorComposite;
-import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreator;
 import org.apache.isis.core.runtime.system.DeploymentType;
 import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.IdentifierGenerator;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
 
@@ -56,9 +54,7 @@ public class PersistenceSessionFactoryDelegating implements PersistenceSessionFa
 
     private Boolean fixturesInstalled;
 
-    private PojoRecreator pojoRecreator;
     private ObjectAdapterFactory adapterFactory;
-    private IdentifierGenerator identifierGenerator;
     private ServicesInjectorSpi servicesInjector;
     private RuntimeContext runtimeContext;
 
@@ -102,13 +98,9 @@ public class PersistenceSessionFactoryDelegating implements PersistenceSessionFa
             FixtureClock.initialize();
         }
 
-        pojoRecreator = persistenceSessionFactoryDelegate.createPojoRecreator(getConfiguration());
         adapterFactory = persistenceSessionFactoryDelegate.createAdapterFactory(getConfiguration());
-        identifierGenerator = persistenceSessionFactoryDelegate.createIdentifierGenerator(getConfiguration());
 
-        ensureThatState(pojoRecreator, is(not(nullValue())));
         ensureThatState(adapterFactory, is(not(nullValue())));
-        ensureThatState(identifierGenerator, is(not(nullValue())));
 
         servicesInjector = persistenceSessionFactoryDelegate.createServicesInjector(getConfiguration());
 
@@ -132,7 +124,6 @@ public class PersistenceSessionFactoryDelegating implements PersistenceSessionFa
     }
 
 
-
     @Override
     public final void shutdown() {
         doShutdown();
@@ -153,18 +144,6 @@ public class PersistenceSessionFactoryDelegating implements PersistenceSessionFa
         return adapterFactory;
     }
     
-    public IdentifierGenerator getIdentifierGenerator() {
-        return identifierGenerator;
-    }
-    
-    public PojoRecreator getPojoRecreator() {
-        return pojoRecreator;
-    }
-
-    public RuntimeContext getRuntimeContext() {
-        return runtimeContext;
-    }
-    
     public ServicesInjectorSpi getServicesInjector() {
         return servicesInjector;
     }
@@ -183,7 +162,6 @@ public class PersistenceSessionFactoryDelegating implements PersistenceSessionFa
         persistenceSessionFactoryDelegate.refineProgrammingModel(baseProgrammingModel, configuration);
     }
 
-
     // //////////////////////////////////////////////////////
     // FixturesInstalledFlag impl
     // //////////////////////////////////////////////////////
@@ -215,16 +193,12 @@ public class PersistenceSessionFactoryDelegating implements PersistenceSessionFa
         this.serviceList = serviceList;
     }
 
-
     // //////////////////////////////////////////////////////
     // Dependencies (from context)
     // //////////////////////////////////////////////////////
 
-    
     protected SpecificationLoaderSpi getSpecificationLoader() {
         return IsisContext.getSpecificationLoader();
     }
 
-
-
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/AdapterManagerDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/AdapterManagerDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/AdapterManagerDefault.java
index db668bd..9d67051 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/AdapterManagerDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/AdapterManagerDefault.java
@@ -187,8 +187,7 @@ public class AdapterManagerDefault implements AdapterManagerSpi {
         if(lazilyLoadedAdapter != null) {
             return lazilyLoadedAdapter;
         }
-        
-        
+
         // need to create (and possibly map) the adapter.
         final ObjectSpecification objSpec = getSpecificationLoader().loadSpecification(pojo.getClass());
         

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorDefault.java
index 51d3ac3..b8d2975 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorDefault.java
@@ -26,7 +26,7 @@ import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 
-public class PojoRecreatorDefault implements PojoRecreator {
+class PojoRecreatorDefault implements PojoRecreator {
 
     public Object recreatePojo(final TypedOid oid) {
         final ObjectSpecification spec = getSpecificationLoader().lookupBySpecId(oid.getObjectSpecId());

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorForDataNucleus.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorForDataNucleus.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorForDataNucleus.java
new file mode 100644
index 0000000..ab560a3
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorForDataNucleus.java
@@ -0,0 +1,60 @@
+/*
+ *  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.core.runtime.persistence.adaptermanager;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore;
+
+class PojoRecreatorForDataNucleus implements PojoRecreator {
+
+    private final PojoRecreator delegate = new PojoRecreatorDefault();
+    
+    @Override
+    public Object recreatePojo(TypedOid oid) {
+        if(oid.isTransient() || oid.isViewModel()) {
+            return delegate.recreatePojo(oid);
+        }
+        return getObjectStore().loadPojo(oid);
+    }
+
+    
+    @Override
+    public ObjectAdapter lazilyLoaded(Object pojo) {
+        return getObjectStore().lazilyLoaded(pojo);
+    }
+
+    ///////////////////////////////
+    
+
+    protected PersistenceSession getPersistenceSession() {
+        return IsisContext.getPersistenceSession();
+    }
+
+    protected DataNucleusObjectStore getObjectStore() {
+        return (DataNucleusObjectStore) getPersistenceSession().getObjectStore();
+    }
+
+    
+    
+    
+}
+

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorUnified.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorUnified.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorUnified.java
new file mode 100644
index 0000000..ab60491
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/adaptermanager/PojoRecreatorUnified.java
@@ -0,0 +1,45 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.core.runtime.persistence.adaptermanager;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.runtime.PersistorImplementation;
+
+public class PojoRecreatorUnified implements PojoRecreator {
+
+    private final PojoRecreator pojoRecreator;
+
+    public PojoRecreatorUnified(final IsisConfiguration configuration) {
+        this.pojoRecreator =
+                PersistorImplementation.from(configuration).isDataNucleus()
+                    ? new PojoRecreatorForDataNucleus()
+                    : new PojoRecreatorDefault();
+    }
+
+    public Object recreatePojo(final TypedOid oid) {
+        return pojoRecreator.recreatePojo(oid);
+    }
+
+    public ObjectAdapter lazilyLoaded(Object pojo) {
+        return pojoRecreator.lazilyLoaded(pojo);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/MethodUtils.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/MethodUtils.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/MethodUtils.java
deleted file mode 100644
index 00cde98..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/MethodUtils.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.runtime.persistence.objectfactory;
-
-import java.lang.reflect.Method;
-
-public class MethodUtils {
-
-    public static boolean isGetter(final Method method) {
-        final String name = method.getName();
-        if (name.startsWith("get") && name.length() > 3) {
-            return true;
-        }
-        if (name.startsWith("is") && name.length() > 2) {
-            return true;
-        }
-        return false;
-    }
-
-    public static boolean isSetter(final Method method) {
-        final String name = method.getName();
-        return name.startsWith("set") && name.length() > 3;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/ObjectChanger.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/ObjectChanger.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/ObjectChanger.java
deleted file mode 100644
index 62fffaa..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/ObjectChanger.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.runtime.persistence.objectfactory;
-
-public interface ObjectChanger {
-
-    void objectChanged(Object domainObject);
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/ObjectResolver.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/ObjectResolver.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/ObjectResolver.java
deleted file mode 100644
index d4eeccd..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectfactory/ObjectResolver.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.runtime.persistence.objectfactory;
-
-public interface ObjectResolver {
-
-    void resolve(Object domainObject, String propertyName);
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmUnified.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmUnified.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmUnified.java
index f51bd2c..dca5413 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmUnified.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmUnified.java
@@ -37,7 +37,7 @@ public class PersistAlgorithmUnified extends PersistAlgorithmAbstract {
 
     public PersistAlgorithmUnified(IsisConfiguration configuration) {
         final PersistorImplementation persistorImplementation = PersistorImplementation.from(configuration);
-        persistAlgorithm = persistorImplementation == PersistorImplementation.DATANUCLEUS
+        persistAlgorithm = persistorImplementation.isDataNucleus()
                                 ? new PersistAlgorithmForDataNucleus()
                                 : new PersistAlgorithmDefault();
     }

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGenerator.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGenerator.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGenerator.java
index f1668d7..6c40c3d 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGenerator.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGenerator.java
@@ -28,7 +28,8 @@ public interface IdentifierGenerator extends DebuggableWithTitle {
     public String createTransientIdentifierFor(ObjectSpecId objectSpecId, final Object pojo);
 
     public String createAggregateLocalId(ObjectSpecId objectSpecId, final Object pojo, final ObjectAdapter parentAdapter);
-    
+
     public String createPersistentIdentifierFor(ObjectSpecId objectSpecId, Object pojo, RootOid transientRootOid);
 
-}
+    public <T extends IdentifierGenerator> T underlying(Class<T> cls);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorDefault.java
index 391095f..579eab5 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorDefault.java
@@ -19,25 +19,16 @@
 
 package org.apache.isis.core.runtime.system.persistence;
 
-import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
-import static org.apache.isis.core.commons.matchers.IsisMatchers.greaterThan;
-import static org.hamcrest.CoreMatchers.is;
-
 import org.apache.isis.core.commons.debug.DebugBuilder;
 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.RootOid;
-import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
 import org.apache.isis.core.metamodel.spec.ObjectSpecId;
 
-/**
- * Generates OIDs based on monotonically.
- * 
- * <p>
- * Specifies the {@link OidStringifierDirect} as the
- * {@link #getOidStringifier() OID stringifier} ({@link RootOidDefault} is
- * conformant)).
- */
+import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
+import static org.apache.isis.core.commons.matchers.IsisMatchers.greaterThan;
+import static org.hamcrest.CoreMatchers.is;
+
 public class IdentifierGeneratorDefault implements IdentifierGenerator {
 
     public static class Memento {
@@ -116,7 +107,12 @@ public class IdentifierGeneratorDefault implements IdentifierGenerator {
         return "" + (persistentSerialNumber++); // counts up
     }
 
-    
+    @Override
+    public <T extends IdentifierGenerator> T underlying(Class<T> cls) {
+        return cls == IdentifierGeneratorDefault.class? (T) this : null;
+    }
+
+
     // //////////////////////////////////////////////////////////////
     // Memento (not API)
     // //////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorForDataNucleus.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorForDataNucleus.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorForDataNucleus.java
new file mode 100644
index 0000000..004b0e9
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorForDataNucleus.java
@@ -0,0 +1,143 @@
+/*
+ *  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.core.runtime.system.persistence;
+
+import java.util.UUID;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.spi.PersistenceCapable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+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.facets.object.viewmodel.ViewModelFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore;
+import org.apache.isis.objectstore.jdo.datanucleus.persistence.spi.JdoObjectIdSerializer;
+
+class IdentifierGeneratorForDataNucleus implements IdentifierGenerator {
+
+    @SuppressWarnings("unused")
+    private static final Logger LOG = LoggerFactory.getLogger(IdentifierGeneratorForDataNucleus.class);
+    
+
+
+    // //////////////////////////////////////////////////////////////
+    // main api
+    // //////////////////////////////////////////////////////////////
+
+    /**
+     * TODO: this is really to create a transient or view model identifier.  The responsibilities are split unhappily between this class and its caller, the OidGenerator.
+     */
+    @Override
+    public String createTransientIdentifierFor(ObjectSpecId objectSpecId, Object pojo) {
+
+        final ObjectSpecification spec = getSpecificationLoader().lookupBySpecId(objectSpecId);
+        final ViewModelFacet viewModelFacet = spec.getFacet(ViewModelFacet.class);
+        if(viewModelFacet != null) {
+            return viewModelFacet.memento(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 ObjectSpecification spec = getSpecificationLookup().lookupBySpecId(objectSpecId);
+        if(spec.containsFacet(ViewModelFacet.class)) {
+            ViewModelFacet viewModelFacet = spec.getFacet(ViewModelFacet.class);
+            return viewModelFacet.memento(pojo);
+        }
+        final Object jdoOid = getJdoPersistenceManager().getObjectId(pojo);
+        return JdoObjectIdSerializer.toOidIdentifier(jdoOid);
+    }
+
+
+
+    @Override
+    public <T extends IdentifierGenerator> T underlying(Class<T> cls) {
+        return cls == IdentifierGeneratorForDataNucleus.class? (T) this : null;
+    }
+
+    //////////////////////////////////////////////////////////////////
+    // context
+    //////////////////////////////////////////////////////////////////
+
+    protected SpecificationLoader getSpecificationLookup() {
+        return IsisContext.getSpecificationLoader();
+    }
+
+
+    // //////////////////////////////////////////////////////////////
+    // 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();
+    }
+    protected SpecificationLoader getSpecificationLoader() {
+        return IsisContext.getSpecificationLoader();
+    }
+
+}
+// Copyright (c) Naked Objects Group Ltd.

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorUnified.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorUnified.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorUnified.java
new file mode 100644
index 0000000..be64830
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IdentifierGeneratorUnified.java
@@ -0,0 +1,64 @@
+/*
+ *  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.core.runtime.system.persistence;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+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.core.runtime.PersistorImplementation;
+
+public class IdentifierGeneratorUnified implements IdentifierGenerator {
+
+    private final IdentifierGenerator identifierGenerator;
+
+    public IdentifierGeneratorUnified(final IsisConfiguration configuration) {
+        this.identifierGenerator = PersistorImplementation.from(configuration).isDataNucleus() ? new IdentifierGeneratorForDataNucleus(): new IdentifierGeneratorDefault();
+    }
+
+    public String createTransientIdentifierFor(ObjectSpecId objectSpecId, final Object pojo) {
+        return identifierGenerator.createTransientIdentifierFor(objectSpecId, pojo);
+    }
+
+    public String createAggregateLocalId(ObjectSpecId objectSpecId, final Object pojo, final ObjectAdapter parentAdapter) {
+        return identifierGenerator.createAggregateLocalId(objectSpecId, pojo, parentAdapter);
+    }
+    
+    public String createPersistentIdentifierFor(ObjectSpecId objectSpecId, Object pojo, RootOid transientRootOid) {
+        return identifierGenerator.createPersistentIdentifierFor(objectSpecId, pojo, transientRootOid);
+    }
+
+    public <T extends IdentifierGenerator> T underlying(Class<T> cls) {
+        return cls.isAssignableFrom(identifierGenerator.getClass()) ? (T) cls.cast(identifierGenerator) : null;
+    }
+
+    @Override
+    public String debugTitle() {
+        return identifierGenerator.debugTitle();
+    }
+
+    @Override
+    public void debugData(DebugBuilder debug) {
+        identifierGenerator.debugData(debug);
+    }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/OidGenerator.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/OidGenerator.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/OidGenerator.java
index 3b1255a..c76f004 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/OidGenerator.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/OidGenerator.java
@@ -35,10 +35,6 @@ public class OidGenerator implements DebuggableWithTitle {
 
     private final IdentifierGenerator identifierGenerator;
     
-    public OidGenerator() {
-        this(new IdentifierGeneratorDefault());
-    }
-    
     public OidGenerator(final IdentifierGenerator identifierGenerator) {
         this.identifierGenerator = identifierGenerator;
     }

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
index 4e68d1c..ffd13b6 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
@@ -106,12 +106,11 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
             final PersistenceSessionFactory persistenceSessionFactory,
             final ObjectAdapterFactory adapterFactory,
             final ServicesInjectorSpi servicesInjector,
-            final IdentifierGenerator identifierGenerator,
             final AdapterManagerSpi adapterManager,
             final ObjectStore objectStore,
             final IsisConfiguration configuration) {
 
-        this(persistenceSessionFactory, adapterFactory, servicesInjector, new OidGenerator(identifierGenerator), adapterManager, objectStore, configuration);
+        this(persistenceSessionFactory, adapterFactory, servicesInjector, new OidGenerator(new IdentifierGeneratorUnified(configuration)), adapterManager, objectStore, configuration);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
index 9efc66e..7c3e2bf 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
@@ -25,7 +25,6 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapterFactory;
 import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
 import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
 import org.apache.isis.core.runtime.persistence.PersistenceSessionFactoryDelegate;
-import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreator;
 import org.apache.isis.core.runtime.system.DeploymentType;
 
 /**
@@ -41,8 +40,6 @@ public interface PersistenceSessionFactory extends MetaModelRefiner, Application
     // //////////////////////////////////////////////////////
 
     ObjectAdapterFactory getAdapterFactory();
-    PojoRecreator getPojoRecreator();
-    IdentifierGenerator getIdentifierGenerator();
     ServicesInjectorSpi getServicesInjector();
 
     

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstaller.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstaller.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstaller.java
index ded5a02..9961265 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstaller.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusPersistenceMechanismInstaller.java
@@ -36,9 +36,6 @@ import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMe
 import org.apache.isis.core.runtime.persistence.objectstore.ObjectStoreSpi;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 import org.apache.isis.core.runtime.system.persistence.AdapterManagerSpi;
-import org.apache.isis.core.runtime.system.persistence.IdentifierGenerator;
-import org.apache.isis.objectstore.jdo.datanucleus.persistence.adaptermanager.DataNucleusPojoRecreator;
-import org.apache.isis.objectstore.jdo.datanucleus.persistence.spi.DataNucleusIdentifierGenerator;
 import org.apache.isis.objectstore.jdo.metamodel.facets.object.auditable.AuditableAnnotationInJdoApplibFacetFactory;
 import org.apache.isis.objectstore.jdo.metamodel.facets.object.auditable.AuditableMarkerInterfaceInJdoApplibFacetFactory;
 import org.apache.isis.objectstore.jdo.metamodel.facets.object.datastoreidentity.JdoDatastoreIdentityAnnotationFacetFactory;
@@ -186,10 +183,6 @@ public class DataNucleusPersistenceMechanismInstaller extends PersistenceMechani
     // PersistenceSessionFactoryDelegate impl
     ////////////////////////////////////////////////////////////////////////
 
-    @Override
-    public IdentifierGenerator createIdentifierGenerator(IsisConfiguration configuration) {
-        return new DataNucleusIdentifierGenerator();
-    }
 
     @Override
     public void refineProgrammingModel(ProgrammingModel programmingModel, IsisConfiguration configuration) {
@@ -219,10 +212,6 @@ public class DataNucleusPersistenceMechanismInstaller extends PersistenceMechani
     }
 
 
-    @Override
-    public DataNucleusPojoRecreator createPojoRecreator(IsisConfiguration configuration) {
-        return new DataNucleusPojoRecreator();
-    }
 
     ////////////////////////////////////////////////////////////////////////
     // Dependencies

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/adaptermanager/DataNucleusPojoRecreator.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/adaptermanager/DataNucleusPojoRecreator.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/adaptermanager/DataNucleusPojoRecreator.java
deleted file mode 100644
index cf14157..0000000
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/adaptermanager/DataNucleusPojoRecreator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.apache.isis.objectstore.jdo.datanucleus.persistence.adaptermanager;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
-import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreator;
-import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreatorDefault;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore;
-
-public class DataNucleusPojoRecreator implements PojoRecreator {
-
-    private final PojoRecreator delegate = new PojoRecreatorDefault();
-    
-    @Override
-    public Object recreatePojo(TypedOid oid) {
-        if(oid.isTransient() || oid.isViewModel()) {
-            return delegate.recreatePojo(oid);
-        }
-        return getObjectStore().loadPojo(oid);
-    }
-
-    
-    @Override
-    public ObjectAdapter lazilyLoaded(Object pojo) {
-        return getObjectStore().lazilyLoaded(pojo);
-    }
-
-    ///////////////////////////////
-    
-
-    protected PersistenceSession getPersistenceSession() {
-        return IsisContext.getPersistenceSession();
-    }
-
-    protected DataNucleusObjectStore getObjectStore() {
-        return (DataNucleusObjectStore) getPersistenceSession().getObjectStore();
-    }
-
-    
-    
-    
-}
-

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java
deleted file mode 100644
index 6cbce6d..0000000
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/spi/DataNucleusIdentifierGenerator.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.apache.isis.objectstore.jdo.datanucleus.persistence.spi;
-
-import java.util.UUID;
-
-import javax.jdo.PersistenceManager;
-import javax.jdo.spi.PersistenceCapable;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.ViewModel;
-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.adapter.oid.Oid.State;
-import org.apache.isis.core.metamodel.facets.object.viewmodel.ViewModelFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.IdentifierGenerator;
-import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore;
-
-public class DataNucleusIdentifierGenerator implements IdentifierGenerator {
-
-    @SuppressWarnings("unused")
-    private static final Logger LOG = LoggerFactory.getLogger(DataNucleusIdentifierGenerator.class);
-    
-
-
-    // //////////////////////////////////////////////////////////////
-    // main api
-    // //////////////////////////////////////////////////////////////
-
-    /**
-     * TODO: this is really to create a transient or view model identifier.  The responsibilities are split unhappily between this class and its caller, the OidGenerator.
-     */
-    @Override
-    public String createTransientIdentifierFor(ObjectSpecId objectSpecId, Object pojo) {
-
-        final ObjectSpecification spec = getSpecificationLoader().lookupBySpecId(objectSpecId);
-        final ViewModelFacet viewModelFacet = spec.getFacet(ViewModelFacet.class);
-        if(viewModelFacet != null) {
-            return viewModelFacet.memento(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 ObjectSpecification spec = getSpecificationLookup().lookupBySpecId(objectSpecId);
-        if(spec.containsFacet(ViewModelFacet.class)) {
-            ViewModelFacet viewModelFacet = spec.getFacet(ViewModelFacet.class);
-            return viewModelFacet.memento(pojo);
-        }
-        final Object jdoOid = getJdoPersistenceManager().getObjectId(pojo);
-        return JdoObjectIdSerializer.toOidIdentifier(jdoOid);
-    }
-
-
-    //////////////////////////////////////////////////////////////////
-    // context
-    //////////////////////////////////////////////////////////////////
-
-    protected SpecificationLoader getSpecificationLookup() {
-        return IsisContext.getSpecificationLoader();
-    }
-
-
-    // //////////////////////////////////////////////////////////////
-    // 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();
-    }
-    protected SpecificationLoader getSpecificationLoader() {
-        return IsisContext.getSpecificationLoader();
-    }
-
-}
-// Copyright (c) Naked Objects Group Ltd.

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
index 27be9ef..7b6ac68 100644
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
@@ -43,7 +43,7 @@ import org.apache.isis.core.metamodel.specloader.InjectorMethodEvaluatorDefault;
 import org.apache.isis.core.runtime.persistence.adapter.PojoAdapter;
 import org.apache.isis.core.runtime.persistence.adapter.PojoAdapterFactory;
 import org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDefault;
-import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreatorDefault;
+import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreatorUnified;
 import org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.*;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Persistence;
@@ -150,7 +150,7 @@ public class PersistenceSessionObjectStoreTest {
 
         servicesInjector = new ServicesInjectorDefault(new InjectorMethodEvaluatorDefault());
 
-        adapterManager = new AdapterManagerDefault(new PojoRecreatorDefault());
+        adapterManager = new AdapterManagerDefault(new PojoRecreatorUnified(mockConfiguration));
         adapterFactory = new PojoAdapterFactory();
         persistenceSession = new PersistenceSession(mockPersistenceSessionFactory, adapterFactory, servicesInjector, new OidGenerator(new IdentifierGeneratorDefault()), adapterManager, mockObjectStore, mockConfiguration) {
             @Override

http://git-wip-us.apache.org/repos/asf/isis/blob/e523166f/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/PersistorSessionHydratorTest.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/PersistorSessionHydratorTest.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/PersistorSessionHydratorTest.java
index eb6f528..acd9793 100644
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/PersistorSessionHydratorTest.java
+++ b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/persistence/PersistorSessionHydratorTest.java
@@ -22,7 +22,6 @@ package org.apache.isis.core.integtestsupport.persistence;
 import org.jmock.Expectations;
 import org.junit.Rule;
 import org.junit.Test;
-import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures;
 import org.apache.isis.core.integtestsupport.IsisSystemWithFixtures.Fixtures.Initialization;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -79,11 +78,7 @@ public class PersistorSessionHydratorTest {
     @Rule
     public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder()
         .with(Initialization.NO_INIT)
-        .with(new InMemoryPersistenceMechanismInstaller() {
-            public IdentifierGenerator createIdentifierGenerator(IsisConfiguration configuration) {
-                return mockIdentifierGenerator;
-            };
-        })
+        .with(new InMemoryPersistenceMechanismInstaller())
         .build();