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/07/25 12:39:39 UTC
[3/3] isis git commit: ISIS-1150: mothballed the in-memory
objectstore.
ISIS-1150: mothballed the in-memory objectstore.
In addition, cosmetic change to all the pom.xml in isis/core, removed "Core" from name (since we don't have any separate components anymore).
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/a466fb50
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/a466fb50
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/a466fb50
Branch: refs/heads/master
Commit: a466fb5074819a97da8566ac046b0bb5fb5406a5
Parents: 93a1d5c
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sat Jul 25 11:39:22 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Sat Jul 25 11:39:22 2015 +0100
----------------------------------------------------------------------
core/applib/pom.xml | 2 +-
core/integtestsupport/pom.xml | 2 +-
.../integtestsupport/IsisSystemDefault.java | 12 +-
.../integtestsupport/IsisSystemForTest.java | 7 +-
.../legacy/components/AnnotationInstaller.java | 4 +-
core/log4j/pom.xml | 2 +-
core/metamodel/pom.xml | 2 +-
core/pom.xml | 2 +-
core/runtime/pom.xml | 2 +-
.../core/objectstore/InMemoryObjectStore.java | 502 -------------------
.../InMemoryPersistenceMechanismInstaller.java | 66 ---
.../InMemoryPersistenceSessionFactory.java | 95 ----
.../AbstractInMemoryPersistenceCommand.java | 64 ---
.../commands/InMemoryCreateObjectCommand.java | 49 --
.../commands/InMemoryDestroyObjectCommand.java | 49 --
.../commands/InMemorySaveObjectCommand.java | 48 --
.../internal/ObjectStoreInstances.java | 246 ---------
.../internal/ObjectStorePersistedObjects.java | 94 ----
.../progmodels/JavaReflectorInstaller.java | 3 +
.../core/runtime/installer-registry.properties | 48 +-
...bjectStoreInstances_findInstancesAndAdd.java | 111 ----
.../internal/ObjectStoreInstances_init.java | 69 ---
.../internal/ObjectStoreInstances_save.java | 121 -----
...tStorePersistedObjectsDefault_instances.java | 92 ----
...jectsDefault_savesOidGeneratorAsMemento.java | 60 ---
...ctStorePersistedObjectsDefault_services.java | 76 ---
core/schema/pom.xml | 2 +-
core/security-noop/pom.xml | 2 +-
core/security-shiro/pom.xml | 2 +-
core/specsupport/pom.xml | 2 +-
core/unittestsupport/pom.xml | 2 +-
core/viewer-restfulobjects-applib/pom.xml | 2 +-
core/viewer-restfulobjects-rendering/pom.xml | 2 +-
core/viewer-restfulobjects-server/pom.xml | 2 +-
core/webserver/pom.xml | 2 +-
core/wrapper/pom.xml | 2 +-
.../core/objectstore/InMemoryObjectStore.java | 502 +++++++++++++++++++
.../InMemoryPersistenceMechanismInstaller.java | 66 +++
.../InMemoryPersistenceSessionFactory.java | 95 ++++
.../AbstractInMemoryPersistenceCommand.java | 64 +++
.../commands/InMemoryCreateObjectCommand.java | 49 ++
.../commands/InMemoryDestroyObjectCommand.java | 49 ++
.../commands/InMemorySaveObjectCommand.java | 48 ++
.../internal/ObjectStoreInstances.java | 246 +++++++++
.../internal/ObjectStorePersistedObjects.java | 94 ++++
...bjectStoreInstances_findInstancesAndAdd.java | 111 ++++
.../internal/ObjectStoreInstances_init.java | 69 +++
.../internal/ObjectStoreInstances_save.java | 121 +++++
...tStorePersistedObjectsDefault_instances.java | 92 ++++
...jectsDefault_savesOidGeneratorAsMemento.java | 60 +++
...ctStorePersistedObjectsDefault_services.java | 76 +++
51 files changed, 1788 insertions(+), 1802 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/applib/pom.xml
----------------------------------------------------------------------
diff --git a/core/applib/pom.xml b/core/applib/pom.xml
index 2537dab..2e2b100 100644
--- a/core/applib/pom.xml
+++ b/core/applib/pom.xml
@@ -28,7 +28,7 @@
<artifactId>isis-core-applib</artifactId>
- <name>Isis Core AppLib</name>
+ <name>Isis AppLib</name>
<description>
Isis application library, defining annotations and utilities for the
default (Java) programming model.
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/integtestsupport/pom.xml
----------------------------------------------------------------------
diff --git a/core/integtestsupport/pom.xml b/core/integtestsupport/pom.xml
index ff96578..d4d8e59 100644
--- a/core/integtestsupport/pom.xml
+++ b/core/integtestsupport/pom.xml
@@ -27,7 +27,7 @@
</parent>
<artifactId>isis-core-integtestsupport</artifactId>
- <name>Isis Core Integration Testing Support</name>
+ <name>Isis Integration Testing Support</name>
<properties>
<siteBaseDir>..</siteBaseDir>
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemDefault.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemDefault.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemDefault.java
index 0b69da8..1e05f65 100644
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemDefault.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemDefault.java
@@ -22,8 +22,10 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
+
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.commons.config.IsisConfigurationDefault;
import org.apache.isis.core.commons.resource.ResourceStreamSourceContextLoaderClassPath;
@@ -35,7 +37,6 @@ import org.apache.isis.core.metamodel.metamodelvalidator.dflt.MetaModelValidator
import org.apache.isis.core.metamodel.progmodel.ProgrammingModel;
import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidator;
-import org.apache.isis.core.objectstore.InMemoryPersistenceMechanismInstaller;
import org.apache.isis.core.runtime.authentication.AuthenticationManager;
import org.apache.isis.core.runtime.authentication.standard.AuthenticationManagerStandard;
import org.apache.isis.core.runtime.authentication.standard.Authenticator;
@@ -51,6 +52,7 @@ import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory
import org.apache.isis.core.runtime.systemusinginstallers.IsisSystemAbstract;
import org.apache.isis.core.runtime.transaction.facetdecorator.standard.StandardTransactionFacetDecorator;
import org.apache.isis.core.security.authentication.AuthenticatorBypass;
+import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
import org.apache.isis.progmodels.dflt.JavaReflectorHelper;
import org.apache.isis.progmodels.dflt.ProgrammingModelFacetsJava5;
@@ -196,9 +198,9 @@ public class IsisSystemDefault extends IsisSystemAbstract {
protected PersistenceSessionFactory obtainPersistenceSessionFactory(DeploymentType deploymentType) throws IsisSystemException {
PersistenceMechanismInstaller installer = obtainPersistenceMechanismInstaller(getConfiguration());
if(installer == null) {
- final InMemoryPersistenceMechanismInstaller inMemoryPersistenceMechanismInstaller = new InMemoryPersistenceMechanismInstaller();
- inMemoryPersistenceMechanismInstaller.setConfiguration(getConfiguration());
- installer = inMemoryPersistenceMechanismInstaller;
+ final DataNucleusPersistenceMechanismInstaller persistenceMechanismInstaller = new DataNucleusPersistenceMechanismInstaller();
+ persistenceMechanismInstaller.setConfiguration(getConfiguration());
+ installer = persistenceMechanismInstaller;
}
return installer.createPersistenceSessionFactory(deploymentType);
}
@@ -208,7 +210,7 @@ public class IsisSystemDefault extends IsisSystemAbstract {
* Optional hook; if returns <tt>null</tt> then the {@link #obtainPersistenceSessionFactory(DeploymentType)} is used.
*/
protected PersistenceMechanismInstaller obtainPersistenceMechanismInstaller(IsisConfiguration configuration) throws IsisSystemException {
- InMemoryPersistenceMechanismInstaller installer = new InMemoryPersistenceMechanismInstaller();
+ DataNucleusPersistenceMechanismInstaller installer = new DataNucleusPersistenceMechanismInstaller();
installer.setConfiguration(getConfiguration());
return installer;
}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/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 0da50c0..d55efcc 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
@@ -21,13 +21,16 @@ package org.apache.isis.core.integtestsupport;
import java.util.Arrays;
import java.util.List;
+
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
+
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
+
import org.apache.isis.applib.DomainObjectContainer;
import org.apache.isis.applib.fixtures.FixtureClock;
import org.apache.isis.applib.fixtures.InstallableFixture;
@@ -43,7 +46,6 @@ import org.apache.isis.core.metamodel.progmodel.ProgrammingModel;
import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidator;
-import org.apache.isis.core.objectstore.InMemoryPersistenceMechanismInstaller;
import org.apache.isis.core.runtime.authentication.AuthenticationManager;
import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
import org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate;
@@ -60,6 +62,7 @@ import org.apache.isis.core.runtime.system.transaction.IsisTransaction.State;
import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
import org.apache.isis.core.security.authentication.AuthenticationRequestNameOnly;
import org.apache.isis.core.specsupport.scenarios.DomainServiceProvider;
+import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
/**
* Wraps a plain {@link IsisSystemDefault}, and provides a number of features to assist with testing.
@@ -170,7 +173,7 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
private AuthenticationRequest authenticationRequest = new AuthenticationRequestNameOnly("tester");
private IsisConfigurationDefault configuration;
- private PersistenceMechanismInstaller persistenceMechanismInstaller = new InMemoryPersistenceMechanismInstaller();
+ private PersistenceMechanismInstaller persistenceMechanismInstaller = new DataNucleusPersistenceMechanismInstaller();
private MetaModelValidator metaModelValidator;
private ProgrammingModel programmingModel;
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
index 9aa23d8..151de42 100644
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
@@ -21,12 +21,12 @@ package org.apache.isis.core.integtestsupport.legacy.components;
import org.apache.isis.core.integtestsupport.legacy.Authenticator;
import org.apache.isis.core.integtestsupport.legacy.Authorizor;
import org.apache.isis.core.integtestsupport.legacy.Persistor;
-import org.apache.isis.core.objectstore.InMemoryPersistenceMechanismInstaller;
import org.apache.isis.core.runtime.authentication.AuthenticationManagerInstaller;
import org.apache.isis.core.runtime.authorization.AuthorizationManagerInstaller;
import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
import org.apache.isis.core.security.authentication.BypassAuthenticationManagerInstaller;
import org.apache.isis.core.security.authorization.BypassAuthorizationManagerInstaller;
+import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
public class AnnotationInstaller {
@@ -79,7 +79,7 @@ public class AnnotationInstaller {
final Persistor annotation = javaClass.getAnnotation(Persistor.class);
return annotation != null
? addPersistorRepresentedBy(annotation)
- : new InMemoryPersistenceMechanismInstaller();
+ : new DataNucleusPersistenceMechanismInstaller();
}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/log4j/pom.xml
----------------------------------------------------------------------
diff --git a/core/log4j/pom.xml b/core/log4j/pom.xml
index 7edf892..bd1fbdd 100644
--- a/core/log4j/pom.xml
+++ b/core/log4j/pom.xml
@@ -19,7 +19,7 @@
</parent>
<artifactId>isis-core-log4j</artifactId>
- <name>Isis Core Log4j Impls</name>
+ <name>Isis Log4j Impls</name>
<properties>
<siteBaseDir>..</siteBaseDir>
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/metamodel/pom.xml
----------------------------------------------------------------------
diff --git a/core/metamodel/pom.xml b/core/metamodel/pom.xml
index 2cf5e9a..0f82492 100644
--- a/core/metamodel/pom.xml
+++ b/core/metamodel/pom.xml
@@ -27,7 +27,7 @@
</parent>
<artifactId>isis-core-metamodel</artifactId>
- <name>Isis Core MetaModel</name>
+ <name>Isis MetaModel</name>
<properties>
<siteBaseDir>..</siteBaseDir>
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 0d21f4e..6111219 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -33,7 +33,7 @@
<packaging>pom</packaging>
- <name>Apache Isis Core</name>
+ <name>Apache Isis</name>
<description>
Core framework, providing metamodel, runtime and core APIs.
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/pom.xml
----------------------------------------------------------------------
diff --git a/core/runtime/pom.xml b/core/runtime/pom.xml
index fd3e82f..428b772 100644
--- a/core/runtime/pom.xml
+++ b/core/runtime/pom.xml
@@ -27,7 +27,7 @@
</parent>
<artifactId>isis-core-runtime</artifactId>
- <name>Isis Core Runtime</name>
+ <name>Isis Runtime</name>
<properties>
<siteBaseDir>..</siteBaseDir>
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryObjectStore.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryObjectStore.java b/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryObjectStore.java
deleted file mode 100644
index 53e3775..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryObjectStore.java
+++ /dev/null
@@ -1,502 +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.objectstore;
-
-import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import com.google.common.collect.Lists;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebugUtils;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.objectstore.commands.InMemoryCreateObjectCommand;
-import org.apache.isis.core.objectstore.commands.InMemoryDestroyObjectCommand;
-import org.apache.isis.core.objectstore.commands.InMemorySaveObjectCommand;
-import org.apache.isis.core.objectstore.internal.ObjectStoreInstances;
-import org.apache.isis.core.objectstore.internal.ObjectStorePersistedObjects;
-import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
-import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
-import org.apache.isis.core.runtime.persistence.UnsupportedFindException;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.CreateObjectCommand;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.SaveObjectCommand;
-import org.apache.isis.core.runtime.persistence.query.PersistenceQueryBuiltIn;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.ObjectStore;
-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.PersistenceSessionFactory;
-
-public class InMemoryObjectStore implements ObjectStore {
-
- private final static Logger LOG = LoggerFactory.getLogger(InMemoryObjectStore.class);
-
- protected ObjectStorePersistedObjects persistedObjects;
-
- public InMemoryObjectStore() {
- LOG.info("creating memory object store");
- }
-
- // ///////////////////////////////////////////////////////
- // Name
- // ///////////////////////////////////////////////////////
-
- @Override
- public String name() {
- return "In-Memory Object Store";
- }
-
- // ///////////////////////////////////////////////////////
- // open, close, shutdown
- // ///////////////////////////////////////////////////////
-
- @Override
- public void open() {
- // TODO: all a bit hacky, but is to keep tests running. Should really
- // sort out using mocks.
- final InMemoryPersistenceSessionFactory inMemoryPersistenceSessionFactory = getInMemoryPersistenceSessionFactory();
- persistedObjects = inMemoryPersistenceSessionFactory == null ? null : inMemoryPersistenceSessionFactory.getPersistedObjects();
- if (persistedObjects == null) {
- if (inMemoryPersistenceSessionFactory != null) {
- persistedObjects = inMemoryPersistenceSessionFactory.createPersistedObjects();
- } else {
- persistedObjects = new ObjectStorePersistedObjects();
- }
- } else {
- recreateAdapters();
- }
- }
-
- protected void recreateAdapters() {
- for (final ObjectSpecId noSpec : persistedObjects.specifications()) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("recreating adapters for: " + noSpec.asString());
- }
- recreateAdapters(persistedObjects.instancesFor(noSpec));
- }
- }
-
- private void recreateAdapters(final ObjectStoreInstances objectStoreInstances) {
- for (final Oid oid : objectStoreInstances.getOids()) {
-
- // it's important not to "touch" the pojo, not even in log messages.
- // That's because
- // the toString() will cause bytecode enhancement to try to resolve
- // references.
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("recreating adapter: oid=" + oid);
- }
- final Object pojo = objectStoreInstances.getPojo(oid);
-
- final ObjectAdapter existingAdapterLookedUpByPojo = getAdapterManager().getAdapterFor(pojo);
- if (existingAdapterLookedUpByPojo != null) {
- // this could happen if we rehydrate a persisted object that
- // depends on another persisted object
- // not yet rehydrated.
- getPersistenceSession().getAdapterManager().removeAdapter(existingAdapterLookedUpByPojo);
- }
-
- final ObjectAdapter existingAdapterLookedUpByOid = getAdapterManager().getAdapterFor(oid);
- if (existingAdapterLookedUpByOid != null) {
- throw new IsisException("A mapping already exists for " + oid + ": " + existingAdapterLookedUpByOid);
- }
-
- final ObjectAdapter recreatedAdapter = getPersistenceSession().getAdapterManager().mapRecreatedPojo(oid, pojo);
-
- final Version version = objectStoreInstances.getVersion(oid);
- recreatedAdapter.setVersion(version);
- }
- }
-
- @Override
- public void close() {
- final InMemoryPersistenceSessionFactory inMemoryPersistenceSessionFactory = getInMemoryPersistenceSessionFactory();
- // TODO: this is hacky, only here to keep tests running. Should sort out
- // using mocks
- if (inMemoryPersistenceSessionFactory != null) {
- inMemoryPersistenceSessionFactory.attach(getPersistenceSession(), persistedObjects);
- persistedObjects = null;
- }
- }
-
- // ///////////////////////////////////////////////////////
- // fixtures
- // ///////////////////////////////////////////////////////
-
- /**
- * No permanent persistence, so must always install fixtures.
- */
- @Override
- public boolean isFixturesInstalled() {
- return false;
- }
-
- // ///////////////////////////////////////////////////////
- // reset
- // ///////////////////////////////////////////////////////
-
- @Override
- public void reset() {
- }
-
- // ///////////////////////////////////////////////////////
- // Transaction management
- // ///////////////////////////////////////////////////////
-
- @Override
- public void startTransaction() {
- }
-
- @Override
- public void endTransaction() {
- }
-
- @Override
- public void abortTransaction() {
- }
-
- // ///////////////////////////////////////////////////////
- // Command Creation
- // ///////////////////////////////////////////////////////
-
- @Override
- public CreateObjectCommand createCreateObjectCommand(final ObjectAdapter object) {
- if (object.getSpecification().isParented()) {
- return null;
- }
- return new InMemoryCreateObjectCommand(object, persistedObjects);
- }
-
- @Override
- public SaveObjectCommand createSaveObjectCommand(final ObjectAdapter object) {
- if (object.getSpecification().isParented()) {
- return null;
- }
- return new InMemorySaveObjectCommand(object, persistedObjects);
- }
-
- @Override
- public DestroyObjectCommand createDestroyObjectCommand(final ObjectAdapter object) {
- return new InMemoryDestroyObjectCommand(object, persistedObjects);
- }
-
- // ///////////////////////////////////////////////////////
- // Command Execution
- // ///////////////////////////////////////////////////////
-
- @Override
- public void execute(final List<PersistenceCommand> commands) throws ObjectPersistenceException {
- if (LOG.isInfoEnabled()) {
- LOG.info("execute commands");
- }
- for (final PersistenceCommand command : commands) {
- command.execute(null);
- }
- LOG.info("end execution");
- }
-
- // ///////////////////////////////////////////////////////
- // getObject, resolveField, resolveImmediately
- // ///////////////////////////////////////////////////////
-
- @Override
- public ObjectAdapter loadInstanceAndAdapt(final TypedOid oid) throws ObjectNotFoundException, ObjectPersistenceException {
- if(LOG.isDebugEnabled()) {
- LOG.debug("getObject " + oid);
- }
- final ObjectSpecification objectSpec = getSpecificationLookup().lookupBySpecId(oid.getObjectSpecId());
- final ObjectStoreInstances ins = instancesFor(objectSpec.getSpecId());
- final ObjectAdapter adapter = ins.getObjectAndMapIfRequired(oid);
- if (adapter == null) {
- throw new ObjectNotFoundException(oid);
- }
- return adapter;
- }
-
- @Override
- public void resolveImmediately(final ObjectAdapter adapter) throws ObjectPersistenceException {
-
- // these diagnostics are because, even though this method is called by
- // PersistenceSessionObjectStore#resolveImmediately which has a check,
- // seem to be hitting a race condition with another thread that is
- // resolving the object before I get here.
- if (adapter.canTransitionToResolving()) {
- if(LOG.isDebugEnabled()) {
- LOG.debug("resolve " + adapter);
- }
- } else {
- LOG.warn("resolveImmediately ignored, " + "adapter's current state is: " + adapter.getResolveState() + " ; oid: " + adapter.getOid());
- }
-
- adapter.markAsResolvedIfPossible();
- }
-
-
- // ///////////////////////////////////////////////////////
- // getInstances, hasInstances
- // ///////////////////////////////////////////////////////
-
- @Override
- public List<ObjectAdapter> loadInstancesAndAdapt(final PersistenceQuery persistenceQuery) throws ObjectPersistenceException, UnsupportedFindException {
-
- if (!(persistenceQuery instanceof PersistenceQueryBuiltIn)) {
- throw new IllegalArgumentException(MessageFormat.format("Provided PersistenceQuery not supported; was {0}; " + "the in-memory object store only supports {1}", persistenceQuery.getClass().getName(), PersistenceQueryBuiltIn.class.getName()));
- }
- final PersistenceQueryBuiltIn builtIn = (PersistenceQueryBuiltIn) persistenceQuery;
-
- final List<ObjectAdapter> instances = Lists.newArrayList();
- final ObjectSpecification spec = persistenceQuery.getSpecification();
- findInstances(spec, builtIn, instances);
- return resolved(instances);
- }
-
- @Override
- public boolean hasInstances(final ObjectSpecification spec) {
- if (instancesFor(spec.getSpecId()).hasInstances()) {
- return true;
- }
-
- // includeSubclasses
- final List<ObjectSpecification> subclasses = spec.subclasses();
- for (int i = 0; i < subclasses.size(); i++) {
- if (hasInstances(subclasses.get(i))) {
- return true;
- }
- }
-
- return false;
- }
-
- private void findInstances(final ObjectSpecification spec, final PersistenceQueryBuiltIn persistenceQuery, final List<ObjectAdapter> foundInstances) {
-
- instancesFor(spec.getSpecId()).findInstancesAndAdd(persistenceQuery, foundInstances);
-
- // include subclasses
- final List<ObjectSpecification> subclasses = spec.subclasses();
- for (int i = 0; i < subclasses.size(); i++) {
- findInstances(subclasses.get(i), persistenceQuery, foundInstances);
- }
- }
-
- private static List<ObjectAdapter> resolved(final List<ObjectAdapter> instances) {
- for (ObjectAdapter adapter: instances) {
- adapter.markAsResolvedIfPossible();
- }
- return instances;
- }
-
- // ///////////////////////////////////////////////////////
- // Services
- // ///////////////////////////////////////////////////////
-
- @Override
- public RootOid getOidForService(ObjectSpecification serviceSpec) {
- return (RootOid) persistedObjects.getService(serviceSpec.getSpecId());
- }
-
- @Override
- public void registerService(final RootOid rootOid) {
- persistedObjects.registerService(rootOid.getObjectSpecId(), rootOid);
- }
-
- private ObjectStoreInstances instancesFor(final ObjectSpecId spec) {
- return persistedObjects.instancesFor(spec);
- }
-
- // ///////////////////////////////////////////////////////
- // Debugging
- // ///////////////////////////////////////////////////////
-
- @Override
- public String debugTitle() {
- return name();
- }
-
- @Override
- public void debugData(final DebugBuilder debug) {
- debug.appendTitle("Domain Objects");
- for (final ObjectSpecId specId : persistedObjects.specifications()) {
- debug.appendln(specId.asString());
- final ObjectStoreInstances instances = instancesFor(specId);
- instances.debugData(debug);
- }
- debug.unindent();
- debug.appendln();
- }
-
- private String debugCollectionGraph(final ObjectAdapter collection, final int level, final Vector<ObjectAdapter> recursiveElements) {
- final StringBuffer s = new StringBuffer();
-
- if (recursiveElements.contains(collection)) {
- s.append("*\n");
- } else {
- recursiveElements.addElement(collection);
-
- final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
- final Iterator<ObjectAdapter> e = facet.iterator(collection);
-
- while (e.hasNext()) {
- indent(s, level);
-
- ObjectAdapter element;
- try {
- element = e.next();
- } catch (final ClassCastException ex) {
- LOG.error(ex.getMessage(), ex);
- return s.toString();
- }
-
- s.append(element);
- s.append(debugGraph(element, level + 1, recursiveElements));
- }
- }
-
- return s.toString();
- }
-
- private String debugGraph(final ObjectAdapter object, final int level, final Vector<ObjectAdapter> recursiveElements) {
- if (level > 3) {
- return "...\n"; // only go 3 levels?
- }
-
- Vector<ObjectAdapter> elements;
- if (recursiveElements == null) {
- elements = new Vector<ObjectAdapter>(25, 10);
- } else {
- elements = recursiveElements;
- }
-
- if (object.getSpecification().isParentedOrFreeCollection()) {
- return "\n" + debugCollectionGraph(object, level, elements);
- } else {
- return "\n" + debugObjectGraph(object, level, elements);
- }
- }
-
- private String debugObjectGraph(final ObjectAdapter object, final int level, final Vector<ObjectAdapter> recursiveElements) {
- final StringBuffer s = new StringBuffer();
-
- recursiveElements.addElement(object);
-
- // work through all its fields
- final List<ObjectAssociation> fields = object.getSpecification().getAssociations(Contributed.EXCLUDED);
-
- for (int i = 0; i < fields.size(); i++) {
- final ObjectAssociation field = fields.get(i);
- final Object obj = field.get(object);
-
- final String id = field.getId();
- indent(s, level);
-
- if (field.isOneToManyAssociation()) {
- s.append(id + ": \n" + debugCollectionGraph((ObjectAdapter) obj, level + 1, recursiveElements));
- } else {
- if (recursiveElements.contains(obj)) {
- s.append(id + ": " + obj + "*\n");
- } else {
- s.append(id + ": " + obj);
- s.append(debugGraph((ObjectAdapter) obj, level + 1, recursiveElements));
- }
- }
- }
-
- return s.toString();
- }
-
- private void indent(final StringBuffer s, final int level) {
- for (int indent = 0; indent < level; indent++) {
- s.append(DebugUtils.indentString(4) + "|");
- }
-
- s.append(DebugUtils.indentString(4) + "+--");
- }
-
- // ///////////////////////////////////////////////////////
- // Dependencies (from context)
- // ///////////////////////////////////////////////////////
-
- /**
- * Must use {@link IsisContext context}, because although this object is
- * recreated with each {@link PersistenceSession session}, the persisted
- * objects that get attached to
- * it span multiple sessions.
- *
- * <p>
- * The alternative design would be to laboriously inject the session into
- * not only this object but also the {@link ObjectStoreInstances} that do
- * the work.
- */
- protected PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
- /**
- * Must use {@link IsisContext context}, because although this object is
- * recreated with each {@link PersistenceSession session}, the persisted
- * objects that get attached to it span multiple sessions.
- *
- * <p>
- * The alternative design would be to laboriously inject the session into
- * not only this object but also the {@link ObjectStoreInstances} that do
- * the work.
- */
- protected AdapterManager getAdapterManager() {
- return getPersistenceSession().getAdapterManager();
- }
-
- protected SpecificationLoader getSpecificationLookup() {
- return IsisContext.getSpecificationLoader();
- }
-
-
- /**
- * Downcasts the {@link org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory} to
- * {@link InMemoryPersistenceSessionFactory}.
- */
- protected InMemoryPersistenceSessionFactory getInMemoryPersistenceSessionFactory() {
- final PersistenceSessionFactory persistenceSessionFactory = getPersistenceSession().getPersistenceSessionFactory();
-
- if (!(persistenceSessionFactory instanceof InMemoryPersistenceSessionFactory)) {
- // for testing support
- return null;
- }
- return (InMemoryPersistenceSessionFactory) persistenceSessionFactory;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceMechanismInstaller.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceMechanismInstaller.java b/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceMechanismInstaller.java
deleted file mode 100644
index cc48c06..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceMechanismInstaller.java
+++ /dev/null
@@ -1,66 +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.objectstore;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstallerAbstract;
-import org.apache.isis.core.runtime.system.DeploymentType;
-import org.apache.isis.core.runtime.system.persistence.ObjectStore;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
-
-/**
- * Installs the in-memory object store.
- */
-public class InMemoryPersistenceMechanismInstaller extends PersistenceMechanismInstallerAbstract {
-
- public static final String NAME = "in-memory";
-
- public InMemoryPersistenceMechanismInstaller() {
- super(NAME);
- }
-
- // ///////////////////////////////////////////////////////////////
- // createPersistenceSessionFactory
- // ///////////////////////////////////////////////////////////////
-
- @Override
- public PersistenceSessionFactory createPersistenceSessionFactory(final DeploymentType deploymentType) {
- return new InMemoryPersistenceSessionFactory(deploymentType, getConfiguration(), this);
- }
-
- // ///////////////////////////////////////////////////////////////
- // Hook methods
- // ///////////////////////////////////////////////////////////////
-
- /**
- * Hook method to return {@link ObjectStore}.
- */
- @Override
- public ObjectStore createObjectStore(
- final IsisConfiguration configuration) {
- return new InMemoryObjectStore();
- }
-
-
-
-
-}
-
-
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceSessionFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceSessionFactory.java b/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceSessionFactory.java
deleted file mode 100644
index 455ca6a..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/objectstore/InMemoryPersistenceSessionFactory.java
+++ /dev/null
@@ -1,95 +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.objectstore;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.objectstore.internal.ObjectStoreInstances;
-import org.apache.isis.core.objectstore.internal.ObjectStorePersistedObjects;
-import org.apache.isis.core.runtime.persistence.ObjectStoreFactory;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
-import org.apache.isis.core.runtime.system.DeploymentType;
-import org.apache.isis.core.runtime.system.persistence.IdentifierGenerator;
-import org.apache.isis.core.runtime.system.persistence.IdentifierGeneratorDefault;
-import org.apache.isis.core.runtime.system.persistence.OidGenerator;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-
-public class InMemoryPersistenceSessionFactory extends PersistenceSessionFactory {
-
- private ObjectStorePersistedObjects persistedObjects;
-
- public InMemoryPersistenceSessionFactory(final DeploymentType deploymentType, final IsisConfiguration configuration, final ObjectStoreFactory objectStoreFactory) {
- super(deploymentType, configuration, objectStoreFactory);
- }
-
- ObjectStorePersistedObjects getPersistedObjects() {
- return persistedObjects;
- }
-
- @Override
- public PersistenceSession createPersistenceSession() {
- final PersistenceSession persistenceSession = super.createPersistenceSession();
- if (persistedObjects != null) {
- final OidGenerator oidGenerator = persistenceSession.getOidGenerator();
- final IdentifierGenerator identifierGenerator = oidGenerator.getIdentifierGenerator();
- final IdentifierGeneratorDefault identifierGeneratorDefault = identifierGenerator.underlying(IdentifierGeneratorDefault.class);
- if(identifierGeneratorDefault != null) {
- identifierGeneratorDefault.resetTo(persistedObjects.getOidGeneratorMemento());
- }
- }
-
- return persistenceSession;
- }
-
- /**
- * Not API - called when {@link InMemoryObjectStore} first
- * {@link InMemoryObjectStore#open() open}ed.
- */
- public ObjectStorePersistedObjects createPersistedObjects() {
- return new ObjectStorePersistedObjects();
- }
-
- /**
- * Not API - called when {@link InMemoryObjectStore} is
- * {@link InMemoryObjectStore#close() close}d.
- */
- public void attach(final PersistenceSession persistenceSession, final ObjectStorePersistedObjects persistedObjects) {
- final OidGenerator oidGenerator = persistenceSession.getOidGenerator();
- final IdentifierGenerator identifierGenerator = oidGenerator.getIdentifierGenerator();
-
- final IdentifierGeneratorDefault identifierGeneratorDefault = identifierGenerator.underlying(IdentifierGeneratorDefault.class);
- if(identifierGeneratorDefault != null) {
- identifierGeneratorDefault.resetTo(persistedObjects.getOidGeneratorMemento());
- persistedObjects.saveOidGeneratorMemento(identifierGeneratorDefault.getMemento());
- }
-
- this.persistedObjects = persistedObjects;
- }
-
- @Override
- protected void doShutdown() {
- if (persistedObjects != null) {
- for (final ObjectStoreInstances inst : persistedObjects.instances()) {
- inst.shutdown();
- }
- persistedObjects.clear();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/AbstractInMemoryPersistenceCommand.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/AbstractInMemoryPersistenceCommand.java b/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/AbstractInMemoryPersistenceCommand.java
deleted file mode 100644
index 9c5602c..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/AbstractInMemoryPersistenceCommand.java
+++ /dev/null
@@ -1,64 +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.objectstore.commands;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.objectstore.internal.ObjectStoreInstances;
-import org.apache.isis.core.objectstore.internal.ObjectStorePersistedObjects;
-import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommandAbstract;
-
-public abstract class AbstractInMemoryPersistenceCommand extends PersistenceCommandAbstract {
-
- private final static Logger LOG = LoggerFactory.getLogger(AbstractInMemoryPersistenceCommand.class);
-
- private final ObjectStorePersistedObjects persistedObjects;
-
- public AbstractInMemoryPersistenceCommand(final ObjectAdapter adapter, final ObjectStorePersistedObjects persistedObjects) {
- super(adapter);
- this.persistedObjects = persistedObjects;
- }
-
- protected void save(final ObjectAdapter adapter) throws ObjectPersistenceException {
- final ObjectSpecification specification = adapter.getSpecification();
- if (LOG.isDebugEnabled()) {
- LOG.debug(" saving object " + adapter + " as instance of " + specification.getShortIdentifier());
- }
- final ObjectStoreInstances ins = instancesFor(specification.getSpecId());
- ins.save(adapter); // also sets the version
- }
-
- protected void destroy(final ObjectAdapter adapter) {
- final ObjectSpecification specification = adapter.getSpecification();
- if (LOG.isDebugEnabled()) {
- LOG.debug(" destroy object " + adapter + " as instance of " + specification.getShortIdentifier());
- }
- final ObjectStoreInstances ins = instancesFor(specification.getSpecId());
- ins.remove(adapter.getOid());
- }
-
- private ObjectStoreInstances instancesFor(final ObjectSpecId spec) {
- return persistedObjects.instancesFor(spec);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemoryCreateObjectCommand.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemoryCreateObjectCommand.java b/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemoryCreateObjectCommand.java
deleted file mode 100644
index af2d363..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemoryCreateObjectCommand.java
+++ /dev/null
@@ -1,49 +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.objectstore.commands;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.objectstore.internal.ObjectStorePersistedObjects;
-import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.CreateObjectCommand;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
-
-public final class InMemoryCreateObjectCommand extends AbstractInMemoryPersistenceCommand implements CreateObjectCommand {
- private final static Logger LOG = LoggerFactory.getLogger(InMemoryCreateObjectCommand.class);
-
- public InMemoryCreateObjectCommand(final ObjectAdapter object, final ObjectStorePersistedObjects persistedObjects) {
- super(object, persistedObjects);
- }
-
- @Override
- public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
- if (LOG.isDebugEnabled()) {
- LOG.debug(" create object " + onAdapter());
- }
- save(onAdapter());
- }
-
- @Override
- public String toString() {
- return "CreateObjectCommand [object=" + onAdapter() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemoryDestroyObjectCommand.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemoryDestroyObjectCommand.java b/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemoryDestroyObjectCommand.java
deleted file mode 100644
index 16093ab..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemoryDestroyObjectCommand.java
+++ /dev/null
@@ -1,49 +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.objectstore.commands;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.objectstore.internal.ObjectStorePersistedObjects;
-import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
-
-public final class InMemoryDestroyObjectCommand extends AbstractInMemoryPersistenceCommand implements DestroyObjectCommand {
- private final static Logger LOG = LoggerFactory.getLogger(InMemoryDestroyObjectCommand.class);
-
- public InMemoryDestroyObjectCommand(final ObjectAdapter adapter, final ObjectStorePersistedObjects persistedObjects) {
- super(adapter, persistedObjects);
- }
-
- @Override
- public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
- if (LOG.isInfoEnabled()) {
- LOG.info(" delete object '" + onAdapter() + "'");
- }
- destroy(onAdapter());
- }
-
- @Override
- public String toString() {
- return "DestroyObjectCommand [object=" + onAdapter() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemorySaveObjectCommand.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemorySaveObjectCommand.java b/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemorySaveObjectCommand.java
deleted file mode 100644
index 4b48f61..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/objectstore/commands/InMemorySaveObjectCommand.java
+++ /dev/null
@@ -1,48 +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.objectstore.commands;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.objectstore.internal.ObjectStorePersistedObjects;
-import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
-import org.apache.isis.core.runtime.persistence.objectstore.transaction.SaveObjectCommand;
-
-public final class InMemorySaveObjectCommand extends AbstractInMemoryPersistenceCommand implements SaveObjectCommand {
-
- @SuppressWarnings("unused")
- private final static Logger LOG = LoggerFactory.getLogger(InMemorySaveObjectCommand.class);
-
- public InMemorySaveObjectCommand(final ObjectAdapter object, final ObjectStorePersistedObjects persistedObjects) {
- super(object, persistedObjects);
- }
-
- @Override
- public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
- save(onAdapter());
- }
-
- @Override
- public String toString() {
- return "SaveObjectCommand [object=" + onAdapter() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/main/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances.java b/core/runtime/src/main/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances.java
deleted file mode 100644
index b24f332..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances.java
+++ /dev/null
@@ -1,246 +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.objectstore.internal;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.isis.applib.clock.Clock;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.adapter.version.SerialNumberVersion;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.objectstore.InMemoryObjectStore;
-import org.apache.isis.core.runtime.persistence.query.PersistenceQueryBuiltIn;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-
-/*
- * The objects need to store in a repeatable sequence so the elements and instances method return the same data for any repeated
- * call, and so that one subset of instances follows on the previous. This is done by keeping the objects in the order that they
- * where created.
- */
-public class ObjectStoreInstances {
-
- private final Map<Oid, Object> pojoByOidMap = new HashMap<Oid, Object>();
- private final Map<Oid, Version> versionByOidMap = new HashMap<Oid, Version>();
-
- @SuppressWarnings("unused")
- private final ObjectSpecId spec;
-
- // ///////////////////////////////////////////////////////
- // Constructors
- // ///////////////////////////////////////////////////////
-
- public ObjectStoreInstances(final ObjectSpecId spec) {
- this.spec = spec;
- }
-
- // ///////////////////////////////////////////////////////
- // Object Instances
- // ///////////////////////////////////////////////////////
-
- /**
- * TODO: shouldn't really be exposing this directly.
- */
- public Map<Oid, Object> getObjectInstances() {
- return pojoByOidMap;
- }
-
- public Set<Oid> getOids() {
- return Collections.unmodifiableSet(pojoByOidMap.keySet());
- }
-
- public Object getPojo(final Oid oid) {
- return pojoByOidMap.get(oid);
- }
-
- public Version getVersion(final Oid oid) {
- return versionByOidMap.get(oid);
- }
-
- // ///////////////////////////////////////////////////////
- // shutdown
- // ///////////////////////////////////////////////////////
-
- public void shutdown() {
- pojoByOidMap.clear();
- versionByOidMap.clear();
- }
-
- // ///////////////////////////////////////////////////////
- // save, remove
- // ///////////////////////////////////////////////////////
-
- public void save(final ObjectAdapter adapter) {
- pojoByOidMap.put(adapter.getOid(), adapter.getObject());
-
- final Version version = versionByOidMap.get(adapter.getOid());
- final Version nextVersion = nextVersion(version);
- versionByOidMap.put(adapter.getOid(), nextVersion);
- adapter.setVersion(nextVersion);
- }
-
- private synchronized Version nextVersion(final Version version) {
- final long sequence = (version != null ? version.getSequence() : 0) + 1;
- return SerialNumberVersion.create(sequence, getAuthenticationSession().getUserName(), new Date(Clock.getTime()));
- }
-
- public void remove(final Oid oid) {
- pojoByOidMap.remove(oid);
- versionByOidMap.remove(oid);
- }
-
- // ///////////////////////////////////////////////////////
- // retrieveObject
- // ///////////////////////////////////////////////////////
-
- /**
- * If the pojo exists in the object store, then looks up the
- * {@link ObjectAdapter adapter} from the {@link org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDefault}, and only
- * if none found does it recreates a new {@link ObjectAdapter adapter}.
- */
- public ObjectAdapter getObjectAndMapIfRequired(final Oid oid) {
- final Object pojo = getObjectInstances().get(oid);
- if (pojo == null) {
- return null;
- }
- final ObjectAdapter adapterLookedUpByPojo = getAdapterManager().getAdapterFor(pojo);
- if (adapterLookedUpByPojo != null) {
- return adapterLookedUpByPojo;
- }
- final ObjectAdapter adapterLookedUpByOid = getAdapterManager().getAdapterFor(oid);
- if (adapterLookedUpByOid != null) {
- return adapterLookedUpByOid;
- }
- return getPersistenceSession().getAdapterManager().mapRecreatedPojo(oid, pojo);
- }
-
- // ///////////////////////////////////////////////////////
- // instances, numberOfInstances, hasInstances
- // ///////////////////////////////////////////////////////
-
- /**
- * Not API, but <tt>public</tt> so can be called by
- * {@link InMemoryObjectStore}.
- */
- public void findInstancesAndAdd(final PersistenceQueryBuiltIn persistenceQuery, final List<ObjectAdapter> foundInstances) {
- for (final ObjectAdapter element : elements()) {
- if (persistenceQuery.matches(element)) {
- foundInstances.add(element);
- }
- }
- }
-
- public int numberOfInstances() {
- return getObjectInstances().size();
- }
-
- public boolean hasInstances() {
- return numberOfInstances() > 0;
- }
-
- private List<ObjectAdapter> elements() {
- final List<ObjectAdapter> v = new ArrayList<ObjectAdapter>(getObjectInstances().size());
- for (final Oid oid : getObjectInstances().keySet()) {
- v.add(getObjectAndMapIfRequired(oid));
- }
- return v;
- }
-
- // ///////////////////////////////////////////////////////
- // Debugging
- // ///////////////////////////////////////////////////////
-
- public void debugData(final DebugBuilder debug) {
- debug.indent();
- if (getObjectInstances().size() == 0) {
- debug.appendln("no instances");
- }
- for (final Oid oid : getObjectInstances().keySet()) {
- final ObjectAdapter objectAdapter = getObjectAndMapIfRequired(oid);
- final String title = objectAdapter.titleString();
- final Object object = getObjectInstances().get(oid);
- debug.appendln(oid.toString(), object + " (" + title + ")");
- }
- debug.appendln();
- debug.unindent();
- }
-
- // ///////////////////////////////////////////////////////
- // Dependencies (from context)
- // ///////////////////////////////////////////////////////
-
- /**
- * Must use {@link IsisContext context}, because although this object is
- * recreated with each {@link PersistenceSession session}, the persisted
- * objects that get
- * {@link #attachPersistedObjects(MemoryObjectStorePersistedObjects)
- * attached} to it span multiple sessions.
- *
- * <p>
- * The alternative design would be to laboriously inject this object via the
- * {@link InMemoryObjectStore}.
- */
- protected PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
- /**
- * Must use {@link IsisContext context}, because although this object is
- * recreated with each {@link PersistenceSession session}, the persisted
- * objects that get
- * {@link #attachPersistedObjects(MemoryObjectStorePersistedObjects)
- * attached} to it span multiple sessions.
- *
- * <p>
- * The alternative design would be to laboriously inject this object via the
- * {@link InMemoryObjectStore}.
- */
- protected AdapterManager getAdapterManager() {
- return getPersistenceSession().getAdapterManager();
- }
-
- /**
- * Must use {@link IsisContext context}, because although this object is
- * recreated with each {@link PersistenceSession session}, the persisted
- * objects that get
- * {@link #attachPersistedObjects(MemoryObjectStorePersistedObjects)
- * attached} to it span multiple sessions.
- *
- * <p>
- * The alternative design would be to laboriously inject this object via the
- * {@link InMemoryObjectStore}.
- */
- protected AuthenticationSession getAuthenticationSession() {
- return IsisContext.getAuthenticationSession();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/main/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjects.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjects.java b/core/runtime/src/main/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjects.java
deleted file mode 100644
index 4e3cf35..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjects.java
+++ /dev/null
@@ -1,94 +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.objectstore.internal;
-
-import java.util.Map;
-import java.util.Set;
-
-import com.google.common.collect.Maps;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.runtime.system.persistence.IdentifierGeneratorDefault;
-
-/**
- * Represents the persisted objects.
- *
- * Attached and detached to each session.
- */
-public class ObjectStorePersistedObjects {
-
- private final Map<ObjectSpecId, ObjectStoreInstances> instancesBySpecMap = Maps.newHashMap();
- private final Map<ObjectSpecId, Oid> serviceOidByIdMap = Maps.newHashMap();
-
- private IdentifierGeneratorDefault.Memento oidGeneratorMemento;
-
-
- public IdentifierGeneratorDefault.Memento getOidGeneratorMemento() {
- return oidGeneratorMemento;
- }
-
- public void saveOidGeneratorMemento(final IdentifierGeneratorDefault.Memento memento) {
- this.oidGeneratorMemento = memento;
- }
-
- public Oid getService(final ObjectSpecId objectSpecId) {
- return serviceOidByIdMap.get(objectSpecId);
- }
-
- public void registerService(final ObjectSpecId objectSpecId, final Oid oid) {
- final Oid oidLookedUpByName = serviceOidByIdMap.get(objectSpecId);
- if (oidLookedUpByName != null) {
- if (oidLookedUpByName.equals(oid)) {
- throw new IsisException("Already another service registered as name: " + objectSpecId + " (existing Oid: " + oidLookedUpByName + ", " + "intended: " + oid + ")");
- }
- } else {
- serviceOidByIdMap.put(objectSpecId, oid);
- }
- }
-
- // TODO: this is where the clever logic needs to go to determine how to save
- // into our custom Map.
- // also think we shouldn't surface the entire Map, just the API we require
- // (keySet, values etc).
- public ObjectStoreInstances instancesFor(final ObjectSpecId specId) {
- ObjectStoreInstances ins = instancesBySpecMap.get(specId);
- if (ins == null) {
- ins = new ObjectStoreInstances(specId);
- instancesBySpecMap.put(specId, ins);
- }
- return ins;
- }
-
- public Iterable<ObjectSpecId> specifications() {
- return instancesBySpecMap.keySet();
- }
-
- public void clear() {
- instancesBySpecMap.clear();
- }
-
- public Iterable<ObjectStoreInstances> instances() {
- return instancesBySpecMap.values();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/main/java/org/apache/isis/core/runtime/progmodels/JavaReflectorInstaller.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/progmodels/JavaReflectorInstaller.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/progmodels/JavaReflectorInstaller.java
index a94012e..6713530 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/progmodels/JavaReflectorInstaller.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/progmodels/JavaReflectorInstaller.java
@@ -34,6 +34,9 @@ import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
import org.apache.isis.core.runtime.installerregistry.InstallerLookupAware;
import org.apache.isis.progmodels.dflt.JavaReflectorInstallerNoDecorators;
+/**
+ * in default runtime only for dynamic lookup of facet decorators
+ */
public class JavaReflectorInstaller extends JavaReflectorInstallerNoDecorators implements InstallerLookupAware {
private static final Logger LOG = LoggerFactory.getLogger(JavaReflectorInstaller.class);
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/main/resources/org/apache/isis/core/runtime/installer-registry.properties
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/resources/org/apache/isis/core/runtime/installer-registry.properties b/core/runtime/src/main/resources/org/apache/isis/core/runtime/installer-registry.properties
index 8a59b0a..5808137 100644
--- a/core/runtime/src/main/resources/org/apache/isis/core/runtime/installer-registry.properties
+++ b/core/runtime/src/main/resources/org/apache/isis/core/runtime/installer-registry.properties
@@ -14,57 +14,35 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-############################################################
-# CORE
-############################################################
-org.apache.isis.core.metamodel.facetdecorator.i18n.resourcebundle.I18nDecoratorUsingResourceBundleInstaller # "resource-i18n"
-org.apache.isis.core.metamodel.facetdecorator.help.file.HelpFacetDecoratorUsingFilesInstaller # "help-file"
+# ObjectReflectorInstaller
+org.apache.isis.core.runtime.progmodels.JavaReflectorInstaller # "java"
-############################################################
-# SECURITY
-############################################################
+# FacetDecoratorInstaller
+org.apache.isis.core.metamodel.facetdecorator.i18n.resourcebundle.I18nDecoratorUsingResourceBundleInstaller # "resource-i18n"
+org.apache.isis.core.metamodel.facetdecorator.help.file.HelpFacetDecoratorUsingFilesInstaller # "help-file"
+org.apache.isis.core.runtime.transaction.facetdecorator.standard.TransactionFacetDecoratorInstaller # "transaction"
+# AuthenticationManagerInstaller
org.apache.isis.core.security.authentication.BypassAuthenticationManagerInstaller # "bypass"
-org.apache.isis.core.security.authorization.BypassAuthorizationManagerInstaller # "bypass"
-
org.apache.isis.security.shiro.authentication.ShiroAuthenticationManagerInstaller # "shiro"
-org.apache.isis.security.shiro.authorization.ShiroAuthorizationManagerInstaller # "shiro"
-
+# AuthorizationManagerInstaller
+org.apache.isis.core.security.authorization.BypassAuthorizationManagerInstaller # "bypass"
+org.apache.isis.security.shiro.authorization.ShiroAuthorizationManagerInstaller # "shiro"
-############################################################
-# PROGRAMMING MODELS
-############################################################
-
-# in default runtime only for dynamic lookup of facet decorators
-org.apache.isis.core.runtime.progmodels.JavaReflectorInstaller # "java"
-
-
-############################################################
-# CORE AND ALTERNATIVE RUNTIME COMPONENTS
-############################################################
-
-# image loader
-org.apache.isis.core.runtime.imageloader.awt.TemplateImageLoaderAwtInstaller # "awt"
-org.apache.isis.core.runtime.imageloader.noop.TemplateImageLoaderNoopInstaller # "noop"
-
-# fixture loaders
+# FixturesInstaller
org.apache.isis.core.runtime.fixtures.FixturesInstallerFromConfiguration "configuration"
-# services
+# ServicesInstaller
org.apache.isis.core.runtime.services.ServicesInstallerFromConfiguration # "configuration"
org.apache.isis.core.runtime.services.ServicesInstallerFromAnnotation # "annotation"
org.apache.isis.core.runtime.services.ServicesInstallerFromConfigurationAndAnnotation # "configuration-and-annotation"
-# objectstores
-org.apache.isis.core.objectstore.InMemoryPersistenceMechanismInstaller # "in-memory"
+# PersistenceMechanismInstaller
org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller # datanucleus
-# reflector decorators
-org.apache.isis.core.runtime.transaction.facetdecorator.standard.TransactionFacetDecoratorInstaller # "transaction"
-
####### END #########
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_findInstancesAndAdd.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_findInstancesAndAdd.java b/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_findInstancesAndAdd.java
deleted file mode 100644
index 45294aa..0000000
--- a/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_findInstancesAndAdd.java
+++ /dev/null
@@ -1,111 +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.objectstore.internal;
-
-import java.util.List;
-import com.google.common.collect.Lists;
-import org.jmock.Expectations;
-import org.jmock.auto.Mock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.matchers.IsisMatchers;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDefault;
-import org.apache.isis.core.runtime.persistence.query.PersistenceQueryBuiltIn;
-import org.apache.isis.core.unittestsupport.jmocking.IsisActions;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
-import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public class ObjectStoreInstances_findInstancesAndAdd {
-
- private ObjectStoreInstances instances;
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- @Mock
- private ObjectSpecId mockSpecId;
- @Mock
- private PersistenceQueryBuiltIn mockPersistenceQueryBuiltIn;
- @Mock
- private AuthenticationSession mockAuthSession;
- @Mock
- private AdapterManagerDefault mockAdapterManager;
-
- @Mock
- private ObjectAdapter mockAdapter1;
- @Mock
- private ObjectAdapter mockAdapter2;
-
- @Before
- public void setUp() throws Exception {
- instances = new ObjectStoreInstances(mockSpecId) {
- @Override
- protected AuthenticationSession getAuthenticationSession() {
- return mockAuthSession;
- }
- @Override
- protected AdapterManagerDefault getAdapterManager() {
- return mockAdapterManager;
- }
- };
- context.ignoring(mockAuthSession);
- }
-
- @Test
- public void findInstancesAndAdd_whenEmpty() throws Exception {
- context.never(mockPersistenceQueryBuiltIn);
- final List<ObjectAdapter> foundInstances = Lists.newArrayList();
- instances.findInstancesAndAdd(mockPersistenceQueryBuiltIn, foundInstances);
- }
-
- @Test
- public void findInstancesAndAdd_whenNotEmpty() throws Exception {
- context.ignoring(mockAdapter1, mockAdapter2);
- context.checking(new Expectations() {
- {
- one(mockPersistenceQueryBuiltIn).matches(mockAdapter1);
- will(returnValue(false));
-
- one(mockPersistenceQueryBuiltIn).matches(mockAdapter2);
- will(returnValue(true));
-
- allowing(mockAdapterManager).getAdapterFor(with(any(Object.class)));
- will(IsisActions.returnEach(mockAdapter1, mockAdapter2));
- }
- });
-
- instances.save(mockAdapter1);
- instances.save(mockAdapter2);
-
- final List<ObjectAdapter> foundInstances = Lists.newArrayList();
- instances.findInstancesAndAdd(mockPersistenceQueryBuiltIn, foundInstances);
-
- assertThat(foundInstances.size(), is(1));
- assertThat(foundInstances, IsisMatchers.listContaining(mockAdapter2));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_init.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_init.java b/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_init.java
deleted file mode 100644
index cd2c384..0000000
--- a/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_init.java
+++ /dev/null
@@ -1,69 +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.objectstore.internal;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-
-/**
- * Tested in style of <i>Working Effectively with Legacy Code</i> (Feathers) and
- * <i>Growing Object-Oriented Software</i> (Freeman & Pryce).
- */
-@RunWith(JMock.class)
-public class ObjectStoreInstances_init {
-
- private ObjectStoreInstances instances;
-
- private final Mockery context = new JUnit4Mockery();
-
- private ObjectSpecId mockSpecId;
-
- @Before
- public void setUp() throws Exception {
- mockSpecId = context.mock(ObjectSpecId.class);
- instances = new ObjectStoreInstances(mockSpecId);
- }
-
- @Test
- public void initiallyEmpty() throws Exception {
- final Map<Oid, Object> objectInstances = instances.getObjectInstances();
- assertThat(objectInstances.size(), is(0));
-
- final Set<Oid> oids = instances.getOids();
- assertThat(oids.size(), is(0));
-
- assertThat(instances.hasInstances(), is(false));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a466fb50/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_save.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_save.java b/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_save.java
deleted file mode 100644
index 9d93d54..0000000
--- a/core/runtime/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_save.java
+++ /dev/null
@@ -1,121 +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.objectstore.internal;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-
-@RunWith(JMock.class)
-public class ObjectStoreInstances_save {
-
- private ObjectStoreInstances instances;
-
- private final Mockery context = new JUnit4Mockery();
-
- private ObjectSpecId mockSpecId;
- private ObjectAdapter mockAdapter;
- private AuthenticationSession mockAuthSession;
-
- @Before
- public void setUp() throws Exception {
- mockSpecId = context.mock(ObjectSpecId.class);
- mockAdapter = context.mock(ObjectAdapter.class);
- mockAuthSession = context.mock(AuthenticationSession.class);
- instances = new ObjectStoreInstances(mockSpecId) {
- @Override
- protected AuthenticationSession getAuthenticationSession() {
- return mockAuthSession;
- }
- };
- ignoreAuthenticationSession();
- }
-
- private void ignoreAuthenticationSession() {
- context.checking(new Expectations() {
- {
- ignoring(mockAuthSession);
- }
- });
- }
-
- @Test
- public void saveUpdatesTheOptimisticLock() throws Exception {
- allowingGetOidAndGetObjectAndTitleStringFromAdapter();
- context.checking(new Expectations() {
- {
- one(mockAdapter).setVersion(with(any(Version.class)));
- }
- });
- instances.save(mockAdapter);
-
- }
-
- @Test
- public void saveStoresObject() throws Exception {
- allowingGetOidAndGetObjectAndTitleStringFromAdapter();
- ignoringInteractionsWithAdapter();
- instances.save(mockAdapter);
-
- final Map<Oid, Object> objectInstances = instances.getObjectInstances();
- assertThat(objectInstances.size(), is(1));
-
- final Set<Oid> oids = instances.getOids();
- assertThat(oids.size(), is(1));
-
- assertThat(instances.hasInstances(), is(true));
-
- }
-
- private void ignoringInteractionsWithAdapter() {
- context.checking(new Expectations() {
- {
- ignoring(mockAdapter);
- }
- });
- }
-
- private void allowingGetOidAndGetObjectAndTitleStringFromAdapter() {
- context.checking(new Expectations() {
- {
- allowing(mockAdapter).getOid();
- allowing(mockAdapter).getObject();
- allowing(mockAdapter).titleString();
- }
- });
- }
-
-}