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 2015/09/11 00:08:52 UTC

[28/50] isis git commit: ISIS-1194: passing dependencies through to FrameworkSynchronizer, so that it no longer needs to use IsisContext.

ISIS-1194: passing dependencies through to FrameworkSynchronizer, so that it no longer needs to use IsisContext.


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

Branch: refs/heads/master
Commit: 06d685c466d1e9053e304d22432a0af513bccd7b
Parents: ecd2b75
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Sep 10 16:05:41 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Sep 10 16:05:41 2015 +0100

----------------------------------------------------------------------
 .../persistence/FrameworkSynchronizer.java      | 41 +++++++++++++-------
 .../system/persistence/OidGenerator.java        |  6 +--
 .../system/persistence/PersistenceSession.java  |  2 +-
 3 files changed, 30 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/06d685c4/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/FrameworkSynchronizer.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/FrameworkSynchronizer.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/FrameworkSynchronizer.java
index 8c1695d..65cfb68 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/FrameworkSynchronizer.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/FrameworkSynchronizer.java
@@ -44,17 +44,28 @@ import org.apache.isis.core.metamodel.facets.object.callbacks.PersistingCallback
 import org.apache.isis.core.metamodel.facets.object.callbacks.RemovingCallbackFacet;
 import org.apache.isis.core.metamodel.facets.object.callbacks.UpdatedCallbackFacet;
 import org.apache.isis.core.metamodel.facets.object.callbacks.UpdatingCallbackFacet;
+import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
 import org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDefault;
-import org.apache.isis.core.runtime.system.context.IsisContext;
 import org.apache.isis.core.runtime.system.transaction.IsisTransaction;
 
 public class FrameworkSynchronizer {
 
     private static final Logger LOG = LoggerFactory.getLogger(FrameworkSynchronizer.class);
 
-    public FrameworkSynchronizer() {
+    private final PersistenceSession persistenceSession;
+    private final AuthenticationSession authenticationSession;
+    private ServicesInjectorSpi servicesInjector;
+
+    public FrameworkSynchronizer(
+            final PersistenceSession persistenceSession,
+            final AuthenticationSession authenticationSession) {
+        this.persistenceSession = persistenceSession;
+        this.authenticationSession = authenticationSession;
+
+        this.servicesInjector = getPersistenceSession().getServicesInjector();
+
     }
-    
+
     /**
      * Categorises where called from.
      * 
@@ -84,7 +95,7 @@ public class FrameworkSynchronizer {
                 
                 // need to do eagerly, because (if a viewModel then) a
                 // viewModel's #viewModelMemento might need to use services 
-                getPersistenceSession().getServicesInjector().injectServicesInto(pojo);
+                servicesInjector.injectServicesInto(pojo);
                 
                 final Version datastoreVersion = getVersionIfAny(pc);
                 
@@ -381,28 +392,28 @@ public class FrameworkSynchronizer {
     // Dependencies (from context)
     // /////////////////////////////////////////////////////////
 
-    protected AdapterManagerDefault getAdapterManager() {
-        return getPersistenceSession().getAdapterManager();
-    }
-
-    protected OidGenerator getOidGenerator() {
-        return getPersistenceSession().getOidGenerator();
+    protected AuthenticationSession getAuthenticationSession() {
+        return authenticationSession;
     }
 
     protected PersistenceSession getPersistenceSession() {
-        return IsisContext.getPersistenceSession();
+        return persistenceSession;
     }
 
-    protected AuthenticationSession getAuthenticationSession() {
-        return IsisContext.getAuthenticationSession();
+    protected AdapterManagerDefault getAdapterManager() {
+        return getPersistenceSession().getAdapterManager();
     }
 
-    protected IsisTransaction getCurrentTransaction() {
-        return IsisContext.getCurrentTransaction();
+    protected OidGenerator getOidGenerator() {
+        return getPersistenceSession().getOidGenerator();
     }
 
     protected PersistenceManager getJdoPersistenceManager() {
         return getPersistenceSession().getPersistenceManager();
     }
 
+    protected IsisTransaction getCurrentTransaction() {
+        return persistenceSession.getTransactionManager().getTransaction();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/06d685c4/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 936b8f3..fb92048 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
@@ -81,10 +81,11 @@ public class OidGenerator implements DebuggableWithTitle {
 
     //endregion
 
-    //region > helpers
+    //region > helpers: newIdentifier
 
     enum Type {
-        TRANSIENT, PERSISTENT
+        TRANSIENT,
+        PERSISTENT
     }
 
     private RootOid newIdentifier(final Object pojo, final OidGenerator.Type type) {
@@ -140,7 +141,6 @@ public class OidGenerator implements DebuggableWithTitle {
     public void debugData(final DebugBuilder debug) {
     }
 
-
     @Override
     public String debugTitle() {
         return "OidGenerator";

http://git-wip-us.apache.org/repos/asf/isis/blob/06d685c4/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 2fe4b3b..e9ec445 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
@@ -177,7 +177,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
         // sub-components
 
         this.oidMarshaller = new OidMarshaller();
-        this.frameworkSynchronizer = new FrameworkSynchronizer();
+        this.frameworkSynchronizer = new FrameworkSynchronizer(this, authenticationSession);
 
         this.objectFactory = new ObjectFactory(this, servicesInjector);
         this.oidGenerator = new OidGenerator(this, specificationLoader);