incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1304796 [2/16] - in /incubator/isis/trunk/framework: applib/src/main/java/org/apache/isis/applib/ applib/src/test/java/org/apache/isis/applib/ core/commons/src/main/java/org/apache/isis/core/commons/config/ core/commons/src/main/java/org/a...
Date Sat, 24 Mar 2012 14:01:52 GMT

Modified: incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java (original)
+++ incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java Sat Mar 24 14:01:35 2012
@@ -21,6 +21,7 @@ package org.apache.isis.applib;
 
 import java.util.List;
 
+import org.apache.isis.applib.annotation.Aggregated;
 import org.apache.isis.applib.annotation.Hidden;
 import org.apache.isis.applib.filter.Filter;
 import org.apache.isis.applib.query.Query;
@@ -40,16 +41,33 @@ public abstract class AbstractContainedO
         return getContainer().newTransientInstance(ofType);
     }
 
+    /**
+     * Create an instance that will be persisted as part of this domain object
+     * (ie this domain object is its parent in the aggregate).
+     * 
+     * <p>
+     * The type provided should be annotated with {@link Aggregated}.
+     * 
+     *  @see #newAggregatedInstance(Object, Class)
+     */
     @Hidden
     protected <T> T newAggregatedInstance(final Class<T> ofType) {
         return newAggregatedInstance(this, ofType);
     }
 
+    /**
+     * Create an instance that will be persisted as part of specified paremt domain object
+     * (ie that domain object will be its parent in the aggregate).
+     * 
+     * <p>
+     * The type provided should be annotated with {@link Aggregated}.
+     * 
+     *  @see #newAggregatedInstance(Class)
+     */
     @Hidden
     protected <T> T newAggregatedInstance(final Object parent, final Class<T> ofType) {
         return getContainer().newAggregatedInstance(parent, ofType);
     }
-
     // }}
 
     // {{ allInstances, allMatches

Modified: incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java (original)
+++ incubator/isis/trunk/framework/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java Sat Mar 24 14:01:35 2012
@@ -21,6 +21,7 @@ package org.apache.isis.applib;
 
 import java.util.List;
 
+import org.apache.isis.applib.annotation.Aggregated;
 import org.apache.isis.applib.filter.Filter;
 import org.apache.isis.applib.query.Query;
 import org.apache.isis.applib.security.UserMemento;
@@ -95,10 +96,20 @@ public interface DomainObjectContainer {
     /**
      * Create a new instance of the specified class, but do not persist it.
      * 
+     * <p>
+     * If the type is annotated with {@link Aggregated}, then as per
+     * {@link #newAggregatedInstance(Object, Class)}.  Otherwise will be an
+     * aggregate root.
+     * 
      * @see #newPersistentInstance(Class)
+     * @see #newAggregatedInstance(Object, Class)
      */
     <T> T newTransientInstance(Class<T> ofType);
 
+    /**
+     * Create a new instance that will be persisted as part of the specified
+     * parent (ie will be a part of a larger aggregate).
+     */
     <T> T newAggregatedInstance(Object parent, Class<T> ofType);
 
     /**

Modified: incubator/isis/trunk/framework/applib/src/test/java/org/apache/isis/applib/FactoryAndRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/applib/src/test/java/org/apache/isis/applib/FactoryAndRepositoryTest.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/applib/src/test/java/org/apache/isis/applib/FactoryAndRepositoryTest.java (original)
+++ incubator/isis/trunk/framework/applib/src/test/java/org/apache/isis/applib/FactoryAndRepositoryTest.java Sat Mar 24 14:01:35 2012
@@ -30,10 +30,17 @@ import java.util.List;
 
 import org.jmock.Expectations;
 import org.jmock.Mockery;
+import org.jmock.integration.junit4.JMock;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 
+@RunWith(JMock.class)
 public class FactoryAndRepositoryTest {
+    
+    public static class TestDomainObject {
+    }
+
     private DomainObjectContainer container;
     private AbstractFactoryAndRepository object;
     private Mockery context;
@@ -61,8 +68,6 @@ public class FactoryAndRepositoryTest {
         });
 
         object.informUser("message");
-
-        context.assertIsSatisfied();
     }
 
     @Test
@@ -74,8 +79,6 @@ public class FactoryAndRepositoryTest {
         });
 
         object.warnUser("message");
-
-        context.assertIsSatisfied();
     }
 
     @Test
@@ -87,8 +90,6 @@ public class FactoryAndRepositoryTest {
         });
 
         object.raiseError("message");
-
-        context.assertIsSatisfied();
     }
 
     @Test
@@ -111,8 +112,6 @@ public class FactoryAndRepositoryTest {
         assertThat(allInstances.get(0), equalTo(list.get(0)));
         assertThat(allInstances.get(1), equalTo(list.get(1)));
         assertThat(allInstances.get(2), equalTo(list.get(2)));
-
-        context.assertIsSatisfied();
     }
 
 }

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/InstallerAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/InstallerAbstract.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/InstallerAbstract.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/InstallerAbstract.java Sat Mar 24 14:01:35 2012
@@ -26,7 +26,7 @@ import com.google.common.collect.Lists;
 
 import org.apache.isis.core.commons.components.Installer;
 
-public abstract class InstallerAbstract implements Installer, IsisConfigurationBuilderAware {
+public abstract class InstallerAbstract implements Installer, IsisConfigurationBuilderAware, IsisConfigurationAware {
 
     private final String type;
     private final String name;
@@ -135,7 +135,7 @@ public abstract class InstallerAbstract 
      */
     public void setConfiguration(final IsisConfiguration configuration) {
         if (isisConfigurationBuilder != null) {
-            throw new IllegalStateException("A IsisConfiguration has already been provided.");
+            throw new IllegalStateException("A IsisConfigurationBuilder has already been provided.");
         }
         this.configuration = configuration;
     }

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/IsisConfigurationAware.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/IsisConfigurationAware.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/IsisConfigurationAware.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/IsisConfigurationAware.java Sat Mar 24 14:01:35 2012
@@ -28,5 +28,5 @@ public interface IsisConfigurationAware 
     /**
      * Inject the {@link IsisConfiguration} into the component.
      */
-    void setIsisConfiguration(IsisConfiguration configuration);
+    void setConfiguration(IsisConfiguration configuration);
 }

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/IsisConfigurationDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/IsisConfigurationDefault.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/IsisConfigurationDefault.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/config/IsisConfigurationDefault.java Sat Mar 24 14:01:35 2012
@@ -32,8 +32,6 @@ import org.apache.isis.core.commons.debu
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.commons.resource.ResourceStreamSource;
 
-import com.google.common.base.Joiner;
-
 public class IsisConfigurationDefault implements IsisConfiguration {
     private static final Logger LOG = Logger.getLogger(IsisConfigurationDefault.class);
     private final Properties properties = new Properties();
@@ -376,7 +374,7 @@ public class IsisConfigurationDefault im
     public void injectInto(final Object candidate) {
         if (IsisConfigurationAware.class.isAssignableFrom(candidate.getClass())) {
             final IsisConfigurationAware cast = IsisConfigurationAware.class.cast(candidate);
-            cast.setIsisConfiguration(this);
+            cast.setConfiguration(this);
         }
     }
 

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/DataOutputStreamExtended.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/DataOutputStreamExtended.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/DataOutputStreamExtended.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/DataOutputStreamExtended.java Sat Mar 24 14:01:35 2012
@@ -61,6 +61,7 @@ public class DataOutputStreamExtended im
         FieldType.CHAR_ARRAY.write(this, value);
     }
 
+    
     // ////////////////////////////////////////
     // Integral Numbers
     // ////////////////////////////////////////

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Ensure.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Ensure.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Ensure.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Ensure.java Sat Mar 24 14:01:35 2012
@@ -32,6 +32,17 @@ public final class Ensure {
     }
 
     /**
+     * To ensure that the provided assertion is true
+     * 
+     * @throws IllegalArgumentException
+     */
+    public static void ensure(final String expectation, final boolean expression) {
+        if (!expression) {
+            throw new IllegalArgumentException("illegal argument, expected: " + expectation);
+        }
+    }
+
+    /**
      * To ensure that the provided argument is correct.
      * 
      * @see #ensureThatArg(Object, Matcher,State)
@@ -48,6 +59,7 @@ public final class Ensure {
         return object;
     }
 
+
     /**
      * To ensure that the provided argument is correct.
      * 

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java Sat Mar 24 14:01:35 2012
@@ -22,6 +22,7 @@ package org.apache.isis.core.commons.mat
 import static org.hamcrest.CoreMatchers.nullValue;
 
 import java.io.File;
+import java.util.Arrays;
 import java.util.List;
 
 import org.hamcrest.CoreMatchers;
@@ -256,4 +257,36 @@ public final class IsisMatchers {
         };
     }
 
+    public static <T> Matcher<List<T>> listContaining(final T t) {
+        return new TypeSafeMatcher<List<T>>() {
+    
+            @Override
+            public void describeTo(Description arg0) {
+                arg0.appendText("list containing ").appendValue(t);
+            }
+    
+            @Override
+            public boolean matchesSafely(List<T> arg0) {
+                return arg0.contains(t);
+            }
+        };
+    }
+
+    public static <T> Matcher<List<T>> listContainingAll(final T... items) {
+        return new TypeSafeMatcher<List<T>>() {
+
+            @Override
+            public void describeTo(Description arg0) {
+                arg0.appendText("has items ").appendValue(items);
+                
+            }
+
+            @Override
+            public boolean matchesSafely(List<T> arg0) {
+                return arg0.containsAll(Arrays.asList(items));
+            }
+        };
+    }
+
+
 }

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/DomainObjectServices.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/DomainObjectServices.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/DomainObjectServices.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/DomainObjectServices.java Sat Mar 24 14:01:35 2012
@@ -20,6 +20,8 @@ import java.util.List;
 
 import org.apache.isis.core.commons.components.Injectable;
 import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
 import org.apache.isis.core.metamodel.runtimecontext.RuntimeContextAbstract;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 
@@ -37,6 +39,18 @@ public interface DomainObjectServices ex
      */
     ObjectAdapter createTransientInstance(ObjectSpecification spec);
 
+    /**
+     * Create an instance of an aggregated object that will be persisted within the
+     * parent adapter.
+     * 
+     * <p>
+     * The {@link Oid} of the returned {@link ObjectAdapter adapter} will be of type
+     * {@link AggregatedOid}.  The oid's {@link AggregatedOid#getLocalId() localId}
+     * is generated as per the configured objectstore (<tt>OidGenerator</tt>).
+     * 
+     * <p>
+     * Called by <tt>DomainObjectContainerDefault</tt>.
+     */
     ObjectAdapter createAggregatedInstance(ObjectSpecification spec, ObjectAdapter parent);
 
     /**

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapter.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapter.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapter.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapter.java Sat Mar 24 14:01:35 2012
@@ -19,6 +19,9 @@
 
 package org.apache.isis.core.metamodel.adapter;
 
+import org.apache.isis.core.metamodel.adapter.map.AdapterMap;
+import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
+import org.apache.isis.core.metamodel.adapter.oid.CollectionOid;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
 import org.apache.isis.core.metamodel.adapter.version.Version;
 import org.apache.isis.core.metamodel.spec.ObjectMetaModel;
@@ -59,41 +62,61 @@ public interface ObjectAdapter extends O
     void checkLock(Version version);
 
     /**
-     * The objects unique id. This id allows the object to added to, stored by,
-     * and retrieved from the object store.
+     * The object's unique {@link Oid}. 
+     * 
+     * <p>
+     * This id allows the object to added to, stored by,
+     * and retrieved from the object store.  Objects can be looked up by their
+     * {@link Oid} from the {@link AdapterMap}.
+     * 
+     * <p>
+     * Note that standalone value objects ("foobar", or 5, or a date),
+     * are not mapped and have a <tt>null</tt> oid.
      */
     Oid getOid();
 
     /**
+     * Since {@link Oid}s are now immutable, it is the reference from the 
+     * {@link ObjectAdapter} to its {@link Oid} that must now be updated. 
+     */
+    void replaceOid(Oid persistedOid);
+
+    /**
      * Determines what 'lazy loaded' state the domain object is in.
      * 
      * @see ResolveState
      */
     ResolveState getResolveState();
 
-    /**
-     * Returns the current version of the domain object.
-     */
     Version getVersion();
 
-    /**
-     * Sets the versions of the domain object.
-     */
-    void setOptimisticLock(Version version);
+    void setVersion(Version version);
 
     void fireChangedEvent();
 
     /**
      * Whether this instance belongs to another object (meaning its
-     * {@link #getOid()} will be <tt>AggregatedOid</tt>.
+     * {@link #getOid()} will be <tt>ParentedOid</tt>, either an 
+     * {@link AggregatedOid} or a {@link CollectionOid}).
+     */
+    boolean isParented();
+
+    /**
+     * Whether this is an aggregated Oid.
      */
     boolean isAggregated();
 
     /**
+     * Whether this is a value (standalone, has no oid).
+     */
+    boolean isValue();
+
+
+    /**
      * Either itself or its parent adapter (if aggregated).
-     * 
-     * @return
      */
-    ObjectAdapter getAggregateRoot();
+    ObjectAdapter getAggregateRoot(ObjectAdapterLookup objectAdapterLookup);
+
+
 
 }

Copied: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterFactoryAbstract.java (from r1301918, incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/AdapterFactoryAbstract.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterFactoryAbstract.java?p2=incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterFactoryAbstract.java&p1=incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/AdapterFactoryAbstract.java&r1=1301918&r2=1304796&rev=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/AdapterFactoryAbstract.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterFactoryAbstract.java Sat Mar 24 14:01:35 2012
@@ -17,13 +17,11 @@
  *  under the License.
  */
 
-package org.apache.isis.runtimes.dflt.runtime.persistence.adapterfactory;
+package org.apache.isis.core.metamodel.adapter;
 
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapterFactory;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
 
-public abstract class AdapterFactoryAbstract implements ObjectAdapterFactory {
+public abstract class ObjectAdapterFactoryAbstract implements ObjectAdapterFactory {
 
     @Override
     public abstract ObjectAdapter createAdapter(Object pojo, Oid oid);
@@ -47,10 +45,11 @@ public abstract class AdapterFactoryAbst
      */
     @Override
     public void injectInto(final Object candidate) {
-        if (AdapterFactoryAware.class.isAssignableFrom(candidate.getClass())) {
-            final AdapterFactoryAware cast = AdapterFactoryAware.class.cast(candidate);
+        if (ObjectAdapterFactoryAware.class.isAssignableFrom(candidate.getClass())) {
+            final ObjectAdapterFactoryAware cast = ObjectAdapterFactoryAware.class.cast(candidate);
             cast.setAdapterFactory(this);
         }
     }
 
+
 }

Copied: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterFactoryAware.java (from r1301918, incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/AdapterFactoryAware.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterFactoryAware.java?p2=incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterFactoryAware.java&p1=incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/AdapterFactoryAware.java&r1=1301918&r2=1304796&rev=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/AdapterFactoryAware.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterFactoryAware.java Sat Mar 24 14:01:35 2012
@@ -17,11 +17,10 @@
  *  under the License.
  */
 
-package org.apache.isis.runtimes.dflt.runtime.persistence.adapterfactory;
+package org.apache.isis.core.metamodel.adapter;
 
-import org.apache.isis.core.metamodel.adapter.ObjectAdapterFactory;
 
-public interface AdapterFactoryAware {
+public interface ObjectAdapterFactoryAware {
 
     void setAdapterFactory(ObjectAdapterFactory adapterFactory);
 }

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterLookup.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterLookup.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterLookup.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/ObjectAdapterLookup.java Sat Mar 24 14:01:35 2012
@@ -19,7 +19,6 @@
 
 package org.apache.isis.core.metamodel.adapter;
 
-import org.apache.isis.core.commons.components.Injectable;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
 
 /**
@@ -36,7 +35,7 @@ import org.apache.isis.core.metamodel.ad
  * work with the POJOs even though it does not understand their types. Each POJO
  * maps to an {@link ObjectAdapter adapter} and these are reused.
  */
-public interface ObjectAdapterLookup extends Injectable {
+public interface ObjectAdapterLookup {
 
     /**
      * Gets the {@link ObjectAdapter adapter} for the {@link Oid} if it exists

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/map/AdapterMap.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/map/AdapterMap.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/map/AdapterMap.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/map/AdapterMap.java Sat Mar 24 14:01:35 2012
@@ -16,12 +16,16 @@
  */
 package org.apache.isis.core.metamodel.adapter.map;
 
+import org.apache.isis.applib.annotation.Aggregated;
 import org.apache.isis.core.commons.components.Injectable;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.ResolveState;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
+import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
+import org.apache.isis.core.metamodel.adapter.oid.CollectionOid;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 
 public interface AdapterMap extends Injectable {
 
@@ -39,62 +43,68 @@ public interface AdapterMap extends Inje
     ObjectAdapter getAdapterFor(Object pojo);
 
     /**
-     * Either returns an existing adapter (as per {@link #getAdapterFor(Object)}
-     * ), otherwise creates either a transient root or a standalone
-     * {@link ObjectAdapter adapter} for the supplied domain object, depending
-     * on its {@link ObjectSpecification}.
+     * Looks up or creates a standalone (value) or root adapter.
      * 
      * <p>
-     * The rules for creating a {@link ResolveState#VALUE standalone} vs
-     * {@link ResolveState#TRANSIENT transient} root {@link ObjectAdapter
-     * adapter} are as for
-     * {@link #adapterFor(Object, ObjectAdapter, IdentifiedHolder)}.
+     * Implementation should simply delegate to {@link #adapterFor(Object, ObjectAdapter, ObjectAssociation)}, 
+     * with <tt>parentAdapter</tt> and <tt>association</tt> both null.
      * 
-     * <p>
-     * Historical notes: previously called <tt>createAdapterForTransient</tt>,
-     * though this name wasn't quite right.
-     * 
-     * <p>
-     * Provided by the <tt>AdapterManager</tt> when used by framework.
+     * @see #adapterFor(Object, ObjectAdapter)
+     * @see #adapterFor(Object, ObjectAdapter, ObjectAssociation)
      */
     ObjectAdapter adapterFor(Object domainObject);
 
     /**
-     * Either returns an existing adapter (as per {@link #getAdapterFor(Object)}
-     * ), otherwise creates either a aggregated {@link ObjectAdapter adapter}
-     * for the supplied domain object, depending on its
-     * {@link ObjectSpecification}.
+     * Looks up or creates a standalone (value), aggregated or root adapter.
      * 
      * <p>
-     * Provided by the <tt>AdapterManager</tt> when used by framework.
+     * Implementation should simply delegate to {@link #adapterFor(Object, ObjectAdapter, ObjectAssociation)}, 
+     * with <tt>parentAdapter</tt> set but <tt>association</tt> both null.
+     * 
+     * <p>
+     * @see #adapterFor(Object)
+     * @see #adapterFor(Object, ObjectAdapter, ObjectAssociation)
      */
-    ObjectAdapter adapterForAggregated(Object domainObject, ObjectAdapter parent);
+    ObjectAdapter adapterFor(Object domainObject, ObjectAdapter parentAdapter);
 
     /**
-     * Either returns an existing adapter (as per {@link #getAdapterFor(Object)}
-     * ), otherwise creates either a transient, standalone or aggregated
-     * {@link ObjectAdapter adapter} for the supplied domain object, depending
-     * on its {@link ObjectSpecification} and the context arguments provided.
+     * Looks up or creates either a standalone, root, aggregated or collection adapter.
+     * If a newly created root adapter is returned, it will be transient.
+     * In all cases the {@link ResolveState} is in the appropriate state.
      * 
      * <p>
      * If no adapter is found for the provided pojo, then the rules for creating
      * the {@link ObjectAdapter adapter} are as follows:
      * <ul>
+     * 
      * <li>if the pojo's {@link ObjectSpecification specification} indicates
      * that this is an immutable value, then a {@link ResolveState#VALUE}
-     * {@link ObjectAdapter adapter} is created
-     * <li>otherwise, if context <tt>ownerAdapter</tt> and <tt>identified</tt>
-     * arguments have both been provided and also either the
-     * {@link IdentifiedHolder} argument indicates that for this particular
-     * property/collection the object is aggregated <i>or</i> that the pojo's
-     * own {@link ObjectSpecification specification} indicates that the pojo is
-     * intrinsically aggregated, then an {@link ObjectAdapter#isAggregated()
-     * aggregated} adapter is created. Note that the {@link ResolveState} of
-     * such {@link ObjectAdapter's} is independent of its <tt>ownerAdapter</tt>,
-     * but it has the same {@link ObjectAdapter#setOptimisticLock(Version)
-     * optimistic locking version}.
-     * <li>otherwise, a {@link ResolveState#TRANSIENT} {@link ObjectAdapter
-     * adapter} is created.
+     * {@link ObjectAdapter adapter} is created.  Such an adapter has a null {@link Oid}
+     * and is never mapped.
+     * 
+     * <li>if context <tt>parentAdapter</tt> has been provided but no <tt>association</tt>
+     * has been provided, then the pojo's {@link ObjectSpecification} is checked to determine
+     * if the type is intrinsically aggregated.  If so then an aggregated adapter (one 
+     * with an {@link AggregatedOid}) is created, and is parented.  
+     * The {@link AggregatedOid#getLocalId() localId} of this adapter's {@link AggregatedOid}
+     * will be as generated by <tt>OidGenerator</tt>.  Its {@link ResolveState} will 
+     * be inferred from its parent adapter.
+     * 
+     * <li>if context <tt>parentAdapter</tt> has been provided but no <tt>association</tt>,
+     * and the pojo's {@link ObjectSpecification} is <i>not</i> intrinsically aggregated, then a
+     * root adapter (with a {@link RootOid}) will be created.  The state of this adapter is transient.
+     * 
+     * <li>if context <tt>parentAdapter</tt> has been provided and the <tt>association</tt>
+     * is a one-to-one association (property), then this association will be inspected for the 
+     * {@link Aggregated} annotation.  If so, then the adapter will be aggregated, else a root.
+     * Note that the {@link AggregatedOid#getLocalId() localId} of this adapter's {@link AggregatedOid}
+     * will be as generated by <tt>OidGenerator</tt>; the association is only used as a hint.
+     *
+     * <li>if context <tt>parentAdapter</tt> has been provided and the <tt>association</tt>
+     * is a one-to-many association (collection), then a collection adapter will be created, 
+     * representing the collection instance (List, Set etc).  This collection adapter
+     * is parented by the <tt>parentAdapter</tt>, and its Oid will be of type {@link CollectionOid}.
+     * 
      * </ul>
      * 
      * <p>
@@ -102,11 +112,14 @@ public interface AdapterMap extends Inje
      * 
      * @param pojo
      *            - pojo to adapt
-     * @param ownerAdapter
-     *            - only used if aggregated
-     * @param identifier
-     *            - only used if aggregated
+     * @param parentAdapter
+     *            - optional; used if adapter is parented (either based on its spec, or because an association which indicates/requires it to be so).
+     * @param association
+     *            - optional; if a OTMA then will return a collection adapter; if a OTOA then used to hint whether aggregated adapter
+     *            
+     * @see #adapterFor(Object)
+     * @see #adapterFor(Object, ObjectAdapter)            
      */
-    public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter ownerAdapter, IdentifiedHolder identifiedHolder);
+    public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter parentAdapter, ObjectAssociation association);
 
 }

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/map/AdapterMapDelegator.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/map/AdapterMapDelegator.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/map/AdapterMapDelegator.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/map/AdapterMapDelegator.java Sat Mar 24 14:01:35 2012
@@ -17,7 +17,7 @@
 package org.apache.isis.core.metamodel.adapter.map;
 
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 
 /**
  * Just delegates to an underlying {@link AdapterMap}.
@@ -44,7 +44,7 @@ public abstract class AdapterMapDelegato
     }
 
     @Override
-    public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter ownerAdapter, final IdentifiedHolder identifiedHolder) {
-        return underlying.adapterFor(pojo, ownerAdapter, identifiedHolder);
+    public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter ownerAdapter, final ObjectAssociation association) {
+        return underlying.adapterFor(pojo, ownerAdapter, association);
     }
 }

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/AggregatedOid.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/AggregatedOid.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/AggregatedOid.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/AggregatedOid.java Sat Mar 24 14:01:35 2012
@@ -19,108 +19,52 @@
 
 package org.apache.isis.core.metamodel.adapter.oid;
 
-import java.io.IOException;
 import java.io.Serializable;
 
-import org.apache.isis.core.commons.encoding.DataInputExtended;
-import org.apache.isis.core.commons.encoding.DataOutputExtended;
+import com.google.common.base.Objects;
+
+import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.applib.annotation.Aggregated;
 import org.apache.isis.core.commons.ensure.Assert;
-import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 
 /**
- * Used as the {@link Oid} for collections, values and <tt>@Aggregated</tt>
- * types.
+ * Used as the {@link Oid} for {@link Aggregated} {@link ObjectAdapter}s
+ *
+ * <p>
+ * Aggregated adapters are created explicitly by the application using 
+ * {@link DomainObjectContainer#newAggregatedInstance(Object, Class)}.
+ * 
+ * @see CollectionOid
  */
-public final class AggregatedOid implements Oid, Serializable {
+public final class AggregatedOid extends ParentedOid implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    private final Oid parentOid;
-    private final String id;
-
-    private AggregatedOid previous;
+    private final String localId;
 
     private int cachedHashCode;
 
     // /////////////////////////////////////////////////////////
     // Constructor, Encodeable
     // /////////////////////////////////////////////////////////
-    public AggregatedOid(final Oid oid, final String id) {
-        Assert.assertNotNull("ID required", id);
-        this.parentOid = oid;
-        this.id = id;
-        initialized();
-    }
-
-    public AggregatedOid(final DataInputExtended input) throws IOException {
-        this.parentOid = input.readEncodable(Oid.class);
-        this.id = input.readUTF();
-        initialized();
-    }
-
-    @Override
-    public void encode(final DataOutputExtended output) throws IOException {
-        output.writeEncodable(parentOid);
-        output.writeUTF(id);
-    }
 
-    private void initialized() {
+    public AggregatedOid(final Oid parentOid, final String localId) {
+        super(parentOid);
+        Assert.assertNotNull("LocalId required", localId);
+        this.localId = localId;
         cacheState();
     }
 
+    
     // /////////////////////////////////////////////////////////
     // Properties
     // /////////////////////////////////////////////////////////
 
-    public Oid getParentOid() {
-        return parentOid;
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    // /////////////////////////////////////////////////////////
-    // makePersistent
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public void makePersistent() {
-        this.previous = new AggregatedOid(this.parentOid, this.id);
-        cacheState();
-    }
-
-    // /////////////////////////////////////////////////////////
-    // Previous
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public Oid getPrevious() {
-        return previous;
-    }
-
-    @Override
-    public boolean hasPrevious() {
-        return false;
-    }
-
-    @Override
-    public void clearPrevious() {
-    }
-
-    // /////////////////////////////////////////////////////////
-    // Other OID stuff
-    // /////////////////////////////////////////////////////////
-
-    @Override
-    public void copyFrom(final Oid oid) {
-        throw new NotYetImplementedException();
+    public String getLocalId() {
+        return localId;
     }
 
-    @Override
-    public boolean isTransient() {
-        return parentOid.isTransient();
-    }
 
     // /////////////////////////////////////////////////////////
     // Value semantics
@@ -141,7 +85,7 @@ public final class AggregatedOid impleme
     }
 
     public boolean equals(final AggregatedOid other) {
-        return other.parentOid.equals(parentOid) && other.id.equals(id);
+        return Objects.equal(other.getParentOid(), getParentOid()) && Objects.equal(other.localId, localId);
     }
 
     @Override
@@ -152,18 +96,40 @@ public final class AggregatedOid impleme
 
     private void cacheState() {
         int hashCode = 17;
-        hashCode = 37 * hashCode + parentOid.hashCode();
-        hashCode = 37 * hashCode + id.hashCode();
+        hashCode = 37 * hashCode + getParentOid().hashCode();
+        hashCode = 37 * hashCode + localId.hashCode();
         cachedHashCode = hashCode;
     }
 
+    
+    // /////////////////////////////////////////////////////////
+    // asPersistent
+    // /////////////////////////////////////////////////////////
+
+    /**
+     * When the RootOid is persisted, all its &quot;children&quot;
+     * need updating similarly.
+     */
+    public AggregatedOid asPersistent(Oid newParentOid) {
+        return new AggregatedOid(newParentOid, localId);
+    }
+
+    // /////////////////////////////////////////////////////////
+    // enString
+    // /////////////////////////////////////////////////////////
+
+    @Override
+    public String enString() {
+        return getParentOid().enString() + "@" + localId;
+    }
+
     // /////////////////////////////////////////////////////////
     // toString
     // /////////////////////////////////////////////////////////
 
     @Override
     public String toString() {
-        return "AOID[" + parentOid + "," + id + "]";
+        return "AOID[" + getParentOid() + "," + localId + "]";
     }
 
 }

Added: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/CollectionOid.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/CollectionOid.java?rev=1304796&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/CollectionOid.java (added)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/CollectionOid.java Sat Mar 24 14:01:35 2012
@@ -0,0 +1,131 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.metamodel.adapter.oid;
+
+import java.io.Serializable;
+
+import com.google.common.base.Objects;
+
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+
+/**
+ * Used as the {@link Oid} for collections.
+ */
+public final class CollectionOid extends ParentedOid implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private final String name;
+
+    private int cachedHashCode;
+
+    // /////////////////////////////////////////////////////////
+    // Constructor, Encodeable
+    // /////////////////////////////////////////////////////////
+
+    public CollectionOid(Oid parentOid, OneToManyAssociation otma) {
+        this(parentOid, otma.getName());
+        cacheState();
+    }
+
+    public CollectionOid(Oid parentOid, String name) {
+        super(parentOid);
+        this.name = name;
+        cacheState();
+    }
+    
+    // /////////////////////////////////////////////////////////
+    // Properties
+    // /////////////////////////////////////////////////////////
+
+    public String getName() {
+        return name;
+    }
+
+
+    // /////////////////////////////////////////////////////////
+    // Value semantics
+    // /////////////////////////////////////////////////////////
+
+    @Override
+    public boolean equals(final Object other) {
+        if (other == this) {
+            return true;
+        }
+        if (other == null) {
+            return false;
+        }
+        if (getClass() != other.getClass()) {
+            return false;
+        }
+        return equals((CollectionOid) other);
+    }
+
+    public boolean equals(final CollectionOid other) {
+        return Objects.equal(other.getParentOid(), getParentOid()) && Objects.equal(other.name, name);
+    }
+
+    
+    @Override
+    public int hashCode() {
+        cacheState();
+        return cachedHashCode;
+    }
+
+    private void cacheState() {
+        int hashCode = 17;
+        hashCode = 37 * hashCode + getParentOid().hashCode();
+        hashCode = 37 * hashCode + name.hashCode();
+        cachedHashCode = hashCode;
+    }
+
+
+    
+    // /////////////////////////////////////////////////////////
+    // asPersistent
+    // /////////////////////////////////////////////////////////
+
+    /**
+     * When the RootOid is persisted, all its &quot;children&quot;
+     * need updating similarly.
+     */
+    public CollectionOid asPersistent(Oid newParentRootOid) {
+        return new CollectionOid(newParentRootOid, name);
+    }
+
+    // /////////////////////////////////////////////////////////
+    // enString
+    // /////////////////////////////////////////////////////////
+
+    @Override
+    public String enString() {
+        return getParentOid().enString() + "@" + name;
+    }
+
+    // /////////////////////////////////////////////////////////
+    // toString
+    // /////////////////////////////////////////////////////////
+
+    @Override
+    public String toString() {
+        return "COID[" + getParentOid() + "," + name + "]";
+    }
+
+}

Propchange: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/CollectionOid.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/Oid.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/Oid.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/Oid.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/Oid.java Sat Mar 24 14:01:35 2012
@@ -19,58 +19,42 @@
 
 package org.apache.isis.core.metamodel.adapter.oid;
 
-import org.apache.isis.core.commons.encoding.Encodable;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.applib.annotation.Value;
 
-public interface Oid extends Encodable {
 
-    /**
-     * Copies the content of the specified oid into this oid.
-     * 
-     * <p>
-     * After this call the {@link #hashCode()} return by both the specified
-     * object and this object will be the same, and both objects will be
-     * {@link #equals(Object) equal}.
-     * 
-     * <p>
-     * Only ever used by client-server remoting.
-     */
-    void copyFrom(Oid oid);
-
-    /**
-     * Returns the pending oid if there is one.
-     * 
-     * @see #hasPrevious()
-     * @see #clearPrevious()
-     */
-    Oid getPrevious();
+/**
+ * An immutable identifier for either a root object (subtype {@link RootOid}) or 
+ * an aggregated object (subtype {@link AggregatedOid}).
+ * 
+ * <p>
+ * Note that value objects (strings, ints, {@link Value}s etc) do not have an {@link Oid}. 
+ */
+public interface Oid {
 
     /**
-     * Returns true if this oid contains a {@link #getPrevious() previous}
-     * value, specifically that the {@link Oid} was changed from transient to
-     * persistent.
+     * A string representation of this {@link Oid}.
      * 
-     * @see #getPrevious()
-     * @see #clearPrevious()
+     * <p>
+     * Note that {@link RootOid} provide a reciprocal static <tt>deString</tt> method so that
+     * they can be round-tripped.  However, this feature is not required or provided by
+     * {@link AggregatedOid}.
      */
-    boolean hasPrevious();
+    String enString();
 
     /**
-     * Indicate that the {@link #getPrevious() previous value} has been used to
-     * remap the {@link ObjectAdapter adapter} and should not been cleared.
+     * Flags whether this OID is for a transient (not-yet-persisted) object.
      * 
-     * @see #getPrevious()
-     * @see #hasPrevious()
-     */
-    void clearPrevious();
-
-    /**
-     * Flags whether this OID is temporary, and is for a transient object..
+     * <p>
+     * In the case of an {@link AggregatedOid}, is determined by the state 
+     * of its {@link AggregatedOid#getParentOid() parent}'s {@link RootOid#isTransient() state}.
      */
     boolean isTransient();
 
-    /**
-     * Marks the Oid as persistent.
-     */
-    void makePersistent();
+    public static enum State {
+        PERSISTENT, TRANSIENT;
+        public boolean isTransient() {
+            return this == TRANSIENT;
+        }
+    }
+
 }

Added: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/OidMatchers.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/OidMatchers.java?rev=1304796&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/OidMatchers.java (added)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/OidMatchers.java Sat Mar 24 14:01:35 2012
@@ -0,0 +1,30 @@
+package org.apache.isis.core.metamodel.adapter.oid;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+
+public class OidMatchers {
+    
+    private OidMatchers(){}
+
+    public static Matcher<Oid> matching(final String objectType, final String identifier) {
+        return new TypeSafeMatcher<Oid>() {
+
+            @Override
+            public void describeTo(Description arg0) {
+                arg0.appendText("matching [" + objectType + ", " + identifier +"]");
+            }
+
+            @Override
+            public boolean matchesSafely(Oid oid) {
+                if(oid instanceof RootOid) {
+                    RootOid rootOid = (RootOid) oid;
+                    return rootOid.getObjectType().equals(objectType) && rootOid.getIdentifier().equals(identifier);
+                }
+                return false;
+            }
+        };
+    }
+
+}

Propchange: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/OidMatchers.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/RootOid.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/RootOid.java?rev=1304796&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/RootOid.java (added)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/RootOid.java Sat Mar 24 14:01:35 2012
@@ -0,0 +1,56 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.metamodel.adapter.oid;
+
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+
+
+/**
+ * Defines a subtype of {@link Oid} specific to a root adapter.
+ * 
+ * <p>
+ * The root adapter/pojo can be recreated with no further information; the
+ * {@link #getObjectType()} can be used to fetch the corresponding
+ * {@link ObjectSpecification} using {@link SpecificationLoader#lookupByObjectType(String)}.
+ * 
+ * <p>
+ * <p>
+ * As such, is directly akin to the DSP's oid that is of the form 
+ * <tt>CUS|1234567A</tt>, where the overall form is a simple string
+ * and also identifies the type of the object.
+ *
+ * <p>
+ * In addition, can be directly encoded/decoded into strings.  The {@link #enString()} interface
+ * is defined in the interface; implementations must also provide a static 
+ * <tt>deString(String)</tt> factory method.
+ */
+public interface RootOid extends Oid {
+
+    String getObjectType();
+    
+    String getIdentifier();
+
+    /**
+     * Returns a new RootOid for the same {@link #getObjectType()}, but persistent and with the specified {@link #getIdentifier() identifier}.
+     */
+    RootOid asPersistent(String identifier);
+
+}

Propchange: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/RootOid.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/stringable/OidStringifier.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/stringable/OidStringifier.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/stringable/OidStringifier.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/stringable/OidStringifier.java Sat Mar 24 14:01:35 2012
@@ -19,11 +19,69 @@
 
 package org.apache.isis.core.metamodel.adapter.oid.stringable;
 
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.isis.core.commons.ensure.Ensure;
+import org.apache.isis.core.commons.lang.JavaClassUtils;
+import org.apache.isis.core.commons.url.UrlEncodingUtils;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+
+public class OidStringifier {
+
+    private final Class<? extends Oid> oidClass;
+    private final Method deStringMethod;
+
+    public OidStringifier(final Class<? extends Oid> oidClass) {
+        Ensure.ensureThatArg(oidClass, is(not(nullValue(Class.class))));
+
+        this.oidClass = oidClass;
+        try {
+            deStringMethod = oidClass.getMethod("deString", String.class);
+            final Class<?> returnType = deStringMethod.getReturnType();
+            if(!RootOid.class.isAssignableFrom(returnType)) {
+                throw new IllegalArgumentException("deString(String) method must return RootOid, from class '" + oidClass.getName() + "'");
+            }
+        } catch (final SecurityException ex) {
+            throw new IllegalArgumentException("Trying to obtain 'deString(String)' method from  Oid class '" + oidClass.getName() + "'", ex);
+        } catch (final NoSuchMethodException ex) {
+            throw new IllegalArgumentException("Trying to obtain 'deString(String)' method from  Oid class '" + oidClass.getName() + "'", ex);
+        }
+        if (!JavaClassUtils.isStatic(deStringMethod)) {
+            throw new IllegalArgumentException("'deString(String)' method for Oid class '" + oidClass.getName() + "' must be static");
+        }
+        if (!JavaClassUtils.isPublic(deStringMethod)) {
+            throw new IllegalArgumentException("'deString(String)' method for Oid class '" + oidClass.getName() + "' must be public");
+        }
+    }
+
+    public String enString(final RootOid rootOid) {
+        return rootOid.enString();
+    }
+
+    public RootOid deString(final String urlEncodedOidStr) {
+        // we do need to URL decode here, though.
+        final String oidStr = UrlEncodingUtils.urlDecode(urlEncodedOidStr);
+        try {
+            return (RootOid) deStringMethod.invoke(null, oidStr);
+        } catch (final IllegalAccessException ex) {
+            throw new IllegalArgumentException("deString(String) method failed; ", ex);
+        } catch (final InvocationTargetException ex) {
+            throw new IllegalArgumentException("deString(String) method failed; ", ex);
+        }
+    }
 
-public interface OidStringifier {
+    Class<? extends Oid> getOidClass() {
+        return oidClass;
+    }
 
-    public String enString(Oid oid);
+    Method getDestringMethod() {
+        return deStringMethod;
+    }
 
-    public Oid deString(String oidStr);
 }

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/version/SerialNumberVersion.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/version/SerialNumberVersion.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/version/SerialNumberVersion.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/version/SerialNumberVersion.java Sat Mar 24 14:01:35 2012
@@ -66,12 +66,6 @@ public class SerialNumberVersion extends
         return Long.toString(versionNumber, 16);
     }
 
-    // don't think is used
-    // @Override
-    // protected VersionAbstract next() {
-    // return new SerialNumberVersion(versionNumber + 1, null, null);
-    // }
-
     @Override
     public boolean different(final Version version) {
         if (version instanceof SerialNumberVersion) {

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/modify/CollectionFacet.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/modify/CollectionFacet.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/modify/CollectionFacet.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/modify/CollectionFacet.java Sat Mar 24 14:01:35 2012
@@ -60,7 +60,10 @@ public interface CollectionFacet extends
 
     boolean contains(ObjectAdapter collectionAdapter, ObjectAdapter element);
 
-    void init(ObjectAdapter collectionAdapter, ObjectAdapter[] initData);
+    /**
+     * Set the contents of this collection.
+     */
+    void init(ObjectAdapter collectionAdapter, ObjectAdapter[] elements);
 
     /**
      * Convenience method that returns the {@link TypeOfFacet} on this facet's

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/runtimecontext/noruntime/RuntimeContextNoRuntime.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/runtimecontext/noruntime/RuntimeContextNoRuntime.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/runtimecontext/noruntime/RuntimeContextNoRuntime.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/runtimecontext/noruntime/RuntimeContextNoRuntime.java Sat Mar 24 14:01:35 2012
@@ -43,7 +43,6 @@ import org.apache.isis.core.metamodel.ad
 import org.apache.isis.core.metamodel.adapter.ServicesProviderAbstract;
 import org.apache.isis.core.metamodel.adapter.map.AdapterMap;
 import org.apache.isis.core.metamodel.adapter.map.AdapterMapAbstract;
-import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
 import org.apache.isis.core.metamodel.runtimecontext.DependencyInjector;
 import org.apache.isis.core.metamodel.runtimecontext.DependencyInjectorAbstract;
 import org.apache.isis.core.metamodel.runtimecontext.RuntimeContextAbstract;
@@ -51,6 +50,7 @@ import org.apache.isis.core.metamodel.sp
 import org.apache.isis.core.metamodel.spec.ObjectInstantiator;
 import org.apache.isis.core.metamodel.spec.ObjectInstantiatorAbstract;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 
 public class RuntimeContextNoRuntime extends RuntimeContextAbstract {
 
@@ -91,12 +91,12 @@ public class RuntimeContextNoRuntime ext
             }
 
             @Override
-            public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter ownerAdapter, final IdentifiedHolder identifiedHolder) {
+            public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter ownerAdapter) {
                 throw new UnsupportedOperationException("Not supported by this implementation of RuntimeContext");
             }
 
             @Override
-            public ObjectAdapter adapterForAggregated(final Object domainObject, final ObjectAdapter parent) {
+            public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter ownerAdapter, final ObjectAssociation association) {
                 throw new UnsupportedOperationException("Not supported by this implementation of RuntimeContext");
             }
 

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java Sat Mar 24 14:01:35 2012
@@ -86,14 +86,10 @@ public class DomainObjectContainerDefaul
     // newInstance, disposeInstance
     // //////////////////////////////////////////////////////////////////
 
-    /**
-     * @see #doCreateTransientInstance(ObjectSpecification)
-     */
     @Override
     @SuppressWarnings("unchecked")
     public <T> T newTransientInstance(final Class<T> ofClass) {
         final ObjectSpecification spec = getSpecificationLookup().loadSpecification(ofClass);
-        // TODO check aggregation is supported
         if (spec.isAggregated()) {
             return newAggregatedInstance(this, ofClass);
         } else {
@@ -106,19 +102,14 @@ public class DomainObjectContainerDefaul
     @SuppressWarnings("unchecked")
     public <T> T newAggregatedInstance(final Object parent, final Class<T> ofClass) {
         final ObjectSpecification spec = getSpecificationLookup().loadSpecification(ofClass);
-        // TODO check aggregation is supported
         if (!spec.isAggregated()) {
-            throw new IsisException("Cannot instantiate an object unless it is marked as Aggregated using the newAggregatedInstance method: " + ofClass); // TODO
-                                                                                                                                                          // proper
-                                                                                                                                                          // type
+            throw new IsisException("Type must be annotated as @Aggregated: " + ofClass);
         }
         final ObjectAdapter adapter = doCreateAggregatedInstance(spec, parent);
         if (adapter.getOid() instanceof AggregatedOid) {
             return (T) adapter.getObject();
         } else {
-            throw new IsisException("Object instatiated but was not given a AggregatedOid: " + ofClass); // TODO
-                                                                                                         // proper
-                                                                                                         // type
+            throw new IsisException("Object instantiated but was not given a AggregatedOid (does the configured object store support aggregates?): " + ofClass);
         }
     }
 
@@ -242,7 +233,7 @@ public class DomainObjectContainerDefaul
     public void persist(final Object transientObject) {
         final ObjectAdapter adapter = getAdapterMap().getAdapterFor(transientObject);
         // TODO check aggregation is supported
-        if (adapter.isAggregated()) {
+        if (adapter.isParented()) {
             return;
         }
         if (isPersistent(transientObject)) {

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/Instance.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/Instance.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/Instance.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/Instance.java Sat Mar 24 14:01:35 2012
@@ -36,13 +36,5 @@ public interface Instance {
      */
     Specification getSpecification();
 
-    /**
-     * The owning {@link ObjectAdapter} of this instance.
-     * 
-     * <p>
-     * In the case of the {@link ObjectAdapter} interface, just returns
-     * <tt>null</tt>.
-     */
-    ObjectAdapter getOwner();
 
 }

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/InstanceAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/InstanceAbstract.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/InstanceAbstract.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/InstanceAbstract.java Sat Mar 24 14:01:35 2012
@@ -23,7 +23,6 @@ import org.apache.isis.core.metamodel.ad
 
 public abstract class InstanceAbstract implements Instance {
 
-    private final ObjectAdapter owner;
     private Specification specification;
 
     protected InstanceAbstract() {
@@ -35,16 +34,10 @@ public abstract class InstanceAbstract i
     }
 
     protected InstanceAbstract(final ObjectAdapter owner, final Specification specification) {
-        this.owner = owner;
         this.specification = specification;
     }
 
     @Override
-    public final ObjectAdapter getOwner() {
-        return owner;
-    }
-
-    @Override
     public Specification getSpecification() {
         if (specification == null) {
             specification = loadSpecification();

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/ObjectSpecification.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/ObjectSpecification.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/ObjectSpecification.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/ObjectSpecification.java Sat Mar 24 14:01:35 2012
@@ -25,6 +25,7 @@ import java.util.List;
 
 import com.google.common.base.Function;
 
+import org.apache.isis.applib.annotation.ObjectType;
 import org.apache.isis.applib.profiles.Localization;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -41,6 +42,7 @@ import org.apache.isis.core.metamodel.fa
 import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
 import org.apache.isis.core.metamodel.facets.object.icon.IconFacet;
 import org.apache.isis.core.metamodel.facets.object.immutable.ImmutableFacet;
+import org.apache.isis.core.metamodel.facets.object.objecttype.ObjectTypeFacet;
 import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
 import org.apache.isis.core.metamodel.facets.object.plural.PluralFacet;
 import org.apache.isis.core.metamodel.facets.object.title.TitleFacet;
@@ -50,6 +52,7 @@ import org.apache.isis.core.metamodel.in
 import org.apache.isis.core.metamodel.interactions.ObjectValidityContext;
 import org.apache.isis.core.metamodel.spec.feature.ObjectActionContainer;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationContainer;
+import org.apache.isis.core.metamodel.specloader.classsubstitutor.ClassSubstitutor;
 
 /**
  * Represents an entity or value (cf {@link java.lang.Class}) within the
@@ -93,6 +96,19 @@ public interface ObjectSpecification ext
     Class<?> getCorrespondingClass();
 
     /**
+     * Returns the (unique) object type, as per the {@link ObjectTypeFacet}.
+     * 
+     * <p>
+     * This will typically be the value of the {@link ObjectType} annotation (or equivalent);
+     * if non has been specified then will default to the fully qualified class name (with
+     * {@link ClassSubstitutor class name substituted} if necessary to allow for runtime bytecode enhancement.
+     * 
+     * <p>
+     * The {@link ObjectSpecification} can be retrieved using {@link SpecificationLookup#lookupByObjectType(String)}.
+     */
+    String getObjectType();
+    
+    /**
      * Returns an (immutable) "full" identifier for this specification.
      * 
      * <p>
@@ -100,7 +116,7 @@ public interface ObjectSpecification ext
      * object represents (i.e. it includes the package name).
      */
     String getFullIdentifier();
-
+    
     /**
      * Returns an (immutable) "short" identifier for this specification.
      * 
@@ -301,26 +317,16 @@ public interface ObjectSpecification ext
     // //////////////////////////////////////////////////////////////
 
     /**
-     * Used by {@link ObjectSpecification#createObject(CreationMode)}
-     */
-    public enum CreationMode {
-        /**
-         * Default all properties and call any {@link CreatedCallbackFacet
-         * created callbacks}.
-         */
-        INITIALIZE, NO_INITIALIZE
-    }
-
-    /**
      * Create and optionally {@link CreationMode#INITIALIZE initialize} object.
      */
-    Object createObject(CreationMode creationMode);
+    Object createObject();
 
     /**
-     * Create and optionally {@link CreationMode#INITIALIZE initialize} an
-     * aggregated object with a parent.
+     * REVIEW: should this behaviour move, eg onto ObjectAdapter?
      */
-    Object createAggregatedObject(ObjectAdapter parent, CreationMode creationMode);
+    ObjectAdapter initialize(ObjectAdapter object);
+
+
 
     // //////////////////////////////////////////////////////////////
     // Service

Copied: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/SpecificationLoaderProvider.java (from r1301918, incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/nof/SpecificationLoaderAccessor.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/SpecificationLoaderProvider.java?p2=incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/SpecificationLoaderProvider.java&p1=incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/nof/SpecificationLoaderAccessor.java&r1=1301918&r2=1304796&rev=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/nof/SpecificationLoaderAccessor.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/SpecificationLoaderProvider.java Sat Mar 24 14:01:35 2012
@@ -17,11 +17,10 @@
  *  under the License.
  */
 
-package org.apache.isis.viewer.wicket.model.nof;
+package org.apache.isis.core.metamodel.spec;
 
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
 
-public interface SpecificationLoaderAccessor {
+public interface SpecificationLoaderProvider {
 
     SpecificationLoader getSpecificationLoader();
 }

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefault.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefault.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ObjectReflectorDefault.java Sat Mar 24 14:01:35 2012
@@ -206,7 +206,6 @@ public class ObjectReflectorDefault impl
         }
 
         this.metaModelValidator = metaModelValidator;
-
         this.facetProcessor = new FacetProcessor(configuration, collectionTypeRegistry, programmingModel);
     }
 
@@ -602,16 +601,15 @@ public class ObjectReflectorDefault impl
     public void validateSpecifications() {
         final Map<String, ObjectSpecification> specByObjectType = Maps.newHashMap();
         for (final ObjectSpecification objSpec : allSpecifications()) {
-            final ObjectTypeFacet facet = objSpec.getFacet(ObjectTypeFacet.class);
-            if (facet == null) {
+            final String objectType = objSpec.getObjectType();
+            if (objectType == null) {
                 continue;
             }
-            final String objectTypeValue = facet.value();
-            final ObjectSpecification existingSpec = specByObjectType.put(objectTypeValue, objSpec);
+            final ObjectSpecification existingSpec = specByObjectType.put(objectType, objSpec);
             if (existingSpec == null) {
                 continue;
             }
-            throw new MetaModelInvalidException(MessageFormat.format("Cannot have two entities with same object type (@ObjectType facet or equivalent) Value; " + "both {0} and {1} are annotated with value of ''{2}''.", existingSpec.getFullIdentifier(), objSpec.getFullIdentifier(), objectTypeValue));
+            throw new MetaModelInvalidException(MessageFormat.format("Cannot have two entities with same object type (@ObjectType facet or equivalent) Value; " + "both {0} and {1} are annotated with value of ''{2}''.", existingSpec.getFullIdentifier(), objSpec.getFullIdentifier(), objectType));
         }
         
         getCache().setCacheByObjectType(specByObjectType);

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/facetprocessor/FacetProcessor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/facetprocessor/FacetProcessor.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/facetprocessor/FacetProcessor.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/facetprocessor/FacetProcessor.java Sat Mar 24 14:01:35 2012
@@ -153,9 +153,6 @@ public class FacetProcessor implements R
     /**
      * This is <tt>public</tt> so that can be used for <tt>@Facets</tt>
      * processing.
-     * 
-     * <p>
-     * See NOF bug-517.
      */
     public void injectDependenciesInto(final FacetFactory factory) {
         getCollectionTypeRepository().injectInto(factory);

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java Sat Mar 24 14:01:35 2012
@@ -58,6 +58,7 @@ import org.apache.isis.core.metamodel.fa
 import org.apache.isis.core.metamodel.facets.object.immutable.ImmutableFacet;
 import org.apache.isis.core.metamodel.facets.object.notpersistable.InitiatedBy;
 import org.apache.isis.core.metamodel.facets.object.notpersistable.NotPersistableFacet;
+import org.apache.isis.core.metamodel.facets.object.objecttype.ObjectTypeFacet;
 import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
 import org.apache.isis.core.metamodel.facets.object.plural.PluralFacet;
 import org.apache.isis.core.metamodel.facets.object.title.TitleFacet;
@@ -124,6 +125,8 @@ public abstract class ObjectSpecificatio
     private final String shortName;
     private final Identifier identifier;
     private final boolean isAbstract;
+    // derived lazily, cached since immutable
+    private String objectType;
 
     private ObjectSpecification superclassSpec;
 
@@ -166,6 +169,17 @@ public abstract class ObjectSpecificatio
         return FeatureType.OBJECT;
     }
 
+    @Override
+    public String getObjectType() {
+        if(objectType == null) {
+            final ObjectTypeFacet facet = getFacet(ObjectTypeFacet.class);
+            if(facet != null) {
+                objectType = facet.value();
+            }
+        }
+        return objectType;
+    }
+    
     /**
      * As provided explicitly within the
      * {@link #IntrospectableSpecificationAbstract(Class, String, SpecificationContext)
@@ -915,13 +929,13 @@ public abstract class ObjectSpecificatio
     }
 
     @Override
-    public Object createObject(final CreationMode creationMode) {
+    public Object createObject() {
         throw new UnsupportedOperationException(getFullIdentifier());
     }
 
     @Override
-    public Object createAggregatedObject(final ObjectAdapter parent, final CreationMode creationMode) {
-        throw new UnsupportedOperationException(getFullIdentifier());
+    public ObjectAdapter initialize(ObjectAdapter objectAdapter) {
+        return objectAdapter;
     }
 
     // //////////////////////////////////////////////////////////////////////

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToOneAssociationImpl.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToOneAssociationImpl.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToOneAssociationImpl.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToOneAssociationImpl.java Sat Mar 24 14:01:35 2012
@@ -125,7 +125,7 @@ public class OneToOneAssociationImpl ext
             return null;
         }
 
-        return getAdapterMap().adapterFor(referencedPojo, ownerAdapter, this);
+        return getAdapterMap().adapterFor(referencedPojo, ownerAdapter, null);
     }
 
     /**

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java Sat Mar 24 14:01:35 2012
@@ -428,46 +428,37 @@ public class ObjectSpecificationDefault 
     // //////////////////////////////////////////////////////////////////////
 
     @Override
-    public Object createObject(final CreationMode creationMode) {
-        return createObject(null, creationMode);
-    }
-
-    @Override
-    public Object createAggregatedObject(final ObjectAdapter parent, final CreationMode creationMode) {
-        return createObject(parent, creationMode);
-    }
-
-    private Object createObject(final ObjectAdapter parent, final CreationMode creationMode) {
+    public Object createObject() {
         if (getCorrespondingClass().isArray()) {
             return Array.newInstance(getCorrespondingClass().getComponentType(), 0);
         }
-
+        
         try {
-            final Object object = getObjectInstantiator().instantiate(getCorrespondingClass());
-
-            if (creationMode == CreationMode.INITIALIZE) {
-                final ObjectAdapter adapter;
-                if (parent == null) {
-                    adapter = getAdapterMap().adapterFor(object);
-                } else {
-                    adapter = getAdapterMap().adapterForAggregated(object, parent);
-                }
-
-                // initialize new object
-                final List<ObjectAssociation> fields = adapter.getSpecification().getAssociations();
-                for (int i = 0; i < fields.size(); i++) {
-                    fields.get(i).toDefault(adapter);
-                }
-                getDependencyInjector().injectDependenciesInto(object);
-
-                CallbackUtils.callCallback(adapter, CreatedCallbackFacet.class);
-            }
-            return object;
+            return getObjectInstantiator().instantiate(getCorrespondingClass());
         } catch (final ObjectInstantiationException e) {
             throw new IsisException("Failed to create instance of type " + getFullIdentifier(), e);
         }
     }
 
+    /**
+     * REVIEW: does this behaviour live best here?  Not that sure that it does...
+     */
+    @Override
+    public ObjectAdapter initialize(final ObjectAdapter adapter) {
+                        
+        // initialize new object
+        final List<ObjectAssociation> fields = adapter.getSpecification().getAssociations();
+        for (int i = 0; i < fields.size(); i++) {
+            fields.get(i).toDefault(adapter);
+        }
+        getDependencyInjector().injectDependenciesInto(adapter.getObject());
+        
+        CallbackUtils.callCallback(adapter, CreatedCallbackFacet.class);
+        
+        return adapter;
+    }
+
+
     // //////////////////////////////////////////////////////////////////////
     // getMember, catalog... (not API)
     // //////////////////////////////////////////////////////////////////////

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/objectlist/ObjectSpecificationForObjectList.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/objectlist/ObjectSpecificationForObjectList.java?rev=1304796&r1=1304795&r2=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/objectlist/ObjectSpecificationForObjectList.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/objectlist/ObjectSpecificationForObjectList.java Sat Mar 24 14:01:35 2012
@@ -185,4 +185,5 @@ public class ObjectSpecificationForObjec
         return Collections.emptyList();
     }
 
+
 }

Copied: incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/oid/stringable/GivenOidStringifierDirectWhenInstantiateTest.java (from r1301191, incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/oid/stringable/directly/GivenOidStringifierDirectWhenInstantiateTest.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/oid/stringable/GivenOidStringifierDirectWhenInstantiateTest.java?p2=incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/oid/stringable/GivenOidStringifierDirectWhenInstantiateTest.java&p1=incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/oid/stringable/directly/GivenOidStringifierDirectWhenInstantiateTest.java&r1=1301191&r2=1304796&rev=1304796&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/oid/stringable/directly/GivenOidStringifierDirectWhenInstantiateTest.java (original)
+++ incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/oid/stringable/GivenOidStringifierDirectWhenInstantiateTest.java Sat Mar 24 14:01:35 2012
@@ -17,7 +17,7 @@
  *  under the License.
  */
 
-package org.apache.isis.core.metamodel.adapter.oid.stringable.directly;
+package org.apache.isis.core.metamodel.adapter.oid.stringable;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
@@ -31,21 +31,20 @@ public class GivenOidStringifierDirectWh
 
     @Test
     public void withConformantOidClassThenCorrectlyInitialized() {
-        final OidStringifierDirect oidStringifier = new OidStringifierDirect(OidConformant.class);
+        final OidStringifier oidStringifier = new OidStringifier(OidConformant.class);
         assertThat(oidStringifier.getDestringMethod(), is(not(nullValue())));
         assertThat(oidStringifier.getDestringMethod().getName(), is("deString"));
-        assertThat(oidStringifier.getOidClass(), is(not(nullValue())));
         assertEquals(OidConformant.class, oidStringifier.getOidClass());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void withOidClassWithNonPublicDestringMethodThenFails() {
-        new OidStringifierDirect(OidWithNonPublicDestringMethod.class);
+        new OidStringifier(OidWithNonPublicDestringMethod.class);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void withOidClassWithNonStaticDestringMethodThenFails() {
-        new OidStringifierDirect(OidWithNonStaticDestringMethod.class);
+        new OidStringifier(OidWithNonStaticDestringMethod.class);
     }
 
 }



Mime
View raw message