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/04 08:27:26 UTC

[isis] 05/07: ISIS-1976: move responsibility for pre-loading service adapters from PersistenceSession to ObjectAdapterContext

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 c37cde638a7222ac48f6a64c7ad33c607a92af0a
Author: Andi Huber <ah...@apache.org>
AuthorDate: Tue Sep 4 08:17:55 2018 +0200

    ISIS-1976: move responsibility for pre-loading service adapters from
    PersistenceSession to ObjectAdapterContext
    
    Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
---
 .../system/persistence/PersistenceSession5.java    | 25 ++--------------------
 .../adaptermanager/ObjectAdapterContext.java       | 21 ++++++++++++++++++
 2 files changed, 23 insertions(+), 23 deletions(-)

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 05ff2b7..2d0f87c 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
@@ -159,8 +159,6 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
             LOG.debug("opening {}", this);
         }
 
-        objectAdapterContext = ObjectAdapterLegacy.openContext(servicesInjector, authenticationSession, specificationLoader, this);
-
         persistenceManager = jdoPersistenceManagerFactory.getPersistenceManager();
 
         final IsisLifecycleListener.PersistenceSessionLifecycleManagement psLifecycleMgmt = this;
@@ -173,8 +171,8 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
         persistenceQueryProcessorByClass.put(
                 PersistenceQueryFindUsingApplibQueryDefault.class,
                 new PersistenceQueryFindUsingApplibQueryProcessor(this));
-
-        initServices();
+        
+        objectAdapterContext = ObjectAdapterLegacy.openContext(servicesInjector, authenticationSession, specificationLoader, this);
 
         // tell the proxy of all request-scoped services to instantiate the underlying
         // services, store onto the thread-local and inject into them...
@@ -223,25 +221,6 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
             }
         }
     }
-
-    /**
-     * Creates {@link ObjectAdapter adapters} for the service list, ensuring that these are mapped correctly,
-     * and have the same OIDs as in any previous sessions.
-     * 
-     * @deprecated https://issues.apache.org/jira/browse/ISIS-1976
-     */
-    @Deprecated
-    private void initServices() {
-        final List<Object> registeredServices = servicesInjector.getRegisteredServices();
-        for (final Object service : registeredServices) {
-            final ObjectAdapter serviceAdapter = adapterFor(service);
-            
-            // remap as Persistent if required
-            if (serviceAdapter.getOid().isTransient()) {
-                objectAdapterContext.remapAsPersistent(serviceAdapter, null, this);
-            }
-        }
-    }
     
     @Override
     public List<ObjectAdapter> getServices() {
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 f1dd2ad..b002242 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
@@ -18,6 +18,7 @@
  */
 package org.apache.isis.core.runtime.system.persistence.adaptermanager;
 
+import java.util.List;
 import java.util.UUID;
 import java.util.function.Function;
 
@@ -86,6 +87,7 @@ public class ObjectAdapterContext {
     public void open() {
         oidAdapterMap.open();
         pojoAdapterMap.open();
+        initServices();
     }
     
     public void close() {
@@ -251,6 +253,25 @@ public class ObjectAdapterContext {
     
     // ------------------------------------------------------------------------------------------------
     
+    /**
+     * Creates {@link ObjectAdapter adapters} for the service list, ensuring that these are mapped correctly,
+     * and have the same OIDs as in any previous sessions.
+     * 
+     * @deprecated https://issues.apache.org/jira/browse/ISIS-1976
+     */
+    @Deprecated
+    private void initServices() {
+        final List<Object> registeredServices = servicesInjector.getRegisteredServices();
+        for (final Object service : registeredServices) {
+            final ObjectAdapter serviceAdapter = objectAdapterProviderMixin.adapterFor(service);
+            
+            // remap as Persistent if required
+            if (serviceAdapter.getOid().isTransient()) {
+                remapAsPersistent(serviceAdapter, null, persistenceSession);
+            }
+        }
+    }
+    
     @Deprecated // don't expose caching
     public void addAdapterHonoringSpecImmutability(Object pojo, ObjectAdapter adapter) {
         // add all aggregated collections