polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [24/28] zest-java git commit: ZEST-180, ZEST-186, ZEST-187, ZEST-188 Big Identity refactoring UnitOfWorkFactory is auto added to all modules that doesn't declare one IdentityGenerator is auto-added to all modules that deosn't declare one. Removed DCI/DDD
Date Sun, 23 Oct 2016 14:24:05 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
index acfbeae..90d5acb 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
@@ -33,6 +33,9 @@ import org.apache.zest.api.cache.CacheOptions;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.IdentityGenerator;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
@@ -91,6 +94,9 @@ public class JSONMapEntityStoreMixin
     @Tagged( ValueSerialization.Formats.JSON )
     private ValueSerialization valueSerialization;
 
+    @Service
+    IdentityGenerator identityGenerator;
+
     @Optional
     @Service
     private Migration migration;
@@ -148,14 +154,14 @@ public class JSONMapEntityStoreMixin
 
     @Override
     public EntityState newEntityState( EntityStoreUnitOfWork unitOfWork,
-                                       EntityReference identity,
+                                       EntityReference reference,
                                        EntityDescriptor entityDescriptor
     )
     {
         try
         {
             JSONObject state = new JSONObject();
-            state.put( JSONKeys.IDENTITY, identity.identity() );
+            state.put( JSONKeys.IDENTITY, reference.identity() );
             state.put( JSONKeys.APPLICATION_VERSION, application.version() );
             state.put( JSONKeys.TYPE, entityDescriptor.types().findFirst().get().getName() );
             state.put( JSONKeys.VERSION, unitOfWork.identity() );
@@ -168,7 +174,7 @@ public class JSONMapEntityStoreMixin
                                         valueSerialization,
                                         "",
                                         unitOfWork.currentTime(),
-                                        identity,
+                                        reference,
                                         EntityStatus.NEW,
                                         entityDescriptor,
                                         state );
@@ -182,30 +188,30 @@ public class JSONMapEntityStoreMixin
     @Override
     public synchronized EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork,
                                                    ModuleDescriptor module,
-                                                   EntityReference identity
+                                                   EntityReference reference
     )
     {
-        EntityState state = fetchCachedState( identity, module, unitOfWork.currentTime() );
+        EntityState state = fetchCachedState( reference, module, unitOfWork.currentTime() );
         if( state != null )
         {
             return state;
         }
         // Get state
-        Reader in = mapEntityStore.get( identity );
+        Reader in = mapEntityStore.get( reference );
         JSONEntityState loadedState = readEntityState( module, in );
         if( doCacheOnRead( unitOfWork ) )
         {
-            cache.put( identity.identity(), new CacheState( loadedState.state() ) );
+            cache.put( reference.identity().toString(), new CacheState( loadedState.state() ) );
         }
         return loadedState;
     }
 
     @Override
     public synchronized String versionOf( EntityStoreUnitOfWork unitOfWork,
-                                          EntityReference identity
+                                          EntityReference reference
     )
     {
-        CacheState cacheState = cache.get( identity.identity() );
+        CacheState cacheState = cache.get( reference.identity().toString() );
         if( cacheState != null )
         {
             try
@@ -219,7 +225,7 @@ public class JSONMapEntityStoreMixin
             }
         }
         // Get state
-        Reader entityState = mapEntityStore.get( identity );
+        Reader entityState = mapEntityStore.get( reference );
         try
         {
             JSONObject jsonObject = new JSONObject( new JSONTokener( entityState ) );
@@ -261,30 +267,30 @@ public class JSONMapEntityStoreMixin
                                 JSONEntityState state = (JSONEntityState) entityState;
                                 if( state.status().equals( EntityStatus.NEW ) )
                                 {
-                                    try (Writer writer = changer.newEntity( state.identity(), state.entityDescriptor() ))
+                                    try (Writer writer = changer.newEntity( state.entityReference(), state.entityDescriptor() ))
                                     {
-                                        writeEntityState( state, writer, unitOfWork.identity(), unitOfWork.currentTime() );
+                                        writeEntityState( state, writer, unitOfWork.identity().toString(), unitOfWork.currentTime() );
                                     }
                                     if( options.cacheOnNew() )
                                     {
-                                        cache.put( state.identity().identity(), new CacheState( state.state() ) );
+                                        cache.put( state.entityReference().identity().toString(), new CacheState( state.state() ) );
                                     }
                                 }
                                 else if( state.status().equals( EntityStatus.UPDATED ) )
                                 {
-                                    try (Writer writer = changer.updateEntity( state.identity(), state.entityDescriptor() ))
+                                    try (Writer writer = changer.updateEntity( state.entityReference(), state.entityDescriptor() ))
                                     {
-                                        writeEntityState( state, writer, unitOfWork.identity(), unitOfWork.currentTime() );
+                                        writeEntityState( state, writer, unitOfWork.identity().toString(), unitOfWork.currentTime() );
                                     }
                                     if( options.cacheOnWrite() )
                                     {
-                                        cache.put( state.identity().identity(), new CacheState( state.state() ) );
+                                        cache.put( state.entityReference().identity().toString(), new CacheState( state.state() ) );
                                     }
                                 }
                                 else if( state.status().equals( EntityStatus.REMOVED ) )
                                 {
-                                    changer.removeEntity( state.identity(), state.entityDescriptor() );
-                                    cache.remove( state.identity().identity() );
+                                    changer.removeEntity( state.entityReference(), state.entityDescriptor() );
+                                    cache.remove( state.entityReference().identity().toString() );
                                 }
                             }
                         }
@@ -392,7 +398,7 @@ public class JSONMapEntityStoreMixin
                 for( EntityState migratedEntity : migratedEntities )
                 {
                     JSONEntityState state = (JSONEntityState) migratedEntity;
-                    try (Writer writer = changer.updateEntity( state.identity(), state.entityDescriptor() ))
+                    try (Writer writer = changer.updateEntity( state.entityReference(), state.entityDescriptor() ))
                     {
                         writeEntityState( state, writer, state.version(), state.lastModified() );
                     }
@@ -402,18 +408,18 @@ public class JSONMapEntityStoreMixin
         migratedEntities.clear();
     }
 
-    protected String newUnitOfWorkId()
+    protected Identity newUnitOfWorkId()
     {
-        return uuid + Integer.toHexString( count++ );
+        return identityGenerator.generate(EntityStore.class);
     }
 
-    protected void writeEntityState( JSONEntityState state, Writer writer, String identity, Instant lastModified )
+    protected void writeEntityState(JSONEntityState state, Writer writer, String version, Instant lastModified )
         throws EntityStoreException
     {
         try
         {
             JSONObject jsonState = state.state();
-            jsonState.put( JSONKeys.VERSION, identity );
+            jsonState.put( JSONKeys.VERSION, version );
             jsonState.put( JSONKeys.MODIFIED, lastModified.toEpochMilli() );
             writer.append( jsonState.toString() );
         }
@@ -433,7 +439,7 @@ public class JSONMapEntityStoreMixin
 
             String version = jsonObject.getString( JSONKeys.VERSION );
             Instant modified = Instant.ofEpochMilli(jsonObject.getLong( JSONKeys.MODIFIED ));
-            String identity = jsonObject.getString( JSONKeys.IDENTITY );
+            Identity identity = new StringIdentity(jsonObject.getString( JSONKeys.IDENTITY ));
 
             // Check if NamedAssociation is supported
             if( !jsonObject.has( JSONKeys.NAMED_ASSOCIATIONS ) )
@@ -470,7 +476,7 @@ public class JSONMapEntityStoreMixin
                                         valueSerialization,
                                         version,
                                         modified,
-                                        EntityReference.parseEntityReference( identity ),
+                                        EntityReference.create( identity ),
                                         status,
                                         entityDescriptor,
                                         jsonObject
@@ -496,9 +502,9 @@ public class JSONMapEntityStoreMixin
         }
     }
 
-    private EntityState fetchCachedState( EntityReference identity, ModuleDescriptor module, Instant currentTime )
+    private EntityState fetchCachedState( EntityReference reference, ModuleDescriptor module, Instant currentTime )
     {
-        CacheState cacheState = cache.get( identity.identity() );
+        CacheState cacheState = cache.get( reference.identity().toString() );
         if( cacheState != null )
         {
             JSONObject data = cacheState.json;
@@ -507,7 +513,7 @@ public class JSONMapEntityStoreMixin
                 String type = data.getString( JSONKeys.TYPE );
                 EntityDescriptor entityDescriptor = module.entityDescriptor( type );
                 Instant lastModified = Instant.ofEpochMilli(data.getLong(JSONKeys.MODIFIED));
-                return new JSONEntityState( module, valueSerialization, data.getString( JSONKeys.VERSION ), lastModified, identity, EntityStatus.LOADED, entityDescriptor, data );
+                return new JSONEntityState( module, valueSerialization, data.getString( JSONKeys.VERSION ), lastModified, reference, EntityStatus.LOADED, entityDescriptor, data );
             }
             catch( JSONException e )
             {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONNamedAssociationState.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONNamedAssociationState.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONNamedAssociationState.java
index e3e3e07..b648ef1 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONNamedAssociationState.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONNamedAssociationState.java
@@ -62,12 +62,12 @@ public final class JSONNamedAssociationState
     {
         try
         {
-            if( references.has( name ) && entityReference.identity().equals( references.getString( name ) ) )
+            if( references.has( name ) && entityReference.identity().toString().equals( references.getString( name ) ) )
             {
                 return false;
             }
             entityState.cloneStateIfGlobalStateLoaded();
-            references.put( name, entityReference.identity() );
+            references.put( name, entityReference.identity().toString() );
             entityState.markUpdated();
             return true;
         }
@@ -95,7 +95,7 @@ public final class JSONNamedAssociationState
     {
         try
         {
-            return new EntityReference( references.getString( name ) );
+            return EntityReference.parseEntityReference( references.getString( name ) );
         }
         catch( JSONException ex )
         {
@@ -116,7 +116,7 @@ public final class JSONNamedAssociationState
             for( int idx = 0; idx < names.length(); idx++ )
             {
                 String name = names.getString( idx );
-                if( entityReference.identity().equals( references.getString( name ) ) )
+                if( entityReference.identity().toString().equals( references.getString( name ) ) )
                 {
                     return name;
                 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
index 37b349e..fceae54 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
@@ -28,11 +28,13 @@ import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.UUID;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.common.QualifiedName;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.IdentityGenerator;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
@@ -94,17 +96,13 @@ public class MapEntityStoreMixin
     @Service
     private Migration migration;
 
-    //    @Uses
-//    private ServiceDescriptor descriptor;
-//
-    protected String uuid;
-    private int count;
+    @Service
+    private IdentityGenerator identityGenerator;
 
     @Override
     public void activateMapEntityStore()
         throws Exception
     {
-        uuid = UUID.randomUUID().toString() + "-";
     }
 
     // EntityStore
@@ -117,29 +115,29 @@ public class MapEntityStoreMixin
     // EntityStoreSPI
     @Override
     public EntityState newEntityState( EntityStoreUnitOfWork unitOfWork,
-                                       EntityReference identity,
+                                       EntityReference reference,
                                        EntityDescriptor entityDescriptor
     )
     {
-        return new DefaultEntityState( unitOfWork.currentTime(), identity, entityDescriptor );
+        return new DefaultEntityState( unitOfWork.currentTime(), reference, entityDescriptor );
     }
 
     @Override
     public synchronized EntityState entityStateOf( EntityStoreUnitOfWork unitofwork,
                                                    ModuleDescriptor module,
-                                                   EntityReference identity
+                                                   EntityReference reference
     )
     {
-        Reader in = mapEntityStore.get( identity );
+        Reader in = mapEntityStore.get( reference );
         return readEntityState( module, in );
     }
 
     @Override
     public synchronized String versionOf( EntityStoreUnitOfWork unitofwork,
-                                          EntityReference identity
+                                          EntityReference reference
     )
     {
-        Reader in = mapEntityStore.get( identity );
+        Reader in = mapEntityStore.get( reference );
         try
         {
             JSONObject jsonObject = new JSONObject( new JSONTokener( in ) );
@@ -169,21 +167,21 @@ public class MapEntityStoreMixin
                             DefaultEntityState state1 = (DefaultEntityState) entityState;
                             if( state1.status().equals( EntityStatus.NEW ) )
                             {
-                                try (Writer writer = changer.newEntity( state1.identity(), state1.entityDescriptor() ))
+                                try (Writer writer = changer.newEntity( state1.entityReference(), state1.entityDescriptor() ))
                                 {
-                                    writeEntityState( state1, writer, unitofwork.identity(), unitofwork.currentTime() );
+                                    writeEntityState( state1, writer, unitofwork.identity().toString(), unitofwork.currentTime() );
                                 }
                             }
                             else if( state1.status().equals( EntityStatus.UPDATED ) )
                             {
-                                try (Writer writer = changer.updateEntity( state1.identity(), state1.entityDescriptor() ))
+                                try (Writer writer = changer.updateEntity( state1.entityReference(), state1.entityDescriptor() ))
                                 {
-                                    writeEntityState( state1, writer, unitofwork.identity(), unitofwork.currentTime() );
+                                    writeEntityState( state1, writer, unitofwork.identity().toString(), unitofwork.currentTime() );
                                 }
                             }
                             else if( state1.status().equals( EntityStatus.REMOVED ) )
                             {
-                                changer.removeEntity( state1.identity(), state1.entityDescriptor() );
+                                changer.removeEntity( state1.entityReference(), state1.entityDescriptor() );
                             }
                         }
                     } );
@@ -279,7 +277,7 @@ public class MapEntityStoreMixin
             for( EntityState migratedEntity : migratedEntities )
             {
                 DefaultEntityState state = (DefaultEntityState) migratedEntity;
-                try (Writer writer = changer.updateEntity( state.identity(), state.entityDescriptor() ))
+                try (Writer writer = changer.updateEntity( state.entityReference(), state.entityDescriptor() ))
                 {
                     writeEntityState( state, writer, state.version(), state.lastModified() );
                 }
@@ -288,19 +286,19 @@ public class MapEntityStoreMixin
         migratedEntities.clear();
     }
 
-    protected String newUnitOfWorkId()
+    protected Identity newUnitOfWorkId()
     {
-        return uuid + Integer.toHexString( count++ );
+        return identityGenerator.generate( EntityStore.class );
     }
 
-    protected void writeEntityState( DefaultEntityState state, Writer writer, String version, Instant lastModified )
+    protected void writeEntityState(DefaultEntityState state, Writer writer, String version, Instant lastModified )
         throws EntityStoreException
     {
         try
         {
             JSONWriter json = new JSONWriter( writer );
             JSONWriter properties = json.object().
-                key( JSONKeys.IDENTITY ).value( state.identity().identity() ).
+                key( JSONKeys.IDENTITY ).value( state.entityReference().identity() ).
                 key( JSONKeys.APPLICATION_VERSION ).value( application.version() ).
                 key( JSONKeys.TYPE ).value( state.entityDescriptor().types().findFirst().get().getName() ).
                 key( JSONKeys.VERSION ).value( version ).
@@ -389,7 +387,7 @@ public class MapEntityStoreMixin
 
             String version = jsonObject.getString( JSONKeys.VERSION );
             Instant modified = Instant.ofEpochMilli(jsonObject.getLong( JSONKeys.MODIFIED ));
-            String identity = jsonObject.getString( JSONKeys.IDENTITY );
+            Identity identity = new StringIdentity(jsonObject.getString( JSONKeys.IDENTITY ));
 
             // Check if version is correct
             String currentAppVersion = jsonObject.optString( JSONKeys.APPLICATION_VERSION, "0.0" );
@@ -517,7 +515,7 @@ public class MapEntityStoreMixin
 
             return new DefaultEntityState( version,
                                            modified,
-                                           EntityReference.parseEntityReference( identity ),
+                                           EntityReference.create(identity),
                                            status[ 0 ],
                                            entityDescriptor,
                                            properties,

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java b/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
index 5375913..0d11cc1 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java
@@ -19,7 +19,7 @@
  */
 package org.apache.zest.spi.module;
 
-import org.apache.zest.api.entity.IdentityGenerator;
+import org.apache.zest.api.identity.IdentityGenerator;
 import org.apache.zest.api.metrics.MetricsProvider;
 import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.structure.TypeLookup;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/uuid/UuidIdentityGeneratorMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/uuid/UuidIdentityGeneratorMixin.java b/core/spi/src/main/java/org/apache/zest/spi/uuid/UuidIdentityGeneratorMixin.java
index 4c69145..de7252b 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/uuid/UuidIdentityGeneratorMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/uuid/UuidIdentityGeneratorMixin.java
@@ -20,7 +20,9 @@
 package org.apache.zest.spi.uuid;
 
 import java.util.UUID;
-import org.apache.zest.api.entity.IdentityGenerator;
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.IdentityGenerator;
+import org.apache.zest.api.identity.StringIdentity;
 
 /**
  * UUID based Identity generator mixin.
@@ -37,8 +39,8 @@ public class UuidIdentityGeneratorMixin
     }
 
     @Override
-    public String generate( Class<?> compositeType )
+    public Identity generate(Class<?> compositeType )
     {
-        return uuid + Integer.toHexString( count++ );
+        return new StringIdentity(uuid + Integer.toHexString( count++ ));
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/uuid/UuidIdentityGeneratorService.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/uuid/UuidIdentityGeneratorService.java b/core/spi/src/main/java/org/apache/zest/spi/uuid/UuidIdentityGeneratorService.java
index 46cac60..08a4c7d 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/uuid/UuidIdentityGeneratorService.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/uuid/UuidIdentityGeneratorService.java
@@ -20,7 +20,7 @@
 
 package org.apache.zest.spi.uuid;
 
-import org.apache.zest.api.entity.IdentityGenerator;
+import org.apache.zest.api.identity.IdentityGenerator;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.service.ServiceComposite;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
index 93a8d7e..e104739 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
@@ -44,6 +44,8 @@ import java.util.Scanner;
 import java.util.Set;
 import java.util.function.Function;
 import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.type.CollectionType;
 import org.apache.zest.api.type.EnumType;
@@ -158,6 +160,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
         // Number types
         registerDeserializer( BigDecimal.class, input -> new BigDecimal( input.toString() ) );
         registerDeserializer( BigInteger.class, input -> new BigInteger( input.toString() ) );
+        registerDeserializer( Identity.class, input -> StringIdentity.fromString( input.toString() ) );
 
         // Date types
         registerDeserializer( Instant.class, input -> Instant.parse( input.toString() ) );
@@ -269,7 +272,13 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
     private <T> T deserializeRoot( ModuleDescriptor module, ValueType valueType, InputStream input )
         throws Exception
     {
-        final Class<?> type = valueType.types().findFirst().orElse( null );
+        Class<?> type = valueType.types().findFirst().orElse( null );
+
+        if( Identity.class.isAssignableFrom( type ) )
+        {
+            type = Identity.class;
+        }
+
         // Plain ValueType
         Function<Object, Object> deserializationFunction = deserializers.get( type );
         if( deserializationFunction != null )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java b/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
index e428f4e..60093fc 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
@@ -45,6 +45,7 @@ import org.apache.zest.api.association.NamedAssociation;
 import org.apache.zest.api.composite.CompositeInstance;
 import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.identity.Identity;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.value.ValueComposite;
 import org.apache.zest.api.value.ValueDescriptor;
@@ -144,6 +145,7 @@ public abstract class ValueSerializerAdapter<OutputType>
         // Number types
         registerSerializer( BigDecimal.class, ( options, bigDecimal ) -> bigDecimal.toString() );
         registerSerializer( BigInteger.class, ( options, bigInteger ) -> bigInteger.toString() );
+        registerSerializer( Identity.class, ( options, identity ) -> identity.toString() );
 
         // Date types
         registerSerializer( Instant.class, ( options, date ) -> date.toString() );
@@ -261,6 +263,11 @@ public abstract class ValueSerializerAdapter<OutputType>
                 Object serialized = serializers.get( object.getClass() ).apply( options, object );
                 output.write( serialized.toString().getBytes( UTF_8 ) );
             }
+            else if( object instanceof Identity )
+            {
+                Object serialized = serializers.get( Identity.class ).apply( options, object );
+                output.write( serialized.toString().getBytes( UTF_8 ) );
+            }
             else if( object.getClass().isEnum() )
             {
                 // Enum Value
@@ -300,7 +307,11 @@ public abstract class ValueSerializerAdapter<OutputType>
                 complexSerializers.get( object.getClass() ).serialize( options, object, output );
             }
             else // ValueComposite
-                if( ValueComposite.class.isAssignableFrom( object.getClass() ) )
+                if( Identity.class.isAssignableFrom( object.getClass() ) )
+                {
+                    serializeIdentity( object, output );
+                }
+                else if( ValueComposite.class.isAssignableFrom( object.getClass() ) )
                 {
                     serializeValueComposite( options, object, output, rootPass );
                 }
@@ -335,6 +346,12 @@ public abstract class ValueSerializerAdapter<OutputType>
                                     }
     }
 
+    private void serializeIdentity( Object object, OutputType output )
+            throws Exception
+    {
+        onValue( output, object.toString() );
+    }
+
     private void serializeValueComposite( Options options, Object object, OutputType output, boolean rootPass )
         throws Exception
     {
@@ -382,7 +399,7 @@ public abstract class ValueSerializerAdapter<OutputType>
                 }
                 else
                 {
-                    onValue( output, ref.identity() );
+                    onValue( output, ref.identity().toString() );
                 }
                 onValueEnd( output );
                 onFieldEnd( output );
@@ -402,7 +419,7 @@ public abstract class ValueSerializerAdapter<OutputType>
                 for( EntityReference ref : manyAssociation.references() )
                 {
                     onValueStart( output );
-                    onValue( output, ref.identity() );
+                    onValue( output, ref.identity().toString() );
                     onValueEnd( output );
                 }
                 onArrayEnd( output );
@@ -426,7 +443,7 @@ public abstract class ValueSerializerAdapter<OutputType>
                     onFieldStart( output, name );
                     onValueStart( output );
                     EntityReference ref = namedAssociation.referenceOf( name );
-                    onValue( output, ref.identity() );
+                    onValue( output, ref.identity().toString() );
                     onValueEnd( output );
                     onFieldEnd( output );
                 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
----------------------------------------------------------------------
diff --git a/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java b/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
index 3699cf6..f2ebb41 100644
--- a/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
+++ b/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
@@ -93,9 +93,9 @@ public class JSONManyAssociationStateTest
 
         assertThat( jsonState.contains( EntityReference.parseEntityReference( "1" ) ), is( true ) );
 
-        assertThat( jsonState.get( 0 ).identity(), equalTo( "0" ) );
-        assertThat( jsonState.get( 1 ).identity(), equalTo( "1" ) );
-        assertThat( jsonState.get( 2 ).identity(), equalTo( "2" ) );
+        assertThat( jsonState.get( 0 ).identity().toString(), equalTo( "0" ) );
+        assertThat( jsonState.get( 1 ).identity().toString(), equalTo( "1" ) );
+        assertThat( jsonState.get( 2 ).identity().toString(), equalTo( "2" ) );
 
         assertThat( jsonState.count(), equalTo( 3 ) );
 
@@ -103,8 +103,8 @@ public class JSONManyAssociationStateTest
 
         assertThat( jsonState.count(), equalTo( 2 ) );
         assertThat( jsonState.contains( EntityReference.parseEntityReference( "1" ) ), is( false ) );
-        assertThat( jsonState.get( 0 ).identity(), equalTo( "0" ) );
-        assertThat( jsonState.get( 1 ).identity(), equalTo( "2" ) );
+        assertThat( jsonState.get( 0 ).identity().toString(), equalTo( "0" ) );
+        assertThat( jsonState.get( 1 ).identity().toString(), equalTo( "2" ) );
 
         jsonState.add( 2, EntityReference.parseEntityReference( "1" ) );
 
@@ -116,9 +116,9 @@ public class JSONManyAssociationStateTest
 
         assertThat( jsonState.count(), equalTo( 6 ) );
 
-        assertThat( jsonState.get( 0 ).identity(), equalTo( "C" ) );
-        assertThat( jsonState.get( 1 ).identity(), equalTo( "B" ) );
-        assertThat( jsonState.get( 2 ).identity(), equalTo( "A" ) );
+        assertThat( jsonState.get( 0 ).identity().toString(), equalTo( "C" ) );
+        assertThat( jsonState.get( 1 ).identity().toString(), equalTo( "B" ) );
+        assertThat( jsonState.get( 2 ).identity().toString(), equalTo( "A" ) );
 
         assertThat( jsonState.contains( EntityReference.parseEntityReference( "C" ) ), is( true ) );
         assertThat( jsonState.contains( EntityReference.parseEntityReference( "B" ) ), is( true ) );
@@ -132,7 +132,7 @@ public class JSONManyAssociationStateTest
             @Override
             public String apply( EntityReference from )
             {
-                return from.identity();
+                return from.identity().toString();
             }
         }, jsonState ) );
         assertThat( refList.isEmpty(), is( false ) );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/EntityTestAssembler.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/EntityTestAssembler.java b/core/testsupport/src/main/java/org/apache/zest/test/EntityTestAssembler.java
index 810bd95..bd84719 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/EntityTestAssembler.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/EntityTestAssembler.java
@@ -41,7 +41,7 @@ public class EntityTestAssembler
         ServiceDeclaration service = module.services( MemoryEntityStoreService.class ).visibleIn( visibility() );
         if( hasIdentity() )
         {
-            service.identifiedBy( identity() );
+            service.identifiedBy( identity().toString() );
         }
         module.services( UuidIdentityGeneratorService.class ).visibleIn( visibility() );
         module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
index 3fb4aa0..f93180b 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
@@ -23,7 +23,7 @@ package org.apache.zest.test.entity;
 import org.junit.Test;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.configuration.Configuration;
-import org.apache.zest.api.entity.Identity;
+import org.apache.zest.api.identity.HasIdentity;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.property.Property;
@@ -107,7 +107,7 @@ public abstract class AbstractConfigurationDeserializationTest extends AbstractZ
         }
     }
 
-    public interface ConfigSerializationConfig extends Identity
+    public interface ConfigSerializationConfig extends HasIdentity
     {
         Property<String> name();
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
index e1f17c1..faf706e 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
@@ -38,6 +38,7 @@ import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.common.UseDefaults;
 import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.entity.EntityComposite;
+import org.apache.zest.api.identity.Identity;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.property.Property;
@@ -298,7 +299,7 @@ public abstract class AbstractEntityStoreTest
     {
         UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork();
         TestEntity newInstance = createEntity( unitOfWork );
-        String identity = newInstance.identity().get();
+        Identity identity = newInstance.identity().get();
         unitOfWork.complete();
 
         // Remove entity
@@ -483,7 +484,7 @@ public abstract class AbstractEntityStoreTest
         UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork();
         try
         {
-            String identity = createEntity( unitOfWork ).identity().get();
+            Identity identity = createEntity( unitOfWork ).identity().get();
             unitOfWork.complete();
 
             unitOfWork = unitOfWorkFactory.newUnitOfWork();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
index 4767c40..8010176 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
@@ -75,7 +75,7 @@ public abstract class AbstractEntityFinderTest
 
     private static final Integer NO_MAX_RESULTS = null;
 
-    private static final Map<String, Object> NO_VARIABLES = Collections.<String, Object>emptyMap();
+    private static final Map<String, Object> NO_VARIABLES = Collections.emptyMap();
 
     private static final String JACK = "Jack Doe";
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
index 1175bc4..05c038e 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
@@ -29,6 +29,7 @@ import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.util.HashMap;
 import java.util.Map;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.query.NotQueryableException;
 import org.apache.zest.api.query.Query;
@@ -491,7 +492,7 @@ public abstract class AbstractQueryTest
     {
         QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Person person = templateFor( Person.class );
-        Domain gaming = unitOfWork.get( Domain.class, "Gaming" );
+        Domain gaming = unitOfWork.get( Domain.class, new StringIdentity( "Gaming" ) );
         Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.interests(), gaming ) ) );
         System.out.println( "*** script33: " + query );
 
@@ -503,7 +504,7 @@ public abstract class AbstractQueryTest
     {
         QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Person person = templateFor( Person.class );
-        Female annDoe = unitOfWork.get( Female.class, "anndoe" );
+        Female annDoe = unitOfWork.get( Female.class, new StringIdentity( "anndoe" ) );
         Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.mother(), annDoe ) ) );
         System.out.println( "*** script34: " + query );
 
@@ -526,7 +527,7 @@ public abstract class AbstractQueryTest
     {
         QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Person person = templateFor( Person.class );
-        Account anns = unitOfWork.get( Account.class, "accountOfAnnDoe" );
+        Account anns = unitOfWork.get( Account.class, new StringIdentity( "accountOfAnnDoe" ) );
         Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.accounts(), anns ) ) );
         System.out.println( "*** script36: " + query );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/NameableAssert.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/NameableAssert.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/NameableAssert.java
index 79e3eb9..5429ab7 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/NameableAssert.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/NameableAssert.java
@@ -27,7 +27,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
+import org.apache.zest.api.identity.Identity;
 import org.apache.zest.test.indexing.model.Nameable;
 
 import static org.hamcrest.core.IsEqual.equalTo;
@@ -39,7 +39,7 @@ import static org.apache.zest.functional.Iterables.toList;
 public class NameableAssert
 {
     // id -> name
-    private static final Map<String, String> world = new HashMap<>();
+    private static final Map<Identity, String> world = new HashMap<>();
 
     public static void clear()
     {
@@ -72,7 +72,7 @@ public class NameableAssert
 
     public static void trace( Nameable nameable )
     {
-        world.put( ( (Identity) nameable ).identity().get(), nameable.name().get() );
+        world.put( nameable.identity().get(), nameable.name().get() );
     }
 
     public static void assertName( String expectedName, EntityReference reference )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
index 8d20a6e..70b084b 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
@@ -27,6 +27,7 @@ import java.time.ZonedDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.zest.api.entity.EntityBuilder;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
@@ -58,7 +59,7 @@ public class TestData
             NameableAssert.clear();
             Domain gaming;
             {
-                EntityBuilder<Domain> domainBuilder = unitOfWork.newEntityBuilder( Domain.class, "Gaming" );
+                EntityBuilder<Domain> domainBuilder = unitOfWork.newEntityBuilder( Domain.class, new StringIdentity( "Gaming" ) );
                 gaming = domainBuilder.instance();
                 gaming.name().set( "Gaming" );
                 gaming.description().set( "Gaming domain" );
@@ -120,7 +121,7 @@ public class TestData
 
             Account annsAccount;
             {
-                EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, "accountOfAnnDoe" );
+                EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, new StringIdentity( "accountOfAnnDoe" ) );
                 annsAccount = accountBuilder.instance();
                 annsAccount.number().set( "accountOfAnnDoe" );
                 annsAccount = accountBuilder.newInstance();
@@ -128,7 +129,7 @@ public class TestData
 
             Account jacksAccount;
             {
-                EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, "accountOfJackDoe" );
+                EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, new StringIdentity( "accountOfJackDoe" ) );
                 jacksAccount = accountBuilder.instance();
                 jacksAccount.number().set( "accountOfJackDoe" );
                 jacksAccount = accountBuilder.newInstance();
@@ -142,7 +143,7 @@ public class TestData
 
             Female annDoe;
             {
-                EntityBuilder<Female> femaleBuilder = unitOfWork.newEntityBuilder( Female.class, "anndoe" );
+                EntityBuilder<Female> femaleBuilder = unitOfWork.newEntityBuilder( Female.class, new StringIdentity( "anndoe" ) );
                 annDoe = femaleBuilder.instance();
                 annDoe.name().set( "Ann Doe" );
                 annDoe.title().set( Person.Title.MRS );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java
index ce97a54..9f1053c 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java
@@ -43,7 +43,6 @@ class AccountModule
     public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
         throws AssemblyException
     {
-        module.withDefaultUnitOfWorkFactory();
         module.entities( Account.class, Domain.class ).visibleIn( Visibility.layer );
         module.values( File.class, Host.class, Port.class, Protocol.class, QueryParam.class, URL.class )
             .visibleIn( Visibility.layer );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java
index fb356d9..caeba11 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java
@@ -35,7 +35,6 @@ class ConfigModule
     public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
         throws AssemblyException
     {
-        module.withDefaultUnitOfWorkFactory();
         module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application );
         return module;
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java
index 38ebd20..a780dcb 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java
@@ -41,7 +41,6 @@ class FamilyModule
     public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
         throws AssemblyException
     {
-        module.withDefaultUnitOfWorkFactory();
         module.entities( Male.class,
                          Female.class,
                          City.class,

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java
index d01f3e4..d7332dd 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java
@@ -37,7 +37,6 @@ class PersistenceModule
     public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
         throws AssemblyException
     {
-        module.withDefaultUnitOfWorkFactory();
         module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON );
         module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application );
         return module;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java
index 6207257..f21eca1 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java
@@ -40,7 +40,6 @@ public class TestExecutionModule
     public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
         throws AssemblyException
     {
-        module.withDefaultUnitOfWorkFactory();
         module.objects( testClass ).visibleIn( Visibility.layer );
         return module;
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java
index 11d4b5b..ca35934 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java
@@ -37,7 +37,6 @@ class TestSuite1Module
     public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
         throws AssemblyException
     {
-        module.withDefaultUnitOfWorkFactory();
         declareTestCase( module, Suite1Case1.class );
         declareTestCase( module, Suite1Case2.class );
         return module;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java
index 4e58d78..75fd6ab 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java
@@ -33,7 +33,6 @@ class TestSuite2Module
     public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
         throws AssemblyException
     {
-        module.withDefaultUnitOfWorkFactory();
         return module;
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java
index df3b08c..251788d 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java
@@ -33,7 +33,6 @@ class TestSuite3Module
     public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
         throws AssemblyException
     {
-        module.withDefaultUnitOfWorkFactory();
         return module;
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Nameable.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Nameable.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Nameable.java
index a62f7c2..8bf724f 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Nameable.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Nameable.java
@@ -19,12 +19,13 @@
  */
 package org.apache.zest.test.indexing.model;
 
+import org.apache.zest.api.identity.HasIdentity;
 import org.apache.zest.api.property.Property;
 
 /**
  * JAVADOC Add JavaDoc
  */
-public interface Nameable
+public interface Nameable extends HasIdentity
 {
     Property<String> name();
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
index 3ac1039..48a0994 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
@@ -28,6 +28,8 @@ import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
 import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -254,7 +256,7 @@ public abstract class AbstractPlainValueSerializationTest
             value = serialization.deserialize( module, Regression142Type.class, serialized ); // ok
         }
         {
-            String valueId = "abcdefg";
+            Identity valueId = new StringIdentity( "abcdefg" );
             {
                 try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "create" ) ))
                 {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/cache-ehcache/src/main/java/org/apache/zest/cache/ehcache/EhCachePoolMixin.java
----------------------------------------------------------------------
diff --git a/extensions/cache-ehcache/src/main/java/org/apache/zest/cache/ehcache/EhCachePoolMixin.java b/extensions/cache-ehcache/src/main/java/org/apache/zest/cache/ehcache/EhCachePoolMixin.java
index 927c2cb..2629b30 100644
--- a/extensions/cache-ehcache/src/main/java/org/apache/zest/cache/ehcache/EhCachePoolMixin.java
+++ b/extensions/cache-ehcache/src/main/java/org/apache/zest/cache/ehcache/EhCachePoolMixin.java
@@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.zest.api.configuration.Configuration;
-import org.apache.zest.api.entity.Identity;
+import org.apache.zest.api.identity.HasIdentity;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.util.NullArgumentException;
 import org.apache.zest.spi.cache.Cache;
@@ -43,7 +43,7 @@ public abstract class EhCachePoolMixin
     private final ConcurrentHashMap<String, EhCacheImpl<?>> caches = new ConcurrentHashMap<>();
 
     @This
-    private Identity identity;
+    private HasIdentity identity;
 
     @This
     private Configuration<EhCacheConfiguration> configuration;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/cache-ehcache/src/main/java/org/apache/zest/cache/ehcache/assembly/EhCacheAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/cache-ehcache/src/main/java/org/apache/zest/cache/ehcache/assembly/EhCacheAssembler.java b/extensions/cache-ehcache/src/main/java/org/apache/zest/cache/ehcache/assembly/EhCacheAssembler.java
index a208ff3..b574492 100644
--- a/extensions/cache-ehcache/src/main/java/org/apache/zest/cache/ehcache/assembly/EhCacheAssembler.java
+++ b/extensions/cache-ehcache/src/main/java/org/apache/zest/cache/ehcache/assembly/EhCacheAssembler.java
@@ -36,7 +36,7 @@ public class EhCacheAssembler
         ServiceDeclaration service = module.services( EhCachePoolService.class ).visibleIn( visibility() );
         if( hasIdentity() )
         {
-            service.identifiedBy( identity() );
+            service.identifiedBy( identity().toString() );
         }
         if( hasConfig() )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/cache-memcache/src/main/java/org/apache/zest/cache/memcache/MemcacheAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/cache-memcache/src/main/java/org/apache/zest/cache/memcache/MemcacheAssembler.java b/extensions/cache-memcache/src/main/java/org/apache/zest/cache/memcache/MemcacheAssembler.java
index 4cfc36f..ca9d1e0 100644
--- a/extensions/cache-memcache/src/main/java/org/apache/zest/cache/memcache/MemcacheAssembler.java
+++ b/extensions/cache-memcache/src/main/java/org/apache/zest/cache/memcache/MemcacheAssembler.java
@@ -37,7 +37,7 @@ public class MemcacheAssembler
         ServiceDeclaration service = module.services( MemcachePoolService.class ).visibleIn( visibility() );
         if( hasIdentity() )
         {
-            service.identifiedBy( identity() );
+            service.identifiedBy( identity().toString() );
         }
         if( hasConfig() )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java b/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
index 2d1f4b1..14eccad 100644
--- a/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
+++ b/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
@@ -78,7 +78,7 @@ public class FileEntityStoreMixin
         {
             if( fileConfiguration != null )
             {
-                String storeId = config.get().identity().get();
+                String storeId = config.get().identity().get().toString();
                 pathName = new File( fileConfiguration.dataDirectory(), storeId ).getAbsolutePath();
             }
             else
@@ -321,7 +321,7 @@ public class FileEntityStoreMixin
                     public void receive( String item )
                         throws IOException
                     {
-                        String id = item.substring( "{\"identity\":\"".length() );
+                        String id = item.substring( "{\"reference\":\"".length() );
                         id = id.substring( 0, id.indexOf( '"' ) );
                         byte[] stateArray = item.getBytes( "UTF-8" );
                         store( getDataFile( id ), stateArray );
@@ -379,7 +379,7 @@ public class FileEntityStoreMixin
      * The resulting files should be portable across filesystems.
      * </p>
      *
-     * @param identity The identity that needs a file to be stored in.
+     * @param identity The reference that needs a file to be stored in.
      *
      * @return A filesystem-safe name.
      */
@@ -415,7 +415,7 @@ public class FileEntityStoreMixin
 
     private File getDataFile( EntityReference ref )
     {
-        return getDataFile( ref.identity() );
+        return getDataFile( ref.identity().toString() );
     }
 
     private byte[] fetch( File dataFile )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/assembly/FileEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/assembly/FileEntityStoreAssembler.java b/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/assembly/FileEntityStoreAssembler.java
index 6dc3d2c..5af7bc6 100644
--- a/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/assembly/FileEntityStoreAssembler.java
+++ b/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/assembly/FileEntityStoreAssembler.java
@@ -38,7 +38,7 @@ public class FileEntityStoreAssembler
         ServiceDeclaration service = module.services( FileEntityStoreService.class ).visibleIn( visibility() );
         if( hasIdentity() )
         {
-            service.identifiedBy( identity() );
+            service.identifiedBy( identity().toString() );
         }
         if( hasConfig() )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/GeodeEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/GeodeEntityStoreMixin.java b/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/GeodeEntityStoreMixin.java
index 0f26db2..1267577 100644
--- a/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/GeodeEntityStoreMixin.java
+++ b/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/GeodeEntityStoreMixin.java
@@ -149,7 +149,7 @@ public class GeodeEntityStoreMixin
     @Override
     public Reader get( EntityReference entityReference ) throws EntityStoreException
     {
-        String serializedState = region.get( entityReference.identity() );
+        String serializedState = region.get( entityReference.identity().toString() );
         if( serializedState == null )
         {
             throw new EntityNotFoundException( entityReference );
@@ -175,7 +175,7 @@ public class GeodeEntityStoreMixin
                             throws IOException
                     {
                         super.close();
-                        region.put( ref.identity(), toString() );
+                        region.put( ref.identity().toString(), toString() );
                     }
                 };
             }
@@ -191,7 +191,7 @@ public class GeodeEntityStoreMixin
             public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor )
                     throws EntityNotFoundException
             {
-                region.remove( ref.identity() );
+                region.remove( ref.identity().toString() );
             }
         } );
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/assembly/GeodeEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/assembly/GeodeEntityStoreAssembler.java b/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/assembly/GeodeEntityStoreAssembler.java
index 8478657..778af1f 100644
--- a/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/assembly/GeodeEntityStoreAssembler.java
+++ b/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/assembly/GeodeEntityStoreAssembler.java
@@ -41,7 +41,7 @@ public class GeodeEntityStoreAssembler
         ServiceDeclaration service = module.services( GeodeEntityStoreService.class ).visibleIn( visibility() );
         if( hasIdentity() )
         {
-            service.identifiedBy( identity() );
+            service.identifiedBy( identity().toString() );
         }
         if( hasConfig() )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/HazelcastEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/HazelcastEntityStoreMixin.java b/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/HazelcastEntityStoreMixin.java
index ab954e5..f588862 100644
--- a/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/HazelcastEntityStoreMixin.java
+++ b/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/HazelcastEntityStoreMixin.java
@@ -98,7 +98,7 @@ public class HazelcastEntityStoreMixin
     public Reader get( EntityReference ref )
         throws EntityStoreException
     {
-        final String serializedState = stringMap.get( ref.identity() );
+        final String serializedState = stringMap.get( ref.identity().toString() );
         if( serializedState == null )
         {
             throw new EntityNotFoundException( ref );
@@ -125,7 +125,7 @@ public class HazelcastEntityStoreMixin
                         throws IOException
                     {
                         super.close();
-                        stringMap.put( ref.identity(), toString() );
+                        stringMap.put( ref.identity().toString(), toString() );
                     }
                 };
             }
@@ -141,7 +141,7 @@ public class HazelcastEntityStoreMixin
             public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor )
                 throws EntityNotFoundException
             {
-                stringMap.remove( ref.identity() );
+                stringMap.remove( ref.identity().toString() );
             }
         } );
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/assembly/HazelcastEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/assembly/HazelcastEntityStoreAssembler.java b/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/assembly/HazelcastEntityStoreAssembler.java
index 71fd4b5..9d255a6 100644
--- a/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/assembly/HazelcastEntityStoreAssembler.java
+++ b/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/assembly/HazelcastEntityStoreAssembler.java
@@ -40,7 +40,7 @@ public class HazelcastEntityStoreAssembler
             instantiateOnStartup();
         if( hasIdentity() )
         {
-            service.identifiedBy( identity() );
+            service.identifiedBy( identity().toString() );
         }
         if( hasConfig() )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/JCloudsMapEntityStoreMixin.java b/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
index 3e71f08..37c0d0e 100644
--- a/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
+++ b/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
@@ -65,7 +65,6 @@ import org.slf4j.LoggerFactory;
 import static com.google.common.base.Charsets.UTF_8;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.collect.Iterables.contains;
-import static org.apache.zest.api.entity.EntityReference.parseEntityReference;
 
 /**
  * JClouds implementation of MapEntityStore.
@@ -170,7 +169,7 @@ public class JCloudsMapEntityStoreMixin
     public Reader get( EntityReference entityReference )
         throws EntityStoreException
     {
-        Blob blob = storeContext.getBlobStore().getBlob( container, entityReference.identity() );
+        Blob blob = storeContext.getBlobStore().getBlob( container, entityReference.identity().toString() );
         if( blob == null )
         {
             throw new EntityNotFoundException( entityReference );
@@ -226,7 +225,7 @@ public class JCloudsMapEntityStoreMixin
                         throws IOException
                         {
                             super.close();
-                            Blob blob = blobStore.blobBuilder( ref.identity() )
+                            Blob blob = blobStore.blobBuilder( ref.identity().toString() )
                                 .payload( ByteSource.wrap( toString().getBytes( UTF_8 ) ) )
                                 .build();
                             blobStore.putBlob( container, blob );
@@ -238,7 +237,7 @@ public class JCloudsMapEntityStoreMixin
                 public Writer updateEntity( final EntityReference ref, EntityDescriptor entityDescriptor )
                     throws IOException
                 {
-                    if( !blobStore.blobExists( container, ref.identity() ) )
+                    if( !blobStore.blobExists( container, ref.identity().toString() ) )
                     {
                         throw new EntityNotFoundException( ref );
                     }
@@ -249,7 +248,7 @@ public class JCloudsMapEntityStoreMixin
                         throws IOException
                         {
                             super.close();
-                            Blob blob = blobStore.blobBuilder( ref.identity() )
+                            Blob blob = blobStore.blobBuilder( ref.identity().toString() )
                                 .payload( ByteSource.wrap( toString().getBytes( UTF_8 ) ) )
                                 .build();
                             blobStore.putBlob( container, blob );
@@ -261,11 +260,11 @@ public class JCloudsMapEntityStoreMixin
                 public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor )
                     throws EntityNotFoundException
                 {
-                    if( !blobStore.blobExists( container, ref.identity() ) )
+                    if( !blobStore.blobExists( container, ref.identity().toString() ) )
                     {
                         throw new EntityNotFoundException( ref );
                     }
-                    blobStore.removeBlob( container, ref.identity() );
+                    blobStore.removeBlob( container, ref.identity().toString() );
                 }
             }
         );
@@ -292,7 +291,7 @@ public class JCloudsMapEntityStoreMixin
                                 Payload payload = storeContext.getBlobStore().getBlob( container, stored.getName() ).getPayload();
                                 if( payload == null )
                                 {
-                                    throw new EntityNotFoundException( parseEntityReference( stored.getName() ) );
+                                    throw new EntityNotFoundException( EntityReference.parseEntityReference( stored.getName() ) );
                                 }
                                 InputStream input = null;
                                 try

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/assembly/JCloudsEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/assembly/JCloudsEntityStoreAssembler.java b/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/assembly/JCloudsEntityStoreAssembler.java
index 4c029d8..a9b2f78 100644
--- a/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/assembly/JCloudsEntityStoreAssembler.java
+++ b/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/assembly/JCloudsEntityStoreAssembler.java
@@ -41,7 +41,7 @@ public class JCloudsEntityStoreAssembler
             instantiateOnStartup();
         if( hasIdentity() )
         {
-            service.identifiedBy( identity() );
+            service.identifiedBy( identity().toString() );
         }
         if( hasConfig() )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java b/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
index 86df0ec..fe3a9cf 100644
--- a/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
+++ b/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
@@ -41,6 +41,8 @@ import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.injection.scope.Uses;
@@ -165,7 +167,7 @@ public class JdbmEntityStoreMixin
                         {
                             super.close();
 
-                            Long stateIndex = getStateIndex( ref.toString() );
+                            Long stateIndex = getStateIndex( ref.identity() );
                             byte[] stateArray = toString().getBytes( "UTF-8" );
                             recordManager.update( stateIndex, stateArray, serializer );
                         }
@@ -178,7 +180,7 @@ public class JdbmEntityStoreMixin
                 {
                     try
                     {
-                        Long stateIndex = getStateIndex( ref.toString() );
+                        Long stateIndex = getStateIndex( ref.identity() );
                         recordManager.delete( stateIndex );
                         index.remove( ref.toString().getBytes( "UTF-8" ) );
                     }
@@ -234,7 +236,7 @@ public class JdbmEntityStoreMixin
 
                             while( browser.getNext( tuple ) )
                             {
-                                String id = new String( (byte[]) tuple.getKey(), "UTF-8" );
+                                Identity id = new StringIdentity( (byte[]) tuple.getKey() );
 
                                 Long stateIndex = getStateIndex( id );
 
@@ -284,7 +286,7 @@ public class JdbmEntityStoreMixin
                             {
                                 String id = new String( (byte[]) tuple.getKey(), "UTF-8" );
 
-                                Long stateIndex = getStateIndex( id );
+                                Long stateIndex = getStateIndex( new StringIdentity( id ) );
 
                                 if( stateIndex == null )
                                 {
@@ -343,7 +345,7 @@ public class JdbmEntityStoreMixin
                                 recordManager.commit();
                             }
 
-                            String id = item.substring( "{\"identity\":\"".length() );
+                            String id = item.substring( "{\"reference\":\"".length() );
                             id = id.substring( 0, id.indexOf( '"' ) );
 
                             // Insert
@@ -440,10 +442,10 @@ public class JdbmEntityStoreMixin
         return properties;
     }
 
-    private Long getStateIndex( String identity )
+    private Long getStateIndex( Identity identity )
         throws IOException
     {
-        return (Long) index.find( identity.getBytes( "UTF-8" ) );
+        return (Long) index.find( identity.toBytes() );
     }
 
     private void initialize()

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/assembly/JdbmEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/assembly/JdbmEntityStoreAssembler.java b/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/assembly/JdbmEntityStoreAssembler.java
index c1034eb..609ac87 100644
--- a/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/assembly/JdbmEntityStoreAssembler.java
+++ b/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/assembly/JdbmEntityStoreAssembler.java
@@ -38,7 +38,7 @@ public class JdbmEntityStoreAssembler
         ServiceDeclaration service = module.services( UuidIdentityGeneratorService.class ).visibleIn( visibility() );
         if( hasIdentity() )
         {
-            service.identifiedBy( identity() );
+            service.identifiedBy( identity().toString() );
         }
         if( hasConfig() )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/LevelDBEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/LevelDBEntityStoreMixin.java b/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/LevelDBEntityStoreMixin.java
index adadfd4..638b021 100644
--- a/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/LevelDBEntityStoreMixin.java
+++ b/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/LevelDBEntityStoreMixin.java
@@ -26,12 +26,6 @@ import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.nio.charset.Charset;
-import org.iq80.leveldb.CompressionType;
-import org.iq80.leveldb.DB;
-import org.iq80.leveldb.DBFactory;
-import org.iq80.leveldb.DBIterator;
-import org.iq80.leveldb.Options;
-import org.iq80.leveldb.WriteBatch;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
@@ -48,6 +42,12 @@ import org.apache.zest.library.fileconfig.FileConfiguration;
 import org.apache.zest.spi.entitystore.EntityNotFoundException;
 import org.apache.zest.spi.entitystore.EntityStoreException;
 import org.apache.zest.spi.entitystore.helpers.MapEntityStore;
+import org.iq80.leveldb.CompressionType;
+import org.iq80.leveldb.DB;
+import org.iq80.leveldb.DBFactory;
+import org.iq80.leveldb.DBIterator;
+import org.iq80.leveldb.Options;
+import org.iq80.leveldb.WriteBatch;
 
 /**
  * LevelDB implementation of MapEntityStore.
@@ -128,7 +128,7 @@ public class LevelDBEntityStoreMixin
         }
 
         // Open/Create the database
-        File dbFile = new File( fileConfig.dataDirectory(), descriptor.identity() );
+        File dbFile = new File( fileConfig.dataDirectory(), descriptor.identity().toString() );
         db = factory.open( dbFile, options );
     }
 
@@ -187,7 +187,7 @@ public class LevelDBEntityStoreMixin
     public Reader get( EntityReference entityReference )
         throws EntityStoreException
     {
-        byte[] state = db.get( entityReference.identity().getBytes( charset ) );
+        byte[] state = db.get( entityReference.identity().toString().getBytes( charset ) );
         if( state == null )
         {
             throw new EntityNotFoundException( entityReference );
@@ -258,7 +258,7 @@ public class LevelDBEntityStoreMixin
                         {
                             super.close();
                             String jsonState = toString();
-                            writeBatch.put( ref.identity().getBytes( charset ), jsonState.getBytes( charset ) );
+                            writeBatch.put( ref.identity().toString().getBytes( charset ), jsonState.getBytes( charset ) );
                         }
 
                     };
@@ -277,7 +277,7 @@ public class LevelDBEntityStoreMixin
                         {
                             super.close();
                             String jsonState = toString();
-                            writeBatch.put( ref.identity().getBytes( charset ), jsonState.getBytes( charset ) );
+                            writeBatch.put( ref.identity().toString().getBytes( charset ), jsonState.getBytes( charset ) );
                         }
 
                     };
@@ -287,7 +287,7 @@ public class LevelDBEntityStoreMixin
                 public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor )
                     throws EntityNotFoundException
                 {
-                    writeBatch.delete( ref.identity().getBytes( charset ) );
+                    writeBatch.delete( ref.identity().toString().getBytes( charset ) );
                 }
 
             } );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/assembly/LevelDBEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/assembly/LevelDBEntityStoreAssembler.java b/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/assembly/LevelDBEntityStoreAssembler.java
index b54b767..032da7c 100644
--- a/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/assembly/LevelDBEntityStoreAssembler.java
+++ b/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/assembly/LevelDBEntityStoreAssembler.java
@@ -41,7 +41,7 @@ public class LevelDBEntityStoreAssembler
         ServiceDeclaration service = module.services( LevelDBEntityStoreService.class ).visibleIn( visibility() );
         if( hasIdentity() )
         {
-            service.identifiedBy( identity() );
+            service.identifiedBy( identity().toString() );
         }
         if( hasConfig() )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-memory/src/main/java/org/apache/zest/entitystore/memory/assembly/MemoryEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-memory/src/main/java/org/apache/zest/entitystore/memory/assembly/MemoryEntityStoreAssembler.java b/extensions/entitystore-memory/src/main/java/org/apache/zest/entitystore/memory/assembly/MemoryEntityStoreAssembler.java
index d6b09d1..ddeaa10 100644
--- a/extensions/entitystore-memory/src/main/java/org/apache/zest/entitystore/memory/assembly/MemoryEntityStoreAssembler.java
+++ b/extensions/entitystore-memory/src/main/java/org/apache/zest/entitystore/memory/assembly/MemoryEntityStoreAssembler.java
@@ -40,7 +40,7 @@ public class MemoryEntityStoreAssembler
         ServiceDeclaration service = module.services( MemoryEntityStoreService.class ).visibleIn( visibility() );
         if( hasIdentity() )
         {
-            service.identifiedBy( identity() );
+            service.identifiedBy( identity().toString() );
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreMixin.java b/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreMixin.java
index 9786586..93f5af0 100644
--- a/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreMixin.java
+++ b/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreMixin.java
@@ -236,7 +236,7 @@ public class MongoMapEntityStoreMixin
                         DBObject bsonState = (DBObject) JSON.parse( jsonState );
 
                         BasicDBObject entity = new BasicDBObject();
-                        entity.put( IDENTITY_COLUMN, ref.identity() );
+                        entity.put( IDENTITY_COLUMN, ref.identity().toString() );
                         entity.put( STATE_COLUMN, bsonState );
                         entities.insert( entity, writeConcern );
                     }
@@ -258,7 +258,7 @@ public class MongoMapEntityStoreMixin
                         DBObject bsonState = (DBObject) JSON.parse( toString() );
 
                         BasicDBObject entity = new BasicDBObject();
-                        entity.put( IDENTITY_COLUMN, ref.identity() );
+                        entity.put( IDENTITY_COLUMN, ref.identity().toString() );
                         entity.put( STATE_COLUMN, bsonState );
                         entities.update( byIdentity( ref ), entity, false, false, writeConcern );
                     }
@@ -312,6 +312,6 @@ public class MongoMapEntityStoreMixin
 
     private DBObject byIdentity( EntityReference entityReference )
     {
-        return new BasicDBObject( IDENTITY_COLUMN, entityReference.identity() );
+        return new BasicDBObject( IDENTITY_COLUMN, entityReference.identity().toString() );
     }
 }


Mime
View raw message