incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1098940 [1/5] - in /incubator/isis/trunk/runtimes: dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/ dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ dflt/ob...
Date Tue, 03 May 2011 06:42:09 GMT
Author: danhaywood
Date: Tue May  3 06:42:06 2011
New Revision: 1098940

URL: http://svn.apache.org/viewvc?rev=1098940&view=rev
Log:
ISIS-25, ISIS-28, ISIS-22: code cleanup of runtimes:embedded, runtimes.dflt.objectstores:xml, runtimes.dflt.objectstores:dflt

Modified:
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryPersistenceMechanismInstaller.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryPersistenceSessionFactory.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjects.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/AbstractInMemoryPersistenceCommand.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemoryCreateObjectCommand.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemoryDestroyObjectCommand.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemorySaveObjectCommand.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/AbstractInMemoryObjectStoreTest.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_debug.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_init.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_interactionWithAdapterManager.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_name.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_openAndClose.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_persist.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_reset.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_retrieve.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_serviceRegistry.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/fixture/ObjectFixtureFilePersistorTest.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/fixture/ObjectFixtureServiceTest.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_findInstancesAndAdd.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_init.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_save.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_instances.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_savesOidGeneratorAsMemento.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_services.java
    incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/testsystem/TestProxySystemII.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStore.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstaller.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceSessionFactory.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/adapter/XmlAdapterManager.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/Clock.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClock.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/AbstractXmlPersistenceCommand.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlCreateObjectCommand.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlDestroyObjectCommand.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/commands/XmlUpdateObjectCommand.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/CollectionData.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Data.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/DataManager.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectData.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataVector.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/PersistorException.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ReferenceVector.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManager.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/services/ServiceManager.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/services/xml/XmlServiceManager.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/utils/CopyXmlObjectStore.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/main/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/version/FileVersion.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/ObjectStorePersistenceHelper.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlObjectStoreTest.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/XmlPersistenceMechanismInstallerTest.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/DefaultClockTest.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/clock/TestClock.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/MockDataManager.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataTest.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ObjectDataVectorTest.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Person.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/ReferenceVectorTest.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Role.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/Team.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManagerInstancesTest.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/data/xml/XmlDataManagerTest.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/services/DummyServiceManager.java
    incubator/isis/trunk/runtimes/dflt/objectstores/xml/src/test/java/org/apache/isis/runtimes/dflt/objectstores/xml/internal/version/FileVersionTest.java
    incubator/isis/trunk/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/EmbeddedContext.java
    incubator/isis/trunk/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/EmbeddedContextNoop.java
    incubator/isis/trunk/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/IsisMetaModel.java
    incubator/isis/trunk/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/internal/PersistenceState.java
    incubator/isis/trunk/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/internal/RuntimeContextForEmbeddedMetaModel.java
    incubator/isis/trunk/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/internal/ServiceAdapter.java
    incubator/isis/trunk/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/internal/StandaloneAdapter.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenEmbeddedViewerAndPersistentDomainObject.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialize.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialized.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiate.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiated.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenShutdown.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/claim/Approver.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/claim/Claim.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/claim/ClaimItem.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/claim/ClaimRepository.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/claim/ClaimRepositoryImpl.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/claim/Claimant.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/employee/Employee.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/employee/EmployeeRepository.java
    incubator/isis/trunk/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/employee/EmployeeRepositoryImpl.java

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.dflt;
 
 import java.text.MessageFormat;
@@ -25,8 +24,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
 
-import org.apache.log4j.Logger;
-
 import org.apache.isis.core.commons.debug.DebugBuilder;
 import org.apache.isis.core.commons.debug.DebugUtils;
 import org.apache.isis.core.commons.exceptions.IsisException;
@@ -38,6 +35,12 @@ import org.apache.isis.core.metamodel.fa
 import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStoreInstances;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjects;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjectsDefault;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands.InMemoryCreateObjectCommand;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands.InMemoryDestroyObjectCommand;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands.InMemorySaveObjectCommand;
 import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectNotFoundException;
 import org.apache.isis.runtimes.dflt.runtime.persistence.PersistorUtil;
 import org.apache.isis.runtimes.dflt.runtime.persistence.UnsupportedFindException;
@@ -54,13 +57,7 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionFactory;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionHydrator;
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStoreInstances;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjects;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjectsDefault;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands.InMemoryCreateObjectCommand;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands.InMemoryDestroyObjectCommand;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands.InMemorySaveObjectCommand;
-
+import org.apache.log4j.Logger;
 
 public class InMemoryObjectStore implements ObjectStore {
 
@@ -87,70 +84,72 @@ public class InMemoryObjectStore impleme
 
     @Override
     public void open() {
-        // TODO: all a bit hacky, but is to keep tests running.  Should really sort out using mocks.
-        InMemoryPersistenceSessionFactory inMemoryPersistenceSessionFactory = getInMemoryPersistenceSessionFactory();
-        persistedObjects = inMemoryPersistenceSessionFactory == null ? null : inMemoryPersistenceSessionFactory.getPersistedObjects();
+        // 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 ObjectStorePersistedObjectsDefault();
-        	}
+            if (inMemoryPersistenceSessionFactory != null) {
+                persistedObjects = inMemoryPersistenceSessionFactory.createPersistedObjects();
+            } else {
+                persistedObjects = new ObjectStorePersistedObjectsDefault();
+            }
         } else {
             recreateAdapters();
         }
     }
 
     protected void recreateAdapters() {
-        for(ObjectSpecification noSpec: persistedObjects.specifications()) {
-			if (LOG.isDebugEnabled()) {
-				LOG.debug("recreating adapters for: " + noSpec.getFullIdentifier());
-			}
-        	recreateAdapters(persistedObjects.instancesFor(noSpec));
+        for (final ObjectSpecification noSpec : persistedObjects.specifications()) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("recreating adapters for: " + noSpec.getFullIdentifier());
+            }
+            recreateAdapters(persistedObjects.instancesFor(noSpec));
         }
     }
 
-	private void recreateAdapters(ObjectStoreInstances objectStoreInstances) {
-		for (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);
-			}
-		    Object pojo = objectStoreInstances.getPojo(oid);
-
-		    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.
-		    	getAdapterManager().removeAdapter(existingAdapterLookedUpByPojo);
-		    }
-
-		    ObjectAdapter existingAdapterLookedUpByOid = getAdapterManager().getAdapterFor(oid);
-		    if (existingAdapterLookedUpByOid != null) {
-		        throw new IsisException("A mapping already exists for " + oid  + ": " + existingAdapterLookedUpByOid);
-		    }
-
-		    ObjectAdapter recreatedAdapter = getHydrator().recreateAdapter(oid, pojo);
-		    
-		    Version version = objectStoreInstances.getVersion(oid);
-		    recreatedAdapter.setOptimisticLock(version);
-		}
-	}
+    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.
+                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 = getHydrator().recreateAdapter(oid, pojo);
 
-	@Override
+            final Version version = objectStoreInstances.getVersion(oid);
+            recreatedAdapter.setOptimisticLock(version);
+        }
+    }
+
+    @Override
     public void close() {
-        final InMemoryPersistenceSessionFactory inMemoryPersistenceSessionFactory = getInMemoryPersistenceSessionFactory();
-        // TODO: this is hacky, only here to keep tests running.  Should sort out using mocks
+        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;
-        } 
+            inMemoryPersistenceSessionFactory.attach(getPersistenceSession(), persistedObjects);
+            persistedObjects = null;
+        }
     }
 
-
     // ///////////////////////////////////////////////////////
     // fixtures
     // ///////////////////////////////////////////////////////
@@ -168,20 +167,24 @@ public class InMemoryObjectStore impleme
     // ///////////////////////////////////////////////////////
 
     @Override
-    public void reset() {}
+    public void reset() {
+    }
 
     // ///////////////////////////////////////////////////////
     // Transaction management
     // ///////////////////////////////////////////////////////
 
     @Override
-    public void startTransaction() {}
+    public void startTransaction() {
+    }
 
     @Override
-    public void endTransaction() {}
+    public void endTransaction() {
+    }
 
     @Override
-    public void abortTransaction() {}
+    public void abortTransaction() {
+    }
 
     // ///////////////////////////////////////////////////////
     // Command Creation
@@ -211,7 +214,7 @@ public class InMemoryObjectStore impleme
         if (LOG.isInfoEnabled()) {
             LOG.info("execute commands");
         }
-        for (PersistenceCommand command : commands) {
+        for (final PersistenceCommand command : commands) {
             command.execute(null);
         }
         LOG.info("end execution");
@@ -223,7 +226,7 @@ public class InMemoryObjectStore impleme
 
     @Override
     public ObjectAdapter getObject(final Oid oid, final ObjectSpecification hint) throws ObjectNotFoundException,
-            ObjectPersistenceException {
+        ObjectPersistenceException {
         LOG.debug("getObject " + oid);
         final ObjectStoreInstances ins = instancesFor(hint);
         final ObjectAdapter object = ins.retrieveObject(oid);
@@ -238,27 +241,27 @@ public class InMemoryObjectStore impleme
     @Override
     public void resolveImmediately(final ObjectAdapter adapter) throws ObjectPersistenceException {
 
-        // this is a nasty hack, but even though this method is called by 
+        // this is a nasty hack, but 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.
-    	// as belt-n-braces, have also made PSOS#resolveImmediately synchronize on
-    	// the object being resolved.
+        // seem to be hitting a race condition with another thread that is resolving the object
+        // before I get here.
+        // as belt-n-braces, have also made PSOS#resolveImmediately synchronize on
+        // the object being resolved.
         if (adapter.getResolveState().canChangeTo(ResolveState.RESOLVING)) {
             LOG.debug("resolve " + adapter);
             setupReferencedObjects(adapter);
-            
-        	PersistorUtil.start(adapter, ResolveState.RESOLVING);
-        	PersistorUtil.end(adapter); // moves to RESOLVED
+
+            PersistorUtil.start(adapter, ResolveState.RESOLVING);
+            PersistorUtil.end(adapter); // moves to RESOLVED
         } else {
-        	LOG.warn("resolveImmediately ignored, " +
-        			 "adapter's current state is: " + adapter.getResolveState() + 
-        			 " ; oid: " + adapter.getOid());
+            LOG.warn("resolveImmediately ignored, " + "adapter's current state is: " + adapter.getResolveState()
+                + " ; oid: " + adapter.getOid());
         }
     }
 
     @Override
-    public void resolveField(final ObjectAdapter object, final ObjectAssociation field) throws ObjectPersistenceException {
+    public void resolveField(final ObjectAdapter object, final ObjectAssociation field)
+        throws ObjectPersistenceException {
         final ObjectAdapter reference = field.get(object);
         PersistorUtil.start(reference, ResolveState.RESOLVING);
         PersistorUtil.end(reference);
@@ -269,7 +272,7 @@ public class InMemoryObjectStore impleme
     }
 
     private void setupReferencedObjects(final ObjectAdapter adapter, final Vector all) {
-    	// TODO: is this code needed, then?  Looks like it isn't...
+        // TODO: is this code needed, then? Looks like it isn't...
         if (true) {
             return;
         }
@@ -305,20 +308,17 @@ public class InMemoryObjectStore impleme
     // ///////////////////////////////////////////////////////
 
     @Override
-    public ObjectAdapter[] getInstances(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()));
-    	}
-		PersistenceQueryBuiltIn builtIn = (PersistenceQueryBuiltIn) persistenceQuery;
-    	
-    	final Vector<ObjectAdapter> instances = new Vector<ObjectAdapter>();
+    public ObjectAdapter[] getInstances(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 Vector<ObjectAdapter> instances = new Vector<ObjectAdapter>();
         final ObjectSpecification spec = persistenceQuery.getSpecification();
         findInstances(spec, builtIn, instances);
         return toInstancesArray(instances);
@@ -329,7 +329,7 @@ public class InMemoryObjectStore impleme
         if (instancesFor(spec).hasInstances()) {
             return true;
         }
-        
+
         // includeSubclasses
         final List<ObjectSpecification> subclasses = spec.subclasses();
         for (int i = 0; i < subclasses.size(); i++) {
@@ -337,15 +337,13 @@ public class InMemoryObjectStore impleme
                 return true;
             }
         }
-        
+
         return false;
     }
 
-    private void findInstances(
-            final ObjectSpecification spec,
-            final PersistenceQueryBuiltIn persistenceQuery,
-            final Vector<ObjectAdapter> foundInstances) {
-    	
+    private void findInstances(final ObjectSpecification spec, final PersistenceQueryBuiltIn persistenceQuery,
+        final Vector<ObjectAdapter> foundInstances) {
+
         instancesFor(spec).findInstancesAndAdd(persistenceQuery, foundInstances);
 
         // include subclasses
@@ -353,7 +351,7 @@ public class InMemoryObjectStore impleme
         for (int i = 0; i < subclasses.size(); i++) {
             findInstances(subclasses.get(i), persistenceQuery, foundInstances);
         }
-        
+
     }
 
     private ObjectAdapter[] toInstancesArray(final Vector<ObjectAdapter> instances) {
@@ -374,7 +372,6 @@ public class InMemoryObjectStore impleme
     // Services
     // ///////////////////////////////////////////////////////
 
-
     @Override
     public Oid getOidForService(final String name) {
         return persistedObjects.getService(name);
@@ -382,11 +379,11 @@ public class InMemoryObjectStore impleme
 
     @Override
     public void registerService(final String name, final Oid oid) {
-    	persistedObjects.registerService(name, oid);
+        persistedObjects.registerService(name, oid);
     }
 
     private ObjectStoreInstances instancesFor(final ObjectSpecification spec) {
-    	return persistedObjects.instancesFor(spec);
+        return persistedObjects.instancesFor(spec);
     }
 
     // ///////////////////////////////////////////////////////
@@ -401,7 +398,7 @@ public class InMemoryObjectStore impleme
     @Override
     public void debugData(final DebugBuilder debug) {
         debug.appendTitle("Domain Objects");
-        for(final ObjectSpecification spec: persistedObjects.specifications()) {
+        for (final ObjectSpecification spec : persistedObjects.specifications()) {
             debug.appendln(spec.getFullIdentifier());
             final ObjectStoreInstances instances = instancesFor(spec);
             instances.debugData(debug);
@@ -465,7 +462,7 @@ public class InMemoryObjectStore impleme
         recursiveElements.addElement(object);
 
         // work through all its fields
-        List<ObjectAssociation> fields = object.getSpecification().getAssociations();
+        final List<ObjectAssociation> fields = object.getSpecification().getAssociations();
 
         for (int i = 0; i < fields.size(); i++) {
             final ObjectAssociation field = fields.get(i);
@@ -497,9 +494,6 @@ public class InMemoryObjectStore impleme
         s.append(DebugUtils.indentString(4) + "+--");
     }
 
-    
-
-    
     // ///////////////////////////////////////////////////////
     // Dependencies (from context)
     // ///////////////////////////////////////////////////////
@@ -507,12 +501,11 @@ public class InMemoryObjectStore impleme
     /**
      * Must use {@link IsisContext context}, because although this object is recreated with each
      * {@link PersistenceSession session}, the persisted objects that get
-     * {@link #attachPersistedObjects(ObjectStorePersistedObjects) attached} to it span multiple
-     * sessions.
+     * {@link #attachPersistedObjects(ObjectStorePersistedObjects) 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.
+     * 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();
@@ -521,12 +514,11 @@ public class InMemoryObjectStore impleme
     /**
      * Must use {@link IsisContext context}, because although this object is recreated with each
      * {@link PersistenceSession session}, the persisted objects that get
-     * {@link #attachPersistedObjects(ObjectStorePersistedObjects) attached} to it span multiple
-     * sessions.
+     * {@link #attachPersistedObjects(ObjectStorePersistedObjects) 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.
+     * 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();
@@ -535,30 +527,28 @@ public class InMemoryObjectStore impleme
     /**
      * Must use {@link IsisContext context}, because although this object is recreated with each
      * {@link PersistenceSession session}, the persisted objects that get
-     * {@link #attachPersistedObjects(ObjectStorePersistedObjects) attached} to it span multiple
-     * sessions.
+     * {@link #attachPersistedObjects(ObjectStorePersistedObjects) 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.
+     * 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 PersistenceSessionHydrator getHydrator() {
         return getPersistenceSession();
     }
 
-    
-	/**
-	 * Downcasts the {@link PersistenceSessionFactory} to {@link InMemoryPersistenceSessionFactory}.
-	 */
-	protected InMemoryPersistenceSessionFactory getInMemoryPersistenceSessionFactory() {
-		PersistenceSessionFactory persistenceSessionFactory = getPersistenceSession().getPersistenceSessionFactory();
+    /**
+     * Downcasts the {@link PersistenceSessionFactory} to {@link InMemoryPersistenceSessionFactory}.
+     */
+    protected InMemoryPersistenceSessionFactory getInMemoryPersistenceSessionFactory() {
+        final PersistenceSessionFactory persistenceSessionFactory =
+            getPersistenceSession().getPersistenceSessionFactory();
 
         if (!(persistenceSessionFactory instanceof InMemoryPersistenceSessionFactory)) {
-        	// for testing support
+            // for testing support
             return null;
         }
         return (InMemoryPersistenceSessionFactory) persistenceSessionFactory;
-	}
-
+    }
 
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryPersistenceMechanismInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryPersistenceMechanismInstaller.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryPersistenceMechanismInstaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryPersistenceMechanismInstaller.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.dflt;
 
 import org.apache.isis.core.commons.config.IsisConfiguration;
@@ -28,44 +27,35 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionFactory;
 
-
 /**
  * Installs the in-memory object store.
  */
-public class InMemoryPersistenceMechanismInstaller extends ObjectStorePersistenceMechanismInstallerAbstract  {
-    
-    
+public class InMemoryPersistenceMechanismInstaller extends ObjectStorePersistenceMechanismInstallerAbstract {
 
     public InMemoryPersistenceMechanismInstaller() {
-		super("in-memory");
-	}
+        super("in-memory");
+    }
 
-    
-    /////////////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////////////
     // createPersistenceSessionFactory
-    /////////////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////////////
 
+    @Override
     public PersistenceSessionFactory createPersistenceSessionFactory(final DeploymentType deploymentType) {
         return new InMemoryPersistenceSessionFactory(deploymentType, this);
     }
 
-    
-    /////////////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////////////
     // Hook methods
-    /////////////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////////////
 
     /**
-     * Hook method to return {@link ObjectStore}. 
+     * Hook method to return {@link ObjectStore}.
      */
-    protected ObjectStore createObjectStore(
-            final IsisConfiguration configuration, 
-            final ObjectAdapterFactory adapterFactory, 
-            final AdapterManager adapterManager) {
+    @Override
+    protected ObjectStore createObjectStore(final IsisConfiguration configuration,
+        final ObjectAdapterFactory adapterFactory, final AdapterManager adapterManager) {
         return new InMemoryObjectStore();
     }
 
-
-
-
-
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryPersistenceSessionFactory.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryPersistenceSessionFactory.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryPersistenceSessionFactory.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryPersistenceSessionFactory.java Tue May  3 06:42:06 2011
@@ -17,78 +17,72 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.dflt;
 
-package org.apache.isis.runtimes.dflt.objectstores.dflt;
-
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStoreInstances;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjects;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjectsDefault;
 import org.apache.isis.runtimes.dflt.runtime.persistence.PersistenceSessionFactoryDelegate;
 import org.apache.isis.runtimes.dflt.runtime.persistence.PersistenceSessionFactoryDelegating;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SimpleOidGenerator;
 import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStoreInstances;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjects;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjectsDefault;
-
-
-public class InMemoryPersistenceSessionFactory extends PersistenceSessionFactoryDelegating {
-
-    private ObjectStorePersistedObjects persistedObjects;
-
-    public InMemoryPersistenceSessionFactory(
-            final DeploymentType deploymentType,
-            final PersistenceSessionFactoryDelegate persistenceSessionFactoryDelegate) {
-        super(deploymentType, persistenceSessionFactoryDelegate);
-    }
-
-    protected ObjectStorePersistedObjects getPersistedObjects() {
-		return persistedObjects;
-	}
-
-    @Override
-    public PersistenceSession createPersistenceSession() {
-        PersistenceSession persistenceSession =  super.createPersistenceSession();
-        if (persistedObjects != null) {
-            OidGenerator oidGenerator = persistenceSession.getOidGenerator();
-            if (oidGenerator instanceof SimpleOidGenerator) {
-                SimpleOidGenerator simpleOidGenerator = (SimpleOidGenerator) oidGenerator;
-                simpleOidGenerator.resetTo(persistedObjects.getOidGeneratorMemento());
-            }
-        }
-
-        return persistenceSession;
-    }
-
-
-    /**
-     * Not API - called when {@link InMemoryObjectStore} first {@link InMemoryObjectStore#open() open}ed.
-     */
-	public ObjectStorePersistedObjects createPersistedObjects() {
-		return new ObjectStorePersistedObjectsDefault();
-	}
-
-    /**
-     * Not API - called when {@link InMemoryObjectStore} is {@link InMemoryObjectStore#close() close}d.
-     */
-    public void attach(final PersistenceSession persistenceSession, final ObjectStorePersistedObjects persistedObjects) {
-        OidGenerator oidGenerator = persistenceSession.getOidGenerator();
-        if (oidGenerator instanceof SimpleOidGenerator) {
-            SimpleOidGenerator simpleOidGenerator = (SimpleOidGenerator) oidGenerator;
-            persistedObjects.saveOidGeneratorMemento(simpleOidGenerator.getMemento());
-        }
-        this.persistedObjects = persistedObjects;
-    }
-
-    
-    @Override
-    protected void doShutdown() {
-        if (persistedObjects != null) {
-        	for (ObjectStoreInstances inst: persistedObjects.instances()) {
-        		inst.shutdown();
-        	}
-        	persistedObjects.clear();
-        }
-    }
-
-}
-
+
+public class InMemoryPersistenceSessionFactory extends PersistenceSessionFactoryDelegating {
+
+    private ObjectStorePersistedObjects persistedObjects;
+
+    public InMemoryPersistenceSessionFactory(final DeploymentType deploymentType,
+        final PersistenceSessionFactoryDelegate persistenceSessionFactoryDelegate) {
+        super(deploymentType, persistenceSessionFactoryDelegate);
+    }
+
+    protected ObjectStorePersistedObjects getPersistedObjects() {
+        return persistedObjects;
+    }
+
+    @Override
+    public PersistenceSession createPersistenceSession() {
+        final PersistenceSession persistenceSession = super.createPersistenceSession();
+        if (persistedObjects != null) {
+            final OidGenerator oidGenerator = persistenceSession.getOidGenerator();
+            if (oidGenerator instanceof SimpleOidGenerator) {
+                final SimpleOidGenerator simpleOidGenerator = (SimpleOidGenerator) oidGenerator;
+                simpleOidGenerator.resetTo(persistedObjects.getOidGeneratorMemento());
+            }
+        }
+
+        return persistenceSession;
+    }
+
+    /**
+     * Not API - called when {@link InMemoryObjectStore} first {@link InMemoryObjectStore#open() open}ed.
+     */
+    public ObjectStorePersistedObjects createPersistedObjects() {
+        return new ObjectStorePersistedObjectsDefault();
+    }
+
+    /**
+     * 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();
+        if (oidGenerator instanceof SimpleOidGenerator) {
+            final SimpleOidGenerator simpleOidGenerator = (SimpleOidGenerator) oidGenerator;
+            persistedObjects.saveOidGeneratorMemento(simpleOidGenerator.getMemento());
+        }
+        this.persistedObjects = persistedObjects;
+    }
+
+    @Override
+    protected void doShutdown() {
+        if (persistedObjects != null) {
+            for (final ObjectStoreInstances inst : persistedObjects.instances()) {
+                inst.shutdown();
+            }
+            persistedObjects.clear();
+        }
+    }
+
+}

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.dflt.internal;
 
 import java.util.ArrayList;
@@ -27,7 +26,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Vector;
 
 import org.apache.isis.applib.clock.Clock;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
@@ -37,14 +35,13 @@ import org.apache.isis.core.metamodel.ad
 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.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.InMemoryObjectStore;
 import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryBuiltIn;
 import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindByTitle;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionHydrator;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.InMemoryObjectStore;
-
 
 /*
  * The objects need to store in a repeatable sequence so the elements and instances method return the same data for any repeated
@@ -52,52 +49,48 @@ import org.apache.isis.runtimes.dflt.obj
  * where created.
  */
 public class ObjectStoreInstances {
-    
+
     private final Map<Oid, Object> pojoByOidMap = new HashMap<Oid, Object>();
     private final Map<Oid, String> titleByOidMap = new HashMap<Oid, String>();
     private final Map<Oid, SerialNumberVersion> versionByOidMap = new HashMap<Oid, SerialNumberVersion>();
-    
-	@SuppressWarnings("unused")
-	private final ObjectSpecification spec;
 
-    
-    /////////////////////////////////////////////////////////
+    @SuppressWarnings("unused")
+    private final ObjectSpecification spec;
+
+    // ///////////////////////////////////////////////////////
     // Constructors
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
 
-    public ObjectStoreInstances(ObjectSpecification spec) {
-    	this.spec = spec;
+    public ObjectStoreInstances(final ObjectSpecification 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(Oid oid) {
-		return pojoByOidMap.get(oid);
-	}
+    public Map<Oid, Object> getObjectInstances() {
+        return pojoByOidMap;
+    }
 
-	public Version getVersion(Oid oid) {
-		return versionByOidMap.get(oid);
-	}
+    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();
@@ -105,69 +98,65 @@ public class ObjectStoreInstances {
         versionByOidMap.clear();
     }
 
-
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // save, remove
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
 
     public void save(final ObjectAdapter adapter) {
         pojoByOidMap.put(adapter.getOid(), adapter.getObject());
         titleByOidMap.put(adapter.getOid(), adapter.titleString().toLowerCase());
-        
-        SerialNumberVersion version = versionByOidMap.get(adapter.getOid());
-        SerialNumberVersion nextVersion = nextVersion(version);
-		versionByOidMap.put(adapter.getOid(), nextVersion);
+
+        final SerialNumberVersion version = versionByOidMap.get(adapter.getOid());
+        final SerialNumberVersion nextVersion = nextVersion(version);
+        versionByOidMap.put(adapter.getOid(), nextVersion);
         adapter.setOptimisticLock(nextVersion);
     }
 
-    private synchronized SerialNumberVersion nextVersion(SerialNumberVersion version) {
-    	long sequence = (version != null? version.getSequence(): 0) +1;
-		return new SerialNumberVersion(sequence, getAuthenticationSession().getUserName(), new Date(Clock.getTime()));
-	}
-
+    private synchronized SerialNumberVersion nextVersion(final SerialNumberVersion version) {
+        final long sequence = (version != null ? version.getSequence() : 0) + 1;
+        return new SerialNumberVersion(sequence, getAuthenticationSession().getUserName(), new Date(Clock.getTime()));
+    }
 
-	public void remove(final Oid oid) {
-		pojoByOidMap.remove(oid);
+    public void remove(final Oid oid) {
+        pojoByOidMap.remove(oid);
         titleByOidMap.remove(oid);
         versionByOidMap.remove(oid);
     }
 
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // retrieveObject
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
 
     /**
-     * If the pojo exists in the object store, then looks up the
-     * {@link ObjectAdapter adapter} from the {@link AdapterManager}, and only
-     * if none found does it {@link PersistenceSessionHydrator#recreateAdapter(Oid, Object) recreate}
-     * a new {@link ObjectAdapter adapter}.
+     * If the pojo exists in the object store, then looks up the {@link ObjectAdapter adapter} from the
+     * {@link AdapterManager}, and only if none found does it
+     * {@link PersistenceSessionHydrator#recreateAdapter(Oid, Object) recreate} a new {@link ObjectAdapter adapter}.
      */
     public ObjectAdapter retrieveObject(final Oid oid) {
         final Object pojo = getObjectInstances().get(oid);
         if (pojo == null) {
             return null;
         }
-        ObjectAdapter adapterLookedUpByPojo = getAdapterManager().getAdapterFor(pojo);
+        final ObjectAdapter adapterLookedUpByPojo = getAdapterManager().getAdapterFor(pojo);
         if (adapterLookedUpByPojo != null) {
             return adapterLookedUpByPojo;
         }
-        ObjectAdapter adapterLookedUpByOid = getAdapterManager().getAdapterFor(oid);
+        final ObjectAdapter adapterLookedUpByOid = getAdapterManager().getAdapterFor(oid);
         if (adapterLookedUpByOid != null) {
             return adapterLookedUpByOid;
         }
         return getHydrator().recreateAdapter(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) {
+    public void findInstancesAndAdd(final PersistenceQueryBuiltIn persistenceQuery,
+        final List<ObjectAdapter> foundInstances) {
         if (persistenceQuery instanceof PersistenceQueryFindByTitle) {
             for (final Oid oid : titleByOidMap.keySet()) {
                 final String title = titleByOidMap.get(oid);
@@ -194,7 +183,6 @@ public class ObjectStoreInstances {
         return numberOfInstances() > 0;
     }
 
-
     private List<ObjectAdapter> elements() {
         final List<ObjectAdapter> v = new ArrayList<ObjectAdapter>(getObjectInstances().size());
         for (final Oid oid : getObjectInstances().keySet()) {
@@ -203,10 +191,9 @@ public class ObjectStoreInstances {
         return v;
     }
 
-
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // Debugging
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
 
     public void debugData(final DebugBuilder debug) {
         debug.indent();
@@ -222,8 +209,6 @@ public class ObjectStoreInstances {
         debug.unindent();
     }
 
-
-
     // ///////////////////////////////////////////////////////
     // Dependencies (from context)
     // ///////////////////////////////////////////////////////
@@ -231,12 +216,10 @@ public class ObjectStoreInstances {
     /**
      * 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.
+     * {@link #attachPersistedObjects(MemoryObjectStorePersistedObjects) attached} to it span multiple sessions.
      * 
      * <p>
-     * The alternative design would be to laboriously inject this object via the
-     * {@link InMemoryObjectStore}.
+     * The alternative design would be to laboriously inject this object via the {@link InMemoryObjectStore}.
      */
     protected PersistenceSession getPersistenceSession() {
         return IsisContext.getPersistenceSession();
@@ -245,12 +228,10 @@ public class ObjectStoreInstances {
     /**
      * 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.
+     * {@link #attachPersistedObjects(MemoryObjectStorePersistedObjects) attached} to it span multiple sessions.
      * 
      * <p>
-     * The alternative design would be to laboriously inject this object via the
-     * {@link InMemoryObjectStore}.
+     * The alternative design would be to laboriously inject this object via the {@link InMemoryObjectStore}.
      */
     protected AdapterManager getAdapterManager() {
         return getPersistenceSession().getAdapterManager();
@@ -259,12 +240,10 @@ public class ObjectStoreInstances {
     /**
      * 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.
+     * {@link #attachPersistedObjects(MemoryObjectStorePersistedObjects) attached} to it span multiple sessions.
      * 
      * <p>
-     * The alternative design would be to laboriously inject this object via the
-     * {@link InMemoryObjectStore}.
+     * The alternative design would be to laboriously inject this object via the {@link InMemoryObjectStore}.
      */
     protected PersistenceSessionHydrator getHydrator() {
         return getPersistenceSession();
@@ -273,16 +252,13 @@ public class ObjectStoreInstances {
     /**
      * 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.
+     * {@link #attachPersistedObjects(MemoryObjectStorePersistedObjects) attached} to it span multiple sessions.
      * 
      * <p>
-     * The alternative design would be to laboriously inject this object via the
-     * {@link InMemoryObjectStore}.
+     * The alternative design would be to laboriously inject this object via the {@link InMemoryObjectStore}.
      */
-	protected AuthenticationSession getAuthenticationSession() {
-		return IsisContext.getAuthenticationSession();
-	}
-
+    protected AuthenticationSession getAuthenticationSession() {
+        return IsisContext.getAuthenticationSession();
+    }
 
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjects.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjects.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjects.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjects.java Tue May  3 06:42:06 2011
@@ -17,32 +17,33 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.dflt.internal;
 
-package org.apache.isis.runtimes.dflt.objectstores.dflt.internal;
-
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SimpleOidGenerator.Memento;
-
-/**
- * Represents the persisted objects.
- * 
- * Attached and detached to each session.
- */
-public interface ObjectStorePersistedObjects {
-
-    public Memento getOidGeneratorMemento();
-    public void saveOidGeneratorMemento(Memento memento);
-
-    public void registerService(String name, Oid oid);
-    public Oid getService(String name);
-
-	public Iterable<ObjectSpecification> specifications();
-	public ObjectStoreInstances instancesFor(ObjectSpecification spec);
-	public Iterable<ObjectStoreInstances> instances();
-
-	public void clear();
-
-}
-
-
+
+/**
+ * Represents the persisted objects.
+ * 
+ * Attached and detached to each session.
+ */
+public interface ObjectStorePersistedObjects {
+
+    public Memento getOidGeneratorMemento();
+
+    public void saveOidGeneratorMemento(Memento memento);
+
+    public void registerService(String name, Oid oid);
+
+    public Oid getService(String name);
+
+    public Iterable<ObjectSpecification> specifications();
+
+    public ObjectStoreInstances instancesFor(ObjectSpecification spec);
+
+    public Iterable<ObjectStoreInstances> instances();
+
+    public void clear();
+
+}

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault.java Tue May  3 06:42:06 2011
@@ -17,87 +17,86 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.dflt.internal;
+
+import java.util.HashMap;
+import java.util.Map;
 
-package org.apache.isis.runtimes.dflt.objectstores.dflt.internal;
-
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator.simple.SimpleOidGenerator.Memento;
-
-/**
- * Represents the persisted objects.
- * 
- * Attached and detached to each session.
- */
-public class ObjectStorePersistedObjectsDefault implements ObjectStorePersistedObjects {
-
-    private final Map<ObjectSpecification, ObjectStoreInstances> instancesBySpecMap;
-    private final Map<String, Oid> serviceOidByIdMap;
-
-	private Memento oidGeneratorMemento;
-
-    public ObjectStorePersistedObjectsDefault() {
-        instancesBySpecMap = new HashMap<ObjectSpecification, ObjectStoreInstances>();
-        serviceOidByIdMap = new HashMap<String, Oid>();
-    }
-
-    
-    public Memento getOidGeneratorMemento() {
-		return oidGeneratorMemento;
-	}
-	public void saveOidGeneratorMemento(Memento memento) {
-		this.oidGeneratorMemento = memento;
-	}
-
-	public Oid getService(String name) {
-		return serviceOidByIdMap.get(name);
-	}
-	public void registerService(String name, Oid oid) {
-    	Oid oidLookedUpByName = serviceOidByIdMap.get(name);
-    	if (oidLookedUpByName != null) {
-    		if (oidLookedUpByName.equals(oid)) {
-    			throw new IsisException(
-    					"Already another service registered as name: " + name + 
-    					" (existing Oid: " + oidLookedUpByName + ", " +
-    					"intended: " + oid + ")");
-    		}
-    	} else {
-    		serviceOidByIdMap.put(name, 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(ObjectSpecification spec) {
-        ObjectStoreInstances ins = instancesBySpecMap.get(spec);
-        if (ins == null) {
-            ins = new ObjectStoreInstances(spec);
-            instancesBySpecMap.put(spec, ins);
-        }
-        return ins;
-	}
-
-
-	public Iterable<ObjectSpecification> specifications() {
-		return instancesBySpecMap.keySet();
-	}
-
-	public void clear() {
-		instancesBySpecMap.clear();		
-	}
-
-	public Iterable<ObjectStoreInstances> instances() {
-		return instancesBySpecMap.values();
-	}
-
-
-}
-
-
+
+/**
+ * Represents the persisted objects.
+ * 
+ * Attached and detached to each session.
+ */
+public class ObjectStorePersistedObjectsDefault implements ObjectStorePersistedObjects {
+
+    private final Map<ObjectSpecification, ObjectStoreInstances> instancesBySpecMap;
+    private final Map<String, Oid> serviceOidByIdMap;
+
+    private Memento oidGeneratorMemento;
+
+    public ObjectStorePersistedObjectsDefault() {
+        instancesBySpecMap = new HashMap<ObjectSpecification, ObjectStoreInstances>();
+        serviceOidByIdMap = new HashMap<String, Oid>();
+    }
+
+    @Override
+    public Memento getOidGeneratorMemento() {
+        return oidGeneratorMemento;
+    }
+
+    @Override
+    public void saveOidGeneratorMemento(final Memento memento) {
+        this.oidGeneratorMemento = memento;
+    }
+
+    @Override
+    public Oid getService(final String name) {
+        return serviceOidByIdMap.get(name);
+    }
+
+    @Override
+    public void registerService(final String name, final Oid oid) {
+        final Oid oidLookedUpByName = serviceOidByIdMap.get(name);
+        if (oidLookedUpByName != null) {
+            if (oidLookedUpByName.equals(oid)) {
+                throw new IsisException("Already another service registered as name: " + name + " (existing Oid: "
+                    + oidLookedUpByName + ", " + "intended: " + oid + ")");
+            }
+        } else {
+            serviceOidByIdMap.put(name, 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).
+    @Override
+    public ObjectStoreInstances instancesFor(final ObjectSpecification spec) {
+        ObjectStoreInstances ins = instancesBySpecMap.get(spec);
+        if (ins == null) {
+            ins = new ObjectStoreInstances(spec);
+            instancesBySpecMap.put(spec, ins);
+        }
+        return ins;
+    }
+
+    @Override
+    public Iterable<ObjectSpecification> specifications() {
+        return instancesBySpecMap.keySet();
+    }
+
+    @Override
+    public void clear() {
+        instancesBySpecMap.clear();
+    }
+
+    @Override
+    public Iterable<ObjectStoreInstances> instances() {
+        return instancesBySpecMap.values();
+    }
+
+}

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/AbstractInMemoryPersistenceCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/AbstractInMemoryPersistenceCommand.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/AbstractInMemoryPersistenceCommand.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/AbstractInMemoryPersistenceCommand.java Tue May  3 06:42:06 2011
@@ -17,47 +17,47 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands;
 
-package org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands;
-
-import org.apache.log4j.Logger;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandAbstract;
-import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
 import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStoreInstances;
 import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjects;
-
-public abstract class AbstractInMemoryPersistenceCommand extends PersistenceCommandAbstract {
-
-	private final static Logger LOG = Logger.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);
-        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);
-        ins.remove(adapter.getOid());
-    }
-    
-    private ObjectStoreInstances instancesFor(final ObjectSpecification spec) {
-    	return persistedObjects.instancesFor(spec);
-    }
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandAbstract;
+import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
+import org.apache.log4j.Logger;
+
+public abstract class AbstractInMemoryPersistenceCommand extends PersistenceCommandAbstract {
+
+    private final static Logger LOG = Logger.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);
+        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);
+        ins.remove(adapter.getOid());
+    }
+
+    private ObjectStoreInstances instancesFor(final ObjectSpecification spec) {
+        return persistedObjects.instancesFor(spec);
+    }
 }
\ No newline at end of file

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemoryCreateObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemoryCreateObjectCommand.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemoryCreateObjectCommand.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemoryCreateObjectCommand.java Tue May  3 06:42:06 2011
@@ -17,33 +17,33 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands;
 
-package org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands;
-
-import org.apache.log4j.Logger;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjects;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjects;
-
-public final class InMemoryCreateObjectCommand extends AbstractInMemoryPersistenceCommand implements
-		CreateObjectCommand {
-	private final static Logger LOG = Logger.getLogger(InMemoryCreateObjectCommand.class);
-
-	public InMemoryCreateObjectCommand(ObjectAdapter object, final ObjectStorePersistedObjects persistedObjects) {
-		super(object, persistedObjects);
-	}
-
-	public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
-		if (LOG.isDebugEnabled()) {
-			LOG.debug("  create object " + onObject());
-		}
-	    save(onObject());
-	}
-
-	@Override
-	public String toString() {
-	    return "CreateObjectCommand [object=" + onObject() + "]";
-	}
+import org.apache.log4j.Logger;
+
+public final class InMemoryCreateObjectCommand extends AbstractInMemoryPersistenceCommand implements
+    CreateObjectCommand {
+    private final static Logger LOG = Logger.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 " + onObject());
+        }
+        save(onObject());
+    }
+
+    @Override
+    public String toString() {
+        return "CreateObjectCommand [object=" + onObject() + "]";
+    }
 }
\ No newline at end of file

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemoryDestroyObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemoryDestroyObjectCommand.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemoryDestroyObjectCommand.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemoryDestroyObjectCommand.java Tue May  3 06:42:06 2011
@@ -17,34 +17,33 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands;
 
-package org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands;
-
-import org.apache.log4j.Logger;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjects;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjects;
-
-public final class InMemoryDestroyObjectCommand 
-		extends AbstractInMemoryPersistenceCommand 
-		implements DestroyObjectCommand {
-	private final static Logger LOG = Logger.getLogger(InMemoryDestroyObjectCommand.class);
-
-	public InMemoryDestroyObjectCommand(final ObjectAdapter adapter, final ObjectStorePersistedObjects persistedObjects) {
-		super(adapter, persistedObjects);
-	}
-
-	public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
-		if (LOG.isInfoEnabled()) {
-			LOG.info("  delete object '" + onObject() + "'");
-		}
-	    destroy(onObject());
-	}
-
-	@Override
-	public String toString() {
-	    return "DestroyObjectCommand [object=" + onObject() + "]";
-	}
+import org.apache.log4j.Logger;
+
+public final class InMemoryDestroyObjectCommand extends AbstractInMemoryPersistenceCommand implements
+    DestroyObjectCommand {
+    private final static Logger LOG = Logger.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 '" + onObject() + "'");
+        }
+        destroy(onObject());
+    }
+
+    @Override
+    public String toString() {
+        return "DestroyObjectCommand [object=" + onObject() + "]";
+    }
 }
\ No newline at end of file

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemorySaveObjectCommand.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemorySaveObjectCommand.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemorySaveObjectCommand.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/commands/InMemorySaveObjectCommand.java Tue May  3 06:42:06 2011
@@ -17,33 +17,31 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands;
 
-package org.apache.isis.runtimes.dflt.objectstores.dflt.internal.commands;
-
-import org.apache.log4j.Logger;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjects;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.SaveObjectCommand;
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
-import org.apache.isis.runtimes.dflt.objectstores.dflt.internal.ObjectStorePersistedObjects;
-
-public final class InMemorySaveObjectCommand 
-		extends AbstractInMemoryPersistenceCommand 
-		implements SaveObjectCommand {
-	
-	@SuppressWarnings("unused")
-	private final static Logger LOG = Logger.getLogger(InMemorySaveObjectCommand.class);
-
-	public InMemorySaveObjectCommand(ObjectAdapter object, final ObjectStorePersistedObjects persistedObjects) {
-		super(object, persistedObjects);
-	}
-
-	public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
-	    save(onObject());
-	}
-
-	@Override
-	public String toString() {
-	    return "SaveObjectCommand [object=" + onObject() + "]";
-	}
+import org.apache.log4j.Logger;
+
+public final class InMemorySaveObjectCommand extends AbstractInMemoryPersistenceCommand implements SaveObjectCommand {
+
+    @SuppressWarnings("unused")
+    private final static Logger LOG = Logger.getLogger(InMemorySaveObjectCommand.class);
+
+    public InMemorySaveObjectCommand(final ObjectAdapter object, final ObjectStorePersistedObjects persistedObjects) {
+        super(object, persistedObjects);
+    }
+
+    @Override
+    public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
+        save(onObject());
+    }
+
+    @Override
+    public String toString() {
+        return "SaveObjectCommand [object=" + onObject() + "]";
+    }
 }
\ No newline at end of file

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/AbstractInMemoryObjectStoreTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/AbstractInMemoryObjectStoreTest.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/AbstractInMemoryObjectStoreTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/AbstractInMemoryObjectStoreTest.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.dflt;
 
 import java.util.Collections;
@@ -27,7 +26,6 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
 import org.apache.isis.runtimes.dflt.runtime.testsystem.ProxyJunit3TestCase;
 
-
 public abstract class AbstractInMemoryObjectStoreTest extends ProxyJunit3TestCase {
     protected InMemoryObjectStore store;
 
@@ -45,7 +43,6 @@ public abstract class AbstractInMemoryOb
         super.tearDown();
     }
 
-
     protected void resetIdentityMap() {
         IsisContext.getPersistenceSession().testReset();
     }
@@ -53,8 +50,7 @@ public abstract class AbstractInMemoryOb
     protected void addObjectToStore(final ObjectAdapter object) {
         final PersistenceCommand command = store.createCreateObjectCommand(object);
         assertEquals(object, command.onObject());
-        store.execute(Collections.<PersistenceCommand>singletonList(command));
+        store.execute(Collections.<PersistenceCommand> singletonList(command));
     }
 
 }
-

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_debug.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_debug.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_debug.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_debug.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.dflt;
 
 import java.util.Collections;
@@ -29,7 +28,6 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
 import org.apache.isis.runtimes.dflt.runtime.testsystem.ProxyJunit3TestCase;
 
-
 public class InMemoryObjectStore_debug extends ProxyJunit3TestCase {
     private InMemoryObjectStore store;
 
@@ -44,7 +42,7 @@ public class InMemoryObjectStore_debug e
         final ObjectAdapter object = system.createPersistentTestObject();
 
         final CreateObjectCommand command = store.createCreateObjectCommand(object);
-        store.execute(Collections.<PersistenceCommand>singletonList(command));
+        store.execute(Collections.<PersistenceCommand> singletonList(command));
 
         store.debugTitle();
         final DebugBuilder debug = new DebugString();
@@ -57,4 +55,3 @@ public class InMemoryObjectStore_debug e
         store.debugData(debug);
     }
 }
-

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_init.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_init.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_init.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_init.java Tue May  3 06:42:06 2011
@@ -17,12 +17,10 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.dflt;
 
 import org.apache.isis.runtimes.dflt.runtime.testsystem.ProxyJunit3TestCase;
 
-
 public class InMemoryObjectStore_init extends ProxyJunit3TestCase {
     private InMemoryObjectStore store;
 
@@ -33,12 +31,8 @@ public class InMemoryObjectStore_init ex
         store.open();
     }
 
-
     public void testStartsUpInUnitializedSate() throws Exception {
         assertFalse(store.isFixturesInstalled());
     }
 
-
-
 }
-

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_interactionWithAdapterManager.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_interactionWithAdapterManager.java?rev=1098940&r1=1098939&r2=1098940&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_interactionWithAdapterManager.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore_interactionWithAdapterManager.java Tue May  3 06:42:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.dflt;
 
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -26,7 +25,6 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindAllInstances;
 import org.apache.isis.runtimes.dflt.runtime.testsystem.ProxyJunit3TestCase;
 
-
 public class InMemoryObjectStore_interactionWithAdapterManager extends ProxyJunit3TestCase {
     private InMemoryObjectStore store;
 
@@ -56,9 +54,8 @@ public class InMemoryObjectStore_interac
         try {
             store.getObject(object.getOid(), specification);
             fail();
-        } catch (final ObjectNotFoundException expected) {}
+        } catch (final ObjectNotFoundException expected) {
+        }
     }
 
-
 }
-



Mime
View raw message