incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1030308 [6/8] - in /incubator/isis/trunk: alternatives/remoting/common/src/main/java/org/apache/isis/remoting/facade/impl/ alternatives/remoting/common/src/main/java/org/apache/isis/remoting/server/ alternatives/remoting/common/src/test/ja...
Date Wed, 03 Nov 2010 01:24:23 GMT
Modified: incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/adapterfactory/package-info.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/adapterfactory/package-info.java?rev=1030308&r1=1030307&r2=1030308&view=diff
==============================================================================
--- incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/adapterfactory/package-info.java (original)
+++ incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/adapterfactory/package-info.java Wed Nov  3 01:24:18 2010
@@ -17,14 +17,12 @@
  *  under the License.
  */
 
-
-/**
- * ([[NAME]]) Adapter Factory API.
- * 
- * <p>
- * Concrete implementations are in the <tt>objectadapter-xxx</tt> modules.
- * In most scenarios the default implementation is expected to suffice.  However,
- * the API was introduced to allow custom viewers to install more sophisticated
- * adapters, specifically to support observer (MVC) patterns in the UI.
- */
+/**
+ * (Apache Isis) Adapter Factory API.
+ * 
+ * <p>
+ * In most scenarios the default implementation is expected to suffice.  However,
+ * the API was introduced to allow custom viewers to install more sophisticated
+ * adapters, specifically to support observer (MVC) patterns in the UI.
+ */
 package org.apache.isis.runtime.persistence.adapterfactory;
\ No newline at end of file

Modified: incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/adaptermanager/AdapterManagerDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/adaptermanager/AdapterManagerDefault.java?rev=1030308&r1=1030307&r2=1030308&view=diff
==============================================================================
--- incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/adaptermanager/AdapterManagerDefault.java (original)
+++ incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/adaptermanager/AdapterManagerDefault.java Wed Nov  3 01:24:18 2010
@@ -17,17 +17,15 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtime.persistence.adaptermanager;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.apache.isis.commons.ensure.Ensure.ensureThatArg;
 import static org.apache.isis.commons.ensure.Ensure.ensureThatState;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
 
 import java.util.Iterator;
 
-import org.apache.log4j.Logger;
 import org.apache.isis.applib.Identifier;
 import org.apache.isis.commons.debug.DebugInfo;
 import org.apache.isis.commons.debug.DebugString;
@@ -57,11 +55,10 @@ import org.apache.isis.runtime.persisten
 import org.apache.isis.runtime.persistence.adaptermanager.internal.PojoAdapterMap;
 import org.apache.isis.runtime.persistence.oidgenerator.OidGenerator;
 import org.apache.isis.runtime.persistence.oidgenerator.OidGeneratorAware;
+import org.apache.log4j.Logger;
 
-
-public class AdapterManagerDefault 
-		extends AdapterManagerAbstract 
-		implements AdapterFactoryAware, SpecificationLoaderAware, OidGeneratorAware, ServicesInjectorAware, DebugInfo {
+public class AdapterManagerDefault extends AdapterManagerAbstract implements AdapterFactoryAware,
+    SpecificationLoaderAware, OidGeneratorAware, ServicesInjectorAware, DebugInfo {
 
     private static final Logger LOG = Logger.getLogger(AdapterManagerDefault.class);
 
@@ -92,20 +89,21 @@ public class AdapterManagerDefault 
     /**
      * Injected using dependency injection.
      */
-	private ServicesInjector servicesInjector;
+    private ServicesInjector servicesInjector;
 
     // //////////////////////////////////////////////////////////////////
     // constructor
     // //////////////////////////////////////////////////////////////////
 
     public AdapterManagerDefault() {
-    // does nothing
+        // does nothing
     }
 
     // //////////////////////////////////////////////////////////////////
     // open, close
     // //////////////////////////////////////////////////////////////////
 
+    @Override
     public void open() {
         ensureThatState(adapterFactory, is(notNullValue()));
         ensureThatState(specificationLoader, is(notNullValue()));
@@ -123,6 +121,7 @@ public class AdapterManagerDefault 
         pojoAdapterMap.open();
     }
 
+    @Override
     public void close() {
         oidAdapterMap.close();
         pojoAdapterMap.close();
@@ -132,6 +131,7 @@ public class AdapterManagerDefault 
     // reset
     // //////////////////////////////////////////////////////////////////
 
+    @Override
     public void reset() {
         oidAdapterMap.reset();
         pojoAdapterMap.reset();
@@ -141,6 +141,7 @@ public class AdapterManagerDefault 
     // Iterable
     // //////////////////////////////////////////////////////////////////
 
+    @Override
     public Iterator<ObjectAdapter> iterator() {
         return getPojoAdapterMap().iterator();
     }
@@ -149,6 +150,7 @@ public class AdapterManagerDefault 
     // Backdoor
     // //////////////////////////////////////////////////////////////////
 
+    @Override
     public ObjectAdapter addExistingAdapter(final ObjectAdapter adapter) {
         mapAndInjectServices(adapter);
         return adapter;
@@ -158,12 +160,14 @@ public class AdapterManagerDefault 
     // Adapter lookup
     // //////////////////////////////////////////////////////////////////
 
+    @Override
     public ObjectAdapter getAdapterFor(final Object pojo) {
         ensureThatArg(pojo, is(notNullValue()));
 
         return getPojoAdapterMap().getAdapter(pojo);
     }
 
+    @Override
     public ObjectAdapter getAdapterFor(final Oid oid) {
         ensureThatArg(oid, is(notNullValue()));
         ensureMapsConsistent(oid);
@@ -181,8 +185,9 @@ public class AdapterManagerDefault 
      * <p>
      * Looks up {@link #getAdapterFor(Object)} or returns a new transient
      */
+    @Override
     public ObjectAdapter adapterFor(final Object pojo) {
-    	
+
         // attempt to locate adapter for the pojo
         final ObjectAdapter adapter = getAdapterFor(pojo);
         if (adapter != null) {
@@ -201,6 +206,7 @@ public class AdapterManagerDefault 
         return map(createOrRecreateRootAdapter(pojo));
     }
 
+    @Override
     public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter ownerAdapter, Identified identified) {
 
         // attempt to locate adapter for the pojo
@@ -208,7 +214,7 @@ public class AdapterManagerDefault 
         if (adapter != null) {
             return adapter;
         }
-        
+
         // need to create (and possibly map) the adapter.
         final ObjectSpecification noSpec = getSpecificationLoader().loadSpecification(pojo.getClass());
 
@@ -224,7 +230,7 @@ public class AdapterManagerDefault 
         if (ownerAdapter != null && identified != null) {
             if (specIsAggregated(noSpec) || referenceIsAggregated(identified)) {
                 ObjectAdapter newAdapter = createAggregatedAdapter(pojo, ownerAdapter, identified);
-				return mapAndInjectServices(newAdapter);
+                return mapAndInjectServices(newAdapter);
             }
         }
 
@@ -240,6 +246,7 @@ public class AdapterManagerDefault 
         return identified.containsFacet(AggregatedFacet.class);
     }
 
+    @Override
     public ObjectAdapter recreateRootAdapter(final Oid oid, final Object pojo) {
 
         // attempt to locate adapter for the pojo
@@ -261,6 +268,7 @@ public class AdapterManagerDefault 
     // adapter maintenance
     // //////////////////////////////////////////////////////////////////
 
+    @Override
     public void remapUpdated(final Oid oid) {
         ensureThatArg(oid.hasPrevious(), is(true));
 
@@ -297,17 +305,17 @@ public class AdapterManagerDefault 
      * Removes the specified object from both the identity-adapter map, and the pojo-adapter map.
      * 
      * <p>
-     * This indicates that the object is no longer in use, and therefore that no objects exists within the
-     * system.
+     * This indicates that the object is no longer in use, and therefore that no objects exists within the system.
      * 
      * <p>
-     * If an {@link ObjectAdapter adapter} is removed while its pojo still is referenced then a subsequent
-     * interaction of that pojo will create a different {@link ObjectAdapter adapter}, in a
-     * {@link ResolveState#TRANSIENT transient} state.
+     * If an {@link ObjectAdapter adapter} is removed while its pojo still is referenced then a subsequent interaction
+     * of that pojo will create a different {@link ObjectAdapter adapter}, in a {@link ResolveState#TRANSIENT transient}
+     * state.
      * 
      * <p>
      * TODO: should do a cascade remove of any aggregated objects.
      */
+    @Override
     public void removeAdapter(final ObjectAdapter adapter) {
         ensureMapsConsistent(adapter);
 
@@ -326,38 +334,38 @@ public class AdapterManagerDefault 
      * {@inheritDoc}
      * 
      * <p>
-     * Note that there is no management of {@link Version}s here. That is because the
-     * {@link PersistenceSession} is expected to manage this. (In practice this is done by the
-     * <tt>ObjectAdapterStore</tt> implementation delegated by the <tt>PersistenceSessionObjectStore</tt>, and
-     * propogated back to client-side as required).
+     * Note that there is no management of {@link Version}s here. That is because the {@link PersistenceSession} is
+     * expected to manage this. (In practice this is done by the <tt>ObjectAdapterStore</tt> implementation delegated by
+     * the <tt>PersistenceSessionObjectStore</tt>, and propogated back to client-side as required).
      */
+    @Override
     public void remapAsPersistent(final ObjectAdapter adapter) {
         // don't do this because the Oid has been updated already
-    	// ensureMapsConsistent(adapter);
+        // ensureMapsConsistent(adapter);
 
         AggregateAdapters aggregateAdapters = aggregateAdaptersFor(adapter);
         remapAsPersistent(aggregateAdapters);
     }
 
-	private AggregateAdapters aggregateAdaptersFor(final ObjectAdapter rootAdapter) {
+    private AggregateAdapters aggregateAdaptersFor(final ObjectAdapter rootAdapter) {
         AggregateAdapters aggregateAdapters = new AggregateAdapters(rootAdapter);
         Oid rootOid = rootAdapter.getOid();
-        
-		for(OneToManyAssociation otma: rootAdapter.getSpecification().getCollectionList()) {
-			AggregatedOid aggregatedOid = new AggregatedOid(rootOid, otma.getIdentifier());
-			ObjectAdapter collectionAdapter = getAdapterFor(aggregatedOid);
-			if (collectionAdapter != null) {
-				// collection adapters are lazily created and so there may not be one.
-				aggregateAdapters.addCollectionAdapter(otma, collectionAdapter);
-			}
-		}
-		return aggregateAdapters;
-    }
-
-	private void remapAsPersistent(final AggregateAdapters aggregateAdapters) {
-		
-		ObjectAdapter rootAdapter = aggregateAdapters.getRootAdapter();
-		// although the Oid reference doesn't change, the Oid internal values will change
+
+        for (OneToManyAssociation otma : rootAdapter.getSpecification().getCollectionList()) {
+            AggregatedOid aggregatedOid = new AggregatedOid(rootOid, otma.getIdentifier());
+            ObjectAdapter collectionAdapter = getAdapterFor(aggregatedOid);
+            if (collectionAdapter != null) {
+                // collection adapters are lazily created and so there may not be one.
+                aggregateAdapters.addCollectionAdapter(otma, collectionAdapter);
+            }
+        }
+        return aggregateAdapters;
+    }
+
+    private void remapAsPersistent(final AggregateAdapters aggregateAdapters) {
+
+        ObjectAdapter rootAdapter = aggregateAdapters.getRootAdapter();
+        // although the Oid reference doesn't change, the Oid internal values will change
         final Oid oid = rootAdapter.getOid();
         if (LOG.isDebugEnabled()) {
             LOG.debug("remapAsPersistent: " + oid);
@@ -375,61 +383,59 @@ public class AdapterManagerDefault 
         if (LOG.isDebugEnabled()) {
             LOG.debug("removing collection adapter(s) from oid map");
         }
-        for(ObjectAdapter collectionAdapter: aggregateAdapters) {
-        	Oid collectionOid = collectionAdapter.getOid();
+        for (ObjectAdapter collectionAdapter : aggregateAdapters) {
+            Oid collectionOid = collectionAdapter.getOid();
             removed = getOidAdapterMap().remove(collectionOid);
             if (!removed) {
                 LOG.warn("could not remove collectionOid: " + collectionOid);
                 // should we fail here with a more serious error?
             }
         }
-        
+
         if (LOG.isDebugEnabled()) {
-        	LOG.debug("updating the Oid");
+            LOG.debug("updating the Oid");
         }
         getOidGenerator().convertTransientToPersistentOid(oid);
 
-        
         // re-map the root adapter
         if (LOG.isDebugEnabled()) {
             LOG.debug("re-adding into maps; oid is now: " + oid);
         }
         getOidAdapterMap().add(oid, rootAdapter);
 
-
         // re-map the collection adapters
         if (LOG.isDebugEnabled()) {
-        	LOG.debug("re-adding collection adapter(s) to oid map");
+            LOG.debug("re-adding collection adapter(s) to oid map");
         }
-        for(ObjectAdapter collectionAdapter: aggregateAdapters) {
-        	AggregatedOid previousCollectionOid = (AggregatedOid) collectionAdapter.getOid();
+        for (ObjectAdapter collectionAdapter : aggregateAdapters) {
+            AggregatedOid previousCollectionOid = (AggregatedOid) collectionAdapter.getOid();
             getOidAdapterMap().add(previousCollectionOid, collectionAdapter);
         }
 
         // replace any pojos if required, remapping in the pojo map
         if (LOG.isDebugEnabled()) {
-        	LOG.debug("replacing any collection pojos, remapping in pojo map");
+            LOG.debug("replacing any collection pojos, remapping in pojo map");
         }
-        for(OneToManyAssociation otma: aggregateAdapters.getCollections()) {
-        	ObjectAdapter collectionAdapter = aggregateAdapters.getCollectionAdapter(otma);
-        	
-        	Object collectionPojoWrappedByAdapter = collectionAdapter.getObject();
-        	Object collectionPojoOnRootPojo = getCollectionPojo(otma, rootAdapter);
-        	
-        	if (collectionPojoOnRootPojo != collectionPojoWrappedByAdapter) {
-        		getPojoAdapterMap().remove(collectionAdapter);
-        		collectionAdapter.replacePojo(collectionPojoOnRootPojo);
-        		getPojoAdapterMap().add(collectionPojoOnRootPojo, collectionAdapter);
-        	}
+        for (OneToManyAssociation otma : aggregateAdapters.getCollections()) {
+            ObjectAdapter collectionAdapter = aggregateAdapters.getCollectionAdapter(otma);
+
+            Object collectionPojoWrappedByAdapter = collectionAdapter.getObject();
+            Object collectionPojoOnRootPojo = getCollectionPojo(otma, rootAdapter);
+
+            if (collectionPojoOnRootPojo != collectionPojoWrappedByAdapter) {
+                getPojoAdapterMap().remove(collectionAdapter);
+                collectionAdapter.replacePojo(collectionPojoOnRootPojo);
+                getPojoAdapterMap().add(collectionPojoOnRootPojo, collectionAdapter);
+            }
         }
-        
+
         // update the adapter's state
         rootAdapter.changeState(ResolveState.RESOLVED);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("made persistent " + rootAdapter + "; was " + oid.getPrevious());
         }
-	}
+    }
 
     public Object getCollectionPojo(final OneToManyAssociation association, final ObjectAdapter ownerAdapter) {
         final PropertyAccessorFacet accessor = association.getFacet(PropertyAccessorFacet.class);
@@ -443,10 +449,11 @@ public class AdapterManagerDefault 
     /**
      * For testing purposes only.
      */
+    @Override
     public ObjectAdapter testCreateTransient(final Object pojo, final Oid oid) {
         if (!oid.isTransient()) {
             throw new IllegalArgumentException(
-                    "Oid should be transient; use standard API to recreate adapters for persistent Oids");
+                "Oid should be transient; use standard API to recreate adapters for persistent Oids");
         }
         return map(createOrRecreateRootAdapter(pojo, oid));
     }
@@ -467,39 +474,39 @@ public class AdapterManagerDefault 
 
     /**
      * The default implementation will always create a new transient {@link ObjectAdapter adapter}, using the
-     * {@link OidGenerator}. However, the method has <tt>protected</tt> visibility so can be overridden if
-     * required.  For example, some object stores (eg Hibernate) may be able to infer from the pojo itself what the
-     * {@link Oid} and persistence state of the object is.
+     * {@link OidGenerator}. However, the method has <tt>protected</tt> visibility so can be overridden if required. For
+     * example, some object stores (eg Hibernate) may be able to infer from the pojo itself what the {@link Oid} and
+     * persistence state of the object is.
      */
-	protected Oid createOid(final Object pojo) {
-		return getOidGenerator().createTransientOid(pojo);
-	}
+    protected Oid createOid(final Object pojo) {
+        return getOidGenerator().createTransientOid(pojo);
+    }
 
     /**
-     * Creates an {@link ObjectAdapter adapter} with an {@link AggregatedOid} (so that its version and its
-     * persistence are the same as its owning parent).
+     * Creates an {@link ObjectAdapter adapter} with an {@link AggregatedOid} (so that its version and its persistence
+     * are the same as its owning parent).
      * 
      * <p>
      * Should only be called if the pojo is known not to be {@link #getAdapterFor(Object) mapped}.
      * 
      * <p>
-     * Helper method, but <tt>protected</tt> so can be overridden if required.  For example, some object stores
-     * (specifically, the XML object store at time of writing) do not support aggregated Oids for anything other
-     * than collections.
+     * Helper method, but <tt>protected</tt> so can be overridden if required. For example, some object stores
+     * (specifically, the XML object store at time of writing) do not support aggregated Oids for anything other than
+     * collections.
      */
     protected ObjectAdapter createAggregatedAdapter(Object pojo, ObjectAdapter ownerAdapter, Identified identified) {
-    	
-    	Identifier identifier = identified.getIdentifier();
-    	ensureMapsConsistent(ownerAdapter);
+
+        Identifier identifier = identified.getIdentifier();
+        ensureMapsConsistent(ownerAdapter);
         Assert.assertNotNull(pojo);
 
         // persistence of aggregated follows the parent
         final Oid aggregatedOid = new AggregatedOid(ownerAdapter.getOid(), identifier);
         ObjectAdapter aggregatedAdapter = createOrRecreateAdapter(pojo, aggregatedOid);
-        
-		// we copy over the type onto the adapter itself
-		// [not sure why this is really needed, surely we have enough info in the adapter
-		//  to look this up on the fly?]
+
+        // we copy over the type onto the adapter itself
+        // [not sure why this is really needed, surely we have enough info in the adapter
+        // to look this up on the fly?]
         aggregatedAdapter.setTypeOfFacet(identified.getFacet(TypeOfFacet.class));
 
         // same locking as parent
@@ -512,59 +519,56 @@ public class AdapterManagerDefault 
      * Creates a {@link ObjectAdapter adapter} with no {@link Oid}.
      * 
      * <p>
-     * Should only be called if the pojo is known not to be {@link #getAdapterFor(Object) mapped}, and for
-     * immutable value types referenced.
+     * Should only be called if the pojo is known not to be {@link #getAdapterFor(Object) mapped}, and for immutable
+     * value types referenced.
      */
     private ObjectAdapter createStandaloneAdapter(Object pojo) {
         return createOrRecreateAdapter(pojo, null);
     }
 
     /**
-     * Helper method that creates but does not {@link #mapAndInjectServices(ObjectAdapter) add}) the root 
-     * {@link ObjectAdapter adapter} along with adapters for all collections,  an
-     * {@link ObjectAdapter adapter}, and sets its {@link ResolveState} based on the {@link Oid}.
+     * Helper method that creates but does not {@link #mapAndInjectServices(ObjectAdapter) add}) the root
+     * {@link ObjectAdapter adapter} along with adapters for all collections, an {@link ObjectAdapter adapter}, and sets
+     * its {@link ResolveState} based on the {@link Oid}.
      * 
      * <p>
      * The {@link ResolveState} state will be:
      * <ul>
      * <li> {@link ResolveState#TRANSIENT} if the {@link Oid} is {@link Oid#isTransient() transient}.
-     * <li> {@link ResolveState#GHOST} if the {@link Oid} is persistent (not {@link Oid#isTransient()
-     * transient}).
+     * <li> {@link ResolveState#GHOST} if the {@link Oid} is persistent (not {@link Oid#isTransient() transient}).
      * <li> {@link ResolveState#VALUE} if no {@link Oid} was supplied.
      * </ul>
      */
     private AggregateAdapters createOrRecreateRootAdapter(final Object pojo, final Oid oid) {
         ObjectAdapter rootAdapter = createOrRecreateAdapter(pojo, oid);
-        
+
         AggregateAdapters aggregateAdapters = new AggregateAdapters(rootAdapter);
 
-        // failed experiment to try to ensure that all adapters are loaded for the root; 
+        // failed experiment to try to ensure that all adapters are loaded for the root;
         // left in in case we want to re-instate
-		// eagerlyCreateCollectionAdapters(rootAdapter, aggregateAdapters);
-		return aggregateAdapters;
+        // eagerlyCreateCollectionAdapters(rootAdapter, aggregateAdapters);
+        return aggregateAdapters;
     }
 
-	@SuppressWarnings("unused")
-	private void eagerlyCreateCollectionAdapters(ObjectAdapter rootAdapter,
-			AggregateAdapters aggregateAdapters) {
-		for(OneToManyAssociation otma: rootAdapter.getSpecification().getCollectionList()) {
-			Object referencedCollection = getCollectionPojo(otma, rootAdapter);
-			ObjectAdapter collectionAdapter = 
-				createAggregatedAdapter(referencedCollection, rootAdapter, otma);
-			
-			aggregateAdapters.addCollectionAdapter(otma, collectionAdapter);
-		}
-	}
+    @SuppressWarnings("unused")
+    private void eagerlyCreateCollectionAdapters(ObjectAdapter rootAdapter, AggregateAdapters aggregateAdapters) {
+        for (OneToManyAssociation otma : rootAdapter.getSpecification().getCollectionList()) {
+            Object referencedCollection = getCollectionPojo(otma, rootAdapter);
+            ObjectAdapter collectionAdapter = createAggregatedAdapter(referencedCollection, rootAdapter, otma);
 
-	private ObjectAdapter createOrRecreateAdapter(final Object pojo, final Oid oid) {
-		ObjectAdapter adapter = getAdapterFactory().createAdapter(pojo, oid);
+            aggregateAdapters.addCollectionAdapter(otma, collectionAdapter);
+        }
+    }
+
+    private ObjectAdapter createOrRecreateAdapter(final Object pojo, final Oid oid) {
+        ObjectAdapter adapter = getAdapterFactory().createAdapter(pojo, oid);
         if (oid == null) {
             adapter.changeState(ResolveState.VALUE);
         } else {
             adapter.changeState(oid.isTransient() ? ResolveState.TRANSIENT : ResolveState.GHOST);
         }
         return adapter;
-	}
+    }
 
     // //////////////////////////////////////////////////////////////////////////
     // Helpers: map & unmap
@@ -572,14 +576,14 @@ public class AdapterManagerDefault 
 
     private ObjectAdapter map(final AggregateAdapters aggregateAdapters) {
         Assert.assertNotNull(aggregateAdapters);
-    	ObjectAdapter adapter = aggregateAdapters.getRootAdapter();
-    	mapAndInjectServices(adapter);
-    	for(ObjectAdapter collectionAdapter: aggregateAdapters) {
-    		mapAndInjectServices(collectionAdapter);
-    	}
-    	return adapter;
+        ObjectAdapter adapter = aggregateAdapters.getRootAdapter();
+        mapAndInjectServices(adapter);
+        for (ObjectAdapter collectionAdapter : aggregateAdapters) {
+            mapAndInjectServices(collectionAdapter);
+        }
+        return adapter;
     }
-    
+
     private ObjectAdapter mapAndInjectServices(final ObjectAdapter adapter) {
         Assert.assertNotNull(adapter);
         final Object pojo = adapter.getObject();
@@ -593,31 +597,29 @@ public class AdapterManagerDefault 
             LOG.debug("adding identity for adapter with oid=" + adapter.getOid());
         }
 
-        // new design... always map [[NAME]] provided not standalone.
+        // new design... always map ObjectAdapter provided not standalone.
         if (adapter.getResolveState().isValue()) {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("not mapping value adapter");
             }
-    		servicesInjector.injectDependencies(pojo);
+            servicesInjector.injectDependencies(pojo);
             return adapter;
         }
 
         // add all aggregated collections
         ObjectSpecification noSpec = adapter.getSpecification();
-        if (!adapter.isAggregated() || 
-        	 adapter.isAggregated() && !noSpec.isImmutable()) {
+        if (!adapter.isAggregated() || adapter.isAggregated() && !noSpec.isImmutable()) {
             getPojoAdapterMap().add(pojo, adapter);
         }
 
         // order is important - add to pojo map first, then identity map
         getOidAdapterMap().add(adapter.getOid(), adapter);
 
-		// must inject after mapping, otherwise infinite loop 
-		servicesInjector.injectDependencies(pojo);
+        // must inject after mapping, otherwise infinite loop
+        servicesInjector.injectDependencies(pojo);
 
         return adapter;
     }
-    
 
     private void unmap(final ObjectAdapter adapter) {
         ensureMapsConsistent(adapter);
@@ -672,15 +674,16 @@ public class AdapterManagerDefault 
         Object adapterPojo = adapter.getObject();
         ObjectAdapter adapterAccordingToPojoAdapterMap = getPojoAdapterMap().getAdapter(adapterPojo);
         ensureThatArg(adapter, is(adapterAccordingToPojoAdapterMap), "mismatch in PojoAdapterMap: adapter's Pojo: "
-                + adapterPojo + ", \n" + "provided adapter: " + adapter + "; \n" + " but map's adapter was : "
-                + adapterAccordingToPojoAdapterMap);
+            + adapterPojo + ", \n" + "provided adapter: " + adapter + "; \n" + " but map's adapter was : "
+            + adapterAccordingToPojoAdapterMap);
     }
 
     private void ensureOidAdapterMapConsistent(final ObjectAdapter adapter) {
         Oid adapterOid = adapter.getOid();
         ObjectAdapter adapterAccordingToOidAdapterMap = getOidAdapterMap().getAdapter(adapterOid);
         ensureThatArg(adapter, is(adapterAccordingToOidAdapterMap), "mismatch in OidAdapter map: " + "adapter's Oid: "
-                + adapterOid + ", " + "provided adapter: " + adapter + "; " + "map's adapter: " + adapterAccordingToOidAdapterMap);
+            + adapterOid + ", " + "provided adapter: " + adapter + "; " + "map's adapter: "
+            + adapterAccordingToOidAdapterMap);
     }
 
     // //////////////////////////////////////////////////////////////////
@@ -701,7 +704,7 @@ public class AdapterManagerDefault 
     // if (oid != null) {
     // return adapterFor(domainObject, oid);
     // }
-    //        
+    //
     // if (domainObject == null) {
     // return null;
     // }
@@ -738,7 +741,7 @@ public class AdapterManagerDefault 
     // LOG.debug("creating adapter (transient) for adapter with oid=" + adapter.getOid());
     // }
     // identityMap.addAdapter(adapter);
-    //        
+    //
     // final ObjectSpecification specification = adapter.getSpecification();
     // if (specification.isAggregated()) {
     // adapter.changeState(ResolveState.STANDALONE);
@@ -754,10 +757,10 @@ public class AdapterManagerDefault 
     // private ObjectAdapter adapterFor(final Object domainObject, final Oid oid) {
     // ObjectAdapter adapter = getAdapterFor(oid);
     // if (adapter != null) {
-    //            
+    //
     // // TODO: REVIEW: was tripping the exception setting a Boolean on a @NotPersistable.
     // // is it safe for immutable values to use equals(.) instead?
-    //            
+    //
     // ObjectSpecification noSpec = adapter.getSpecification();
     // ValueFacet valueFacet = noSpec.getFacet(ValueFacet.class);
     // ImmutableFacet immutableFacet = valueFacet != null? valueFacet.getFacet(ImmutableFacet.class): null;
@@ -775,7 +778,7 @@ public class AdapterManagerDefault 
     // }
     // return adapter;
     // }
-    //        
+    //
     // adapter = getAdapterFor(domainObject);
     // if (adapter != null) {
     // if (!adapter.getOid().equals(oid)) {
@@ -798,10 +801,12 @@ public class AdapterManagerDefault 
     // debug
     // //////////////////////////////////////////////////////////////////
 
+    @Override
     public String debugTitle() {
         return "Identity map (adapter manager)";
     }
 
+    @Override
     public void debugData(final DebugString debug) {
         debug.appendTitle(pojoAdapterMap.debugTitle());
         pojoAdapterMap.debugData(debug);
@@ -812,7 +817,6 @@ public class AdapterManagerDefault 
 
     }
 
-
     // //////////////////////////////////////////////////////////////////////////
     // Optionally Injected: OidAdapterMap
     // //////////////////////////////////////////////////////////////////////////
@@ -863,6 +867,7 @@ public class AdapterManagerDefault 
     /**
      * Injected.
      */
+    @Override
     public void setAdapterFactory(AdapterFactory adapterFactory) {
         this.adapterFactory = adapterFactory;
     }
@@ -877,6 +882,7 @@ public class AdapterManagerDefault 
     /**
      * Injected.
      */
+    @Override
     public void setSpecificationLoader(SpecificationLoader specificationLoader) {
         this.specificationLoader = specificationLoader;
     }
@@ -891,6 +897,7 @@ public class AdapterManagerDefault 
     /**
      * Injected.
      */
+    @Override
     public void setOidGenerator(OidGenerator oidGenerator) {
         this.oidGenerator = oidGenerator;
     }
@@ -898,9 +905,9 @@ public class AdapterManagerDefault 
     /**
      * Injected.
      */
-	public void setServicesInjector(ServicesInjector servicesInjector) {
-		this.servicesInjector = servicesInjector;
-	}
+    @Override
+    public void setServicesInjector(ServicesInjector servicesInjector) {
+        this.servicesInjector = servicesInjector;
+    }
 
 }
-

Modified: incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/objectstore/ObjectStorePersistence.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/objectstore/ObjectStorePersistence.java?rev=1030308&r1=1030307&r2=1030308&view=diff
==============================================================================
--- incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/objectstore/ObjectStorePersistence.java (original)
+++ incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/objectstore/ObjectStorePersistence.java Wed Nov  3 01:24:18 2010
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtime.persistence.objectstore;
 
 import java.util.List;
@@ -38,100 +37,92 @@ import org.apache.isis.runtime.persisten
 import org.apache.isis.runtime.persistence.objectstore.transaction.SaveObjectCommand;
 import org.apache.isis.runtime.persistence.query.PersistenceQuery;
 
-
 public interface ObjectStorePersistence extends DebugInfo, SessionScopedComponent, NamedComponent {
 
-    
     /**
      * Determine if the object store has been initialized with its set of start up objects.
      * 
      * <p>
-     * This method is called only once after the {@link #init()} has been called. If it returns <code>false</code>
-     * then the framework will run the fixtures to initialise the object store.
+     * This method is called only once after the {@link #init()} has been called. If it returns <code>false</code> then
+     * the framework will run the fixtures to initialise the object store.
      */
     boolean isFixturesInstalled();
 
-
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // reset
-    /////////////////////////////////////////////////////////
-    
+    // ///////////////////////////////////////////////////////
+
     /**
      * TODO: move to {@link PersistenceSessionFactory} ??
      */
     void reset();
 
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // Command Creation
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
 
     /**
-     * Makes a [[NAME]] persistent. The specified object should be stored away via this object store's
-     * persistence mechanism, and have an new and unique OID assigned to it (by calling the object's
-     * <code>setOid</code> method). The object, should also be added to the cache as the object is
-     * implicitly 'in use'.
+     * Makes an {@link ObjectAdapter} persistent. The specified object should be stored away via this object store's
+     * persistence mechanism, and have an new and unique OID assigned to it (by calling the object's <code>setOid</code>
+     * method). The object, should also be added to the cache as the object is implicitly 'in use'.
      * 
      * <p>
-     * If the object has any associations then each of these, where they aren't already persistent, should
-     * also be made persistent by recursively calling this method.
+     * If the object has any associations then each of these, where they aren't already persistent, should also be made
+     * persistent by recursively calling this method.
      * </p>
      * 
      * <p>
-     * If the object to be persisted is a collection, then each element of that collection, that is not
-     * already persistent, should be made persistent by recursively calling this method.
+     * If the object to be persisted is a collection, then each element of that collection, that is not already
+     * persistent, should be made persistent by recursively calling this method.
      * </p>
      * 
      */
     CreateObjectCommand createCreateObjectCommand(ObjectAdapter object);
 
     /**
-     * Persists the specified object's state. Essentially the data held by the persistence mechanism should be
-     * updated to reflect the state of the specified objects. Once updated, the object store should issue a
-     * notification to all of the object's users via the <class>UpdateNotifier </class> object. This can be
-     * achieved simply, if extending the <class> AbstractObjectStore </class> by calling its
-     * <method>broadcastObjectUpdate </method> method.
+     * Persists the specified object's state. Essentially the data held by the persistence mechanism should be updated
+     * to reflect the state of the specified objects. Once updated, the object store should issue a notification to all
+     * of the object's users via the <class>UpdateNotifier </class> object. This can be achieved simply, if extending
+     * the <class> AbstractObjectStore </class> by calling its <method>broadcastObjectUpdate </method> method.
      */
     SaveObjectCommand createSaveObjectCommand(ObjectAdapter object);
 
-
     /**
-     * Removes the specified object from the object store. The specified object's data should be removed from
-     * the persistence mechanism and, if it is cached (which it probably is), removed from the cache also.
+     * Removes the specified object from the object store. The specified object's data should be removed from the
+     * persistence mechanism and, if it is cached (which it probably is), removed from the cache also.
      */
     DestroyObjectCommand createDestroyObjectCommand(ObjectAdapter object);
 
-
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // Command Execution
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
 
     void execute(final List<PersistenceCommand> commands);
 
-
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // getObject
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
 
     /**
-     * Retrieves the object identified by the specified OID from the object store. The cache should be checked
-     * first and, if the object is cached, the cached version should be returned. It is important that if this
-     * method is called again, while the originally returned object is in working memory, then this method
-     * must return that same Java object.
+     * Retrieves the object identified by the specified OID from the object store. The cache should be checked first
+     * and, if the object is cached, the cached version should be returned. It is important that if this method is
+     * called again, while the originally returned object is in working memory, then this method must return that same
+     * Java object.
      * 
      * <p>
-     * Assuming that the object is not cached then the data for the object should be retreived from the
-     * persistence mechanism and the object recreated (as describe previously). The specified OID should then
-     * be assigned to the recreated object by calling its <method>setOID </method>. Before returning the
-     * object its resolved flag should also be set by calling its <method>setResolved </method> method as
-     * well.
+     * Assuming that the object is not cached then the data for the object should be retreived from the persistence
+     * mechanism and the object recreated (as describe previously). The specified OID should then be assigned to the
+     * recreated object by calling its <method>setOID </method>. Before returning the object its resolved flag should
+     * also be set by calling its <method>setResolved </method> method as well.
      * 
-     * <p>If the persistence mechanism does not known of an object with the specified {@link Oid} then a
+     * <p>
+     * If the persistence mechanism does not known of an object with the specified {@link Oid} then a
      * {@link ObjectNotFoundException} should be thrown.
      * 
-     * <para>Note that the OID could be for an internal collection, and is therefore related to the parent
-     * object (using a <class>CompositeOid </class>). The elements for an internal collection are commonly
-     * stored as part of the parent object, so to get element the parent object needs to be retrieved first,
-     * and the internal collection can be got from that. </para>
+     * <para>Note that the OID could be for an internal collection, and is therefore related to the parent object (using
+     * a <class>CompositeOid </class>). The elements for an internal collection are commonly stored as part of the
+     * parent object, so to get element the parent object needs to be retrieved first, and the internal collection can
+     * be got from that. </para>
      * 
      * <p>
      * Returns the stored ObjectAdapter object .
@@ -144,19 +135,17 @@ public interface ObjectStorePersistence 
      */
     ObjectAdapter getObject(Oid oid, ObjectSpecification hint);
 
-    
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // getInstances, hasInstances
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
 
     ObjectAdapter[] getInstances(PersistenceQuery persistenceQuery);
 
     boolean hasInstances(ObjectSpecification specification);
 
-    
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // resolveField, resolveImmediately
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
 
     /**
      * Called by the resolveEagerly method in ObjectAdapterManager.
@@ -171,11 +160,10 @@ public interface ObjectStorePersistence 
      * @see PersistenceSession#resolveImmediately(ObjectAdapter)
      */
     void resolveImmediately(ObjectAdapter object);
-    
 
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
     // Services
-    /////////////////////////////////////////////////////////
+    // ///////////////////////////////////////////////////////
 
     void registerService(String name, Oid oid);
 
@@ -184,8 +172,4 @@ public interface ObjectStorePersistence 
      */
     Oid getOidForService(String name);
 
-
-
-
-
 }

Modified: incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/objectstore/PersistenceSessionObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/objectstore/PersistenceSessionObjectStore.java?rev=1030308&r1=1030307&r2=1030308&view=diff
==============================================================================
--- incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/objectstore/PersistenceSessionObjectStore.java (original)
+++ incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/objectstore/PersistenceSessionObjectStore.java Wed Nov  3 01:24:18 2010
@@ -17,13 +17,18 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtime.persistence.objectstore;
 
+import static org.apache.isis.commons.ensure.Ensure.ensureThatArg;
+import static org.apache.isis.commons.ensure.Ensure.ensureThatState;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.log4j.Logger;
 import org.apache.isis.commons.debug.DebugString;
 import org.apache.isis.commons.ensure.Assert;
 import org.apache.isis.commons.lang.ToString;
@@ -62,14 +67,7 @@ import org.apache.isis.runtime.transacti
 import org.apache.isis.runtime.transaction.TransactionalClosureAbstract;
 import org.apache.isis.runtime.transaction.TransactionalClosureWithReturnAbstract;
 import org.apache.isis.runtime.transaction.updatenotifier.UpdateNotifier;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.apache.isis.commons.ensure.Ensure.ensureThatArg;
-import static org.apache.isis.commons.ensure.Ensure.ensureThatState;
-
+import org.apache.log4j.Logger;
 
 public class PersistenceSessionObjectStore extends PersistenceSessionAbstract implements ToPersistObjectSet {
     private static final Logger LOG = Logger.getLogger(PersistenceSessionObjectStore.class);
@@ -78,18 +76,14 @@ public class PersistenceSessionObjectSto
     private final Map<String, Oid> services = new HashMap<String, Oid>();
 
     /**
-     * Initialize the object store so that calls to this object store access persisted objects and persist
-     * changes to the object that are saved.
+     * Initialize the object store so that calls to this object store access persisted objects and persist changes to
+     * the object that are saved.
      */
-    public PersistenceSessionObjectStore(
-            final PersistenceSessionFactory persistenceSessionFactory,
-            final AdapterFactory adapterFactory,
-            final ObjectFactory objectFactory,
-            final ServicesInjector servicesInjector,
-            final OidGenerator oidGenerator,
-            final AdapterManagerExtended identityMap,
-            final PersistAlgorithm persistAlgorithm,
-            final ObjectStorePersistence objectStore) {
+    public PersistenceSessionObjectStore(final PersistenceSessionFactory persistenceSessionFactory,
+        final AdapterFactory adapterFactory, final ObjectFactory objectFactory,
+        final ServicesInjector servicesInjector, final OidGenerator oidGenerator,
+        final AdapterManagerExtended identityMap, final PersistAlgorithm persistAlgorithm,
+        final ObjectStorePersistence objectStore) {
 
         super(persistenceSessionFactory, adapterFactory, objectFactory, servicesInjector, oidGenerator, identityMap);
         if (LOG.isDebugEnabled()) {
@@ -125,15 +119,16 @@ public class PersistenceSessionObjectSto
     }
 
     /**
-     * Returns the cached value of {@link ObjectStore#isFixturesInstalled() whether fixtures are installed}
-     * from the {@link PersistenceSessionFactory} (provided it implements {@link FixturesInstalledFlag}),
-     * otherwise queries {@link ObjectStore} directly.
+     * Returns the cached value of {@link ObjectStore#isFixturesInstalled() whether fixtures are installed} from the
+     * {@link PersistenceSessionFactory} (provided it implements {@link FixturesInstalledFlag}), otherwise queries
+     * {@link ObjectStore} directly.
      * <p>
-     * This caching is important because if we've determined, for a given run, that fixtures are not
-     * installed, then we don't want to change our mind by asking the object store again in another session.
+     * This caching is important because if we've determined, for a given run, that fixtures are not installed, then we
+     * don't want to change our mind by asking the object store again in another session.
      * 
      * @see FixturesInstalledFlag
      */
+    @Override
     public boolean isFixturesInstalled() {
         PersistenceSessionFactory persistenceSessionFactory = getPersistenceSessionFactory();
         if (persistenceSessionFactory instanceof FixturesInstalledFlag) {
@@ -169,6 +164,7 @@ public class PersistenceSessionObjectSto
     // loadObject, reload
     // ///////////////////////////////////////////////////////////////////////////
 
+    @Override
     public ObjectAdapter loadObject(final Oid oid, final ObjectSpecification hintSpec) {
         ensureThatArg(oid, is(notNullValue()));
         ensureThatArg(hintSpec, is(notNullValue()));
@@ -184,22 +180,27 @@ public class PersistenceSessionObjectSto
     private ObjectAdapter loadObjectFromPersistenceLayer(final Oid oid, final ObjectSpecification hintSpec) {
         // the object store will map for us, using its hydrator (calls back
         // to #recreateAdapter)
-        return getTransactionManager().executeWithinTransaction(new TransactionalClosureWithReturnAbstract<ObjectAdapter>() {
-            public ObjectAdapter execute() {
-                return objectStore.getObject(oid, hintSpec);
-            }
-        });
+        return getTransactionManager().executeWithinTransaction(
+            new TransactionalClosureWithReturnAbstract<ObjectAdapter>() {
+                @Override
+                public ObjectAdapter execute() {
+                    return objectStore.getObject(oid, hintSpec);
+                }
+            });
     }
 
     /**
      * Does nothing.
      */
-    public void reload(final ObjectAdapter object) {}
+    @Override
+    public void reload(final ObjectAdapter object) {
+    }
 
     // ///////////////////////////////////////////////////////////////////////////
     // resolveImmediately, resolveField
     // ///////////////////////////////////////////////////////////////////////////
 
+    @Override
     public void resolveImmediately(final ObjectAdapter adapter) {
         // synchronize on the current session because getting race
         // conditions, I think between different UI threads when running
@@ -216,33 +217,39 @@ public class PersistenceSessionObjectSto
             if (LOG.isInfoEnabled()) {
                 // don't log object - its toString() may use the unresolved field, or unresolved collection
                 LOG.info("resolved: " + adapter.getSpecification().getShortName() + " " + resolveState.code() + " "
-                        + adapter.getOid());
+                    + adapter.getOid());
             }
         }
     }
 
     private void resolveImmediatelyFromPersistenceLayer(final ObjectAdapter adapter) {
         getTransactionManager().executeWithinTransaction(new TransactionalClosureAbstract() {
+            @Override
             public void preExecute() {
                 CallbackUtils.callCallback(adapter, LoadingCallbackFacet.class);
             }
 
+            @Override
             public void execute() {
                 objectStore.resolveImmediately(adapter);
             }
 
+            @Override
             public void onSuccess() {
                 CallbackUtils.callCallback(adapter, LoadedCallbackFacet.class);
             }
 
+            @Override
             public void onFailure() {
-            // TODO: should we do something here?
+                // TODO: should we do something here?
             }
         });
     }
 
+    @Override
     public void resolveField(final ObjectAdapter objectAdapter, final ObjectAssociation field) {
-        if (field.isNotPersisted() || field.isOneToManyAssociation() || field.getSpecification().isCollectionOrIsAggregated()) {
+        if (field.isNotPersisted() || field.isOneToManyAssociation()
+            || field.getSpecification().isCollectionOrIsAggregated()) {
             return;
         }
         final ObjectAdapter referenceAdapter = field.get(objectAdapter);
@@ -256,14 +263,15 @@ public class PersistenceSessionObjectSto
             // don't log object - it's toString() may use the unresolved field
             // or unresolved collection
             LOG.info("resolve field " + objectAdapter.getSpecification().getShortName() + "." + field.getId() + ": "
-                    + referenceAdapter.getSpecification().getShortName() + " " + referenceAdapter.getResolveState().code() + " "
-                    + referenceAdapter.getOid());
+                + referenceAdapter.getSpecification().getShortName() + " " + referenceAdapter.getResolveState().code()
+                + " " + referenceAdapter.getOid());
         }
         resolveFieldFromPersistenceLayer(objectAdapter, field);
     }
 
     private void resolveFieldFromPersistenceLayer(final ObjectAdapter objectAdapter, final ObjectAssociation field) {
         getTransactionManager().executeWithinTransaction(new TransactionalClosureAbstract() {
+            @Override
             public void execute() {
                 objectStore.resolveField(objectAdapter, field);
             }
@@ -275,20 +283,21 @@ public class PersistenceSessionObjectSto
     // ////////////////////////////////////////////////////////////////
 
     /**
-     * Makes a [[NAME]] persistent. The specified object should be stored away via this object store's
-     * persistence mechanism, and have an new and unique OID assigned to it. The object, should also be added
-     * to the {@link AdapterManager} as the object is implicitly 'in use'.
+     * Makes an {@link ObjectAdapter} persistent. The specified object should be stored away via this object store's
+     * persistence mechanism, and have an new and unique OID assigned to it. The object, should also be added to the
+     * {@link AdapterManager} as the object is implicitly 'in use'.
      * 
      * <p>
-     * If the object has any associations then each of these, where they aren't already persistent, should
-     * also be made persistent by recursively calling this method.
+     * If the object has any associations then each of these, where they aren't already persistent, should also be made
+     * persistent by recursively calling this method.
      * 
      * <p>
-     * If the object to be persisted is a collection, then each element of that collection, that is not
-     * already persistent, should be made persistent by recursively calling this method.
+     * If the object to be persisted is a collection, then each element of that collection, that is not already
+     * persistent, should be made persistent by recursively calling this method.
      * 
      * @see #remapAsPersistent(ObjectAdapter)
      */
+    @Override
     public void makePersistent(final ObjectAdapter adapter) {
         if (adapter.isPersistent()) {
             throw new NotPersistableException("Object already persistent: " + adapter);
@@ -308,21 +317,22 @@ public class PersistenceSessionObjectSto
         getTransactionManager().executeWithinTransaction(new TransactionalClosureAbstract() {
             @Override
             public void preExecute() {
-            // callbacks are called by the persist algorithm
+                // callbacks are called by the persist algorithm
             }
 
+            @Override
             public void execute() {
                 persistAlgorithm.makePersistent(adapter, PersistenceSessionObjectStore.this);
             }
 
             @Override
             public void onSuccess() {
-            // callbacks are called by the persist algorithm
+                // callbacks are called by the persist algorithm
             }
 
             @Override
             public void onFailure() {
-            // TODO: some sort of callback?
+                // TODO: some sort of callback?
             }
         });
     }
@@ -331,6 +341,7 @@ public class PersistenceSessionObjectSto
     // objectChanged
     // ///////////////////////////////////////////////////////////////////////////
 
+    @Override
     public void objectChanged(final ObjectAdapter adapter) {
 
         if (adapter.isTransient()) {
@@ -370,17 +381,20 @@ public class PersistenceSessionObjectSto
                 CallbackUtils.callCallback(adapter, UpdatingCallbackFacet.class);
             }
 
+            @Override
             public void execute() {
                 SaveObjectCommand saveObjectCommand = objectStore.createSaveObjectCommand(adapter);
                 getTransactionManager().addCommand(saveObjectCommand);
             }
 
+            @Override
             public void onSuccess() {
                 CallbackUtils.callCallback(adapter, UpdatedCallbackFacet.class);
             }
 
+            @Override
             public void onFailure() {
-            // TODO: should we do something here?
+                // TODO: should we do something here?
             }
         });
         getUpdateNotifier().addChangedObject(adapter);
@@ -391,9 +405,10 @@ public class PersistenceSessionObjectSto
     // ///////////////////////////////////////////////////////////////////////////
 
     /**
-     * Removes the specified object from the system. The specified object's data should be removed from the
-     * persistence mechanism.
+     * Removes the specified object from the system. The specified object's data should be removed from the persistence
+     * mechanism.
      */
+    @Override
     public void destroyObject(final ObjectAdapter adapter) {
         if (LOG.isInfoEnabled()) {
             LOG.info("destroyObject " + adapter);
@@ -409,17 +424,20 @@ public class PersistenceSessionObjectSto
                 CallbackUtils.callCallback(adapter, RemovingCallbackFacet.class);
             }
 
+            @Override
             public void execute() {
                 final DestroyObjectCommand command = objectStore.createDestroyObjectCommand(adapter);
                 getTransactionManager().addCommand(command);
             }
 
+            @Override
             public void onSuccess() {
                 CallbackUtils.callCallback(adapter, RemovedCallbackFacet.class);
             }
 
+            @Override
             public void onFailure() {
-            // TODO: some sort of callback?
+                // TODO: some sort of callback?
             }
         });
     }
@@ -429,24 +447,25 @@ public class PersistenceSessionObjectSto
     // ///////////////////////////////////////////////////////////////////////////
 
     /**
-     * Callback from the {@link PersistAlgorithm} (or equivalent; some object stores such as Hibernate will
-     * use listeners instead) to indicate that the {@link ObjectAdapter adapter} is persisted, and the adapter
-     * maps should be updated.
+     * Callback from the {@link PersistAlgorithm} (or equivalent; some object stores such as Hibernate will use
+     * listeners instead) to indicate that the {@link ObjectAdapter adapter} is persisted, and the adapter maps should
+     * be updated.
      * 
      * <p>
-     * The object store is expected to have already updated the {@link Oid} state and the {@link ResolveState}
-     * . Some object stores (again, we're thinking Hibernate here) might also have updated collections, both
-     * the Oid of the collection and the pojo wrapped by the adapter.
+     * The object store is expected to have already updated the {@link Oid} state and the {@link ResolveState} . Some
+     * object stores (again, we're thinking Hibernate here) might also have updated collections, both the Oid of the
+     * collection and the pojo wrapped by the adapter.
      * 
      * <p>
      * The {@link PersistAlgorithm} is called from {@link #makePersistent(ObjectAdapter)}.
      * 
      * <p>
-     * TODO: the <tt>PersistenceSessionProxy</tt> doesn't have this method; should document better why this is
-     * the case, and where the equivalent functionality is (somewhere in the marshalling stuff, I think).
+     * TODO: the <tt>PersistenceSessionProxy</tt> doesn't have this method; should document better why this is the case,
+     * and where the equivalent functionality is (somewhere in the marshalling stuff, I think).
      * 
      * @see #remapAsPersistent(ObjectAdapter)
      */
+    @Override
     public void remapAsPersistent(final ObjectAdapter adapter) {
         getAdapterManager().remapAsPersistent(adapter);
     }
@@ -464,16 +483,18 @@ public class PersistenceSessionObjectSto
     }
 
     private ObjectAdapter[] getInstancesFromPersistenceLayer(final PersistenceQuery persistenceQuery) {
-        return getTransactionManager().executeWithinTransaction(new TransactionalClosureWithReturnAbstract<ObjectAdapter[]>() {
-            public ObjectAdapter[] execute() {
-                return objectStore.getInstances(persistenceQuery);
-            }
-
-            @Override
-            public void onSuccess() {
-                clearAllDirty();
-            }
-        });
+        return getTransactionManager().executeWithinTransaction(
+            new TransactionalClosureWithReturnAbstract<ObjectAdapter[]>() {
+                @Override
+                public ObjectAdapter[] execute() {
+                    return objectStore.getInstances(persistenceQuery);
+                }
+
+                @Override
+                public void onSuccess() {
+                    clearAllDirty();
+                }
+            });
     }
 
     // ///////////////////////////////////////////////////////////////////////////
@@ -481,10 +502,11 @@ public class PersistenceSessionObjectSto
     // ///////////////////////////////////////////////////////////////////////////
 
     /**
-     * Checks whether there are any instances of the specified type. The object store should look for
-     * instances of the type represented by <variable>type </variable> and return <code>true</code> if there
-     * are, or <code>false</code> if there are not.
+     * Checks whether there are any instances of the specified type. The object store should look for instances of the
+     * type represented by <variable>type </variable> and return <code>true</code> if there are, or <code>false</code>
+     * if there are not.
      */
+    @Override
     public boolean hasInstances(final ObjectSpecification specification) {
         if (LOG.isInfoEnabled()) {
             LOG.info("hasInstances of " + specification.getShortName());
@@ -494,6 +516,7 @@ public class PersistenceSessionObjectSto
 
     private boolean hasInstancesFromPersistenceLayer(final ObjectSpecification specification) {
         return getTransactionManager().executeWithinTransaction(new TransactionalClosureWithReturnAbstract<Boolean>() {
+            @Override
             public Boolean execute() {
                 return objectStore.hasInstances(specification);
             }
@@ -530,6 +553,7 @@ public class PersistenceSessionObjectSto
     /**
      * Just downcasts.
      */
+    @Override
     public ObjectStoreTransactionManager getTransactionManager() {
         return (ObjectStoreTransactionManager) super.getTransactionManager();
     }
@@ -538,6 +562,7 @@ public class PersistenceSessionObjectSto
      * Uses the {@link ObjectStore} to {@link ObjectStore#createCreateObjectCommand(ObjectAdapter) create} a
      * {@link CreateObjectCommand}, and adds to the {@link IsisTransactionManager}.
      */
+    @Override
     public void addPersistedObject(final ObjectAdapter object) {
         getTransactionManager().addCommand(objectStore.createCreateObjectCommand(object));
     }
@@ -559,6 +584,7 @@ public class PersistenceSessionObjectSto
         objectStore.debugData(debug);
     }
 
+    @Override
     public String debugTitle() {
         return "Object Store Persistor";
     }

Modified: incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/oidgenerator/package-info.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/oidgenerator/package-info.java?rev=1030308&r1=1030307&r2=1030308&view=diff
==============================================================================
--- incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/oidgenerator/package-info.java (original)
+++ incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/oidgenerator/package-info.java Wed Nov  3 01:24:18 2010
@@ -17,24 +17,23 @@
  *  under the License.
  */
 
-
-/**
- * This interface is used by the {@link org.apache.isis.runtime.persistence.PersistenceSession} and
- * is generally not intended to be implemented directly.  
- * 
- * <p>
- * Used by object store implementations to specify how to manufacture
- * {@link org.apache.isis.metamodel.adapter.oid.Oid}s (permanent unique identifiers
- * for each domain object managed by [[NAME]]).  For example, an
- * in-memory object store will just use a unique Id, whereas a generator
- * for Hibernate will hook into Hibernate's own identity generators.
- * 
- * <p>
- * Since there is a close dependency between the {@link org.apache.isis.runtime.persistence.PersistenceSession}
- * and the {@link ClassSubstitutor} implementation, it is the job of the {@link org.apache.isis.runtime.persistence.PersistenceMechanismInstaller} to
- * ensure that the correct {@link OidGenerator} is setup.
- * 
- * @see org.apache.isis.runtime.persistence.objectstore.algorithm.PersistAlgorithm
- * @see org.apache.isis.metamodel.specloader.classsubstitutor.classsubstitor.ClassSubstitutor.ClassStrategy
- */
+/**
+ * This interface is used by the {@link org.apache.isis.runtime.persistence.PersistenceSession} and
+ * is generally not intended to be implemented directly.  
+ * 
+ * <p>
+ * Used by object store implementations to specify how to manufacture
+ * {@link org.apache.isis.metamodel.adapter.oid.Oid}s (permanent unique identifiers
+ * for each domain object managed by Apache Isis).  For example, an
+ * in-memory object store will just use a unique Id, whereas a generator
+ * for Hibernate will hook into Hibernate's own identity generators.
+ * 
+ * <p>
+ * Since there is a close dependency between the {@link org.apache.isis.runtime.persistence.PersistenceSession}
+ * and the {@link ClassSubstitutor} implementation, it is the job of the {@link org.apache.isis.runtime.persistence.PersistenceMechanismInstaller} to
+ * ensure that the correct {@link OidGenerator} is setup.
+ * 
+ * @see org.apache.isis.runtime.persistence.objectstore.algorithm.PersistAlgorithm
+ * @see org.apache.isis.metamodel.specloader.classsubstitutor.classsubstitor.ClassSubstitutor.ClassStrategy
+ */
 package org.apache.isis.runtime.persistence.oidgenerator;
\ No newline at end of file

Modified: incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/services/InitialisationException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/services/InitialisationException.java?rev=1030308&r1=1030307&r2=1030308&view=diff
==============================================================================
--- incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/services/InitialisationException.java (original)
+++ incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/persistence/services/InitialisationException.java Wed Nov  3 01:24:18 2010
@@ -17,14 +17,12 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtime.persistence.services;
 
 import org.apache.isis.commons.exceptions.IsisException;
 
-
 /**
- * Indicates a problem initialising the [[NAME]] system.
+ * Indicates a problem initialising the Apache Isis framework.
  */
 public class InitialisationException extends IsisException {
     private static final long serialVersionUID = 1L;

Modified: incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/session/IsisSessionDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/session/IsisSessionDefault.java?rev=1030308&r1=1030307&r2=1030308&view=diff
==============================================================================
--- incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/session/IsisSessionDefault.java (original)
+++ incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/runtime/session/IsisSessionDefault.java Wed Nov  3 01:24:18 2010
@@ -17,18 +17,16 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtime.session;
 
+import static org.apache.isis.commons.ensure.Ensure.ensureThatArg;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
-import static org.apache.isis.commons.ensure.Ensure.ensureThatArg;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
-import org.apache.log4j.Logger;
 import org.apache.isis.commons.components.SessionScopedComponent;
 import org.apache.isis.commons.debug.DebugInfo;
 import org.apache.isis.commons.debug.DebugString;
@@ -42,15 +40,14 @@ import org.apache.isis.runtime.system.De
 import org.apache.isis.runtime.transaction.IsisTransaction;
 import org.apache.isis.runtime.transaction.IsisTransactionManager;
 import org.apache.isis.runtime.userprofile.UserProfile;
-
+import org.apache.log4j.Logger;
 
 /**
- * Analogous to a Hibernate <tt>Session</tt>, holds the current set of components for a 
- * specific execution context (such as on a thread).
+ * Analogous to a Hibernate <tt>Session</tt>, holds the current set of components for a specific execution context (such
+ * as on a thread).
  * 
  * <p>
- * The <tt>IsisContext</tt> class (in <tt>nof-core</tt>) is responsible for locating
- * the current execution context.
+ * The <tt>IsisContext</tt> class (in <tt>nof-core</tt>) is responsible for locating the current execution context.
  * 
  * @see IsisSessionFactory
  */
@@ -66,67 +63,63 @@ public class IsisSessionDefault implemen
     private final AuthenticationSession authenticationSession;
     private PersistenceSession persistenceSession; // only non-final so can be replaced in tests.
     private final UserProfile userProfile;
-    
+
     private final int id;
     private long accessTime;
     private String debugSnapshot;
 
+    public IsisSessionDefault(final IsisSessionFactory sessionFactory,
+        final AuthenticationSession authenticationSession, final PersistenceSession persistenceSession,
+        final UserProfile userProfile) {
 
-    public IsisSessionDefault(
-            final IsisSessionFactory sessionFactory, 
-            final AuthenticationSession authenticationSession,
-            final PersistenceSession persistenceSession,
-            final UserProfile userProfile) {
-        
         // global context
         ensureThatArg(sessionFactory, is(not(nullValue())), "execution context factory is required");
 
         // session
         ensureThatArg(authenticationSession, is(not(nullValue())), "authentication session is required");
         ensureThatArg(persistenceSession, is(not(nullValue())), "persistence session is required");
-       ensureThatArg(userProfile, is(not(nullValue())), "user profile is required");
+        ensureThatArg(userProfile, is(not(nullValue())), "user profile is required");
 
         this.executionContextFactory = sessionFactory;
 
         this.authenticationSession = authenticationSession;
         this.persistenceSession = persistenceSession;
         this.userProfile = userProfile;
-        
+
         setSessionOpenTime(System.currentTimeMillis());
 
         this.id = nextId++;
     }
 
-
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // open, close
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
 
+    @Override
     public void open() {
         persistenceSession.open();
     }
-    
+
     /**
      * Closes session.
      */
+    @Override
     public void close() {
         takeSnapshot();
         getPersistenceSession().close();
     }
 
-
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // shutdown
-    ////////////////////////////////////////////////////////
-
-    
+    // //////////////////////////////////////////////////////
 
     /**
      * Shuts down all components.
      */
+    @Override
     public void closeAll() {
         close();
-        
+
         shutdownIfRequired(persistenceSession);
     }
 
@@ -137,10 +130,11 @@ public class IsisSessionDefault implemen
         }
     }
 
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // ExecutionContextFactory
-    ////////////////////////////////////////////////////////
-    
+    // //////////////////////////////////////////////////////
+
+    @Override
     public IsisSessionFactory getSessionFactory() {
         return executionContextFactory;
     }
@@ -173,98 +167,91 @@ public class IsisSessionDefault implemen
         return executionContextFactory.getTemplateImageLoader();
     }
 
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // AuthenticationSession
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
 
     /**
      * Returns the security session representing this user for this execution context.
      */
+    @Override
     public AuthenticationSession getAuthenticationSession() {
         return authenticationSession;
     }
 
-
     private String getSessionUserName() {
         return getAuthenticationSession().getUserName();
     }
 
-
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // Id
-    ////////////////////////////////////////////////////////
-
+    // //////////////////////////////////////////////////////
 
     /**
      * Returns an descriptive identifier for this {@link IsisSessionDefault}.
      */
+    @Override
     public String getId() {
         return "#" + id + getSessionUserName();
     }
 
-
-
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // Persistence Session
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
 
+    @Override
     public PersistenceSession getPersistenceSession() {
         return persistenceSession;
     }
 
-    
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // Perspective
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
 
+    @Override
     public UserProfile getUserProfile() {
         return userProfile;
     }
 
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // Session Open Time
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
 
     protected long getSessionOpenTime() {
         return accessTime;
     }
-    
+
     private void setSessionOpenTime(long accessTime) {
         this.accessTime = accessTime;
     }
 
-
-
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // Transaction
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
 
     /**
      * Convenience method that returns the {@link IsisTransaction} of the session, if any.
      */
+    @Override
     public IsisTransaction getCurrentTransaction() {
         return getTransactionManager().getTransaction();
     }
 
-
-
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // testSetObjectPersistor
-    ////////////////////////////////////////////////////////
-
+    // //////////////////////////////////////////////////////
 
     /**
-     * Should only be called in tests. 
+     * Should only be called in tests.
      */
     public void testSetObjectPersistor(PersistenceSession objectPersistor) {
         this.persistenceSession = objectPersistor;
     }
-    
 
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // toString
-    ////////////////////////////////////////////////////////
-    
+    // //////////////////////////////////////////////////////
+
     @Override
     public String toString() {
         final ToString asString = new ToString(this);
@@ -273,18 +260,18 @@ public class IsisSessionDefault implemen
         return asString.toString();
     }
 
-
-
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
     // Debugging
-    ////////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////////
 
+    @Override
     public void debugAll(final DebugString debug) {
-        debug.startSection("[[NAME]] Context Snapshot");
+        debug.startSection("Isis Context Snapshot");
         debug.appendln(debugSnapshot);
         debug.endSection();
     }
 
+    @Override
     public void debug(final DebugString debug) {
         debug.appendAsHexln("hash", hashCode());
         debug.appendln("context id", id);
@@ -311,7 +298,6 @@ public class IsisSessionDefault implemen
         LOG.debug(debugSnapshot);
     }
 
-
     private void debug(final DebugString debug, final Object object) {
         if (object instanceof DebugInfo) {
             final DebugInfo d = (DebugInfo) object;
@@ -323,7 +309,6 @@ public class IsisSessionDefault implemen
         }
     }
 
-    
     public void appendState(final ToString asString) {
         asString.append("authenticationSession", getAuthenticationSession());
         asString.append("persistenceSession", getPersistenceSession());
@@ -334,6 +319,7 @@ public class IsisSessionDefault implemen
         }
     }
 
+    @Override
     public void debugState(final DebugString debug) {
         debug.appendln("authenticationSession", getAuthenticationSession());
         debug.appendln("persistenceSession", getPersistenceSession());
@@ -344,10 +330,9 @@ public class IsisSessionDefault implemen
         }
     }
 
-
-    ///////////////////////////////////////////////////////
+    // /////////////////////////////////////////////////////
     // Dependencies (from constructor)
-    ///////////////////////////////////////////////////////
+    // /////////////////////////////////////////////////////
 
     private IsisTransactionManager getTransactionManager() {
         return getPersistenceSession().getTransactionManager();



Mime
View raw message