You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/05/15 00:45:03 UTC

svn commit: r1338472 [5/8] - in /incubator/isis/trunk/framework/runtimes/dflt: objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/ objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ ob...

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerProxy.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/AdapterManagerProxy.java?rev=1338472&r1=1338471&r2=1338472&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerProxy.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerProxy.java Mon May 14 22:44:57 2012
@@ -22,6 +22,7 @@ package org.apache.isis.runtimes.dflt.ru
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapterLookup;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
 
 /**
@@ -41,7 +42,7 @@ public interface AdapterManagerProxy ext
      * Part of public API so that the proxy persistor can maintain its maps when
      * it processes a newly persisted object.
      * 
-     * @see AdapterManagerPersist#remapAsPersistent(ObjectAdapter)
+     * @see AdapterManagerPersist#remapAsPersistent(ObjectAdapter, RootOid)
      */
     public void remapUpdated(Oid rootOid);
 

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=1338472&r1=1338471&r2=1338472&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 Mon May 14 22:44:57 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(Object, RootOid)}.
+     * {@link #recreateAdapter(RootOid, Object)}.
      * 
      * @see #adapterFor(Object)
-     * @see #recreateAdapter(Object, RootOid)
+     * @see #recreateAdapter(RootOid, Object)
      */
     ObjectAdapter testCreateTransient(Object pojo, RootOid oid);
 

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/RootAndCollectionAdapters.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/RootAndCollectionAdapters.java?rev=1338472&r1=1338471&r2=1338472&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/RootAndCollectionAdapters.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/RootAndCollectionAdapters.java Mon May 14 22:44:57 2012
@@ -32,6 +32,7 @@ import org.apache.isis.core.metamodel.ad
 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.adapter.oid.TypedOid;
 import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
 
 /**
@@ -97,7 +98,7 @@ public class RootAndCollectionAdapters i
 
     private void addCollectionAdapters(ObjectAdapterLookup objectAdapterLookup) {
         for (final OneToManyAssociation otma : parentAdapter.getSpecification().getCollections()) {
-            final CollectionOid collectionOid = new CollectionOid(rootAdapterOid, otma);
+            final CollectionOid collectionOid = new CollectionOid((TypedOid) rootAdapterOid, otma);
             final ObjectAdapter collectionAdapter = objectAdapterLookup.getAdapterFor(collectionOid);
             if (collectionAdapter != null) {
                 // collection adapters are lazily created and so there may not be one.

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/internal/RuntimeContextFromSession.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/internal/RuntimeContextFromSession.java?rev=1338472&r1=1338471&r2=1338472&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/internal/RuntimeContextFromSession.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/internal/RuntimeContextFromSession.java Mon May 14 22:44:57 2012
@@ -50,7 +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;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
 import org.apache.isis.runtimes.dflt.runtime.persistence.container.DomainObjectContainerObjectChanged;
 import org.apache.isis.runtimes.dflt.runtime.persistence.container.DomainObjectContainerResolve;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -108,8 +108,8 @@ public class RuntimeContextFromSession e
             }
 
             @Override
-            public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter ownerAdapter, final ObjectAssociation association) {
-                return getRuntimeAdapterManager().adapterFor(pojo, ownerAdapter, association);
+            public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter ownerAdapter, final OneToManyAssociation collection) {
+                return getRuntimeAdapterManager().adapterFor(pojo, ownerAdapter, collection);
             }
         };
         this.objectInstantiator = new ObjectInstantiatorAbstract() {

Copied: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/IsisObjectStoreLogger.java (from r1331799, incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/IsisStoreLogger.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/IsisObjectStoreLogger.java?p2=incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/IsisObjectStoreLogger.java&p1=incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/IsisStoreLogger.java&r1=1331799&r2=1338472&rev=1338472&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/IsisStoreLogger.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/IsisObjectStoreLogger.java Mon May 14 22:44:57 2012
@@ -25,8 +25,8 @@ import org.apache.isis.core.commons.conf
 import org.apache.isis.core.commons.debug.DebugBuilder;
 import org.apache.isis.core.commons.factory.InstanceCreationException;
 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.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.core.runtime.logging.Logger;
@@ -39,91 +39,92 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceQuery;
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
 
-public class IsisStoreLogger extends Logger implements ObjectStore {
-    private final ObjectStore decorated;
+public class IsisObjectStoreLogger extends Logger implements ObjectStore {
+    private final ObjectStore underlying;
 
-    public IsisStoreLogger(final ObjectStore decorated, final String level) {
+    public IsisObjectStoreLogger(final ObjectStore decorated, final String level) {
         super(level);
-        this.decorated = decorated;
+        this.underlying = decorated;
     }
 
-    public IsisStoreLogger(final ObjectStore decorated) {
-        this.decorated = decorated;
+    public IsisObjectStoreLogger(final ObjectStore decorated) {
+        this.underlying = decorated;
     }
 
     @Override
     public CreateObjectCommand createCreateObjectCommand(final ObjectAdapter object) {
         log("create object " + object);
-        return decorated.createCreateObjectCommand(object);
+        return underlying.createCreateObjectCommand(object);
     }
 
     @Override
     public void registerService(final RootOid rootOid) {
         log("registering service: " + rootOid.enString());
-        decorated.registerService(rootOid);
+        underlying.registerService(rootOid);
     }
 
     @Override
     public DestroyObjectCommand createDestroyObjectCommand(final ObjectAdapter object) {
         log("destroy object " + object);
-        return decorated.createDestroyObjectCommand(object);
+        return underlying.createDestroyObjectCommand(object);
     }
 
     @Override
     public SaveObjectCommand createSaveObjectCommand(final ObjectAdapter object) {
         log("save object " + object);
-        return decorated.createSaveObjectCommand(object);
+        return underlying.createSaveObjectCommand(object);
     }
 
     @Override
     public void debugData(final DebugBuilder debug) {
-        decorated.debugData(debug);
+        underlying.debugData(debug);
     }
 
     @Override
     public String debugTitle() {
-        return decorated.debugTitle();
+        return underlying.debugTitle();
     }
 
     @Override
     protected Class<?> getDecoratedClass() {
-        return decorated.getClass();
+        return underlying.getClass();
     }
 
     @Override
     public ObjectAdapter[] getInstances(final PersistenceQuery criteria) throws ObjectPersistenceException, UnsupportedFindException {
         log("get instances matching " + criteria);
-        return decorated.getInstances(criteria);
+        return underlying.getInstances(criteria);
     }
 
+
     @Override
-    public ObjectAdapter getObject(final Oid oid, final ObjectSpecification hint) throws ObjectNotFoundException, ObjectPersistenceException {
-        final ObjectAdapter object = decorated.getObject(oid, hint);
-        log("get object for " + oid + " (of type " + hint.getShortIdentifier() + ")", object.getObject());
-        return object;
+    public ObjectAdapter getObject(final TypedOid oid) throws ObjectNotFoundException, ObjectPersistenceException {
+        final ObjectAdapter adapter = underlying.getObject(oid);
+        log("get object for " + oid + " (of type '" + oid.getObjectSpecId() + "')", adapter.getObject());
+        return adapter;
     }
 
     @Override
     public RootOid getOidForService(ObjectSpecification serviceSpec) {
-        final RootOid serviceOid = decorated.getOidForService(serviceSpec);
+        final RootOid serviceOid = underlying.getOidForService(serviceSpec);
         if(serviceOid != null) {
             log("get OID for service: " + serviceOid.enString());
         } else {
-            log("get OID for service: null (presumably in the process of being registered for '" + serviceSpec.getObjectType() + "')");
+            log("get OID for service: null (presumably in the process of being registered for '" + serviceSpec.getSpecId() + "')");
         }
         return serviceOid;
     }
 
     @Override
     public boolean hasInstances(final ObjectSpecification specification) throws ObjectPersistenceException {
-        final boolean hasInstances = decorated.hasInstances(specification);
+        final boolean hasInstances = underlying.hasInstances(specification);
         log("has instances of " + specification.getShortIdentifier(), "" + hasInstances);
         return hasInstances;
     }
 
     @Override
     public boolean isFixturesInstalled() {
-        final boolean isInitialized = decorated.isFixturesInstalled();
+        final boolean isInitialized = underlying.isFixturesInstalled();
         log("is initialized: " + isInitialized);
         return isInitialized;
     }
@@ -131,30 +132,30 @@ public class IsisStoreLogger extends Log
     @Override
     public void open() throws IsisConfigurationException, InstanceCreationException, ObjectPersistenceException {
         log("opening " + name());
-        decorated.open();
+        underlying.open();
     }
 
     @Override
     public String name() {
-        return decorated.name();
+        return underlying.name();
     }
 
     @Override
     public void reset() {
         log("reset");
-        decorated.reset();
+        underlying.reset();
     }
 
     @Override
     public void resolveField(final ObjectAdapter object, final ObjectAssociation field) throws ObjectPersistenceException {
         log("resolve eagerly object in field " + field + " of " + object);
-        decorated.resolveField(object, field);
+        underlying.resolveField(object, field);
     }
 
     @Override
     public void resolveImmediately(final ObjectAdapter object) throws ObjectPersistenceException {
         log("resolve immediately: " + object);
-        decorated.resolveImmediately(object);
+        underlying.resolveImmediately(object);
     }
 
     @Override
@@ -164,28 +165,27 @@ public class IsisStoreLogger extends Log
         for (final PersistenceCommand command : commands) {
             log("  " + (i++) + " " + command);
         }
-        decorated.execute(commands);
+        underlying.execute(commands);
     }
 
     @Override
     public void close() throws ObjectPersistenceException {
-        log("closing " + decorated);
-        decorated.close();
+        log("closing " + underlying);
+        underlying.close();
     }
 
     @Override
     public void startTransaction() {
-        decorated.startTransaction();
+        underlying.startTransaction();
     }
 
     @Override
     public void endTransaction() {
-        decorated.endTransaction();
+        underlying.endTransaction();
     }
 
     @Override
     public void abortTransaction() {
-        decorated.abortTransaction();
+        underlying.abortTransaction();
     }
-
 }

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/IsisStoreDelegating.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/IsisStoreDelegating.java?rev=1338472&r1=1338471&r2=1338472&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/IsisStoreDelegating.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/IsisStoreDelegating.java Mon May 14 22:44:57 2012
@@ -23,8 +23,8 @@ import java.util.List;
 
 import org.apache.isis.core.commons.debug.DebugBuilder;
 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.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
@@ -39,7 +39,7 @@ import org.apache.isis.runtimes.dflt.run
  * <p>
  * Useful for quickly writing decorating implementations.
  */
-public abstract class IsisStoreDelegating implements ObjectStore {
+public class IsisStoreDelegating implements ObjectStore {
 
     private final ObjectStore underlying;
     private final String name;
@@ -134,8 +134,8 @@ public abstract class IsisStoreDelegatin
     // ////////////////////////////////////////////////
 
     @Override
-    public ObjectAdapter getObject(final Oid oid, final ObjectSpecification hint) {
-        return underlying.getObject(oid, hint);
+    public ObjectAdapter getObject(final TypedOid oid) {
+        return underlying.getObject(oid);
     }
 
     @Override
@@ -190,4 +190,5 @@ public abstract class IsisStoreDelegatin
         return underlying.debugTitle();
     }
 
+
 }

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStorePersistence.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStorePersistence.java?rev=1338472&r1=1338471&r2=1338472&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStorePersistence.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStorePersistence.java Mon May 14 22:44:57 2012
@@ -26,8 +26,8 @@ import org.apache.isis.core.commons.comp
 import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.commons.debug.DebuggableWithTitle;
 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.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectNotFoundException;
@@ -121,7 +121,7 @@ public interface ObjectStorePersistence 
     // ///////////////////////////////////////////////////////
 
     /**
-     * Retrieves the object identified by the specified OID from the object
+     * Retrieves the object identified by the specified {@link TypedOid} from the object
      * store. The cache should be checked first and, if the object is cached,
      * the cached version should be returned. It is important that if this
      * method is called again, while the originally returned object is in
@@ -129,7 +129,7 @@ public interface ObjectStorePersistence 
      * 
      * <p>
      * Assuming that the object is not cached then the data for the object
-     * should be retreived from the persistence mechanism and the object
+     * should be retrieved from the persistence mechanism and the object
      * recreated (as describe previously). The specified OID should then be
      * assigned to the recreated object by calling its <method>setOID </method>.
      * Before returning the object its resolved flag should also be set by
@@ -137,7 +137,7 @@ public interface ObjectStorePersistence 
      * 
      * <p>
      * If the persistence mechanism does not known of an object with the
-     * specified {@link Oid} then a {@link ObjectNotFoundException} should be
+     * specified {@link TypedOid} then a {@link ObjectNotFoundException} should be
      * thrown.
      * 
      * <para>Note that the OID could be for an internal collection, and is
@@ -152,12 +152,13 @@ public interface ObjectStorePersistence 
      * 
      * 
      * @return the requested {@link ObjectAdapter} that has the specified
-     *         {@link Oid}.
+     *         {@link TypedOid}.
      * 
      * @throws ObjectNotFoundException
      *             when no object corresponding to the oid can be found
      */
-    ObjectAdapter getObject(Oid oid, ObjectSpecification hint);
+    ObjectAdapter getObject(TypedOid oid);
+
 
     // ///////////////////////////////////////////////////////
     // getInstances, hasInstances

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStoreTransactionManagement.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStoreTransactionManagement.java?rev=1338472&r1=1338471&r2=1338472&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStoreTransactionManagement.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/ObjectStoreTransactionManagement.java Mon May 14 22:44:57 2012
@@ -21,9 +21,8 @@ package org.apache.isis.runtimes.dflt.ru
 
 import java.util.List;
 
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.ObjectStoreTransaction;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.ObjectStoreTransactionManager;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
 import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
 
 /**
@@ -39,7 +38,7 @@ public interface ObjectStoreTransactionM
     void startTransaction();
 
     /**
-     * Used by the current {@link ObjectStoreTransaction} to flush changes to
+     * Used by the current {@link IsisTransaction} to flush changes to
      * the {@link ObjectStore} (either via a
      * {@link IsisTransactionManager#flushTransaction()} or a
      * {@link IsisTransactionManager#endTransaction()}).

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/DeploymentType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/DeploymentType.java?rev=1338472&r1=1338471&r2=1338472&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/DeploymentType.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/DeploymentType.java Mon May 14 22:44:57 2012
@@ -59,7 +59,6 @@ import org.apache.isis.runtimes.dflt.run
  */
 public class DeploymentType {
 
-
     private static List<DeploymentType> deploymentTypes = Lists.newArrayList();
 
     public static DeploymentType EXPLORATION = new DeploymentType("EXPLORATION", DeploymentCategory.EXPLORING, ContextCategory.STATIC_RELAXED, SystemConstants.VIEWER_DEFAULT, Splash.SHOW);
@@ -72,6 +71,25 @@ public class DeploymentType {
     public static DeploymentType SINGLE_USER = new DeploymentType("SINGLE_USER", DeploymentCategory.PRODUCTION, ContextCategory.STATIC, SystemConstants.VIEWER_DEFAULT, Splash.NO_SHOW);
     public static DeploymentType UTILITY = new DeploymentType("UTILITY", DeploymentCategory.EXPLORING, ContextCategory.STATIC, null, Splash.NO_SHOW);
 
+    /**
+     * Look up {@link DeploymentType} by their {@link #name()}.
+     * 
+     * <p>
+     * Can substitute <tt>'-'</tt> instead of <tt>'_'</tt>; for example
+     * <tt>server_exploration</tt> will lookup the same as
+     * <tt>server-exploration</tt>.
+     */
+    public static DeploymentType lookup(final String str) {
+        final String underscoredStr = str.replace('-', '_').toUpperCase();
+        for (final DeploymentType deploymentType : deploymentTypes) {
+            if (underscoredStr.equals(deploymentType.name())) {
+                return deploymentType;
+            }
+        }
+        throw new IllegalArgumentException(String.format("Unknown deployment type '%s'", str));
+    }
+
+
     private final String name;
     private final DeploymentCategory deploymentCategory;
     private final ContextCategory contextCategory;
@@ -183,24 +201,6 @@ public class DeploymentType {
         }
     }
 
-    /**
-     * Look up {@link DeploymentType} by their {@link #name()}.
-     * 
-     * <p>
-     * Can substitute <tt>'-'</tt> instead of <tt>'_'</tt>; for example
-     * <tt>server_exploration</tt> will lookup the same as
-     * <tt>server-exploration</tt>.
-     */
-    public static DeploymentType lookup(final String str) {
-        final String underscoredStr = str.replace('-', '_').toUpperCase();
-        for (final DeploymentType deploymentType : deploymentTypes) {
-            if (underscoredStr.equals(deploymentType.name())) {
-                return deploymentType;
-            }
-        }
-        throw new IllegalArgumentException(String.format("Unknown deployment type '%s'", str));
-    }
-
     public String friendlyName() {
         return nameLowerCase().replace('_', '-');
     }
@@ -212,5 +212,10 @@ public class DeploymentType {
     public String name() {
         return name;
     }
+    
+    @Override
+    public String toString() {
+        return name();
+    }
 
 }
\ No newline at end of file

Added: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/IdentifierGenerator.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/IdentifierGenerator.java?rev=1338472&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/IdentifierGenerator.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/IdentifierGenerator.java Mon May 14 22:44:57 2012
@@ -0,0 +1,16 @@
+package org.apache.isis.runtimes.dflt.runtime.system.persistence;
+
+import org.apache.isis.core.commons.debug.DebuggableWithTitle;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+
+public interface IdentifierGenerator extends DebuggableWithTitle {
+
+    public String createTransientIdentifierFor(ObjectSpecId objectSpecId, final Object pojo);
+
+    public String createAggregateLocalId(ObjectSpecId objectSpecId, final Object pojo, final ObjectAdapter parentAdapter);
+    
+    public String createPersistentIdentifierFor(ObjectSpecId objectSpecId, Object pojo, RootOid transientRootOid);
+
+}

Propchange: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/IdentifierGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/IdentifierGeneratorDefault.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/IdentifierGeneratorDefault.java?rev=1338472&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/IdentifierGeneratorDefault.java (added)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/IdentifierGeneratorDefault.java Mon May 14 22:44:57 2012
@@ -0,0 +1,155 @@
+/*
+ *  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.runtimes.dflt.runtime.system.persistence;
+
+import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
+import static org.apache.isis.core.commons.matchers.IsisMatchers.greaterThan;
+import static org.hamcrest.CoreMatchers.is;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+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.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+
+/**
+ * Generates OIDs based on monotonically.
+ * 
+ * <p>
+ * Specifies the {@link OidStringifierDirect} as the
+ * {@link #getOidStringifier() OID stringifier} ({@link RootOidDefault} is
+ * conformant)).
+ */
+public class IdentifierGeneratorDefault implements IdentifierGenerator {
+
+    public static class Memento {
+        private final long persistentSerialNumber;
+        private final long transientSerialNumber;
+
+        Memento(final long persistentSerialNumber, final long transientSerialNumber) {
+            this.persistentSerialNumber = persistentSerialNumber;
+            this.transientSerialNumber = transientSerialNumber;
+        }
+
+        public long getTransientSerialNumber() {
+            return transientSerialNumber;
+        }
+
+        public long getPersistentSerialNumber() {
+            return persistentSerialNumber;
+        }
+    }
+
+    private long persistentSerialNumber;
+    private long transientSerialNumber;
+    private long aggregatedId;
+
+    // //////////////////////////////////////////////////////////////
+    // constructor
+    // //////////////////////////////////////////////////////////////
+
+    public IdentifierGeneratorDefault() {
+        this(1);
+    }
+
+    /**
+     * Persistent {@link Oid}s count up from the provided seed parameter, while
+     * {@link Oid#isTransient()} transient {@link Oid}s count down.
+     */
+    public IdentifierGeneratorDefault(final long seed) {
+        this(seed, Long.MIN_VALUE + seed);
+    }
+
+    public IdentifierGeneratorDefault(final Memento memento) {
+        this(memento.getPersistentSerialNumber(), memento.getTransientSerialNumber());
+    }
+
+    public IdentifierGeneratorDefault(final long persistentSerialNumber, final long transientSerialNumber) {
+        ensureThatArg(persistentSerialNumber, is(greaterThan(0L)));
+        this.persistentSerialNumber = persistentSerialNumber;
+        this.transientSerialNumber = transientSerialNumber;
+    }
+
+    // //////////////////////////////////////////////////////////////
+    // name
+    // //////////////////////////////////////////////////////////////
+
+    public String name() {
+        return "Default Identifier Generator";
+    }
+
+    // //////////////////////////////////////////////////////////////
+    // main API and hooks
+    // //////////////////////////////////////////////////////////////
+
+    @Override
+    public String createAggregateLocalId(ObjectSpecId objectSpecId, final Object pojo, final ObjectAdapter parentAdapter) {
+        return Long.toHexString(aggregatedId++);
+    }
+    
+    @Override
+    public String createTransientIdentifierFor(ObjectSpecId objectSpecId, Object pojo) {
+         // counts down
+        return "" + (transientSerialNumber--);
+    }
+
+    @Override
+    public String createPersistentIdentifierFor(ObjectSpecId objectSpecId, Object pojo, RootOid transientRootOid) {
+        return "" + (persistentSerialNumber++); // counts up
+    }
+
+    
+    // //////////////////////////////////////////////////////////////
+    // Memento (not API)
+    // //////////////////////////////////////////////////////////////
+
+    public Memento getMemento() {
+        return new Memento(this.persistentSerialNumber, this.transientSerialNumber);
+    }
+
+    /**
+     * Reset to a {@link Memento} previously obtained via {@link #getMemento()}.
+     * 
+     * <p>
+     * Used in particular by the <tt>InMemoryObjectStore</tt> to reset (a new
+     * {@link OidGenerator} is created each time).
+     */
+    public void resetTo(final Memento memento) {
+        this.persistentSerialNumber = memento.getPersistentSerialNumber();
+        this.transientSerialNumber = memento.getTransientSerialNumber();
+    }
+
+    // //////////////////////////////////////////////////////////////
+    // debug
+    // //////////////////////////////////////////////////////////////
+
+    @Override
+    public void debugData(final DebugBuilder debug) {
+        debug.appendln("Persistent", persistentSerialNumber);
+        debug.appendln("Transient", transientSerialNumber);
+    }
+
+    @Override
+    public String debugTitle() {
+        return name();
+    }
+
+}

Propchange: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/IdentifierGeneratorDefault.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/OidGenerator.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/OidGenerator.java?rev=1338472&r1=1338471&r2=1338472&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/OidGenerator.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/OidGenerator.java Mon May 14 22:44:57 2012
@@ -22,19 +22,79 @@ package org.apache.isis.runtimes.dflt.ru
 import org.apache.isis.applib.annotation.Aggregated;
 import org.apache.isis.core.commons.components.Injectable;
 import org.apache.isis.core.commons.components.SessionScopedComponent;
+import org.apache.isis.core.commons.debug.DebugBuilder;
 import org.apache.isis.core.commons.debug.DebuggableWithTitle;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
 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.RootOidDefault;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
 import org.apache.isis.core.metamodel.adapter.oid.stringable.OidStringifier;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLookup;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+
+public class OidGenerator implements DebuggableWithTitle, SessionScopedComponent, Injectable {
+
+    private final OidStringifier oidStringifier;
+    private final IdentifierGenerator identifierGenerator;
+    
+    public OidGenerator() {
+        this(new IdentifierGeneratorDefault());
+    }
+    
+    public OidGenerator(final IdentifierGenerator identifierGenerator) {
+        this.identifierGenerator = identifierGenerator;
+        this.oidStringifier = new OidStringifier(RootOidDefault.class);
+    }
+
+    
+    public IdentifierGenerator getIdentifierGenerator() {
+        return identifierGenerator;
+    }
 
-public interface OidGenerator extends DebuggableWithTitle, SessionScopedComponent, Injectable {
+    /**
+     * An {@link OidStringifier} to use for stringifying instances of the
+     * concrete {@link Oid} generated by this generator.
+     */
+    public final OidStringifier getOidStringifier() {
+        return oidStringifier;
+    }
+
+    // //////////////////////////////////////////////////////////////
+    // open, close (session scoped)
+    // //////////////////////////////////////////////////////////////
 
     /**
+     * Default implementation does nothing.
+     */
+    @Override
+    public void open() {
+    }
+
+    /**
+     * Default implementation does nothing.
+     */
+    @Override
+    public void close() {
+    }
+
+    
+    // //////////////////////////////////////////////////////////////
+    // API and mandatory hooks
+    // //////////////////////////////////////////////////////////////
+    
+    /**
      * Create a new {@link Oid#isTransient() transient} {@link Oid} for the
      * supplied pojo, uniquely distinguishable from any other {@link Oid}.
      */
-    RootOid createTransientOid(Object pojo);
+    public final RootOid createTransientOid(final Object pojo) {
+        final ObjectSpecId objectSpecId = objectSpecIdFor(pojo);
+        final String transientIdentifier = identifierGenerator.createTransientIdentifierFor(objectSpecId, pojo);
+        return createTransient(objectSpecId, transientIdentifier);
+    }
 
     /**
      * Creates a new id, locally unique within an aggregate root, for the specified 
@@ -44,7 +104,11 @@ public interface OidGenerator extends De
      * This is used by {@link Aggregated} references (either referenced by properties or by
      * collections).
      */
-    String createAggregateLocalId(Object pojo);
+    public AggregatedOid createAggregateOid(final Object pojo, final ObjectAdapter parentAdapter) {
+        final ObjectSpecId objectSpecId = objectSpecIdFor(pojo);
+        final String aggregateLocalId = identifierGenerator.createAggregateLocalId(objectSpecId, pojo, parentAdapter);
+        return new AggregatedOid(objectSpecId, (TypedOid) parentAdapter.getOid(), aggregateLocalId);
+    }
 
     /**
      * Return an equivalent {@link RootOid}, but being persistent.
@@ -54,13 +118,71 @@ public interface OidGenerator extends De
      * For example, the generator may simply assign a new value from a sequence, or a GUID;
      * or, the generator may use the oid to look up the object and inspect the object in order
      * to obtain an application-defined value.  
+     * 
+     * @param pojo - being persisted
+     * @param transientRootOid - the oid for the pojo when transient.
      */
-    RootOid asPersistent(RootOid rootOid);
+    public final RootOid createPersistent(Object pojo, RootOid transientRootOid) {
 
-    /**
-     * An {@link OidStringifier} to use for stringifying instances of the
-     * concrete {@link Oid} generated by this generator.
-     */
-    OidStringifier getOidStringifier();
+        final ObjectSpecId objectSpecId = objectSpecIdFor(pojo);
+        final String persistentIdentifier = identifierGenerator.createPersistentIdentifierFor(objectSpecId, pojo, transientRootOid);
+        
+        return RootOidDefault.create(objectSpecId, persistentIdentifier);
+    }
+
+
+    // //////////////////////////////////////////////////////////////
+    // Helpers
+    // //////////////////////////////////////////////////////////////
+
+    private RootOid createTransient(final ObjectSpecId objectSpecId, final String transientIdentifier) {
+        return RootOidDefault.createTransient(objectSpecId, transientIdentifier);
+    }
+
+    private ObjectSpecId objectSpecIdFor(final Object pojo) {
+        final Class<? extends Object> cls = pojo.getClass();
+        final ObjectSpecification objectSpec = getSpecificationLookup().loadSpecification(cls);
+        return objectSpec.getSpecId();
+    }
+
+
+
+    // ////////////////////////////////////////////////////////////////////
+    // injectInto
+    // ////////////////////////////////////////////////////////////////////
+
+    @Override
+    public void injectInto(final Object candidate) {
+        if (OidGeneratorAware.class.isAssignableFrom(candidate.getClass())) {
+            final OidGeneratorAware cast = OidGeneratorAware.class.cast(candidate);
+            cast.setOidGenerator(this);
+        }
+    }
+
+
+    // //////////////////////////////////////////////////////////////
+    // debug
+    // //////////////////////////////////////////////////////////////
+
+
+    @Override
+    public void debugData(final DebugBuilder debug) {
+        getIdentifierGenerator().debugData(debug);
+    }
+
+
+    @Override
+    public String debugTitle() {
+        return getIdentifierGenerator().debugTitle();
+    }
+
+    
+    //////////////////////////////////////////////////////////////////
+    // context
+    //////////////////////////////////////////////////////////////////
+
+    protected SpecificationLookup getSpecificationLookup() {
+        return IsisContext.getSpecificationLoader();
+    }
 
 }

Copied: incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/OidGeneratorAware.java (from r1331799, incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/oidgenerator/OidGeneratorAware.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/OidGeneratorAware.java?p2=incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/OidGeneratorAware.java&p1=incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/oidgenerator/OidGeneratorAware.java&r1=1331799&r2=1338472&rev=1338472&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/oidgenerator/OidGeneratorAware.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/persistence/OidGeneratorAware.java Mon May 14 22:44:57 2012
@@ -17,9 +17,8 @@
  *  under the License.
  */
 
-package org.apache.isis.runtimes.dflt.runtime.persistence.oidgenerator;
+package org.apache.isis.runtimes.dflt.runtime.system.persistence;
 
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
 
 public interface OidGeneratorAware {