incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1371197 [3/4] - in /incubator/isis/trunk: examples/quickstart/dom/src/main/java/dom/todo/ framework/core/commons/src/main/java/org/apache/isis/core/commons/base64/ framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapt...
Date Thu, 09 Aug 2012 13:18:21 GMT
Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerPersist.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerPersist.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerPersist.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerPersist.java Thu Aug  9 13:18:18 2012
@@ -24,6 +24,8 @@ import org.apache.isis.core.metamodel.ad
 import org.apache.isis.core.metamodel.adapter.ResolveState;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
 import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
@@ -65,9 +67,39 @@ public interface AdapterManagerPersist {
      * 
      * <p>
      * If the {@link ObjectAdapter adapter} is recreated, its
-     * {@link ResolveState} will be {@link ResolveState#GHOST} if a persistent
-     * {@link Oid}, or {@link ResolveState#TRANSIENT} otherwise.
+     * {@link ResolveState} will be set to either
+     * {@link ResolveState#TRANSIENT} or {@link ResolveState#GHOST} based on
+     * whether the {@link Oid} is {@link Oid#isTransient() transient} or not.
+     * 
+     * @param oid
+     * @param recreatedPojo - already known to the object store impl, or a service
+     */
+    ObjectAdapter mapRecreatedPojo(Oid oid, Object recreatedPojo);
+
+    
+    /**
+     * Either returns an existing {@link ObjectAdapter adapter} (as per 
+     * {@link #getAdapterFor(Oid)}), otherwise re-creates an adapter with the 
+     * specified (persistent) {@link Oid}.
+     * 
+     * <p>
+     * Typically called when the {@link Oid} is already known, that is, when
+     * resolving an already-persisted object. Is also available for
+     * <tt>Memento</tt> support however, so {@link Oid} could also represent a
+     * {@link Oid#isTransient() transient} object.
+     * 
+     * <p>
+     * The pojo itself is recreated by delegating to a {@link PojoRecreator} implementation.
+     * The default impl just uses the {@link ObjectSpecification#createObject()};
+     * however object stores (eg JDO/DataNucleus) can provide alternative implementations
+     * in order to ensure that the created pojo is attached to a persistence context.
+     * 
+     * <p>
+     * If the {@link ObjectAdapter adapter} is recreated, its
+     * {@link ResolveState} will be set to {@link ResolveState#GHOST}.
+     * 
+     * @param oid
      */
-    ObjectAdapter recreateAdapter(Oid oid, Object pojo);
+    ObjectAdapter recreatePersistentAdapter(TypedOid oid);
 
 }

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerTestSupport.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerTestSupport.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerTestSupport.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerTestSupport.java Thu Aug  9 13:18:18 2012
@@ -39,10 +39,10 @@ public interface AdapterManagerTestSuppo
      * Note that the {@link RootOid} must represent a {@link Oid#isTransient()
      * transient} object. If an {@link ObjectAdapter adapter} is required for a
      * persistent {@link RootOid}, just use
-     * {@link #recreateAdapter(RootOid, Object)}.
+     * {@link #mapRecreatedPojo(RootOid, Object)}.
      * 
      * @see #adapterFor(Object)
-     * @see #recreateAdapter(RootOid, Object)
+     * @see #mapRecreatedPojo(RootOid, Object)
      */
     ObjectAdapter testCreateTransient(Object pojo, RootOid oid);
 

Added: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/PojoRecreator.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/PojoRecreator.java?rev=1371197&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/PojoRecreator.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/PojoRecreator.java Thu Aug  9 13:18:18 2012
@@ -0,0 +1,9 @@
+package org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager;
+
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+
+public interface PojoRecreator {
+
+    Object recreatePojo(final TypedOid oid);
+    
+}

Added: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/PojoRecreatorDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/PojoRecreatorDefault.java?rev=1371197&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/PojoRecreatorDefault.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/PojoRecreatorDefault.java Thu Aug  9 13:18:18 2012
@@ -0,0 +1,27 @@
+package org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager;
+
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderAware;
+
+public class PojoRecreatorDefault implements PojoRecreator, SpecificationLoaderAware {
+
+    private SpecificationLoader specificationLoader;
+
+    public Object recreatePojo(final TypedOid oid) {
+        final ObjectSpecification spec = getSpecificationLoader().lookupBySpecId(oid.getObjectSpecId());
+        return spec.createObject();
+    }
+
+    
+    protected SpecificationLoader getSpecificationLoader() {
+        return specificationLoader;
+    }
+
+    @Override
+    public void setSpecificationLoader(SpecificationLoader specificationLoader) {
+        this.specificationLoader = specificationLoader;
+    }
+
+}

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/PersistenceSession.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/PersistenceSession.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/PersistenceSession.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/PersistenceSession.java Thu Aug  9 13:18:18 2012
@@ -74,7 +74,6 @@ import org.apache.isis.core.metamodel.sp
 import org.apache.isis.runtimes.dflt.runtime.persistence.FixturesInstalledFlag;
 import org.apache.isis.runtimes.dflt.runtime.persistence.NotPersistableException;
 import org.apache.isis.runtimes.dflt.runtime.persistence.PersistenceSessionAware;
-import org.apache.isis.runtimes.dflt.runtime.persistence.PersistenceSessionHydratorAware;
 import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerExtended;
 import org.apache.isis.runtimes.dflt.runtime.persistence.internal.RuntimeContextFromSession;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStore;
@@ -97,11 +96,9 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.transaction.TransactionalClosureAbstract;
 import org.apache.isis.runtimes.dflt.runtime.transaction.TransactionalClosureWithReturnAbstract;
 
-public class PersistenceSession implements PersistenceSessionContainer, PersistenceSessionAdaptedServiceManager, PersistenceSessionTransactionManagement, PersistenceSessionHydrator, PersistenceSessionTestSupport, SpecificationLoaderAware,
+public class PersistenceSession implements PersistenceSessionContainer, PersistenceSessionAdaptedServiceManager, PersistenceSessionTransactionManagement, PersistenceSessionTestSupport, SpecificationLoaderAware,
         IsisTransactionManagerAware, SessionScopedComponent, Injectable, DebuggableWithTitle, ToPersistObjectSet {
 
-
-    
     private final PersistenceSessionFactory persistenceSessionFactory;
     private final ObjectAdapterFactory adapterFactory;
     private final ObjectFactory objectFactory;
@@ -303,7 +300,7 @@ public class PersistenceSession implemen
             if (existingOid == null) {
                 serviceAdapter = getAdapterManager().adapterFor(service);
             } else {
-                serviceAdapter = getAdapterManager().recreateAdapter(existingOid, service);
+                serviceAdapter = getAdapterManager().mapRecreatedPojo(existingOid, service);
             }
 
             if (serviceAdapter.getOid().isTransient()) {
@@ -398,49 +395,6 @@ public class PersistenceSession implemen
         return adapter;
     }
 
-    @Override
-    public final ObjectAdapter recreateAdapter(final TypedOid oid) {
-        final ObjectSpecId objectSpecId = oid.getObjectSpecId();
-        final ObjectSpecification objectSpec = getSpecificationLoader().lookupBySpecId(objectSpecId);
-        return recreateAdapter(objectSpec, oid);
-    }
-
-    @Override
-    public ObjectAdapter recreateAdapter(final ObjectSpecification specification, final Oid oid) {
-        final ObjectAdapter adapterLookedUpByOid = getAdapterManager().getAdapterFor(oid);
-        if (adapterLookedUpByOid != null) {
-            return adapterLookedUpByOid;
-        }
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("recreating adapter for Oid: " + oid + " of type " + specification);
-        }
-        
-        final Object pojo = specification.createObject();
-
-        return getAdapterManager().recreateAdapter(oid, pojo);
-    }
-
-    @Override
-    public ObjectAdapter recreateAdapter(final Oid oid, final Object pojo) {
-        final ObjectAdapter adapterLookedUpByOid = getAdapterManager().getAdapterFor(oid);
-        if (adapterLookedUpByOid != null) {
-            return adapterLookedUpByOid;
-        }
-
-        final ObjectAdapter adapterLookedUpByPojo = getAdapterManager().getAdapterFor(pojo);
-        if (adapterLookedUpByPojo != null) {
-            return adapterLookedUpByPojo;
-        }
-
-        if (LOG.isDebugEnabled()) {
-            // don't touch pojo in case cause it to resolve.
-            LOG.debug("recreating adapter for Oid: " + oid + " for provided pojo ");
-        }
-        return getAdapterManager().recreateAdapter(oid, pojo);
-    }
-    
-
 
     // ///////////////////////////////////////////////////////////////////////////
     // findInstances, getInstances
@@ -522,6 +476,20 @@ public class PersistenceSession implemen
         return getInstancesFromPersistenceLayer(persistenceQuery);
     }
 
+    private List<ObjectAdapter> getInstancesFromPersistenceLayer(final PersistenceQuery persistenceQuery) {
+        return getTransactionManager().executeWithinTransaction(new TransactionalClosureWithReturnAbstract<List<ObjectAdapter>>() {
+            @Override
+            public List<ObjectAdapter> execute() {
+                return objectStore.getInstances(persistenceQuery);
+            }
+
+            @Override
+            public void onSuccess() {
+                clearAllDirty();
+            }
+        });
+    }
+
     // ///////////////////////////////////////////////////////////////////////////
     // Manual dirtying support
     // ///////////////////////////////////////////////////////////////////////////
@@ -587,9 +555,9 @@ public class PersistenceSession implemen
                 object.getSpecification().clearDirty(object);
             }
         }
-
     }
 
+    
     // ///////////////////////////////////////////////////////////////////////////
     // Services
     // ///////////////////////////////////////////////////////////////////////////
@@ -637,7 +605,7 @@ public class PersistenceSession implemen
     private ObjectAdapter getService(final Object servicePojo) {
         final ObjectSpecification serviceSpecification = getSpecificationLoader().loadSpecification(servicePojo.getClass());
         final RootOid oid = getOidForService(serviceSpecification);
-        final ObjectAdapter serviceAdapter = getAdapterManager().recreateAdapter(oid, servicePojo);
+        final ObjectAdapter serviceAdapter = getAdapterManager().mapRecreatedPojo(oid, servicePojo);
         
         serviceAdapter.markAsResolvedIfPossible();
         return serviceAdapter;
@@ -651,178 +619,8 @@ public class PersistenceSession implemen
     }
 
 
-    // ////////////////////////////////////////////////////////////////////
-    // Helpers
-    // ////////////////////////////////////////////////////////////////////
-
-    protected boolean isImmutable(final ObjectAdapter adapter) {
-        final ObjectSpecification noSpec = adapter.getSpecification();
-        return ImmutableFacetUtils.isAlwaysImmutable(noSpec) || (ImmutableFacetUtils.isImmutableOncePersisted(noSpec) && adapter.representsPersistent());
-    }
-
-    // ////////////////////////////////////////////////////////////////////
-    // injectInto
-    // ////////////////////////////////////////////////////////////////////
-
-    @Override
-    public void injectInto(final Object candidate) {
-        if (PersistenceSessionAware.class.isAssignableFrom(candidate.getClass())) {
-            final PersistenceSessionAware cast = PersistenceSessionAware.class.cast(candidate);
-            cast.setPersistenceSession(this);
-        }
-        if (PersistenceSessionHydratorAware.class.isAssignableFrom(candidate.getClass())) {
-            final PersistenceSessionHydratorAware cast = PersistenceSessionHydratorAware.class.cast(candidate);
-            cast.setHydrator(this);
-        }
-    }
-
     // ///////////////////////////////////////////////////////////////////////////
-    // Debugging
-    // ///////////////////////////////////////////////////////////////////////////
-
-    @Override
-    public void debugData(final DebugBuilder debug) {
-        debug.appendTitle(getClass().getName());
-        debug.appendln("container", servicesInjector);
-        debug.appendln();
-
-        adapterManager.debugData(debug);
-        debug.appendln();
-
-        debug.appendln("manually dirtiable support (isDirty flag)?", dirtiableSupport);
-
-        debug.appendTitle("OID Generator");
-        oidGenerator.debugData(debug);
-        debug.appendln();
-
-        debug.appendTitle("Services");
-        for (final Object servicePojo : servicesInjector.getRegisteredServices()) {
-            final String id = ServiceUtil.id(servicePojo);
-            final Class<? extends Object> serviceClass = servicePojo.getClass();
-            final ObjectSpecification serviceSpecification = getSpecificationLoader().loadSpecification(serviceClass);
-            final String serviceClassName = serviceClass.getName();
-            final Oid oidForService = getOidForService(serviceSpecification);
-            final String serviceId = id + (id.equals(serviceClassName) ? "" : " (" + serviceClassName + ")");
-            debug.appendln(oidForService != null ? oidForService.toString() : "[NULL]", serviceId);
-        }
-        debug.appendln();
-
-        
-        debug.appendTitle("Persistor");
-        getTransactionManager().debugData(debug);
-        debug.appendln("Persist Algorithm", persistAlgorithm);
-        debug.appendln("Object Store", objectStore);
-        debug.appendln();
-
-        objectStore.debugData(debug);
-    }
-
-    // ///////////////////////////////////////////////////////////////////////////
-    // Dependencies (injected in constructor, possibly implicitly)
-    // ///////////////////////////////////////////////////////////////////////////
-
-    /**
-     * The configured {@link ObjectAdapterFactory}.
-     * 
-     * <p>
-     * Injected in constructor.
-     */
-    public final ObjectAdapterFactory getAdapterFactory() {
-        return adapterFactory;
-    }
-
-    /**
-     * The configured {@link OidGenerator}.
-     * 
-     * <p>
-     * Injected in constructor.
-     */
-    public final OidGenerator getOidGenerator() {
-        return oidGenerator;
-    }
-
-    /**
-     * The configured {@link AdapterManager}.
-     * 
-     * <p>
-     * Injected in constructor.
-     */
-    public final AdapterManagerExtended getAdapterManager() {
-        return adapterManager;
-    }
-
-    /**
-     * The configured {@link ServicesInjector}.
-     */
-    public ServicesInjector getServicesInjector() {
-        return servicesInjector;
-    }
-
-    /**
-     * The configured {@link ObjectFactory}.
-     * 
-     * <p>
-     * Obtained indirectly from the injected reflector.
-     */
-    public ObjectFactory getObjectFactory() {
-        return objectFactory;
-    }
-
-    // ///////////////////////////////////////////////////////////////////////////
-    // Dependencies (injected)
-    // ///////////////////////////////////////////////////////////////////////////
-
-    protected SpecificationLoader getSpecificationLoader() {
-        return specificationLoader;
-    }
-
-    /**
-     * Inject the {@link SpecificationLoader}.
-     * 
-     * <p>
-     * The need to inject the reflector was introduced to support the
-     * HibernateObjectStore, which installs its own
-     * <tt>HibernateClassStrategy</tt> to cope with the proxy classes that
-     * Hibernate wraps around lists, sets and maps.
-     */
-    public void setSpecificationLoader(final SpecificationLoader specificationLoader) {
-        this.specificationLoader = specificationLoader;
-    }
-
-    /**
-     * Inject the {@link IsisTransactionManager}.
-     * 
-     * <p>
-     * This must be injected using setter-based injection rather than through
-     * the constructor because there is a bidirectional relationship between the
-     * {@link PersistenceSessionHydrator} and the {@link IsisTransactionManager}.
-     * 
-     * @see #getTransactionManager()
-     */
-    public void setTransactionManager(final IsisTransactionManager transactionManager) {
-        this.transactionManager = transactionManager;
-    }
-
-    
-    /**
-     * The configured {@link IsisTransactionManager}.
-     * 
-     * @see #setTransactionManager(IsisTransactionManager)
-     */
-    public IsisTransactionManager getTransactionManager() {
-        return transactionManager;
-    }
-
-    
-    
-    
-
-    
-    
-    
-
-    // ///////////////////////////////////////////////////////////////////////////
-    // init, shutdown
+    // fixture installation
     // ///////////////////////////////////////////////////////////////////////////
 
 
@@ -862,14 +660,13 @@ public class PersistenceSession implemen
         }
     }
 
-
-
     @Override
     protected void finalize() throws Throwable {
         super.finalize();
-        LOG.debug("finalizing object manager");
+        LOG.debug("finalizing persistence session");
     }
-
+    
+    
     // ///////////////////////////////////////////////////////////////////////////
     // loadObject, reload
     // ///////////////////////////////////////////////////////////////////////////
@@ -1114,6 +911,7 @@ public class PersistenceSession implemen
         getUpdateNotifier().addChangedObject(adapter);
     }
 
+    
     // ///////////////////////////////////////////////////////////////////////////
     // destroyObject
     // ///////////////////////////////////////////////////////////////////////////
@@ -1165,6 +963,8 @@ public class PersistenceSession implemen
     // remapAsPersistent
     // ///////////////////////////////////////////////////////////////////////////
 
+    private Map<Oid, Oid> persistentByTransient = Maps.newHashMap();
+
     /**
      * Callback from the {@link PersistAlgorithm} (or equivalent; some object
      * stores such as Hibernate will use listeners instead) to indicate that the
@@ -1181,11 +981,6 @@ public class PersistenceSession implemen
      * 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).
-     * 
      * @see #remapAsPersistent(ObjectAdapter)
      */
     @Override
@@ -1197,31 +992,12 @@ public class PersistenceSession implemen
     }
 
 
-    private Map<Oid, Oid> persistentByTransient = Maps.newHashMap();
     
     @Override
     public Oid remappedFrom(Oid transientOid) {
         return persistentByTransient.get(transientOid);
     }
 
-    // ///////////////////////////////////////////////////////////////////////////
-    // getInstances
-    // ///////////////////////////////////////////////////////////////////////////
-
-
-    private List<ObjectAdapter> getInstancesFromPersistenceLayer(final PersistenceQuery persistenceQuery) {
-        return getTransactionManager().executeWithinTransaction(new TransactionalClosureWithReturnAbstract<List<ObjectAdapter>>() {
-            @Override
-            public List<ObjectAdapter> execute() {
-                return objectStore.getInstances(persistenceQuery);
-            }
-
-            @Override
-            public void onSuccess() {
-                clearAllDirty();
-            }
-        });
-    }
 
     // ///////////////////////////////////////////////////////////////////////////
     // hasInstances
@@ -1282,6 +1058,7 @@ public class PersistenceSession implemen
         getTransactionManager().addCommand(objectStore.createCreateObjectCommand(object));
     }
 
+    
     // ///////////////////////////////////////////////////////////////////////////
     // Debugging
     // ///////////////////////////////////////////////////////////////////////////
@@ -1293,6 +1070,43 @@ public class PersistenceSession implemen
     }
 
     @Override
+    public void debugData(final DebugBuilder debug) {
+        debug.appendTitle(getClass().getName());
+        debug.appendln("container", servicesInjector);
+        debug.appendln();
+
+        adapterManager.debugData(debug);
+        debug.appendln();
+
+        debug.appendln("manually dirtiable support (isDirty flag)?", dirtiableSupport);
+
+        debug.appendTitle("OID Generator");
+        oidGenerator.debugData(debug);
+        debug.appendln();
+
+        debug.appendTitle("Services");
+        for (final Object servicePojo : servicesInjector.getRegisteredServices()) {
+            final String id = ServiceUtil.id(servicePojo);
+            final Class<? extends Object> serviceClass = servicePojo.getClass();
+            final ObjectSpecification serviceSpecification = getSpecificationLoader().loadSpecification(serviceClass);
+            final String serviceClassName = serviceClass.getName();
+            final Oid oidForService = getOidForService(serviceSpecification);
+            final String serviceId = id + (id.equals(serviceClassName) ? "" : " (" + serviceClassName + ")");
+            debug.appendln(oidForService != null ? oidForService.toString() : "[NULL]", serviceId);
+        }
+        debug.appendln();
+
+        
+        debug.appendTitle("Persistor");
+        getTransactionManager().debugData(debug);
+        debug.appendln("Persist Algorithm", persistAlgorithm);
+        debug.appendln("Object Store", objectStore);
+        debug.appendln();
+
+        objectStore.debugData(debug);
+    }
+    
+    @Override
     public String toString() {
         final ToString toString = new ToString(this);
         if (objectStore != null) {
@@ -1304,8 +1118,31 @@ public class PersistenceSession implemen
         return toString.toString();
     }
 
+    
+    // ////////////////////////////////////////////////////////////////////
+    // Helpers
+    // ////////////////////////////////////////////////////////////////////
+
+    protected boolean isImmutable(final ObjectAdapter adapter) {
+        final ObjectSpecification noSpec = adapter.getSpecification();
+        return ImmutableFacetUtils.isAlwaysImmutable(noSpec) || (ImmutableFacetUtils.isImmutableOncePersisted(noSpec) && adapter.representsPersistent());
+    }
+
+    // ////////////////////////////////////////////////////////////////////
+    // injectInto
+    // ////////////////////////////////////////////////////////////////////
+
+    @Override
+    public void injectInto(final Object candidate) {
+        if (PersistenceSessionAware.class.isAssignableFrom(candidate.getClass())) {
+            final PersistenceSessionAware cast = PersistenceSessionAware.class.cast(candidate);
+            cast.setPersistenceSession(this);
+        }
+    }
+
+    
     // ///////////////////////////////////////////////////////////////////////////
-    // Dependencies
+    // Dependencies (injected in constructor, possibly implicitly)
     // ///////////////////////////////////////////////////////////////////////////
 
     /**
@@ -1326,6 +1163,100 @@ public class PersistenceSession implemen
         return getTransactionManager().getTransaction().getUpdateNotifier();
     }
 
+    /**
+     * The configured {@link ObjectAdapterFactory}.
+     * 
+     * <p>
+     * Injected in constructor.
+     */
+    public final ObjectAdapterFactory getAdapterFactory() {
+        return adapterFactory;
+    }
+
+    /**
+     * The configured {@link OidGenerator}.
+     * 
+     * <p>
+     * Injected in constructor.
+     */
+    public final OidGenerator getOidGenerator() {
+        return oidGenerator;
+    }
+
+    /**
+     * The configured {@link AdapterManager}.
+     * 
+     * <p>
+     * Injected in constructor.
+     */
+    public final AdapterManagerExtended getAdapterManager() {
+        return adapterManager;
+    }
+
+    /**
+     * The configured {@link ServicesInjector}.
+     */
+    public ServicesInjector getServicesInjector() {
+        return servicesInjector;
+    }
+
+    /**
+     * The configured {@link ObjectFactory}.
+     * 
+     * <p>
+     * Obtained indirectly from the injected reflector.
+     */
+    public ObjectFactory getObjectFactory() {
+        return objectFactory;
+    }
+
+    
+    // ///////////////////////////////////////////////////////////////////////////
+    // Dependencies (injected)
+    // ///////////////////////////////////////////////////////////////////////////
+
+    protected SpecificationLoader getSpecificationLoader() {
+        return specificationLoader;
+    }
+
+    /**
+     * Inject the {@link SpecificationLoader}.
+     * 
+     * <p>
+     * The need to inject the reflector was introduced to support the
+     * HibernateObjectStore, which installs its own
+     * <tt>HibernateClassStrategy</tt> to cope with the proxy classes that
+     * Hibernate wraps around lists, sets and maps.
+     */
+    public void setSpecificationLoader(final SpecificationLoader specificationLoader) {
+        this.specificationLoader = specificationLoader;
+    }
+
+    /**
+     * Inject the {@link IsisTransactionManager}.
+     * 
+     * <p>
+     * This must be injected using setter-based injection rather than through
+     * the constructor because there is a bidirectional relationship between the
+     * {@link PersistenceSessionHydrator} and the {@link IsisTransactionManager}.
+     * 
+     * @see #getTransactionManager()
+     */
+    public void setTransactionManager(final IsisTransactionManager transactionManager) {
+        this.transactionManager = transactionManager;
+    }
+
+    
+    /**
+     * The configured {@link IsisTransactionManager}.
+     * 
+     * @see #setTransactionManager(IsisTransactionManager)
+     */
+    public IsisTransactionManager getTransactionManager() {
+        return transactionManager;
+    }
+
+
     // ///////////////////////////////////////////////////////////////////////////
     // Dependencies (from context)
     // ///////////////////////////////////////////////////////////////////////////
@@ -1333,7 +1264,5 @@ public class PersistenceSession implemen
     private static AuthenticationSession getAuthenticationSession() {
         return IsisContext.getAuthenticationSession();
     }
-
-
     
 }

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransaction.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransaction.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransaction.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransaction.java Thu Aug  9 13:18:18 2012
@@ -21,9 +21,9 @@ package org.apache.isis.runtimes.dflt.ru
 
 import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
 import static org.apache.isis.core.commons.ensure.Ensure.ensureThatState;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
 
 import java.util.Collections;
 import java.util.List;
@@ -33,6 +33,7 @@ import com.google.common.collect.Lists;
 import org.apache.log4j.Logger;
 
 import org.apache.isis.core.commons.components.TransactionScopedComponent;
+import org.apache.isis.core.commons.ensure.Ensure;
 import org.apache.isis.core.commons.lang.ToString;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.ResolveState;
@@ -41,6 +42,7 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.SaveObjectCommand;
+import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
 
 /**
  * Used by the {@link IsisTransactionManager} to captures a set of changes to be
@@ -157,11 +159,13 @@ public class IsisTransaction implements 
 
     private static final Logger LOG = Logger.getLogger(IsisTransaction.class);
 
+
     private final ObjectStoreTransactionManagement objectStore;
     private final List<PersistenceCommand> commands = Lists.newArrayList();
     private final IsisTransactionManager transactionManager;
     private final MessageBroker messageBroker;
     private final UpdateNotifier updateNotifier;
+    private final List<ObjectPersistenceException> exceptions = Lists.newArrayList();
 
     private State state;
 
@@ -197,7 +201,6 @@ public class IsisTransaction implements 
         this.state = state;
     }
 
-
     
     // //////////////////////////////////////////////////////////
     // Commands
@@ -264,6 +267,24 @@ public class IsisTransaction implements 
 
 
 
+    /////////////////////////////////////////////////////////////////////////
+    // for worm-hole handling of exceptions
+    /////////////////////////////////////////////////////////////////////////
+
+    public void ensureExceptionsListIsEmpty() {
+        Ensure.ensureThatArg(exceptions.isEmpty(), is(true), "exceptions list is not empty");
+    }
+
+    public void addException(ObjectPersistenceException exception) {
+        exceptions.add(exception);
+    }
+    
+    public List<ObjectPersistenceException> getExceptionsIfAny() {
+        return Collections.unmodifiableList(exceptions);
+    }
+
+    
+
     // ////////////////////////////////////////////////////////////////
     // flush
     // ////////////////////////////////////////////////////////////////
@@ -330,6 +351,7 @@ public class IsisTransaction implements 
 
     public final void commit() {
         ensureThatState(getState().canCommit(), is(true), "state is: " + getState());
+        ensureThatState(exceptions.isEmpty(), is(true), "cannot commit: " + exceptions.size() + " exceptions have been raised");
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("commit transaction " + this);

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransactionManager.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransactionManager.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransactionManager.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/IsisTransactionManager.java Thu Aug  9 13:18:18 2012
@@ -26,6 +26,8 @@ import static org.hamcrest.CoreMatchers.
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.CoreMatchers.nullValue;
 
+import java.util.List;
+
 import org.apache.log4j.Logger;
 
 import org.apache.isis.core.commons.components.Injectable;
@@ -37,6 +39,7 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionTransactionManagement;
 import org.apache.isis.runtimes.dflt.runtime.system.session.IsisSession;
 import org.apache.isis.runtimes.dflt.runtime.transaction.IsisTransactionManagerException;
+import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
 import org.apache.isis.runtimes.dflt.runtime.transaction.messagebroker.MessageBrokerDefault;
 import org.apache.isis.runtimes.dflt.runtime.transaction.updatenotifier.UpdateNotifierDefault;
 
@@ -57,8 +60,6 @@ public class IsisTransactionManager impl
      */
     private IsisTransaction transaction;
 
-    
-
 
 
     // ////////////////////////////////////////////////////////////////
@@ -242,7 +243,7 @@ public class IsisTransactionManager impl
     // start, flush, abort, end
     // //////////////////////////////////////////////////////
 
-    public void startTransaction() {
+    public synchronized void startTransaction() {
 
         boolean noneInProgress = false;
         if (getTransaction() == null || getTransaction().getState().isComplete()) {
@@ -260,7 +261,7 @@ public class IsisTransactionManager impl
         }
     }
 
-    public boolean flushTransaction() {
+    public synchronized boolean flushTransaction() {
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("flushTransaction");
@@ -276,17 +277,60 @@ public class IsisTransactionManager impl
     /**
      * Ends the transaction if nesting level is 0.
      */
-    public void endTransaction() {
+    public synchronized void endTransaction() {
         if (LOG.isDebugEnabled()) {
             LOG.debug("endTransaction: level " + (transactionLevel) + "->" + (transactionLevel - 1));
         }
 
         transactionLevel--;
         if (transactionLevel == 0) {
-            LOG.debug("endTransaction: committing");
-            objectPersistor.objectChangedAllDirty();
-            getTransaction().commit();
-            objectStore.endTransaction();
+
+            //
+            // TODO: granted, this is some fairly byzantine coding.  but I'm trying to account for different types
+            // of object store implementations that could start throwing exceptions at any stage.
+            // once the contract/API for the objectstore is better tied down, hopefully can simplify this...
+            //
+            
+            List<ObjectPersistenceException> exceptions = this.getTransaction().getExceptionsIfAny();
+            if(exceptions.isEmpty()) {
+            
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("endTransaction: committing");
+                }
+                
+                objectPersistor.objectChangedAllDirty();
+                
+                // just in case any additional exceptions were raised...
+                exceptions = this.getTransaction().getExceptionsIfAny();
+            }
+            
+            if(exceptions.isEmpty()) {
+                getTransaction().commit();
+                
+                // in case any additional exceptions were raised...
+                exceptions = this.getTransaction().getExceptionsIfAny();
+            }
+            
+            if(exceptions.isEmpty()) {
+                objectStore.endTransaction();
+                
+                // just in case any additional exceptions were raised...
+                exceptions = this.getTransaction().getExceptionsIfAny();
+            }
+            
+            if(!exceptions.isEmpty()) {
+                
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("endTransaction: aborting instead, " + exceptions.size() + " exception(s) have been raised");
+                }
+                abortTransaction();
+                
+                // just in case any additional exceptions were raised...
+                exceptions = this.getTransaction().getExceptionsIfAny();
+                
+                throw exceptionToThrowFrom(exceptions);
+            }
+            
         } else if (transactionLevel < 0) {
             LOG.error("endTransaction: transactionLevel=" + transactionLevel);
             transactionLevel = 0;
@@ -294,7 +338,20 @@ public class IsisTransactionManager impl
         }
     }
 
-    public void abortTransaction() {
+
+    private ObjectPersistenceException exceptionToThrowFrom(List<ObjectPersistenceException> exceptions) {
+        if(exceptions.size() == 1) {
+            return exceptions.get(0);
+        } 
+        final StringBuilder buf = new StringBuilder();
+        for (ObjectPersistenceException ope : exceptions) {
+            buf.append(ope.getMessage()).append("\n");
+        }
+        return new ObjectPersistenceException(buf.toString());
+    }
+    
+
+    public synchronized void abortTransaction() {
         if (getTransaction() != null) {
             getTransaction().abort();
             transactionLevel = 0;

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/AdapterManagerDefault_aggregateAdapters.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/AdapterManagerDefault_aggregateAdapters.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/AdapterManagerDefault_aggregateAdapters.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/AdapterManagerDefault_aggregateAdapters.java Thu Aug  9 13:18:18 2012
@@ -143,7 +143,7 @@ public class AdapterManagerDefault_aggre
         rootObject = new Customer();
         aggregatedObject = new Name();
         
-        persistentParentAdapter = adapterManager.recreateAdapter(
+        persistentParentAdapter = adapterManager.mapRecreatedPojo(
                 RootOidDefault.create(ObjectSpecId.of("CUS"), "1"), rootObject);
     }
 

Modified: incubator/isis/trunk/framework/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java Thu Aug  9 13:18:18 2012
@@ -44,6 +44,7 @@ import org.apache.isis.core.runtime.auth
 import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
 import org.apache.isis.runtimes.dflt.objectstores.dflt.InMemoryPersistenceMechanismInstaller;
 import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
+import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerExtended;
 import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerPersist;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStore;
 import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
@@ -338,7 +339,7 @@ public class IsisSystemWithFixtures impl
     }
     
     private DomainObjectContainer getContainer() {
-        return IsisContext.getPersistenceSession().getServicesInjector().getContainer();
+        return getPersistenceSession().getServicesInjector().getContainer();
     }
 
     /**
@@ -500,18 +501,18 @@ public class IsisSystemWithFixtures impl
 
     public ObjectAdapter adapterFor(Object domainObject) {
         ensureSessionInProgress();
-        return IsisContext.getPersistenceSession().getAdapterManager().adapterFor(domainObject);
+        return getAdapterManager().adapterFor(domainObject);
     }
 
     public ObjectAdapter reload(RootOid oid) {
         ensureSessionInProgress();
-        final PersistenceSession persistenceSession = IsisContext.getPersistenceSession();
+        final PersistenceSession persistenceSession = getPersistenceSession();
         return persistenceSession.loadObject(oid);
     }
 
     public ObjectAdapter recreateAdapter(RootOid oid) {
         ensureSessionInProgress();
-        return IsisContext.getPersistenceSession().recreateAdapter(oid);
+        return getAdapterManager().recreatePersistentAdapter(oid);
     }
 
     public ObjectAdapter remapAsPersistent(Object pojo, RootOid persistentOid) {
@@ -524,7 +525,7 @@ public class IsisSystemWithFixtures impl
 
     @SuppressWarnings("unchecked")
     public <T extends ObjectStore> T getObjectStore(Class<T> cls) {
-        final PersistenceSession persistenceSession = IsisContext.getPersistenceSession();
+        final PersistenceSession persistenceSession = getPersistenceSession();
         return (T) persistenceSession.getObjectStore();
     }
 
@@ -574,11 +575,11 @@ public class IsisSystemWithFixtures impl
 
     
     private AdapterManagerPersist getAdapterManagerPersist() {
-        return (AdapterManagerPersist)IsisContext.getPersistenceSession().getAdapterManager();
+        return (AdapterManagerPersist)getAdapterManager();
     }
 
     public void beginTran() {
-        final IsisTransactionManager transactionManager = IsisContext.getPersistenceSession().getTransactionManager();
+        final IsisTransactionManager transactionManager = getTransactionManager();
         final IsisTransaction transaction = transactionManager.getTransaction();
 
         if(transaction == null) {
@@ -605,7 +606,7 @@ public class IsisSystemWithFixtures impl
     }
 
     public void commitTran() {
-        final IsisTransactionManager transactionManager = IsisContext.getPersistenceSession().getTransactionManager();
+        final IsisTransactionManager transactionManager = getTransactionManager();
         final IsisTransaction transaction = transactionManager.getTransaction();
         if(transaction == null) {
             Assert.fail("No transaction exists");
@@ -627,7 +628,7 @@ public class IsisSystemWithFixtures impl
     }
 
     public void abortTran() {
-        final IsisTransactionManager transactionManager = IsisContext.getPersistenceSession().getTransactionManager();
+        final IsisTransactionManager transactionManager = getTransactionManager();
         final IsisTransaction transaction = transactionManager.getTransaction();
         if(transaction == null) {
             Assert.fail("No transaction exists");
@@ -649,5 +650,18 @@ public class IsisSystemWithFixtures impl
         }
     }
 
+    protected IsisTransactionManager getTransactionManager() {
+        return getPersistenceSession().getTransactionManager();
+    }
+    
+    protected AdapterManagerExtended getAdapterManager() {
+        return getPersistenceSession().getAdapterManager();
+    }
+
+    protected PersistenceSession getPersistenceSession() {
+        return IsisContext.getPersistenceSession();
+    }
+
+
     
 }

Modified: incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/context/PersistentRootAdapterMapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/context/PersistentRootAdapterMapping.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/context/PersistentRootAdapterMapping.java (original)
+++ incubator/isis/trunk/framework/viewer/html/src/main/java/org/apache/isis/viewer/html/context/PersistentRootAdapterMapping.java Thu Aug  9 13:18:18 2012
@@ -24,6 +24,7 @@ import org.apache.isis.core.commons.ensu
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
 import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerExtended;
 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;
@@ -69,7 +70,7 @@ public class PersistentRootAdapterMappin
     @Override
     public void restoreToLoader() {
         final RootOidDefault oid = RootOidDefault.deString(getOidStr());
-        final ObjectAdapter adapter = getPersistenceSession().recreateAdapter(oid);
+        final ObjectAdapter adapter = getAdapterManager().recreatePersistentAdapter(oid);
         adapter.setVersion(getVersion());
     }
 
@@ -108,12 +109,12 @@ public class PersistentRootAdapterMappin
     // Dependencies (from context)
     // /////////////////////////////////////////////////////
 
-    private static AdapterManager getAdapterManager() {
-        return getPersistenceSession().getAdapterManager();
-    }
-
-    private static PersistenceSession getPersistenceSession() {
+    protected PersistenceSession getPersistenceSession() {
         return IsisContext.getPersistenceSession();
     }
 
+    protected AdapterManagerExtended getAdapterManager() {
+        return getPersistenceSession().getAdapterManager();
+    }
+    
 }

Modified: incubator/isis/trunk/framework/viewer/html/src/main/resources/htmlviewer.js
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/html/src/main/resources/htmlviewer.js?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/html/src/main/resources/htmlviewer.js (original)
+++ incubator/isis/trunk/framework/viewer/html/src/main/resources/htmlviewer.js Thu Aug  9 13:18:18 2012
@@ -18,5 +18,5 @@
  */
 $(document).ready(function()
 {
-    $(".message-header").fadeOut(2000)
+    $(".message-header").fadeOut(5000)
 });
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/restfulobjects/restfulobjects-viewer/src/main/java/org/apache/isis/viewer/restfulobjects/viewer/util/OidUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/restfulobjects/restfulobjects-viewer/src/main/java/org/apache/isis/viewer/restfulobjects/viewer/util/OidUtils.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/restfulobjects/restfulobjects-viewer/src/main/java/org/apache/isis/viewer/restfulobjects/viewer/util/OidUtils.java (original)
+++ incubator/isis/trunk/framework/viewer/restfulobjects/restfulobjects-viewer/src/main/java/org/apache/isis/viewer/restfulobjects/viewer/util/OidUtils.java Thu Aug  9 13:18:18 2012
@@ -35,7 +35,7 @@ public final class OidUtils {
         if(adapterFor != null) {
             return adapterFor;
         }
-        return resourceContext.getPersistenceSession().recreateAdapter(rootOid);
+        return resourceContext.getPersistenceSession().getAdapterManager().recreatePersistentAdapter(rootOid);
     }
 
     public static String getOidStr(final ResourceContext resourceContext, final ObjectAdapter objectAdapter) {

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java Thu Aug  9 13:18:18 2012
@@ -47,6 +47,7 @@ import org.apache.isis.core.metamodel.sp
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
 import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerExtended;
 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;
@@ -325,7 +326,7 @@ public class DefaultOidObjectMapping imp
         final TypedOid typedOid = new OidMarshaller().unmarshal(oidStr, TypedOid.class);
 
         if(!typedOid.isTransient()) {
-            return getPersistenceSession().recreateAdapter(typedOid);
+            return getAdapterManager().recreatePersistentAdapter(typedOid);
         } else {
             return mappedObject(oidStr);
         }
@@ -374,7 +375,6 @@ public class DefaultOidObjectMapping imp
 //        final String aggregatedId = split.length > 2?split[2]:null;
 //            
 //        final ObjectSpecification spec = getSpecificationLoader().lookupByObjectType(objectType);
-        final ObjectSpecification spec = getSpecificationLoader().lookupBySpecId(typedOid.getObjectSpecId());
 
         //if ((type == 'T')) {
         if (typedOid.isTransient()) {
@@ -384,13 +384,12 @@ public class DefaultOidObjectMapping imp
                 mapping = requestTransients.get(oidStr);
             }
             if (mapping == null) {
-                final Object pojo = spec.createObject();
 
                 // create as a (transient) root adapter
                 // Oid oid = deString(objectType, oidData, State.TRANSIENT);
                 //return getPersistenceSession().recreateAdapter(oid, pojo);
                 
-                return getPersistenceSession().recreateAdapter(typedOid, pojo);
+                return getAdapterManager().recreatePersistentAdapter(typedOid);
             }
             
             final ObjectAdapter mappedTransientObject = mapping.getObject();
@@ -522,10 +521,6 @@ public class DefaultOidObjectMapping imp
     // from context
     ///////////////////////////////////////
     
-//    protected OidStringifier getOidStringifier() {
-//        return getPersistenceSession().getOidGenerator().getOidStringifier();
-//    }
-    
     protected SpecificationLoader getSpecificationLoader() {
         return IsisContext.getSpecificationLoader();
     }
@@ -534,7 +529,7 @@ public class DefaultOidObjectMapping imp
         return IsisContext.getPersistenceSession();
     }
 
-    protected AdapterManager getAdapterManager() {
+    protected AdapterManagerExtended getAdapterManager() {
         return getPersistenceSession().getAdapterManager();
     }
 

Modified: incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Mapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Mapping.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Mapping.java (original)
+++ incubator/isis/trunk/framework/viewer/scimpi/scimpi-dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Mapping.java Thu Aug  9 13:18:18 2012
@@ -26,7 +26,9 @@ import org.apache.isis.core.metamodel.ad
 import org.apache.isis.core.metamodel.adapter.oid.RootOid;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.runtimes.dflt.runtime.memento.Memento;
+import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerExtended;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
 
 interface Mapping {
     ObjectAdapter getObject();
@@ -112,7 +114,7 @@ class PersistentRootAdapterMapping imple
 
     @Override
     public String debug() {
-        return oid + "  " + spec.getShortIdentifier() + "  " + IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(oid);
+        return oid + "  " + spec.getShortIdentifier() + "  " + getAdapterManager().getAdapterFor(oid);
     }
 
     @Override
@@ -120,13 +122,14 @@ class PersistentRootAdapterMapping imple
         if (!IsisContext.inTransaction()) {
             throw new IllegalStateException(getClass().getSimpleName() + " requires transaction in order to load");
         }
-        return IsisContext.getPersistenceSession().loadObject(oid);
+        return getPersistenceSession().loadObject(oid);
     }
 
     @Override
     public void reload() {
-        if (IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(oid) == null) {
-            IsisContext.getPersistenceSession().recreateAdapter(spec, oid);
+        if (getAdapterManager().getAdapterFor(oid) == null) {
+            final Object recreatedPojo = spec.createObject();
+            getAdapterManager().mapRecreatedPojo(oid, recreatedPojo);
         }
     }
 
@@ -156,4 +159,18 @@ class PersistentRootAdapterMapping imple
     public void update() {
     }
 
+    
+    ////////////////////////////////////
+    
+
+    protected PersistenceSession getPersistenceSession() {
+        return IsisContext.getPersistenceSession();
+    }
+
+
+    protected AdapterManagerExtended getAdapterManager() {
+        return getPersistenceSession().getAdapterManager();
+    }
+
+
 }

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ActionMemento.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ActionMemento.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ActionMemento.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ActionMemento.java Thu Aug  9 13:18:18 2012
@@ -22,6 +22,7 @@ package org.apache.isis.viewer.wicket.mo
 import java.io.Serializable;
 
 import org.apache.isis.core.metamodel.spec.ActionType;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
 
 /**
@@ -31,24 +32,24 @@ public class ActionMemento implements Se
 
     private static final long serialVersionUID = 1L;
 
-    private final SpecMemento owningType;
+    private final ObjectSpecId owningType;
     private final ActionType actionType;
     private final String nameParmsId;
 
     private transient ObjectAction action;
 
-    public ActionMemento(final SpecMemento owningType, final ActionType actionType, final String nameParmsId) {
+    public ActionMemento(final ObjectSpecId owningType, final ActionType actionType, final String nameParmsId) {
         this.owningType = owningType;
         this.actionType = actionType;
         this.nameParmsId = nameParmsId;
     }
 
     public ActionMemento(final ObjectAction action) {
-        this(new SpecMemento(action.getOnType()), action.getType(), action.getIdentifier().toNameParmsIdentityString());
+        this(action.getOnType().getSpecId(), action.getType(), action.getIdentifier().toNameParmsIdentityString());
         this.action = action;
     }
 
-    public SpecMemento getOwningType() {
+    public ObjectSpecId getOwningType() {
         return owningType;
     }
 
@@ -62,7 +63,7 @@ public class ActionMemento implements Se
 
     public ObjectAction getAction() {
         if (action == null) {
-            action = owningType.getSpecification().getObjectAction(actionType, nameParmsId);
+            action = SpecUtils.getSpecificationFor(owningType).getObjectAction(actionType, nameParmsId);
         }
         return action;
     }

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/CollectionMemento.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/CollectionMemento.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/CollectionMemento.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/CollectionMemento.java Thu Aug  9 13:18:18 2012
@@ -21,6 +21,7 @@ package org.apache.isis.viewer.wicket.mo
 
 import java.io.Serializable;
 
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -37,22 +38,22 @@ public class CollectionMemento implement
         return IsisContext.getSpecificationLoader().loadSpecification(association.getIdentifier().toClassIdentityString());
     }
 
-    private final SpecMemento owningType;
+    private final ObjectSpecId owningType;
     private final String id;
 
     private transient OneToManyAssociation collection;
 
-    public CollectionMemento(final SpecMemento owningType, final String id) {
+    public CollectionMemento(final ObjectSpecId owningType, final String id) {
         this.owningType = owningType;
         this.id = id;
     }
 
     public CollectionMemento(final OneToManyAssociation collection) {
-        this(new SpecMemento(owningSpecFor(collection)), collection.getIdentifier().toNameIdentityString());
+        this(owningSpecFor(collection).getSpecId(), collection.getIdentifier().toNameIdentityString());
         this.collection = collection;
     }
 
-    public SpecMemento getOwningType() {
+    public ObjectSpecId getOwningType() {
         return owningType;
     }
 
@@ -73,7 +74,7 @@ public class CollectionMemento implement
 
     public OneToManyAssociation getCollection() {
         if (collection == null) {
-            collection = (OneToManyAssociation) owningType.getSpecification().getAssociation(id);
+            collection = (OneToManyAssociation) SpecUtils.getSpecificationFor(owningType).getAssociation(id);
         }
         return collection;
     }

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ObjectAdapterMemento.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ObjectAdapterMemento.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ObjectAdapterMemento.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/ObjectAdapterMemento.java Thu Aug  9 13:18:18 2012
@@ -23,11 +23,15 @@ import java.io.Serializable;
 
 import org.apache.isis.core.commons.ensure.Ensure;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.ResolveState;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
 import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.runtimes.dflt.runtime.memento.Memento;
+import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerExtended;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.viewer.wicket.model.util.Oids;
@@ -49,12 +53,10 @@ public class ObjectAdapterMemento implem
     /**
      * Factory method
      */
-    public static ObjectAdapterMemento createPersistent(final Oid oid, final SpecMemento specMemento) {
-        return new ObjectAdapterMemento(oid, specMemento);
+    public static ObjectAdapterMemento createPersistent(final RootOid rootOid) {
+        return new ObjectAdapterMemento(rootOid);
     }
 
-    private final SpecMemento specMemento;
-    private String titleHint;
 
     enum Type {
         /**
@@ -64,14 +66,26 @@ public class ObjectAdapterMemento implem
          */
         ENCODEABLE {
             @Override
-            ObjectAdapter recreateAdapter(final ObjectAdapterMemento nom) {
-                final EncodableFacet encodableFacet = nom.specMemento.getSpecification().getFacet(EncodableFacet.class);
-                return encodableFacet.fromEncodedString(nom.encodableValue);
+            ObjectAdapter recreateAdapter(final ObjectAdapterMemento oam) {
+                ObjectSpecId objectSpecId = oam.objectSpecId;
+                ObjectSpecification objectSpec = SpecUtils.getSpecificationFor(objectSpecId);
+                final EncodableFacet encodableFacet = objectSpec.getFacet(EncodableFacet.class);
+                return encodableFacet.fromEncodedString(oam.encodableValue);
             }
 
             @Override
-            public String toString(final ObjectAdapterMemento nom) {
-                return nom.encodableValue;
+            public boolean equals(ObjectAdapterMemento oam, ObjectAdapterMemento other) {
+                return other.type == ENCODEABLE && oam.encodableValue.equals(other.encodableValue);
+            }
+
+            @Override
+            public int hashCode(ObjectAdapterMemento oam) {
+                return oam.encodableValue.hashCode();
+            }
+
+            @Override
+            public String toString(final ObjectAdapterMemento oam) {
+                return oam.encodableValue;
             }
         },
         /**
@@ -80,17 +94,28 @@ public class ObjectAdapterMemento implem
          */
         PERSISTENT {
             @Override
-            ObjectAdapter recreateAdapter(final ObjectAdapterMemento nom) {
-                return getPersistenceSession().recreateAdapter(nom.getSpecMemento().getSpecification(), nom.persistentOid);
+            ObjectAdapter recreateAdapter(final ObjectAdapterMemento oam) {
+                TypedOid oid = oidMarshaller.unmarshal(oam.persistentOidStr, TypedOid.class);
+                return getAdapterManager().recreatePersistentAdapter(oid);
             }
 
-            private PersistenceSession getPersistenceSession() {
-                return IsisContext.getPersistenceSession();
+            private AdapterManagerExtended getAdapterManager() {
+                return IsisContext.getPersistenceSession().getAdapterManager();
+            }
+            
+            @Override
+            public boolean equals(ObjectAdapterMemento oam, ObjectAdapterMemento other) {
+                return other.type == PERSISTENT && oam.persistentOidStr.equals(other.persistentOidStr);
             }
 
             @Override
-            public String toString(final ObjectAdapterMemento nom) {
-                return nom.persistentOid.toString();
+            public int hashCode(ObjectAdapterMemento oam) {
+                return oam.persistentOidStr.hashCode();
+            }
+
+            @Override
+            public String toString(final ObjectAdapterMemento oam) {
+                return oam.persistentOidStr;
             }
         },
         /**
@@ -99,14 +124,24 @@ public class ObjectAdapterMemento implem
          */
         TRANSIENT {
             @Override
-            ObjectAdapter recreateAdapter(final ObjectAdapterMemento nom) {
-                final ObjectAdapter adapter = nom.transientMemento.recreateObject();
+            ObjectAdapter recreateAdapter(final ObjectAdapterMemento oam) {
+                final ObjectAdapter adapter = oam.transientMemento.recreateObject();
                 return adapter;
             }
 
             @Override
-            public String toString(final ObjectAdapterMemento nom) {
-                return nom.transientMemento.toString();
+            public boolean equals(ObjectAdapterMemento oam, ObjectAdapterMemento other) {
+                return other.type == TRANSIENT && oam.transientMemento.equals(other.transientMemento);
+            }
+
+            @Override
+            public int hashCode(ObjectAdapterMemento oam) {
+                return oam.transientMemento.hashCode();
+            }
+            
+            @Override
+            public String toString(final ObjectAdapterMemento oam) {
+                return oam.transientMemento.toString();
             }
         };
 
@@ -116,11 +151,17 @@ public class ObjectAdapterMemento implem
 
         abstract ObjectAdapter recreateAdapter(ObjectAdapterMemento nom);
 
+        public abstract boolean equals(ObjectAdapterMemento oam, ObjectAdapterMemento other);
+        public abstract int hashCode(ObjectAdapterMemento objectAdapterMemento);
+        
         public abstract String toString(ObjectAdapterMemento adapterMemento);
     }
 
     private Type type;
 
+    private final ObjectSpecId objectSpecId;
+    private String titleHint;
+
     /**
      * The current value, if {@link Type#ENCODEABLE}.
      * 
@@ -128,13 +169,14 @@ public class ObjectAdapterMemento implem
      * Will be <tt>null</tt> otherwise.
      */
     private String encodableValue;
+    
     /**
      * The current value, if {@link Type#PERSISTENT}.
      * 
      * <p>
      * Will be <tt>null</tt> otherwise.
      */
-    private Oid persistentOid;
+    private String persistentOidStr;
 
     /**
      * The current value, if {@link Type#TRANSIENT}.
@@ -144,10 +186,12 @@ public class ObjectAdapterMemento implem
      */
     private Memento transientMemento;
 
-    private ObjectAdapterMemento(final Oid oid, final SpecMemento specMemento) {
-        Ensure.ensureThatArg(oid, Oids.isPersistent());
-        this.persistentOid = oid;
-        this.specMemento = specMemento;
+    private final static OidMarshaller oidMarshaller = new OidMarshaller();
+    
+    private ObjectAdapterMemento(final RootOid rootOid) {
+        Ensure.ensureThatArg(rootOid, Oids.isPersistent());
+        this.persistentOidStr = oidMarshaller.marshal(rootOid);
+        this.objectSpecId = rootOid.getObjectSpecId();
         this.type = Type.PERSISTENT;
     }
 
@@ -156,36 +200,42 @@ public class ObjectAdapterMemento implem
             throw new IllegalArgumentException("adapter cannot be null");
         }
         final ObjectSpecification specification = adapter.getSpecification();
-        specMemento = new SpecMemento(specification);
+        objectSpecId = specification.getSpecId();
         init(adapter);
-        captureTitleHintIfPossible(adapter);
+        captureTitleHintIfPossible();
     }
 
     private void init(final ObjectAdapter adapter) {
-        final ObjectSpecification specification = specMemento.getSpecification();
+        
+        final ObjectSpecification specification = adapter.getSpecification();
+
         final EncodableFacet encodableFacet = specification.getFacet(EncodableFacet.class);
         final boolean isEncodable = encodableFacet != null;
         if (isEncodable) {
             encodableValue = encodableFacet.toEncodedString(adapter);
             type = Type.ENCODEABLE;
-        } else {
-            final Oid oid = adapter.getOid();
-            if (oid.isTransient()) {
-                transientMemento = new Memento(adapter);
-                type = Type.TRANSIENT;
-            } else {
-                persistentOid = oid;
-                type = Type.PERSISTENT;
-            }
+            return;
         }
+        
+        final RootOid oid = (RootOid) adapter.getOid();
+        if (oid.isTransient()) {
+            transientMemento = new Memento(adapter);
+            type = Type.TRANSIENT;
+            return;
+        } 
+        
+        persistentOidStr = oidMarshaller.marshal(oid);
+        type = Type.PERSISTENT;
     }
 
-    public void captureTitleHintIfPossible(final ObjectAdapter adapter) {
-        if (adapter == null) {
+    
+    public void captureTitleHintIfPossible() {
+        if (this.titleHint != null) {
             return;
-        }
-        if (adapter.isTitleAvailable()) {
-            this.titleHint = adapter.titleString();
+        } 
+        ObjectAdapter objectAdapter = this.getObjectAdapter();
+        if (objectAdapter.isTitleAvailable()) {
+            this.titleHint = objectAdapter.titleString();
         }
     }
 
@@ -219,8 +269,19 @@ public class ObjectAdapterMemento implem
         init(adapter);
     }
 
-    public SpecMemento getSpecMemento() {
-        return specMemento;
+    public ObjectSpecId getObjectSpecId() {
+        return objectSpecId;
+    }
+
+    
+    @Override
+    public int hashCode() {
+        return type.hashCode(this);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return (obj instanceof ObjectAdapterMemento) && type.equals(this, (ObjectAdapterMemento)obj);
     }
 
     @Override
@@ -228,4 +289,5 @@ public class ObjectAdapterMemento implem
         return type.toString(this);
     }
 
+
 }

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/PageParameterNames.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/PageParameterNames.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/PageParameterNames.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/PageParameterNames.java Thu Aug  9 13:18:18 2012
@@ -29,17 +29,19 @@ import org.apache.isis.viewer.wicket.mod
  */
 public enum PageParameterNames {
 
+//    /**
+//     * Whether the object is persistent or not.
+//     */
+//    OBJECT_PERSISTENT,
+//    /**
+//     * The object's spec, as the fully qualified class name.
+//     */
+//    OBJECT_SPEC,
     /**
-     * Whether the object is persistent or not.
-     */
-    OBJECT_PERSISTENT,
-    /**
-     * The object's spec, as the fully qualified class name.
-     */
-    OBJECT_SPEC,
-    /**
-     * The object's {@link Oid} (only used if the object is
-     * {@link #OBJECT_PERSISTENT persistent}.
+     * The object's {@link Oid}.
+     * 
+     * <p>
+     * Also encodes the object's spec, and whether the object is persistent or not.
      */
     OBJECT_OID,
     /**

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/PropertyMemento.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/PropertyMemento.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/PropertyMemento.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/PropertyMemento.java Thu Aug  9 13:18:18 2012
@@ -21,6 +21,7 @@ package org.apache.isis.viewer.wicket.mo
 
 import java.io.Serializable;
 
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -34,39 +35,39 @@ public class PropertyMemento implements 
         return IsisContext.getSpecificationLoader().loadSpecification(association.getIdentifier().toClassIdentityString());
     }
 
-    private final SpecMemento owningType;
+    private final ObjectSpecId owningType;
     private final String identifier;
 
     /**
      * Lazily loaded as required.
      */
-    private SpecMemento type;
+    private ObjectSpecId type;
 
     private transient OneToOneAssociation property;
 
-    public PropertyMemento(final SpecMemento owningType, final String name) {
+    public PropertyMemento(final ObjectSpecId owningType, final String name) {
         this(owningType, name, null);
     }
 
-    public PropertyMemento(final SpecMemento owningType, final String name, final SpecMemento type) {
+    public PropertyMemento(final ObjectSpecId owningType, final String name, final ObjectSpecId type) {
         this.owningType = owningType;
         this.identifier = name;
         this.type = type;
     }
 
     public PropertyMemento(final OneToOneAssociation property) {
-        this(new SpecMemento(owningSpecFor(property)), property.getIdentifier().toNameIdentityString(), new SpecMemento(property.getSpecification()));
+        this(owningSpecFor(property).getSpecId(), property.getIdentifier().toNameIdentityString(), property.getSpecification().getSpecId());
         this.property = property;
     }
 
-    public SpecMemento getOwningType() {
+    public ObjectSpecId getOwningType() {
         return owningType;
     }
 
-    public SpecMemento getType() {
+    public ObjectSpecId getType() {
         if (type == null) {
             // lazy load if need be
-            type = new SpecMemento(getProperty().getSpecification());
+            type = getProperty().getSpecification().getSpecId();
         }
         return type;
     }
@@ -77,7 +78,7 @@ public class PropertyMemento implements 
 
     public OneToOneAssociation getProperty() {
         if (property == null) {
-            property = (OneToOneAssociation) owningType.getSpecification().getAssociation(identifier);
+            property = (OneToOneAssociation) SpecUtils.getSpecificationFor(owningType).getAssociation(identifier);
         }
         return property;
     }

Added: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/SpecUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/SpecUtils.java?rev=1371197&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/SpecUtils.java (added)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/mementos/SpecUtils.java Thu Aug  9 13:18:18 2012
@@ -0,0 +1,28 @@
+package org.apache.isis.viewer.wicket.model.mementos;
+
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationContainer;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.wicket.model.util.ClassLoaders;
+
+public final class SpecUtils {
+    
+    private SpecUtils(){}
+
+    public static ObjectSpecification getSpecificationFor(ObjectSpecId objectSpecId) {
+        ObjectSpecification objectSpec = getSpecificationLoader().lookupBySpecId(objectSpecId);
+        if(objectSpec != null) {
+            return objectSpec;
+        } 
+        
+        // attempt to load directly.
+        return getSpecificationLoader().loadSpecification(objectSpecId.asString());
+    }
+
+    protected static SpecificationLoader getSpecificationLoader() {
+        return IsisContext.getSpecificationLoader();
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ActionModel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ActionModel.java?rev=1371197&r1=1371196&r2=1371197&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ActionModel.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ActionModel.java Thu Aug  9 13:18:18 2012
@@ -33,10 +33,12 @@ import org.apache.wicket.markup.html.lin
 import org.apache.isis.applib.Identifier;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
 import org.apache.isis.core.metamodel.adapter.oid.RootOid;
 import org.apache.isis.core.metamodel.adapter.oid.stringable.OidStringifier;
 import org.apache.isis.core.metamodel.consent.Consent;
 import org.apache.isis.core.metamodel.spec.ActionType;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
 import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
@@ -46,7 +48,6 @@ import org.apache.isis.viewer.wicket.mod
 import org.apache.isis.viewer.wicket.model.mementos.ActionParameterMemento;
 import org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento;
 import org.apache.isis.viewer.wicket.model.mementos.PageParameterNames;
-import org.apache.isis.viewer.wicket.model.mementos.SpecMemento;
 import org.apache.isis.viewer.wicket.model.util.ActionParams;
 
 /**
@@ -88,6 +89,8 @@ public class ActionModel extends ModelAb
         SELECT
     }
 
+    private final static OidMarshaller oidMarshaller = new OidMarshaller();
+
     /**
      * Factory; for use directly.
      */
@@ -223,20 +226,28 @@ public class ActionModel extends ModelAb
         return ActionType.valueOf(PageParameterNames.ACTION_TYPE.getFrom(pageParameters));
     }
 
-    private static SpecMemento actionOwningSpecFor(final PageParameters pageParameters) {
-        return SpecMemento.representing(PageParameterNames.ACTION_OWNING_SPEC.getFrom(pageParameters));
+    private static ObjectSpecId actionOwningSpecFor(final PageParameters pageParameters) {
+        return ObjectSpecId.of(PageParameterNames.ACTION_OWNING_SPEC.getFrom(pageParameters));
     }
 
     private static ObjectAdapterMemento newObjectAdapterMementoFrom(final PageParameters pageParameters, final OidStringifier oidStringifier) {
-        return ObjectAdapterMemento.createPersistent(oidFor(pageParameters, oidStringifier), objectSpecFor(pageParameters));
+        RootOid oid = oidFor(pageParameters);
+        if(oid.isTransient()) {
+            //return ObjectAdapterMemento.
+            return null;
+        } else {
+            return ObjectAdapterMemento.createPersistent(oid);
+        }
     }
 
-    private static SpecMemento objectSpecFor(final PageParameters pageParameters) {
-        return SpecMemento.representing(PageParameterNames.OBJECT_SPEC.getFrom(pageParameters));
-    }
+//    private static SpecMemento objectSpecFor(final PageParameters pageParameters) {
+//        return SpecMemento.representing(PageParameterNames.OBJECT_SPEC.getFrom(pageParameters));
+//    }
 
-    private static Oid oidFor(final PageParameters pageParameters, final OidStringifier oidStringifier) {
-        return oidStringifier.deString(PageParameterNames.OBJECT_OID.getFrom(pageParameters));
+    
+    private static RootOid oidFor(final PageParameters pageParameters) {
+        String oidStr = PageParameterNames.OBJECT_OID.getFrom(pageParameters);
+        return oidMarshaller.unmarshal(oidStr, RootOid.class);
     }
 
     private ActionModel(final ObjectAdapterMemento adapterMemento, final ActionMemento actionMemento, final Mode actionMode, final SingleResultsMode singleResultsMode) {



Mime
View raw message