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/10 14:07:31 UTC

[32/50] [abbrv] isis git commit: ISIS-1194: moved remaining helper methods from ObjectStore to PersistenceSession; removed ObjectStore class.

ISIS-1194: moved remaining helper methods from ObjectStore to PersistenceSession; removed ObjectStore class.


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

Branch: refs/heads/ISIS-1194
Commit: f54bcc55b56267a1adc52613c1b1e244911fb5d5
Parents: 769a173
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Sep 10 10:03:39 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Sep 10 10:03:39 2015 +0100

----------------------------------------------------------------------
 .../integtestsupport/IsisSystemForTest.java     |   7 -
 .../persistence/FrameworkSynchronizer.java      |   7 -
 .../runtime/system/persistence/ObjectStore.java | 139 -------------------
 .../system/persistence/PersistenceSession.java  |  43 +++---
 .../IsisConfigurationForJdoIntegTests.java      |   5 +-
 .../PersistenceQueryProcessorAbstract.java      |  12 +-
 .../service/support/IsisJdoSupportImpl.java     |   5 -
 .../persistence/PersistenceSessionTest.java     |   2 -
 8 files changed, 25 insertions(+), 195 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/f54bcc55/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
index 3b3eda0..0044a0b 100644
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
@@ -66,7 +66,6 @@ import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
 import org.apache.isis.core.runtime.systemusinginstallers.IsisComponentProvider;
 import org.apache.isis.core.security.authentication.AuthenticationRequestNameOnly;
 import org.apache.isis.core.specsupport.scenarios.DomainServiceProvider;
-import org.apache.isis.core.runtime.system.persistence.ObjectStore;
 
 /**
  * Wraps a plain {@link IsisSystem}, and provides a number of features to assist with testing.
@@ -599,12 +598,6 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         return adapter;
     }
 
-    @SuppressWarnings("unchecked")
-    public <T extends ObjectStore> T getObjectStore(Class<T> cls) {
-        final PersistenceSession persistenceSession = getPersistenceSession();
-        return (T) persistenceSession.getObjectStore();
-    }
-
     private static void ensureSessionInProgress() {
         if(!IsisContext.inSession()) {
             throw new IllegalStateException("Session must be in progress");

http://git-wip-us.apache.org/repos/asf/isis/blob/f54bcc55/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 0dca780..196b6b5 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
@@ -402,11 +402,4 @@ public class FrameworkSynchronizer {
         return getPersistenceSession().getPersistenceManager();
     }
 
-    protected ObjectStore getObjectStore() {
-        return (ObjectStore) IsisContext.getPersistenceSession().getObjectStore();
-    }
-
-
-
-
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/f54bcc55/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/ObjectStore.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/ObjectStore.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/ObjectStore.java
deleted file mode 100644
index c668397..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/ObjectStore.java
+++ /dev/null
@@ -1,139 +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;
-
-import javax.jdo.PersistenceManager;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
-import org.apache.isis.core.runtime.runner.opts.OptionHandlerFixtureAbstract;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-
-import static org.apache.isis.core.commons.ensure.Ensure.ensureThatContext;
-import static org.apache.isis.core.commons.ensure.Ensure.ensureThatState;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-
-public class ObjectStore implements DebuggableWithTitle {
-
-    private static final Logger LOG = LoggerFactory.getLogger(ObjectStore.class);
-
-    //region > constructors, fields
-
-    private final PersistenceSession persistenceSession;
-    private final SpecificationLoaderSpi specificationLoader;
-    private final IsisConfiguration configuration;
-
-    private static final String ROOT_KEY = OptionHandlerFixtureAbstract.DATANUCLEUS_ROOT_KEY;
-
-    /**
-     * Append regular <a href="http://www.datanucleus.org/products/accessplatform/persistence_properties.html">datanucleus properties</a> to this key
-     */
-    public static final String DATANUCLEUS_PROPERTIES_ROOT = ROOT_KEY + "impl.";
-
-
-
-    private final DataNucleusApplicationComponents applicationComponents;
-    
-    private PersistenceManager persistenceManager;
-
-    public ObjectStore(
-            final PersistenceSession persistenceSession,
-            final SpecificationLoaderSpi specificationLoader,
-            final IsisConfiguration configuration,
-            final DataNucleusApplicationComponents applicationComponents) {
-
-        this.persistenceSession = persistenceSession;
-        this.specificationLoader = specificationLoader;
-        this.configuration = configuration;
-        this.applicationComponents = applicationComponents;
-    }
-
-    //endregion
-
-    //region > helpers
-
-    public void ensureOpened() {
-        persistenceSession.ensureOpened();
-    }
-
-    void ensureInTransaction() {
-        ensureThatContext(IsisContext.inTransaction(), is(true));
-        ensureInJdoTransaction();
-    }
-
-    private void ensureInJdoTransaction() {
-        javax.jdo.Transaction currentTransaction = persistenceManager.currentTransaction();
-        ensureThatState(currentTransaction, is(notNullValue()));
-        ensureThatState(currentTransaction.isActive(), is(true));
-    }
-
-    //endregion
-
-    //region > debug
-
-    public void debugData(final DebugBuilder debug) {
-        // no-op
-        debug.append("this object store does not currently provide any debug data");
-    }
-
-    public String debugTitle() {
-        return "JDO (DataNucleus) ObjectStore";
-    }
-
-    //endregion
-
-    //region > dependencies (from constructor)
-
-    public PersistenceManager getPersistenceManager() {
-        return persistenceManager;
-    }
-
-    public IsisConfiguration getConfiguration() {
-        return configuration;
-    }
-
-    protected SpecificationLoaderSpi getSpecificationLoader() {
-        return specificationLoader;
-    }
-
-    protected PersistenceSession getPersistenceSession() {
-        return persistenceSession;
-    }
-
-    protected AdapterManager getAdapterManager() {
-        return persistenceSession.getAdapterManager();
-    }
-    
-    protected IsisTransactionManager getTransactionManager() {
-        return persistenceSession.getTransactionManager();
-    }
-
-
-    //endregion
-
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/f54bcc55/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 9e38bf9..5c12a30 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
@@ -88,6 +88,7 @@ import org.apache.isis.objectstore.jdo.datanucleus.persistence.spi.JdoObjectIdSe
 
 import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
 import static org.apache.isis.core.commons.ensure.Ensure.ensureThatContext;
+import static org.apache.isis.core.commons.ensure.Ensure.ensureThatState;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -103,6 +104,14 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
     public static final String INSTALL_FIXTURES_KEY = OptionHandlerFixtureAbstract.DATANUCLEUS_INSTALL_FIXTURES_KEY;
     public static final boolean INSTALL_FIXTURES_DEFAULT = false;
 
+    private static final String ROOT_KEY = OptionHandlerFixtureAbstract.DATANUCLEUS_ROOT_KEY;
+
+    /**
+     * Append regular <a href="http://www.datanucleus.org/products/accessplatform/persistence_properties.html">datanucleus properties</a> to this key
+     */
+    public static final String DATANUCLEUS_PROPERTIES_ROOT = ROOT_KEY + "impl.";
+
+
     //region > constructor, fields
     private final ObjectFactory objectFactory;
 
@@ -112,7 +121,6 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
     private final AdapterManagerDefault adapterManager;
 
     private final PersistAlgorithm persistAlgorithm ;
-    private final ObjectStore objectStore;
 
     private final PersistenceQueryFactory persistenceQueryFactory;
     private final IsisConfiguration configuration;
@@ -165,7 +173,6 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
         // sub-components
 
         oidMarshaller = new OidMarshaller();
-        this.objectStore = new ObjectStore(this, specificationLoader, configuration, applicationComponents);
 
         this.objectFactory = new ObjectFactory(this, servicesInjector);
         this.oidGenerator = new OidGenerator(this, specificationLoader);
@@ -211,12 +218,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
 
         adapterManager.open();
 
-        adapterManager.injectInto(objectStore);
-        specificationLoader.injectInto(objectStore);
-
-        this.persistenceManager = applicationComponents.createPersistenceManager();
-
-        persistenceManager = objectStore.getPersistenceManager();
+        persistenceManager = applicationComponents.createPersistenceManager();
 
         persistenceQueryProcessorByClass.put(
                 PersistenceQueryFindAllInstances.class,
@@ -324,7 +326,6 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
 
     //endregion
 
-
     //region > State
 
     private enum State {
@@ -705,13 +706,6 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
 
     //endregion
 
-    //region > transactions
-
-    void ensureInTransaction() {
-        objectStore.ensureInTransaction();
-    }
-
-    //endregion
 
     //region > lazilyLoaded
 
@@ -922,7 +916,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
     public void execute(final List<PersistenceCommand> commands) {
 
         ensureOpened();
-        objectStore.ensureInTransaction();
+        ensureInTransaction();
 
         // previously we used to check that there were some commands, and skip processing otherwise.
         // we no longer do that; it could be (is quite likely) that DataNucleus has some dirty objects anyway that
@@ -999,6 +993,14 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
             transaction.rollback();
         }
     }
+
+    private void ensureInTransaction() {
+        ensureThatContext(IsisContext.inTransaction(), is(true));
+        javax.jdo.Transaction currentTransaction = persistenceManager.currentTransaction();
+        ensureThatState(currentTransaction, is(notNullValue()));
+        ensureThatState(currentTransaction.isActive(), is(true));
+    }
+
     //endregion
 
 
@@ -1036,10 +1038,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
         debug.appendTitle("Persistor");
         getTransactionManager().debugData(debug);
         debug.appendln("Persist Algorithm", persistAlgorithm);
-        debug.appendln("Object Store", objectStore);
         debug.appendln();
-
-        objectStore.debugData(debug);
     }
 
 
@@ -1119,10 +1118,6 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
         this.transactionManager = transactionManager;
     }
 
-    public ObjectStore getObjectStore() {
-        return objectStore;
-    }
-
     /**
      * The configured {@link ObjectFactory}.
      */

http://git-wip-us.apache.org/repos/asf/isis/blob/f54bcc55/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/IsisConfigurationForJdoIntegTests.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/IsisConfigurationForJdoIntegTests.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/IsisConfigurationForJdoIntegTests.java
index c8aef7f..70ce8e8 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/IsisConfigurationForJdoIntegTests.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/IsisConfigurationForJdoIntegTests.java
@@ -28,7 +28,6 @@ import org.slf4j.LoggerFactory;
 import org.apache.isis.core.commons.config.IsisConfigurationDefault;
 import org.apache.isis.core.commons.resource.ResourceStreamSource;
 import org.apache.isis.core.runtime.persistence.PersistenceConstants;
-import org.apache.isis.core.runtime.system.persistence.ObjectStore;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.objectstore.jdo.service.RegisterEntities;
 
@@ -91,12 +90,12 @@ public class IsisConfigurationForJdoIntegTests extends IsisConfigurationDefault
     }
 
     public final IsisConfigurationForJdoIntegTests addDataNucleusProperty(final String key, final String value) {
-        add(ObjectStore.DATANUCLEUS_PROPERTIES_ROOT + key, value);
+        add(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + key, value);
         return this;
     }
 
     public final IsisConfigurationForJdoIntegTests putDataNucleusProperty(final String key, final String value) {
-        put(ObjectStore.DATANUCLEUS_PROPERTIES_ROOT + key, value);
+        put(PersistenceSession.DATANUCLEUS_PROPERTIES_ROOT + key, value);
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/isis/blob/f54bcc55/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
index 6d8ba37..00f68fb 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
@@ -27,18 +27,18 @@ import javax.jdo.metadata.TypeMetadata;
 
 import com.google.common.collect.Lists;
 
+import org.datanucleus.enhancement.Persistable;
+
 import org.apache.isis.core.commons.ensure.Assert;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceQuery;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.persistence.ObjectStore;
 import org.apache.isis.core.runtime.system.persistence.FrameworkSynchronizer;
 import org.apache.isis.core.runtime.system.persistence.FrameworkSynchronizer.CalledFrom;
+import org.apache.isis.core.runtime.system.persistence.PersistenceQuery;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleListener;
-import org.datanucleus.enhancement.Persistable;
 
 public abstract class PersistenceQueryProcessorAbstract<T extends PersistenceQuery>
         implements PersistenceQueryProcessor<T> {
@@ -106,8 +106,4 @@ public abstract class PersistenceQueryProcessorAbstract<T extends PersistenceQue
         return IsisContext.getPersistenceSession().getAdapterManager();
     }
 
-    protected ObjectStore getJdoObjectStore() {
-        return (ObjectStore) IsisContext.getPersistenceSession().getObjectStore();
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/f54bcc55/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/support/IsisJdoSupportImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/support/IsisJdoSupportImpl.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/support/IsisJdoSupportImpl.java
index e3f3406..99c764c 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/support/IsisJdoSupportImpl.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/support/IsisJdoSupportImpl.java
@@ -51,7 +51,6 @@ import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.objectstore.jdo.applib.service.support.IsisJdoSupport;
-import org.apache.isis.core.runtime.system.persistence.ObjectStore;
 
 
 /**
@@ -194,10 +193,6 @@ public class IsisJdoSupportImpl implements IsisJdoSupport {
 
     // //////////////////////////////////////
 
-    
-    protected ObjectStore getObjectStore() {
-        return getPersistenceSession().getObjectStore();
-    }
 
     protected AdapterManager getAdapterManager() {
         return getPersistenceSession().getAdapterManager();

http://git-wip-us.apache.org/repos/asf/isis/blob/f54bcc55/core/runtime/src/test/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionTest.java
index 57343db..c338489 100644
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionTest.java
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionTest.java
@@ -81,8 +81,6 @@ public class PersistenceSessionTest {
     private SpecificationLoaderSpi mockSpecificationLoader;
 
     @Mock
-    private ObjectStore mockObjectStore;
-    @Mock
     private AuditingService3 mockAuditingService3;
     @Mock
     private PublishingServiceWithDefaultPayloadFactories mockPublishingService;