You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/09/11 20:21:46 UTC

[isis] 03/06: ISIS-1976: throw away OA map

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch ISIS-1976-rethink-object-adapters
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 07e3dbb22337d782f8ce980ca2705ee8db6f6158
Author: Andi Huber <ah...@apache.org>
AuthorDate: Tue Sep 11 18:18:01 2018 +0200

    ISIS-1976: throw away OA map
    
    Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
---
 .../system/persistence/PersistenceSession4.java    | 145 ++---------
 .../system/persistence/PersistenceSession5.java    | 129 ++--------
 .../queries/PersistenceQueryProcessorAbstract.java |   3 +-
 .../system/persistence/PersistenceSession.java     |  17 +-
 .../adaptermanager/ObjectAdapterContext.java       | 273 +++++----------------
 .../ObjectAdapterContext_AdapterManager.java       | 135 +---------
 .../ObjectAdapterContext_Consistency.java          | 143 -----------
 .../ObjectAdapterContext_MementoSupport.java       |   8 -
 ...ctAdapterContext_ObjectAdapterByIdProvider.java |  17 +-
 ...ObjectAdapterContext_ObjectAdapterProvider.java |  16 +-
 .../adaptermanager/OidAdapterHashMap.java          | 113 ---------
 .../adaptermanager/PojoAdapterHashMap.java         | 138 -----------
 .../adaptermanager/RootAndCollectionAdapters.java  |   2 +-
 13 files changed, 118 insertions(+), 1021 deletions(-)

diff --git a/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java b/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java
index 346f3a7..78db23d 100644
--- a/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java
+++ b/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java
@@ -459,7 +459,9 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
 
     @Override
     public Object fetchPersistentPojo(final RootOid rootOid) {
-
+        Objects.requireNonNull(rootOid);
+        LOG.debug("getObject; oid={}", rootOid);
+        
         Object result;
         try {
             final Class<?> cls = clsOf(rootOid);
@@ -487,20 +489,8 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         if (result == null) {
             throw new ObjectNotFoundException(rootOid);
         }
-        return result;
-    }
-    
-    @Override
-    public Object fetchPersistentPojoInTransaction(final RootOid oid) {
         
-        Objects.requireNonNull(oid);
-
-        return transactionManager.executeWithinTransaction(()-> {
-            LOG.debug("getObject; oid={}", oid);
-
-            final Object pojo = fetchPersistentPojo(oid);
-            return objectAdapterContext.addRecreatedPojoToCache(oid, pojo).getObject();
-        });
+        return result;
     }
 
     @Override
@@ -576,6 +566,8 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
             debugLogNotPersistentIgnoring(domainObject);
             return; // only resolve object that is representing persistent
         }
+        
+        debugLogRefreshImmediately(domainObject);
 
         try {
             persistenceManager.refresh(domainObject);
@@ -590,21 +582,6 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         initializeMapAndCheckConcurrency((Persistable) domainObject);
     }
     
-    @Override
-    public void refreshRootInTransaction(final Object domainObject) {
-        
-        if(!isRepresentingPersistent(domainObject)) {
-            debugLogNotPersistentIgnoring(domainObject);
-            return; // only resolve object that is representing persistent
-        }
-        
-        getTransactionManager().executeWithinTransaction(()->{
-                debugLogRefreshImmediately(domainObject);
-                refreshRoot(domainObject);
-        });
-    }
-
-    
     // -- makePersistent
 
     /**
@@ -636,7 +613,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         getTransactionManager().executeWithinTransaction(()->{
                 makePersistentTransactionAssumed(adapter);
                 // clear out the map of transient -> persistent
-                // already empty // PersistenceSession4.this.persistentByTransient.clear();
+                // already empty // PersistenceSession5.this.persistentByTransient.clear();
         });
     }
 
@@ -779,76 +756,20 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         servicesInjector.injectInto(pojo);
 
         final Version datastoreVersion = getVersionIfAny(pc);
+        final RootOid originalOid = objectAdapterContext.createPersistentOrViewModelOid(pojo);
 
-        final RootOid originalOid;
-        final ObjectAdapter originalAdapter = objectAdapterContext.lookupAdapterFor(pojo);
-        final ObjectAdapter newAdapter;
-        
-        if (originalAdapter != null) {
-            ensureRootObject(pojo); //[ahuber] while already mapped has no side-effect
-            originalOid = (RootOid) originalAdapter.getOid();
-
-            final Version originalVersion = originalAdapter.getVersion();
-
-            // sync the pojo held by the adapter with that just loaded
-            newAdapter = objectAdapterContext.remapRecreatedPojo(originalAdapter, pojo);
-
-            // since there was already an adapter, do concurrency check
-            // (but don't set abort cause if checking is suppressed through thread-local)
-            final RootOid thisOid = originalOid;
-            final Version thisVersion = originalVersion;
-            final Version otherVersion = datastoreVersion;
-
-            if (    thisVersion != null &&
-                    otherVersion != null &&
-                    thisVersion.different(otherVersion)) {
-
-                if (ConcurrencyChecking.isCurrentlyEnabled()) {
-                    LOG.info("concurrency conflict detected on {} ({})", thisOid, otherVersion);
-                    final String currentUser = authenticationSession.getUserName();
-                    final ConcurrencyException abortCause = new ConcurrencyException(currentUser, thisOid,
-                            thisVersion, otherVersion);
-                    
-                    transactionManager.getCurrentTransaction().setAbortCause(abortCause);
-
-                } else {
-                    LOG.info("concurrency conflict detected but suppressed, on {} ({})", thisOid, otherVersion);
-                }
-            }
-            
-        } else {
-            originalOid = objectAdapterContext.createPersistentOrViewModelOid(pojo);
-
-            ObjectAdapter adapter;
-            
-            // it appears to be possible that there is already an adapter for this Oid,
-            // ie from ObjectStore#resolveImmediately()
-            adapter = objectAdapterContext.lookupAdapterFor(originalOid);
-            if (adapter != null) {
-                adapter = objectAdapterContext.remapRecreatedPojo(adapter, pojo);
-            } else {
-                adapter = objectAdapterContext.addRecreatedPojoToCache(originalOid, pojo);
+        final ObjectAdapter adapter = objectAdapterContext.addRecreatedPojoToCache(originalOid, pojo);
+        adapter.setVersion(datastoreVersion);
 
-                CallbackFacet.Util.callCallback(adapter, LoadedCallbackFacet.class);
-                objectAdapterContext.postLifecycleEventIfRequired(adapter, LoadedLifecycleEventFacet.class);
-            }
-        
-            newAdapter = adapter;
-            
-        }
+        CallbackFacet.Util.callCallback(adapter, LoadedCallbackFacet.class);
+        objectAdapterContext.postLifecycleEventIfRequired(adapter, LoadedLifecycleEventFacet.class);
         
-        newAdapter.setVersion(datastoreVersion);
-        
-        return objectAdapterContext.lookupAdapterFor(pojo);
+        return adapter;
     }
 
     @Override
     public String identifierFor(final Object pojo) {
-        final Object jdoOid = getPersistenceManager().getObjectId(pojo);
-        if(jdoOid==null) {
-            return UUID.randomUUID().toString(); //FIXME[ISIS-1976] should be guarded against somewhere else
-        }
-        
+        final Object jdoOid = pm().getObjectId(pojo);
         requireNonNull(jdoOid, 
                 ()->String.format("Pojo of type '%s' is not recognized by JDO.", 
                         pojo.getClass().getName()));
@@ -866,7 +787,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
      */
     @Override
     public void invokeIsisPersistingCallback(final Persistable pojo) {
-        final ObjectAdapter adapter = objectAdapterContext.lookupAdapterFor(pojo);
+        final ObjectAdapter adapter = null;
         if (adapter == null) {
             // not expected.
             return;
@@ -927,45 +848,17 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
 
     @Override
     public void enlistUpdatingAndInvokeIsisUpdatingCallback(final Persistable pojo) {
-        ObjectAdapter adapter = objectAdapterContext.lookupAdapterFor(pojo);
-        if (adapter == null) {
+        {
             // seen this happen in the case when a parent entity (LeaseItem) has a collection of children
             // objects (LeaseTerm) for which we haven't had a loaded callback fired and so are not yet
             // mapped.
 
             // it seems reasonable in this case to simply map into Isis here ("just-in-time"); presumably
             // DN would not be calling this callback if the pojo was not persistent.
-
-            adapter = objectAdapterContext.addPersistentToCache(pojo);
-            if (adapter == null) {
-                throw new RuntimeException(
-                        "DN could not find objectId for pojo (unexpected) and so could not map into Isis; pojo=["
-                                + pojo + "]");
-            }
-        }
-        if (adapter.isTransient()) {
-            // seen this happen in the case when there's a 1<->m bidirectional collection, and we're
-            // attaching the child object, which is being persisted by DN as a result of persistence-by-reachability,
-            // and it "helpfully" sets up the parent attribute on the child, causing this callback to fire.
-            //
-            // however, at the same time, Isis has only queued up a CreateObjectCommand for the transient object, but it
-            // hasn't yet executed, so thinks that the adapter is still transient.
-            return;
+            throw new RuntimeException(
+                    "DN could not find objectId for pojo (unexpected) and so could not map into Isis; pojo=["
+                            + pojo + "]");
         }
-
-        final boolean wasAlreadyEnlisted = changedObjectsServiceInternal.isEnlisted(adapter);
-
-        // we call this come what may;
-        // additional properties may now have been changed, and the changeKind for publishing might also be modified
-        changedObjectsServiceInternal.enlistUpdating(adapter);
-
-        if(!wasAlreadyEnlisted) {
-            // prevent an infinite loop... don't call the 'updating()' callback on this object if we have already done so
-            CallbackFacet.Util.callCallback(adapter, UpdatingCallbackFacet.class);
-            objectAdapterContext.postLifecycleEventIfRequired(adapter, UpdatingLifecycleEventFacet.class);
-        }
-
-        ensureRootObject(pojo);
     }
 
     /**
diff --git a/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java b/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java
index bd20ea0..a63cb94 100644
--- a/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java
+++ b/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java
@@ -459,7 +459,9 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
 
     @Override
     public Object fetchPersistentPojo(final RootOid rootOid) {
-
+        Objects.requireNonNull(rootOid);
+        LOG.debug("getObject; oid={}", rootOid);
+        
         Object result;
         try {
             final Class<?> cls = clsOf(rootOid);
@@ -487,20 +489,8 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         if (result == null) {
             throw new ObjectNotFoundException(rootOid);
         }
-        return result;
-    }
-    
-    @Override
-    public Object fetchPersistentPojoInTransaction(final RootOid oid) {
         
-        Objects.requireNonNull(oid);
-
-        return transactionManager.executeWithinTransaction(()-> {
-            LOG.debug("getObject; oid={}", oid);
-
-            final Object pojo = fetchPersistentPojo(oid);
-            return objectAdapterContext.addRecreatedPojoToCache(oid, pojo).getObject();
-        });
+        return result;
     }
 
     @Override
@@ -576,6 +566,8 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
             debugLogNotPersistentIgnoring(domainObject);
             return; // only resolve object that is representing persistent
         }
+        
+        debugLogRefreshImmediately(domainObject);
 
         try {
             persistenceManager.refresh(domainObject);
@@ -590,21 +582,6 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         initializeMapAndCheckConcurrency((Persistable) domainObject);
     }
     
-    @Override
-    public void refreshRootInTransaction(final Object domainObject) {
-        
-        if(!isRepresentingPersistent(domainObject)) {
-            debugLogNotPersistentIgnoring(domainObject);
-            return; // only resolve object that is representing persistent
-        }
-        
-        getTransactionManager().executeWithinTransaction(()->{
-                debugLogRefreshImmediately(domainObject);
-                refreshRoot(domainObject);
-        });
-    }
-
-    
     // -- makePersistent
 
     /**
@@ -779,67 +756,15 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         servicesInjector.injectInto(pojo);
 
         final Version datastoreVersion = getVersionIfAny(pc);
+        final RootOid originalOid = objectAdapterContext.createPersistentOrViewModelOid(pojo);
 
-        final RootOid originalOid;
-        final ObjectAdapter originalAdapter = objectAdapterContext.lookupAdapterFor(pojo);
-        final ObjectAdapter newAdapter;
-        
-        if (originalAdapter != null) {
-            ensureRootObject(pojo); //[ahuber] while already mapped has no side-effect
-            originalOid = (RootOid) originalAdapter.getOid();
-
-            final Version originalVersion = originalAdapter.getVersion();
-
-            // sync the pojo held by the adapter with that just loaded
-            newAdapter = objectAdapterContext.remapRecreatedPojo(originalAdapter, pojo);
-
-            // since there was already an adapter, do concurrency check
-            // (but don't set abort cause if checking is suppressed through thread-local)
-            final RootOid thisOid = originalOid;
-            final Version thisVersion = originalVersion;
-            final Version otherVersion = datastoreVersion;
-
-            if (    thisVersion != null &&
-                    otherVersion != null &&
-                    thisVersion.different(otherVersion)) {
-
-                if (ConcurrencyChecking.isCurrentlyEnabled()) {
-                    LOG.info("concurrency conflict detected on {} ({})", thisOid, otherVersion);
-                    final String currentUser = authenticationSession.getUserName();
-                    final ConcurrencyException abortCause = new ConcurrencyException(currentUser, thisOid,
-                            thisVersion, otherVersion);
-                    
-                    transactionManager.getCurrentTransaction().setAbortCause(abortCause);
-
-                } else {
-                    LOG.info("concurrency conflict detected but suppressed, on {} ({})", thisOid, otherVersion);
-                }
-            }
-            
-        } else {
-            originalOid = objectAdapterContext.createPersistentOrViewModelOid(pojo);
-
-            ObjectAdapter adapter;
-            
-            // it appears to be possible that there is already an adapter for this Oid,
-            // ie from ObjectStore#resolveImmediately()
-            adapter = objectAdapterContext.lookupAdapterFor(originalOid);
-            if (adapter != null) {
-                adapter = objectAdapterContext.remapRecreatedPojo(adapter, pojo);
-            } else {
-                adapter = objectAdapterContext.addRecreatedPojoToCache(originalOid, pojo);
+        final ObjectAdapter adapter = objectAdapterContext.addRecreatedPojoToCache(originalOid, pojo);
+        adapter.setVersion(datastoreVersion);
 
-                CallbackFacet.Util.callCallback(adapter, LoadedCallbackFacet.class);
-                objectAdapterContext.postLifecycleEventIfRequired(adapter, LoadedLifecycleEventFacet.class);
-            }
-        
-            newAdapter = adapter;
-            
-        }
-        
-        newAdapter.setVersion(datastoreVersion);
+        CallbackFacet.Util.callCallback(adapter, LoadedCallbackFacet.class);
+        objectAdapterContext.postLifecycleEventIfRequired(adapter, LoadedLifecycleEventFacet.class);
         
-        return objectAdapterContext.lookupAdapterFor(pojo);
+        return adapter;
     }
 
     @Override
@@ -862,7 +787,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
      */
     @Override
     public void invokeIsisPersistingCallback(final Persistable pojo) {
-        final ObjectAdapter adapter = objectAdapterContext.lookupAdapterFor(pojo);
+        final ObjectAdapter adapter = null;
         if (adapter == null) {
             // not expected.
             return;
@@ -923,8 +848,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
 
     @Override
     public void enlistUpdatingAndInvokeIsisUpdatingCallback(final Persistable pojo) {
-        ObjectAdapter adapter = objectAdapterContext.lookupAdapterFor(pojo);
-        if (adapter == null) {
+        {
             // seen this happen in the case when a parent entity (LeaseItem) has a collection of children
             // objects (LeaseTerm) for which we haven't had a loaded callback fired and so are not yet
             // mapped.
@@ -932,36 +856,13 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
             // it seems reasonable in this case to simply map into Isis here ("just-in-time"); presumably
             // DN would not be calling this callback if the pojo was not persistent.
 
-            adapter = objectAdapterContext.addPersistentToCache(pojo);
+            final ObjectAdapter adapter = objectAdapterContext.addPersistentToCache(pojo);
             if (adapter == null) {
                 throw new RuntimeException(
                         "DN could not find objectId for pojo (unexpected) and so could not map into Isis; pojo=["
                                 + pojo + "]");
             }
         }
-        if (adapter.isTransient()) {
-            // seen this happen in the case when there's a 1<->m bidirectional collection, and we're
-            // attaching the child object, which is being persisted by DN as a result of persistence-by-reachability,
-            // and it "helpfully" sets up the parent attribute on the child, causing this callback to fire.
-            //
-            // however, at the same time, Isis has only queued up a CreateObjectCommand for the transient object, but it
-            // hasn't yet executed, so thinks that the adapter is still transient.
-            return;
-        }
-
-        final boolean wasAlreadyEnlisted = changedObjectsServiceInternal.isEnlisted(adapter);
-
-        // we call this come what may;
-        // additional properties may now have been changed, and the changeKind for publishing might also be modified
-        changedObjectsServiceInternal.enlistUpdating(adapter);
-
-        if(!wasAlreadyEnlisted) {
-            // prevent an infinite loop... don't call the 'updating()' callback on this object if we have already done so
-            CallbackFacet.Util.callCallback(adapter, UpdatingCallbackFacet.class);
-            objectAdapterContext.postLifecycleEventIfRequired(adapter, UpdatingLifecycleEventFacet.class);
-        }
-
-        ensureRootObject(pojo);
     }
 
     /**
diff --git a/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java b/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
index def59fd..0c0f2a3 100644
--- a/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
+++ b/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
@@ -56,11 +56,12 @@ implements PersistenceQueryProcessor<T> {
             if(pojo instanceof Persistable) {
                 // an entity
                 adapter = persistenceSession.initializeMapAndCheckConcurrency((Persistable) pojo);
+                Assert.assertNotNull(adapter);
             } else {
                 // a value type
                 adapter = persistenceSession.adapterFor(pojo);
+                Assert.assertNotNull(adapter);
             }
-            Assert.assertNotNull(adapter);
             adapters.add(adapter);
         }
         return adapters;
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 62dbb6b..7a8a0e5 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
@@ -27,7 +27,6 @@ import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapterByIdProvider;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapterProvider;
-import org.apache.isis.core.metamodel.adapter.oid.ParentedCollectionOid;
 import org.apache.isis.core.metamodel.adapter.oid.RootOid;
 import org.apache.isis.core.metamodel.services.ServicesInjector;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
@@ -69,8 +68,9 @@ extends
      * mechanism and be used to set up the value objects and associations.
      * @since 2.0.0-M2
      */
-    void refreshRootInTransaction(Object domainObject);
-    
+    default void refreshRootInTransaction(final Object domainObject) {
+        getTransactionManager().executeWithinTransaction(()->refreshRoot(domainObject));
+    }
     
     /**
      * @param pojo a persistable object
@@ -88,10 +88,15 @@ extends
     /** whether pojo is recognized by the persistence layer, that is, it has an ObjectId
      * @since 2.0.0-M2*/
     boolean isRecognized(Object pojo);
+    
     /**@since 2.0.0-M2*/
     Object fetchPersistentPojo(RootOid rootOid);
+    
     /**@since 2.0.0-M2*/
-    Object fetchPersistentPojoInTransaction(final RootOid oid);
+    default Object fetchPersistentPojoInTransaction(final RootOid oid) {
+        return getTransactionManager().executeWithinTransaction(()->fetchPersistentPojo(oid));
+    }
+    
     /**@since 2.0.0-M2*/
     Map<RootOid, Object> fetchPersistentPojos(List<RootOid> rootOids);
     
@@ -163,11 +168,9 @@ extends
     // -- TODO remove ObjectAdapter references from API
     
     <T> List<ObjectAdapter> allMatchingQuery(final Query<T> query);
-
-    void destroyObjectInTransaction(ObjectAdapter adapter);
-
     <T> ObjectAdapter firstMatchingQuery(final Query<T> query);
     
+    void destroyObjectInTransaction(ObjectAdapter adapter);
     void makePersistentInTransaction(ObjectAdapter adapter);
     
     // -- OTHERS
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext.java
index 19df8fa..7ef6a12 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext.java
@@ -52,9 +52,9 @@ import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
  * @since 2.0.0-M2
  */
 final public class ObjectAdapterContext {
-    
+
     private static final Logger LOG = LoggerFactory.getLogger(ObjectAdapterContext.class);
-    
+
     public static ObjectAdapterContext openContext(
             ServicesInjector servicesInjector, 
             AuthenticationSession authenticationSession, 
@@ -66,68 +66,9 @@ final public class ObjectAdapterContext {
         objectAdapterContext.open();
         return objectAdapterContext;
     }
-    
-    private final static class Cache {
-        private final PojoAdapterHashMap pojoAdapterMap = new PojoAdapterHashMap();
-        private final OidAdapterHashMap oidAdapterMap = new OidAdapterHashMap();
-        
-        public void open() {
-            oidAdapterMap.open();
-            pojoAdapterMap.open();
-        }
-        
-        public void close() {
-            
-            try {
-                oidAdapterMap.close();
-            } catch(final Throwable ex) {
-                // ignore
-                LOG.error("close: oidAdapterMap#close() failed; continuing to avoid memory leakage");
-            }
 
-            try {
-                pojoAdapterMap.close();
-            } catch(final Throwable ex) {
-                // ignore
-                LOG.error("close: pojoAdapterMap#close() failed; continuing to avoid memory leakage");
-            }
-        }
-        
-        private ObjectAdapter lookupAdapterByPojo(Object pojo) {
-            final ObjectAdapter adapter = pojoAdapterMap.getAdapter(pojo);
-            return adapter;
-        }
-        
-        private ObjectAdapter lookupAdapterById(Oid oid) {
-            return oidAdapterMap.getAdapter(oid);
-        }
-        
-        private void addAdapter(ObjectAdapter adapter) {
-            if(adapter==null) {
-                return; // nothing to do
-            }
-            final Oid oid = adapter.getOid();
-            oidAdapterMap.add(oid, adapter);
-            pojoAdapterMap.add(adapter.getObject(), adapter);
-        }
-        
-        private void removeAdapter(ObjectAdapter adapter) {
-            if(adapter==null) {
-                return; // nothing to do
-            }
-            final Oid oid = adapter.getOid();
-            oidAdapterMap.remove(oid);
-            pojoAdapterMap.remove(adapter);
-        }
-        
-    }
-    
-    private final Cache cache = new Cache();
-    
     private final PersistenceSession persistenceSession; 
-    private final ServicesInjector servicesInjector;
     private final SpecificationLoader specificationLoader;
-    private final ObjectAdapterContext_Consistency consistencyMixin;
     private final ObjectAdapterContext_ObjectAdapterProvider objectAdapterProviderMixin;
     private final ObjectAdapterContext_AdapterManager adapterManagerMixin;
     private final ObjectAdapterContext_MementoSupport mementoSupportMixin;
@@ -137,14 +78,13 @@ final public class ObjectAdapterContext {
     private final ObjectAdapterContext_DependencyInjection dependencyInjectionMixin;
     final ObjectAdapterContext_ObjectCreation objectCreationMixin;
     private final ObjectAdapterContext_LifecycleEventSupport lifecycleEventMixin;
-    
+
     private ObjectAdapterContext(
             ServicesInjector servicesInjector, 
             AuthenticationSession authenticationSession, 
             SpecificationLoader specificationLoader, 
             PersistenceSession persistenceSession) {
-        
-        this.consistencyMixin = new ObjectAdapterContext_Consistency(this);
+
         this.objectAdapterProviderMixin = new ObjectAdapterContext_ObjectAdapterProvider(this, persistenceSession);
         this.adapterManagerMixin = new ObjectAdapterContext_AdapterManager(this, persistenceSession);
         this.mementoSupportMixin = new ObjectAdapterContext_MementoSupport(this, persistenceSession);
@@ -154,11 +94,10 @@ final public class ObjectAdapterContext {
         this.dependencyInjectionMixin = new ObjectAdapterContext_DependencyInjection(this, persistenceSession);
         this.objectCreationMixin = new ObjectAdapterContext_ObjectCreation(this, persistenceSession);
         this.lifecycleEventMixin = new ObjectAdapterContext_LifecycleEventSupport(this, persistenceSession);
-        
+
         this.persistenceSession = persistenceSession;
-        this.servicesInjector = servicesInjector;
         this.specificationLoader = specificationLoader;
-        
+
         this.objectAdapterFactories = new ObjectAdapterContext_Factories(
                 authenticationSession, 
                 specificationLoader, 
@@ -166,7 +105,7 @@ final public class ObjectAdapterContext {
     }
 
     // -- DEBUG
-    
+
     void printContextInfo(String msg) {
         if(LOG.isDebugEnabled()) {
             String id = Integer.toHexString(this.hashCode());
@@ -174,91 +113,46 @@ final public class ObjectAdapterContext {
             LOG.debug(String.format("%s id=%s session='%s'", msg, id, session));
         }
     }
-    
+
     // -- LIFE-CYCLING
-    
+
     public void open() {
         printContextInfo("OPEN_");
-        cache.open();
     }
-    
+
     public void close() {
-        cache.close();
         printContextInfo("CLOSE");
     }
-    
-    // -- CACHING POJO
 
-    // package private // don't expose caching
-    ObjectAdapter lookupAdapterByPojo(Object pojo) {
-        return cache.lookupAdapterByPojo(pojo);
-    }
-    
-    // package private // don't expose caching
-    boolean containsAdapterForPojo(Object pojo) {
-        return lookupAdapterByPojo(pojo)!=null;
-    }
-    
-    // -- CACHING OID
-    
-    // package private // don't expose caching
-    ObjectAdapter lookupAdapterById(Oid oid) {
-        return cache.lookupAdapterById(oid);
-    }
-    
-    // -- CACHING BOTH
-
-    // package private // don't expose caching
-    void addAdapter(ObjectAdapter adapter) {
-        cache.addAdapter(adapter);
-    }
-    
-    // package private // don't expose caching
-    void removeAdapter(ObjectAdapter adapter) {
-        cache.removeAdapter(adapter);
-    }
-    
-    // -- CACHE CONSISTENCY
-    
-    // package private // don't expose caching
-    void ensureMapsConsistent(final ObjectAdapter adapter) {
-        consistencyMixin.ensureMapsConsistent(adapter);
-    }
-
-    // package private // don't expose caching
-    void ensureMapsConsistent(final Oid oid) {
-        consistencyMixin.ensureMapsConsistent(oid);
-    }
-    
     // -- NEW IDENTIFIER
-    
+
     public RootOid createPersistentOrViewModelOid(Object pojo) {
         return newIdentifierMixin.createPersistentOid(pojo);
     }
-    
+
     // -- SERVICE LOOKUP
-    
+
     public ObjectAdapter lookupServiceAdapterFor(RootOid rootOid) {
         return serviceLookupMixin.lookupServiceAdapterFor(rootOid);
     }
-    
+
     // -- BY-ID SUPPORT
-    
+
     public ObjectAdapterByIdProvider getObjectAdapterByIdProvider() {
         return objectAdapterByIdProviderMixin;
     }
-    
+
     // -- DEPENDENCY INJECTION
-    
+
     public Object instantiateAndInjectServices(ObjectSpecification objectSpec) {
         return dependencyInjectionMixin.instantiateAndInjectServices(objectSpec);
     }
-    
+
     // -- FACTORIES
-    
+
     // package private
     static interface ObjectAdapterFactories {
-        
+
         /**
          * Creates (but does not {@link #mapAndInjectServices(ObjectAdapter) map}) a new
          * root {@link ObjectAdapter adapter} for the supplied domain object.
@@ -267,7 +161,7 @@ final public class ObjectAdapterContext {
          * @see #createCollectionAdapter(Object, ParentedCollectionOid)
          */
         ObjectAdapter createRootAdapter(Object pojo, RootOid rootOid);
-        
+
         ObjectAdapter createCollectionAdapter(Object pojo, ParentedCollectionOid collectionOid);
 
         /**
@@ -284,104 +178,77 @@ final public class ObjectAdapterContext {
          */
         ObjectAdapter createCollectionAdapter(Object pojo, ObjectAdapter parentAdapter, OneToManyAssociation otma);
     }
-    
+
     private final ObjectAdapterFactories objectAdapterFactories;
-    
+
     // package private
     ObjectAdapterFactories getFactories() {
         return objectAdapterFactories;
     }
-    
+
     // -- ADAPTER MANAGER LEGACY
-    
+
     @Deprecated // don't expose caching
     public ObjectAdapter addRecreatedPojoToCache(Oid oid, Object recreatedPojo) {
         return adapterManagerMixin.addRecreatedPojoToCache(oid, recreatedPojo);
     }
-    
-    @Deprecated // don't expose caching
-    public ObjectAdapter mapAndInjectServices(final ObjectAdapter adapter) {
-        return adapterManagerMixin.mapAndInjectServices(adapter);
-    }
-    
-    @Deprecated // don't expose caching
-    public ObjectAdapter lookupAdapterFor(Object pojo) {
-        return adapterManagerMixin.lookupAdapterFor(pojo);
-    }
-    
-    @Deprecated // don't expose caching
-    public ObjectAdapter lookupAdapterFor(final Oid oid) {
-        Objects.requireNonNull(oid);
-        consistencyMixin.ensureMapsConsistent(oid);
-        return cache.lookupAdapterById(oid);
-    }
-    
-    // package private
-    ObjectAdapter lookupParentedCollectionAdapter(ParentedCollectionOid collectionOid) {
-        Objects.requireNonNull(collectionOid);
-        consistencyMixin.ensureMapsConsistent(collectionOid);
-        return cache.lookupAdapterById(collectionOid);
-    }
-    
-    // package private // don't expose caching
-    void removeAdapterFromCache(final ObjectAdapter adapter) {
-        adapterManagerMixin.removeAdapterFromCache(adapter);
+
+    @Deprecated
+    public ObjectAdapter injectServices(final ObjectAdapter adapter) {
+        return adapterManagerMixin.injectServices(adapter);
     }
     
     @Deprecated // don't expose caching
     public ObjectAdapter addPersistentToCache(final Object pojo) {
         return objectAdapterProviderMixin.addPersistentToCache(pojo);
     }
-    
+
     // -- OBJECT ADAPTER PROVIDER SUPPORT
-    
+
     public ObjectAdapterProvider getObjectAdapterProvider() {
         return objectAdapterProviderMixin;
     }
-    
+
     // -- MEMENTO SUPPORT
-    
+
     public static interface MementoRecreateObjectSupport {
         ObjectAdapter recreateObject(ObjectSpecification spec, Oid oid, Data data);
     }
-    
+
     public MementoRecreateObjectSupport mementoSupport() {
         return mementoSupportMixin;
     }
-    
+
     // -- LIFECYCLE EVENT SUPPORT
-    
+
     public void postLifecycleEventIfRequired(
             final ObjectAdapter adapter,
             final Class<? extends LifecycleEventFacet> lifecycleEventFacetClass) {
         lifecycleEventMixin.postLifecycleEventIfRequired(adapter, lifecycleEventFacetClass);
     }
-    
+
     // ------------------------------------------------------------------------------------------------
-    
+
     public ObjectAdapter disposableAdapterForViewModel(Object viewModelPojo) {
-            final ObjectSpecification objectSpecification = 
-                    specificationLoader.loadSpecification(viewModelPojo.getClass());
-            final ObjectSpecId objectSpecId = objectSpecification.getSpecId();
-            final RootOid newRootOid = RootOid.create(objectSpecId, UUID.randomUUID().toString());
-            final ObjectAdapter createdAdapter = adapterManagerMixin.createRootOrAggregatedAdapter(newRootOid, viewModelPojo);
-            return createdAdapter;
+        final ObjectSpecification objectSpecification = 
+                specificationLoader.loadSpecification(viewModelPojo.getClass());
+        final ObjectSpecId objectSpecId = objectSpecification.getSpecId();
+        final RootOid newRootOid = RootOid.create(objectSpecId, UUID.randomUUID().toString());
+        final ObjectAdapter createdAdapter = adapterManagerMixin.createRootOrAggregatedAdapter(newRootOid, viewModelPojo);
+        return createdAdapter;
     }
-    
+
     // package private
     ObjectAdapter adapterForViewModel(Object viewModelPojo, Function<ObjectSpecId, RootOid> rootOidFactory) {
-        ObjectAdapter viewModelAdapter = adapterManagerMixin.lookupAdapterFor(viewModelPojo);
-        if(viewModelAdapter == null) {
-            final ObjectSpecification objectSpecification = 
-                    specificationLoader.loadSpecification(viewModelPojo.getClass());
-            final ObjectSpecId objectSpecId = objectSpecification.getSpecId();
-            final RootOid newRootOid = rootOidFactory.apply(objectSpecId);
-
-            viewModelAdapter = adapterManagerMixin.addRecreatedPojoToCache(newRootOid, viewModelPojo);
-        }
+        final ObjectSpecification objectSpecification = 
+                specificationLoader.loadSpecification(viewModelPojo.getClass());
+        final ObjectSpecId objectSpecId = objectSpecification.getSpecId();
+        final RootOid newRootOid = rootOidFactory.apply(objectSpecId);
+
+        final ObjectAdapter viewModelAdapter = adapterManagerMixin.addRecreatedPojoToCache(newRootOid, viewModelPojo);
         return viewModelAdapter;
     }
-    
+
     /**
      * Note that there is no management of {@link Version}s here. That is
      * because the {@link PersistenceSession} is expected to manage this.
@@ -394,14 +261,12 @@ final public class ObjectAdapterContext {
 
         Objects.requireNonNull(newRootOid);
         Assert.assertFalse("expected to not be a parented collection", rootAdapter.isParentedCollection());
-        
+
         final RootOid transientRootOid = (RootOid) rootAdapter.getOid();
-        
+
         final RootAndCollectionAdapters rootAndCollectionAdapters = 
                 new RootAndCollectionAdapters(rootAdapter, this);
 
-        removeFromCache(rootAndCollectionAdapters);
-        
         final RootOid persistedRootOid;
         {
             if(newRootOid.isTransient()) {
@@ -421,10 +286,10 @@ final public class ObjectAdapterContext {
         if (LOG.isDebugEnabled()) {
             LOG.debug("replacing root adapter and re-adding into maps; oid is now: {} (was: {})", persistedRootOid.enString(), transientRootOid.enString());
         }
-        
+
         final ObjectAdapter adapterReplacement = rootAdapter.withOid(persistedRootOid); 
         replaceRootAdapter(adapterReplacement, rootAndCollectionAdapters);
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("made persistent {}; was {}", adapterReplacement, transientRootOid);
         }
@@ -433,20 +298,17 @@ final public class ObjectAdapterContext {
     private void replaceRootAdapter(
             final ObjectAdapter adapterReplacement, 
             final RootAndCollectionAdapters rootAndCollectionAdapters) {
-        
-        addAdapter(adapterReplacement);
-        
+
         final RootOid persistedRootOid = (RootOid) adapterReplacement.getOid();
-        
+
         // associate the collection adapters with new Oids, and re-map
         LOG.debug("replacing Oids for collection adapter(s) and re-adding into maps");
-        
+
         rootAndCollectionAdapters.stream()
         .forEach(collectionAdapter->{
             final ParentedCollectionOid previousCollectionOid = (ParentedCollectionOid) collectionAdapter.getOid();
             final ParentedCollectionOid persistedCollectionOid = previousCollectionOid.asPersistent(persistedRootOid);
             Assert.assertTrue("expected equal", Objects.equals(collectionAdapter.getOid(), persistedCollectionOid));
-            addAdapter(collectionAdapter);
         });
 
         // some object store implementations may replace collection instances (eg ORM may replace with a cglib-enhanced
@@ -460,25 +322,12 @@ final public class ObjectAdapterContext {
             final Object collectionPojoActuallyOnPojo = getCollectionPojo(otma, adapterReplacement);
 
             if (collectionPojoActuallyOnPojo != collectionPojoWrappedByAdapter) {
-                cache.removeAdapter(collectionAdapter);
                 final ObjectAdapter newCollectionAdapter = collectionAdapter.withPojo(collectionPojoActuallyOnPojo);
                 Assert.assertTrue("expected same", 
                         Objects.equals(newCollectionAdapter.getObject(), collectionPojoActuallyOnPojo));
-                cache.addAdapter(collectionAdapter);
             }
         });
-        
-    }
 
-    private void removeFromCache(final RootAndCollectionAdapters rootAndCollectionAdapters) {
-        final ObjectAdapter rootAdapter = rootAndCollectionAdapters.getRootAdapter();
-        
-        LOG.debug("removing root adapter from oid map");
-        cache.removeAdapter(rootAdapter);
-    
-        LOG.debug("removing collection adapter(s) from oid map");
-        rootAndCollectionAdapters.stream()
-        .forEach(cache::removeAdapter);
     }
 
     private static Object getCollectionPojo(final OneToManyAssociation association, final ObjectAdapter ownerAdapter) {
@@ -489,9 +338,7 @@ final public class ObjectAdapterContext {
     @Deprecated
     public ObjectAdapter remapRecreatedPojo(ObjectAdapter adapter, final Object pojo) {
         final ObjectAdapter newAdapter = adapter.withPojo(pojo);
-        cache.removeAdapter(adapter);
-        cache.removeAdapter(newAdapter);
-        mapAndInjectServices(newAdapter);
+        injectServices(newAdapter);
         return newAdapter;
     }
 
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_AdapterManager.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_AdapterManager.java
index fc50a81..0dfb93f 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_AdapterManager.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_AdapterManager.java
@@ -20,11 +20,6 @@ package org.apache.isis.core.runtime.system.persistence.adaptermanager;
 
 import java.util.Objects;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.commons.internal.exceptions._Exceptions;
-import org.apache.isis.core.commons.ensure.Assert;
 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.ParentedCollectionOid;
@@ -42,7 +37,6 @@ import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
  */
 class ObjectAdapterContext_AdapterManager {
     
-    private static final Logger LOG = LoggerFactory.getLogger(ObjectAdapterContext_AdapterManager.class);
     private final ObjectAdapterContext objectAdapterContext;
     @SuppressWarnings("unused")
     private final PersistenceSession persistenceSession;
@@ -55,140 +49,15 @@ class ObjectAdapterContext_AdapterManager {
         this.servicesInjector = persistenceSession.getServicesInjector();
     }
     
-    /**
-     * Either returns an existing {@link ObjectAdapter adapter} (as per
-     * {@link #lookupAdapterFor(Object)} or {@link #lookupAdapterFor(Oid)}), otherwise
-     * re-creates an adapter with the specified (persistent) {@link Oid}.
-     *
-     * <p>
-     * Typically called when the {@link Oid} is already known, that is, when
-     * resolving an already-persisted object. Is also available for
-     * <tt>Memento</tt> support however, so {@link Oid} could also represent a
-     * {@link Oid#isTransient() transient} object.
-     *
-     * @param oid
-     * @param recreatedPojo - already known to the object store impl, or a service
-     */
-    //@Override
     ObjectAdapter addRecreatedPojoToCache(Oid oid, Object recreatedPojo) {
-        // attempt to locate adapter for the pojo
-        final ObjectAdapter adapterLookedUpByPojo = lookupAdapterFor(recreatedPojo);
-        if (adapterLookedUpByPojo != null) {
-            return adapterLookedUpByPojo;
-        }
-
-        // attempt to locate adapter for the Oid
-        final ObjectAdapter adapterLookedUpByOid = lookupAdapterFor(oid);
-        if (adapterLookedUpByOid != null) {
-            _Exceptions.throwUnexpectedCodeReach();
-            return adapterLookedUpByOid;
-        }
-
         final ObjectAdapter createdAdapter = createRootOrAggregatedAdapter(oid, recreatedPojo);
-        return mapAndInjectServices(createdAdapter);
-    }
-
-    /**
-     * Removes the specified object from both the identity-adapter map, and the
-     * pojo-adapter map.
-     *
-     * <p>
-     * This indicates that the object is no longer in use, and therefore that no
-     * objects exists within the system.
-     *
-     * <p>
-     * If an {@link ObjectAdapter adapter} is removed while its pojo still is
-     * referenced then a subsequent interaction of that pojo will create a
-     * different {@link ObjectAdapter adapter}.
-     *
-     * <p>
-     * TODO: should do a cascade remove of any aggregated objects.
-     */
-    //@Override
-    void removeAdapterFromCache(final ObjectAdapter adapter) {
-        objectAdapterContext.ensureMapsConsistent(adapter);
-        objectAdapterContext.removeAdapter(adapter);
+        return injectServices(createdAdapter);
     }
 
-    /**
-     * Gets the {@link ObjectAdapter adapter} for the specified domain object if
-     * it exists in the identity map.
-     *
-     * <p>
-     * Provided by the <tt>AdapterManager</tt> when used by framework.
-     *
-     * @param pojo
-     *            - must not be <tt>null</tt>
-     * @return adapter, or <tt>null</tt> if doesn't exist.
-     * @deprecated don't expose caching
-     */
-    //@Override
-    ObjectAdapter lookupAdapterFor(final Object pojo) {
-        Objects.requireNonNull(pojo);
-
-        return objectAdapterContext.lookupAdapterByPojo(pojo);  
-    }
-
-    ObjectAdapter mapAndInjectServices(final ObjectAdapter adapter) {
-        // since the whole point of this method is to map an adapter that's just been created.
-        // so we *don't* call ensureMapsConsistent(adapter);
-
-        final Object pojo = adapter.getObject();
-        Assert.assertFalse("POJO Map already contains object", pojo, objectAdapterContext.containsAdapterForPojo(pojo));
-
-        if (LOG.isDebugEnabled()) {
-            // don't interact with the underlying object because may be a ghost
-            // and would trigger a resolve
-            // don't call toString() on adapter because calls hashCode on
-            // underlying object, may also trigger a resolve.
-            LOG.debug("adding identity for adapter with oid={}", adapter.getOid());
-        }
-
-        // value adapters are not mapped (but all others - root and aggregated adapters - are)
-        if (adapter.isValue()) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("not mapping value adapter");
-            }
-            servicesInjector.injectServicesInto(pojo);
-            return adapter;
-        }
-
-        Assert.assertTrue("expected same", Objects.equals(adapter.getObject(), pojo));
-        objectAdapterContext.addAdapter(adapter);
-
-        // must inject after mapping, otherwise infinite loop
-        servicesInjector.injectServicesInto(pojo);
-
-        return adapter;
-    }
-    
     ObjectAdapter injectServices(final ObjectAdapter adapter) {
-        // since the whole point of this method is to map an adapter that's just been created.
-        // so we *don't* call ensureMapsConsistent(adapter);
-
-        Assert.assertNotNull(adapter);
+        Objects.requireNonNull(adapter);
         final Object pojo = adapter.getObject();
-
-        if (LOG.isDebugEnabled()) {
-            // don't interact with the underlying object because may be a ghost
-            // and would trigger a resolve
-            // don't call toString() on adapter because calls hashCode on
-            // underlying object, may also trigger a resolve.
-            LOG.debug("adding identity for adapter with oid={}", adapter.getOid());
-        }
-
-        // value adapters are not mapped (but all others - root and aggregated adapters - are)
-        if (adapter.isValue()) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("not mapping value adapter");
-            }
-            servicesInjector.injectServicesInto(pojo);
-            return adapter;
-        }
-
-        // must inject after mapping, otherwise infinite loop
         servicesInjector.injectServicesInto(pojo);
-
         return adapter;
     }
     
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_Consistency.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_Consistency.java
deleted file mode 100644
index 2f26bff..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_Consistency.java
+++ /dev/null
@@ -1,143 +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.system.persistence.adaptermanager;
-
-import static org.apache.isis.commons.internal.functions._Predicates.equalTo;
-import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
-
-import java.util.Objects;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-
-/**
- * package private mixin for ObjectAdapterContext
- * <p>
- * Responsibility: ObjectAdapter Cache/Map consistency
- * </p> 
- * @since 2.0.0-M2
- * @deprecated expected to be made obsolete
- */
-class ObjectAdapterContext_Consistency {
-    
-    @SuppressWarnings("unused")
-    private static final Logger LOG = LoggerFactory.getLogger(ObjectAdapterContext_Consistency.class);
-    private final ObjectAdapterContext objectAdapterContext;
-    
-    ObjectAdapterContext_Consistency(ObjectAdapterContext objectAdapterContext) {
-        this.objectAdapterContext = objectAdapterContext;
-    }
-
-    /**
-     * Fail early if any problems.
-     */
-    void ensureMapsConsistent(final ObjectAdapter adapter) {
-        if (adapter.isValue()) {
-            return;
-        }
-        if (adapter.isParentedCollection()) {
-            return;
-        }
-        ensurePojoAdapterMapConsistent(adapter);
-        ensureOidAdapterMapConsistent(adapter);
-    }
-
-    /**
-     * Fail early if any problems.
-     */
-    void ensureMapsConsistent(final Oid oid) {
-        Objects.requireNonNull(oid);
-
-        final ObjectAdapter adapter = objectAdapterContext.lookupAdapterById(oid);
-        if (adapter == null) {
-            return;
-        }
-        ensureOidAdapterMapConsistent(adapter);
-        ensurePojoAdapterMapConsistent(adapter);
-    }
-
-    private void ensurePojoAdapterMapConsistent(final ObjectAdapter adapter) {
-        final Object adapterPojo = adapter.getObject();
-        final ObjectAdapter adapterAccordingToMap = objectAdapterContext.lookupAdapterByPojo(adapterPojo);
-
-        if(adapterPojo == null) {
-            // nothing to check
-            return;
-        }
-        ensureMapConsistent(adapter, adapterAccordingToMap, "PojoAdapterMap");
-    }
-
-    private void ensureOidAdapterMapConsistent(final ObjectAdapter adapter) {
-        final Oid adapterOid = adapter.getOid();
-        final ObjectAdapter adapterAccordingToMap = objectAdapterContext.lookupAdapterById(adapterOid);
-
-        if(adapterOid == null) {
-            // nothing to check
-            return;
-        }
-        ensureMapConsistent(adapter, adapterAccordingToMap, "OidAdapterMap");
-    }
-
-    private void ensureMapConsistent(
-            final ObjectAdapter adapter,
-            final ObjectAdapter adapterAccordingToMap,
-            final String mapName) {
-
-        final Oid adapterOid = adapter.getOid();
-
-        // take care not to touch the pojo, since it might have been deleted.
-
-        if(adapterAccordingToMap == null) {
-            throw new IllegalStateException("mismatch in "
-                    + mapName
-                    + ": provided adapter's OID: " + adapterOid + "; but no adapter found in map");
-        }
-
-        ensureThatArg(
-                adapterOid, equalTo(adapterAccordingToMap.getOid()),
-                ()->"mismatch in "
-                        + mapName
-                        + ": provided adapter's OID: " + adapterOid + ", \n"
-                        + "but map's adapter's OID was: " + adapterAccordingToMap.getOid());
-        
-        ensureThatArg(
-                adapter.getObject(), equalTo(adapterAccordingToMap.getObject()),
-                ()->String.format("mismatch in %s (oid='%s')"
-                        + ": provided adapter's hash: %s (pojo='%s'), \n"
-                        + "but map's adapter's hash was: %s (pojo='%s')",
-                        mapName, adapterOid,
-                        Integer.toHexString(adapter.hashCode()), ""+adapter.getObject(),
-                        Integer.toHexString(adapterAccordingToMap.hashCode()), ""+adapterAccordingToMap.getObject()
-                        ));
-
-//      TODO[ISIS-1976] too strict, remove        
-//        ensureThatArg(
-//                adapter, equalTo(adapterAccordingToMap),
-//                ()->String.format("mismatch in %s (oid='%s')"
-//                        + ": provided adapter's hash: %s (pojo='%s'), \n"
-//                        + "but map's adapter's hash was: %s (pojo='%s')",
-//                        mapName, adapterOid,
-//                        Integer.toHexString(adapter.hashCode()), ""+adapter.getObject(),
-//                        Integer.toHexString(adapterAccordingToMap.hashCode()), ""+adapterAccordingToMap.getObject()
-//                        ));
-    }
-}
\ No newline at end of file
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_MementoSupport.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_MementoSupport.java
index f6ed879..caf0d67 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_MementoSupport.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_MementoSupport.java
@@ -79,14 +79,6 @@ class ObjectAdapterContext_MementoSupport implements MementoRecreateObjectSuppor
         } else {
             Assert.assertTrue("oid must be a RootOid representing an object because spec is not a collection and cannot be a value", oid instanceof RootOid);
             RootOid typedOid = (RootOid) oid;
-
-            // remove adapter if already in the adapter manager maps, because
-            // otherwise would (as a side-effect) update the version to that of the current.
-            adapter = objectAdapterContext.lookupAdapterFor(typedOid);
-            if(adapter != null) {
-                objectAdapterContext.removeAdapterFromCache(adapter);
-            }
-
             // recreate an adapter for the original OID (with correct version)
             adapter = persistenceSession.adapterFor(typedOid);
 
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_ObjectAdapterByIdProvider.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_ObjectAdapterByIdProvider.java
index 1de4fe4..d14c6d5 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_ObjectAdapterByIdProvider.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_ObjectAdapterByIdProvider.java
@@ -132,9 +132,8 @@ class ObjectAdapterContext_ObjectAdapterByIdProvider implements ObjectAdapterByI
             return serviceAdapter;
         }
         
-        // attempt to locate adapter for the Oid
-        ObjectAdapter adapter = objectAdapterContext.lookupAdapterFor(rootOid);
-        if (adapter == null) {
+        final ObjectAdapter adapter;
+        {
             // else recreate
             try {
                 final Object pojo;
@@ -169,14 +168,12 @@ class ObjectAdapterContext_ObjectAdapterByIdProvider implements ObjectAdapterByI
         
         rootOids.forEach(rootOid->{
          // attempt to locate adapter for the Oid
-            ObjectAdapter adapter = objectAdapterContext.lookupAdapterFor(rootOid);
+            ObjectAdapter adapter = null;
             // handle view models or transient
-            if (adapter == null) {
-                if (rootOid.isTransient() || rootOid.isViewModel()) {
-                    final Object pojo = recreatePojoTransientOrViewModel(rootOid);
-                    adapter = objectAdapterContext.addRecreatedPojoToCache(rootOid, pojo);
-                    syncVersion(concurrencyChecking, adapter, rootOid);
-                }
+            if (rootOid.isTransient() || rootOid.isViewModel()) {
+                final Object pojo = recreatePojoTransientOrViewModel(rootOid);
+                adapter = objectAdapterContext.addRecreatedPojoToCache(rootOid, pojo);
+                syncVersion(concurrencyChecking, adapter, rootOid);
             }
             if (adapter != null) {
                 adapterByOid.put(rootOid, adapter);
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_ObjectAdapterProvider.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_ObjectAdapterProvider.java
index 969523a..7c700b9 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_ObjectAdapterProvider.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext_ObjectAdapterProvider.java
@@ -79,15 +79,10 @@ class ObjectAdapterContext_ObjectAdapterProvider implements ObjectAdapterProvide
         if(pojo == null) {
             return null;
         }
-
-        final  ObjectAdapter existing = objectAdapterContext.lookupAdapterByPojo(pojo);
-        if (existing != null) {
-            return existing;
-        }
         
         final RootOid rootOid = oidFactory.oidFor(pojo);
         final ObjectAdapter newAdapter = objectAdapterContext.getFactories().createRootAdapter(pojo, rootOid);
-        return objectAdapterContext.mapAndInjectServices(newAdapter);
+        return objectAdapterContext.injectServices(newAdapter);
     }
     
     
@@ -97,18 +92,11 @@ class ObjectAdapterContext_ObjectAdapterProvider implements ObjectAdapterProvide
         requires(parentAdapter, "parentAdapter");
         requires(collection, "collection");
 
-        final  ObjectAdapter existing = objectAdapterContext.lookupAdapterByPojo(pojo);
-        if (existing != null) {
-            return existing;
-        }
-
-        objectAdapterContext.ensureMapsConsistent(parentAdapter);
-
         // the List, Set etc. instance gets wrapped in its own adapter
         final ObjectAdapter newAdapter = objectAdapterContext.getFactories()
                 .createCollectionAdapter(pojo, parentAdapter, collection);
 
-        return objectAdapterContext.mapAndInjectServices(newAdapter);
+        return objectAdapterContext.injectServices(newAdapter);
     }
 
     @Override
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java
deleted file mode 100644
index 928ea05..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/OidAdapterHashMap.java
+++ /dev/null
@@ -1,113 +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.system.persistence.adaptermanager;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.annotation.Nullable;
-
-import com.google.common.collect.Maps;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.commons.components.SessionScopedComponent;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-
-/**
- * A map of the objects' identities and the adapters' of the objects.
- * @deprecated https://issues.apache.org/jira/browse/ISIS-1976
- */
-@Deprecated
-class OidAdapterHashMap implements Iterable<Oid>, SessionScopedComponent {
-
-    private static final Logger LOG = LoggerFactory.getLogger(OidAdapterHashMap.class);
-    public static final int DEFAULT_OID_ADAPTER_MAP_SIZE = 100;
-
-    private final Map<Oid, ObjectAdapter> adapterByOidMap = Maps.newHashMapWithExpectedSize(DEFAULT_OID_ADAPTER_MAP_SIZE);
-
-    // -- open, close
-
-    public void open() {
-        // nothing to do
-    }
-
-    public void close() {
-        if(LOG.isDebugEnabled()) {
-            LOG.debug("close");
-        }
-        adapterByOidMap.clear();
-    }
-
-
-
-    // -- add, remove
-    /**
-     * Add an adapter for a given oid
-     */
-    public void add(@Nullable final Oid oid, final ObjectAdapter adapter) {
-        if(oid.isValue()) { // not stored for value 
-            return;
-        }
-        adapterByOidMap.put(oid, adapter);
-        // log at end so that if toString needs adapters they're in maps.
-        if (LOG.isDebugEnabled()) {
-            // do not call toString() on adapter because would call hashCode on
-            // the pojo,
-            // which for Hibernate PersistentCollections would trigger a
-            // resolve.
-            LOG.debug("add oid: {} ; oid.hashCode: + #{} ; adapter.hashCode(): #{}", oid, Long.toHexString(oid.hashCode()), Long.toHexString(adapter.hashCode()));
-        }
-    }
-
-    /**
-     * Remove the adapter for the given oid
-     *
-     * @return <tt>true</tt> if an adapter was removed.
-     */
-    public boolean remove(@Nullable final Oid oid) {
-        if(oid.isValue()) { // not stored for value 
-            return false;
-        }
-        LOG.debug("remove oid: {}", oid);
-        return adapterByOidMap.remove(oid) != null;
-    }
-
-
-
-    // -- getAdapter, iterator
-    /**
-     * Get the adapter identified by the specified OID.
-     */
-    public ObjectAdapter getAdapter(final Oid oid) {
-        return adapterByOidMap.get(oid);
-    }
-
-    @Override
-    public Iterator<Oid> iterator() {
-        return adapterByOidMap.keySet().iterator();
-    }
-
-
-
-
-}
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java
deleted file mode 100644
index e256a49..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/PojoAdapterHashMap.java
+++ /dev/null
@@ -1,138 +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.system.persistence.adaptermanager;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import com.google.common.collect.Maps;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.commons.components.SessionScopedComponent;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-
-/**
- * @deprecated https://issues.apache.org/jira/browse/ISIS-1976
- */
-@Deprecated
-class PojoAdapterHashMap implements Iterable<ObjectAdapter>, SessionScopedComponent {
-
-    private static class IdentityHashKey {
-        private final Object pojo;
-
-        public IdentityHashKey(final Object pojo) {
-            this.pojo = pojo;
-        }
-
-        @Override
-        public int hashCode() {
-            return System.identityHashCode(pojo);
-        }
-
-        @Override
-        public boolean equals(final Object obj) {
-            return obj == this || (obj instanceof IdentityHashKey && ((IdentityHashKey) obj).pojo == pojo);
-        }
-    }
-
-    private static final Logger LOG = LoggerFactory.getLogger(PojoAdapterHashMap.class);
-    public static final int DEFAULT_POJO_ADAPTER_MAP_SIZE = OidAdapterHashMap.DEFAULT_OID_ADAPTER_MAP_SIZE;
-
-    protected final Map<Object, ObjectAdapter> adapterByPojoMap;
-
-    // -- Constructors, finalize
-    public PojoAdapterHashMap() {
-        this(DEFAULT_POJO_ADAPTER_MAP_SIZE);
-    }
-
-    public PojoAdapterHashMap(final int capacity) {
-        adapterByPojoMap = Maps.newHashMapWithExpectedSize(capacity);
-    }
-
-    @Override
-    protected void finalize() throws Throwable {
-        super.finalize();
-        if(LOG.isDebugEnabled()) {
-            LOG.debug("finalizing hash of pojos");
-        }
-    }
-
-
-    // -- open, close
-
-    public void open() {
-        // nothing to do
-    }
-
-    public void close() {
-        if(LOG.isDebugEnabled()) {
-            LOG.debug("close");
-        }
-        adapterByPojoMap.clear();
-    }
-
-
-
-    // -- add, remove
-
-    public void add(final Object pojo, final ObjectAdapter adapter) {
-        adapterByPojoMap.put(key(pojo), adapter);
-
-        if(LOG.isDebugEnabled()) {
-            LOG.debug("add adapter: #{} -> #{}", key(pojo), Long.toHexString(adapter.hashCode()));
-
-        }
-    }
-
-    public void remove(final ObjectAdapter object) {
-        LOG.debug("remove adapter: {}", object);
-        adapterByPojoMap.remove(key(object.getObject()));
-    }
-
-
-
-    // -- getAdapter, containsPojo
-
-    public boolean containsPojo(final Object pojo) {
-        return adapterByPojoMap.containsKey(key(pojo));
-    }
-
-    public ObjectAdapter getAdapter(final Object pojo) {
-        return adapterByPojoMap.get(key(pojo));
-    }
-
-
-
-    // -- iterator, key
-    @Override
-    public Iterator<ObjectAdapter> iterator() {
-        return adapterByPojoMap.values().iterator();
-    }
-
-    private Object key(final Object pojo) {
-        return new IdentityHashKey(pojo);
-    }
-
-
-
-
-}
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/RootAndCollectionAdapters.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/RootAndCollectionAdapters.java
index 0364a46..50d8267 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/RootAndCollectionAdapters.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/RootAndCollectionAdapters.java
@@ -96,7 +96,7 @@ final class RootAndCollectionAdapters {
     private void addCollectionAdapters() {
         for (final OneToManyAssociation otma : parentAdapter.getSpecification().getCollections(Contributed.EXCLUDED)) {
             final ParentedCollectionOid collectionOid = new ParentedCollectionOid((RootOid) rootAdapterOid, otma);
-            final ObjectAdapter collectionAdapter = context.lookupParentedCollectionAdapter(collectionOid);
+            final ObjectAdapter collectionAdapter = null;//FIXME context.lookupParentedCollectionAdapter(collectionOid);
             if (collectionAdapter != null) {
                 // collection adapters are lazily created and so there may not be one.
                 addCollectionAdapter(otma, collectionAdapter);