polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [26/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:07 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
index ccfba1b..86f00cc 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityInstance.java
@@ -32,7 +32,7 @@ import org.apache.zest.api.composite.CompositeInstance;
 import org.apache.zest.api.constraint.ConstraintViolationException;
 import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
+import org.apache.zest.api.identity.HasIdentity;
 import org.apache.zest.api.entity.LifecycleException;
 import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.unitofwork.NoSuchEntityException;
@@ -59,7 +59,7 @@ public final class EntityInstance
     private final EntityComposite proxy;
     private final UnitOfWork uow;
     private final EntityModel entityModel;
-    private final EntityReference identity;
+    private final EntityReference reference;
     private final EntityState entityState;
 
     private Object[] mixins;
@@ -72,7 +72,7 @@ public final class EntityInstance
     {
         this.uow = uow;
         this.entityModel = entityModel;
-        this.identity = entityState.identity();
+        this.reference = entityState.entityReference();
         this.entityState = entityState;
 
         proxy = (EntityComposite) entityModel.newProxy( this );
@@ -85,9 +85,9 @@ public final class EntityInstance
         return entityModel.invoke( this, this.proxy, method, args );
     }
 
-    public EntityReference identity()
+    public EntityReference reference()
     {
-        return identity;
+        return reference;
     }
 
     @Override
@@ -201,7 +201,7 @@ public final class EntityInstance
 
         if( status() == EntityStatus.REMOVED )
         {
-            throw new NoSuchEntityException( identity, entityModel.types(), unitOfWork().usecase() );
+            throw new NoSuchEntityException(reference, entityModel.types(), unitOfWork().usecase() );
         }
 
         mixins = entityModel.newMixinHolder();
@@ -211,7 +211,7 @@ public final class EntityInstance
     @Override
     public int hashCode()
     {
-        return identity.hashCode();
+        return reference.hashCode();
     }
 
     @Override
@@ -219,8 +219,8 @@ public final class EntityInstance
     {
         try
         {
-            Identity other = ( (Identity) o );
-            return other != null && other.identity().get().equals( identity.identity() );
+            HasIdentity other = ( (HasIdentity) o );
+            return other != null && other.identity().get().equals( reference.identity() );
         }
         catch( ClassCastException e )
         {
@@ -237,7 +237,7 @@ public final class EntityInstance
         }
         else
         {
-            return identity.toString();
+            return reference.toString();
         }
     }
 
@@ -308,7 +308,7 @@ public final class EntityInstance
         catch( ConstraintViolationException e )
         {
             List<Class<?>> entityModelList = entityModel.types().collect( toList() );
-            throw new ConstraintViolationException( identity.identity(),
+            throw new ConstraintViolationException( reference.identity(),
                                                     entityModelList,
                                                     e.mixinTypeName(),
                                                     e.methodName(),

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
index e0cea54..d08a395 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/entity/EntityModel.java
@@ -28,7 +28,6 @@ import org.apache.zest.api.composite.CompositeInstance;
 import org.apache.zest.api.constraint.ConstraintViolationException;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
 import org.apache.zest.api.entity.Queryable;
 import org.apache.zest.api.property.PropertyDescriptor;
 import org.apache.zest.api.property.StateHolder;
@@ -44,25 +43,14 @@ import org.apache.zest.spi.entitystore.EntityStoreException;
 import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
 import org.apache.zest.spi.module.ModuleSpi;
 
+import static org.apache.zest.api.identity.HasIdentity.IDENTITY_METHOD;
+
 /**
  * JAVADOC
  */
 public final class EntityModel extends CompositeModel
     implements EntityDescriptor
 {
-    private static final Method IDENTITY_METHOD;
-
-    static
-    {
-        try
-        {
-            IDENTITY_METHOD = Identity.class.getMethod( "identity" );
-        }
-        catch( NoSuchMethodException e )
-        {
-            throw new InternalError( "Zest Core Runtime codebase is corrupted. Contact Zest team: ModuleUnitOfWork" );
-        }
-    }
 
     private final boolean queryable;
 
@@ -116,23 +104,23 @@ public final class EntityModel extends CompositeModel
         return ( (EntityMixinsModel) mixinsModel ).newMixin( entityInstance, entityState, mixins, method );
     }
 
-    public EntityState newEntityState( EntityStoreUnitOfWork store, EntityReference identity )
+    public EntityState newEntityState( EntityStoreUnitOfWork store, EntityReference reference )
         throws ConstraintViolationException, EntityStoreException
     {
         try
         {
             // New EntityState
-            EntityState entityState = store.newEntityState( identity, this );
+            EntityState entityState = store.newEntityState( reference, this );
 
-            // Set identity property
+            // Set reference property
             PropertyDescriptor persistentPropertyDescriptor = state().propertyModelFor( IDENTITY_METHOD );
-            entityState.setPropertyValue( persistentPropertyDescriptor.qualifiedName(), identity.identity() );
+            entityState.setPropertyValue( persistentPropertyDescriptor.qualifiedName(), reference.identity() );
 
             return entityState;
         }
         catch( EntityAlreadyExistsException e )
         {
-            throw new EntityCompositeAlreadyExistsException( identity );
+            throw new EntityCompositeAlreadyExistsException( reference );
         }
         catch( EntityStoreException e )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java
index aeda5dd..4caf929 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/injection/provider/ThisInjectionProviderFactory.java
@@ -97,7 +97,7 @@ public final class ThisInjectionProviderFactory
                 }
                 else
                 {
-                    interfaces = Iterables.toArray( Class.class, Iterables.<Class>cast( types ) );
+                    interfaces = Iterables.toArray( Class.class, Iterables.cast( types ) );
                     proxyClass = ProxyGenerator.createProxyClass( mainType.getClassLoader(), interfaces );
                 }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
index f514df5..2bcfc54 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceModel.java
@@ -24,6 +24,7 @@ import java.lang.reflect.Proxy;
 import java.util.stream.Stream;
 import org.apache.zest.api.common.MetaInfo;
 import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.identity.Identity;
 import org.apache.zest.api.service.ImportedServiceDescriptor;
 import org.apache.zest.api.service.ServiceImporter;
 import org.apache.zest.api.service.ServiceImporterException;
@@ -44,7 +45,7 @@ public final class ImportedServiceModel
     private final Visibility visibility;
     @SuppressWarnings( "raw" )
     private final Class<? extends ServiceImporter> serviceImporter;
-    private final String identity;
+    private final Identity identity;
     private final boolean importOnStartup;
     private final MetaInfo metaInfo;
     private final ActivatorsModel<?> activatorsModel;
@@ -55,7 +56,7 @@ public final class ImportedServiceModel
                                  Class serviceType,
                                  Visibility visibility,
                                  Class<? extends ServiceImporter> serviceImporter,
-                                 String identity,
+                                 Identity identity,
                                  boolean importOnStartup,
                                  MetaInfo metaInfo,
                                  ActivatorsModel<?> activatorsModel,
@@ -117,7 +118,7 @@ public final class ImportedServiceModel
     }
 
     @Override
-    public String identity()
+    public Identity identity()
     {
         return identity;
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
index 2254563..bdb7919 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ImportedServiceReferenceInstance.java
@@ -25,6 +25,7 @@ import org.apache.zest.api.activation.ActivationEventListener;
 import org.apache.zest.api.activation.ActivationException;
 import org.apache.zest.api.activation.PassivationException;
 import org.apache.zest.api.composite.ModelDescriptor;
+import org.apache.zest.api.identity.Identity;
 import org.apache.zest.api.service.ServiceImporterException;
 import org.apache.zest.api.service.ServiceReference;
 import org.apache.zest.api.service.ServiceUnavailableException;
@@ -58,7 +59,7 @@ public final class ImportedServiceReferenceInstance<T>
     }
 
     @Override
-    public String identity()
+    public Identity identity()
     {
         return serviceModel.identity();
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java
index 0afa26b..a5c0f14 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceModel.java
@@ -20,7 +20,6 @@
 package org.apache.zest.runtime.service;
 
 import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.util.HashMap;
 import java.util.List;
@@ -29,7 +28,8 @@ import java.util.function.Predicate;
 import org.apache.zest.api.common.MetaInfo;
 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.identity.Identity;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.service.ServiceDescriptor;
@@ -57,21 +57,7 @@ import static org.apache.zest.runtime.legacy.Specifications.translate;
 public final class ServiceModel extends CompositeModel
     implements ServiceDescriptor
 {
-    private static Method identityMethod;
-
-    static
-    {
-        try
-        {
-            identityMethod = Identity.class.getMethod( "identity" );
-        }
-        catch( NoSuchMethodException e )
-        {
-            e.printStackTrace();
-        }
-    }
-
-    private final String identity;
+    private final Identity identity;
     private final boolean instantiateOnStartup;
     private final ActivatorsModel<?> activatorsModel;
     private final Class configurationType;
@@ -84,7 +70,7 @@ public final class ServiceModel extends CompositeModel
                          MixinsModel mixinsModel,
                          StateModel stateModel,
                          CompositeMethodsModel compositeMethodsModel,
-                         String identity,
+                         Identity identity,
                          boolean instantiateOnStartup
     )
     {
@@ -105,7 +91,7 @@ public final class ServiceModel extends CompositeModel
     }
 
     @Override
-    public String identity()
+    public Identity identity()
     {
         return identity;
     }
@@ -151,7 +137,7 @@ public final class ServiceModel extends CompositeModel
         Map<AccessibleObject, Property<?>> properties = new HashMap<>();
         stateModel.properties().forEach( propertyModel -> {
             Object initialValue = propertyModel.initialValue( module );
-            if( propertyModel.accessor().equals( identityMethod ) )
+            if( propertyModel.accessor().equals( HasIdentity.IDENTITY_METHOD ) )
             {
                 initialValue = identity;
             }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
index de63df5..4ca9a74 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/service/ServiceReferenceInstance.java
@@ -29,6 +29,7 @@ import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.composite.CompositeDescriptor;
 import org.apache.zest.api.composite.CompositeInstance;
 import org.apache.zest.api.composite.ModelDescriptor;
+import org.apache.zest.api.identity.Identity;
 import org.apache.zest.api.property.StateHolder;
 import org.apache.zest.api.service.ServiceDescriptor;
 import org.apache.zest.api.service.ServiceImporterException;
@@ -67,7 +68,7 @@ public final class ServiceReferenceInstance<T>
     }
 
     @Override
-    public String identity()
+    public Identity identity()
     {
         return serviceModel.identity();
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
index b9858c8..96278ed 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleInstance.java
@@ -28,7 +28,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.function.Function;
-import java.util.stream.Collector;
 import java.util.stream.Collectors;
 import org.apache.zest.api.activation.Activation;
 import org.apache.zest.api.activation.ActivationEventListener;
@@ -43,7 +42,7 @@ import org.apache.zest.api.composite.TransientBuilder;
 import org.apache.zest.api.composite.TransientBuilderFactory;
 import org.apache.zest.api.composite.TransientDescriptor;
 import org.apache.zest.api.entity.EntityReference;
-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.object.NoSuchObjectException;
 import org.apache.zest.api.object.ObjectDescriptor;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java
index 6591c4c..883faec 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java
@@ -51,7 +51,7 @@ public final class BuilderEntityState
     }
 
     @Override
-    public EntityReference identity()
+    public EntityReference entityReference()
     {
         return reference;
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
index a070e3f..334f263 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityBuilderInstance.java
@@ -19,12 +19,11 @@
  */
 package org.apache.zest.runtime.unitofwork;
 
-import org.apache.zest.api.common.QualifiedName;
 import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
 import org.apache.zest.api.entity.LifecycleException;
+import org.apache.zest.api.identity.Identity;
 import org.apache.zest.runtime.composite.FunctionStateResolver;
 import org.apache.zest.runtime.entity.EntityInstance;
 import org.apache.zest.runtime.entity.EntityModel;
@@ -32,6 +31,8 @@ import org.apache.zest.spi.entity.EntityState;
 import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
 import org.apache.zest.spi.module.ModuleSpi;
 
+import static org.apache.zest.api.identity.HasIdentity.IDENTITY_STATE_NAME;
+
 /**
  * Implementation of EntityBuilder. Maintains an instance of the entity which
  * will not have its state validated until it is created by calling newInstance().
@@ -39,33 +40,19 @@ import org.apache.zest.spi.module.ModuleSpi;
 public final class EntityBuilderInstance<T>
     implements EntityBuilder<T>
 {
-    private static final QualifiedName IDENTITY_STATE_NAME;
-
     private final EntityModel model;
     private final ModuleUnitOfWork uow;
     private final EntityStoreUnitOfWork store;
-    private String identity;
+    private Identity identity;
 
     private final BuilderEntityState entityState;
     private final EntityInstance prototypeInstance;
 
-    static
-    {
-        try
-        {
-            IDENTITY_STATE_NAME = QualifiedName.fromAccessor( Identity.class.getMethod( "identity" ) );
-        }
-        catch( NoSuchMethodException e )
-        {
-            throw new InternalError( "Zest Core Runtime codebase is corrupted. Contact Zest team: EntityBuilderInstance" );
-        }
-    }
-
     public EntityBuilderInstance(
         EntityDescriptor model,
         ModuleUnitOfWork uow,
         EntityStoreUnitOfWork store,
-        String identity
+        Identity identity
     )
     {
         this( model, uow, store, identity, null );
@@ -75,7 +62,7 @@ public final class EntityBuilderInstance<T>
         EntityDescriptor model,
         ModuleUnitOfWork uow,
         EntityStoreUnitOfWork store,
-        String identity,
+        Identity identity,
         FunctionStateResolver stateResolver
     )
     {
@@ -83,7 +70,7 @@ public final class EntityBuilderInstance<T>
         this.uow = uow;
         this.store = store;
         this.identity = identity;
-        EntityReference reference = new EntityReference( identity );
+        EntityReference reference = EntityReference.create( identity );
         entityState = new BuilderEntityState( model, reference );
         this.model.initState( model.module(), entityState );
         if( stateResolver != null )
@@ -116,9 +103,9 @@ public final class EntityBuilderInstance<T>
     {
         checkValid();
 
-        // Figure out whether to use given or generated identity
-        String identity = (String) entityState.propertyValueOf( IDENTITY_STATE_NAME );
-        EntityReference entityReference = EntityReference.parseEntityReference( identity );
+        // Figure out whether to use given or generated reference
+        Identity identity = (Identity) entityState.propertyValueOf( IDENTITY_STATE_NAME );
+        EntityReference entityReference = EntityReference.create( identity );
         EntityState newEntityState = model.newEntityState( store, entityReference );
 
         prototypeInstance.invokeCreate();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityStateStore.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityStateStore.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityStateStore.java
index a301064..91726a6 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityStateStore.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/EntityStateStore.java
@@ -34,6 +34,6 @@ final class EntityStateStore
     @Override
     public String toString()
     {
-        return state.identity().toString();
+        return state.entityReference().toString();
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
index 222d959..153d546 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
@@ -35,15 +35,16 @@ import org.apache.zest.api.association.AssociationDescriptor;
 import org.apache.zest.api.association.AssociationStateHolder;
 import org.apache.zest.api.association.ManyAssociation;
 import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.common.QualifiedName;
 import org.apache.zest.api.composite.Composite;
 import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.entity.IdentityGenerator;
 import org.apache.zest.api.entity.LifecycleException;
+import org.apache.zest.api.identity.HasIdentity;
+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.Uses;
@@ -86,7 +87,7 @@ import org.apache.zest.spi.query.EntityFinderException;
 import org.apache.zest.spi.query.QueryBuilderSPI;
 import org.apache.zest.spi.query.QuerySource;
 
-import static org.apache.zest.api.entity.EntityReference.parseEntityReference;
+import static org.apache.zest.api.identity.HasIdentity.IDENTITY_STATE_NAME;
 
 /**
  * JAVADOC
@@ -94,20 +95,6 @@ import static org.apache.zest.api.entity.EntityReference.parseEntityReference;
 public class ModuleUnitOfWork
     implements UnitOfWork
 {
-    private static final QualifiedName IDENTITY_STATE_NAME;
-
-    static
-    {
-        try
-        {
-            IDENTITY_STATE_NAME = QualifiedName.fromAccessor( Identity.class.getMethod( "identity" ) );
-        }
-        catch( NoSuchMethodException e )
-        {
-            throw new InternalError( "Zest Core Runtime codebase is corrupted. Contact Zest team: ModuleUnitOfWork" );
-        }
-    }
-
     @Uses
     private UnitOfWorkInstance uow;
 
@@ -177,7 +164,7 @@ public class ModuleUnitOfWork
     }
 
     @Override
-    public <T> T newEntity( Class<T> type, String identity )
+    public <T> T newEntity( Class<T> type, Identity identity )
         throws NoSuchEntityTypeException, LifecycleException
     {
         return newEntityBuilder( type, identity ).newInstance();
@@ -191,7 +178,7 @@ public class ModuleUnitOfWork
     }
 
     @Override
-    public <T> EntityBuilder<T> newEntityBuilder( Class<T> type, String identity )
+    public <T> EntityBuilder<T> newEntityBuilder( Class<T> type, Identity identity )
         throws NoSuchEntityTypeException
     {
         EntityDescriptor model = module.typeLookup().lookupEntityModel( type );
@@ -243,7 +230,7 @@ public class ModuleUnitOfWork
 
     @Override
     public <T> EntityBuilder<T> newEntityBuilderWithState(
-        Class<T> type, String identity,
+        Class<T> type, Identity identity,
         Function<PropertyDescriptor, Object> propertyFunction,
         Function<AssociationDescriptor, EntityReference> associationFunction,
         Function<AssociationDescriptor, Iterable<EntityReference>> manyAssociationFunction,
@@ -273,14 +260,14 @@ public class ModuleUnitOfWork
 
         if( identity == null )
         {
-            // Use identity from StateResolver if available
+            // Use reference from StateResolver if available
             PropertyModel identityModel = (PropertyModel) model
                 .state()
                 .findPropertyModelByQualifiedName( IDENTITY_STATE_NAME );
-            identity = (String) stateResolver.getPropertyState( identityModel );
-            if( identity == null )
+            String propertyState = (String) stateResolver.getPropertyState(identityModel);
+            if( propertyState == null )
             {
-                // Generate identity
+                // Generate reference
                 IdentityGenerator idGen = moduleSpi.identityGenerator();
                 if( idGen == null )
                 {
@@ -289,6 +276,10 @@ public class ModuleUnitOfWork
                 }
                 identity = idGen.generate( model.types().findFirst().orElse( null ) );
             }
+            else
+            {
+                identity = new StringIdentity(propertyState);
+            }
         }
 
         return new EntityBuilderInstance<>( model,
@@ -299,7 +290,7 @@ public class ModuleUnitOfWork
     }
 
     @Override
-    public <T> T get( Class<T> type, String identity )
+    public <T> T get( Class<T> type, Identity identity )
         throws NoSuchEntityTypeException, NoSuchEntityException
     {
         Iterable<? extends EntityDescriptor> models = module.typeLookup().lookupEntityModels( type );
@@ -309,7 +300,7 @@ public class ModuleUnitOfWork
             throw new NoSuchEntityTypeException( type.getName(), module.name(), module.typeLookup() );
         }
 
-        return uow.get( parseEntityReference( identity ), this, models, type );
+        return uow.get( EntityReference.create( identity ), this, models, type );
     }
 
     @Override
@@ -321,7 +312,7 @@ public class ModuleUnitOfWork
         EntityInstance compositeInstance = EntityInstance.entityInstanceOf( entityComposite );
         EntityDescriptor model = compositeInstance.entityModel();
         Class<T> type = (Class<T>) compositeInstance.types().findFirst().orElse( null );
-        return uow.get( compositeInstance.identity(), this, Collections.singletonList( model ), type );
+        return uow.get( compositeInstance.reference(), this, Collections.singletonList( model ), type );
     }
 
     @Override
@@ -337,7 +328,7 @@ public class ModuleUnitOfWork
         if( compositeInstance.status() == EntityStatus.NEW )
         {
             compositeInstance.remove( this );
-            uow.remove( compositeInstance.identity() );
+            uow.remove( compositeInstance.reference() );
         }
         else if( compositeInstance.status() == EntityStatus.LOADED || compositeInstance.status() == EntityStatus.UPDATED )
         {
@@ -345,7 +336,7 @@ public class ModuleUnitOfWork
         }
         else
         {
-            throw new NoSuchEntityException( compositeInstance.identity(), compositeInstance.types(), usecase() );
+            throw new NoSuchEntityException( compositeInstance.reference(), compositeInstance.types(), usecase() );
         }
     }
 
@@ -440,7 +431,7 @@ public class ModuleUnitOfWork
     }
 
     @Override
-    public <T extends Identity> T toValue( Class<T> primaryType, T entityComposite )
+    public <T extends HasIdentity> T toValue(Class<T> primaryType, T entityComposite )
     {
         Function<PropertyDescriptor, Object> propertyFunction = new ToValuePropertyMappingFunction( entityComposite );
         Function<AssociationDescriptor, EntityReference> assocationFunction = new ToValueAssociationMappingFunction<>( entityComposite );
@@ -454,7 +445,7 @@ public class ModuleUnitOfWork
     }
 
     @Override
-    public <T extends Identity> Map<String, T> toValueMap( NamedAssociation<T> association )
+    public <T extends HasIdentity> Map<String, T> toValueMap(NamedAssociation<T> association )
     {
         @SuppressWarnings( "unchecked" )
         Class<T> primaryType = (Class<T>) api.associationDescriptorFor( association ).type();
@@ -467,7 +458,7 @@ public class ModuleUnitOfWork
     }
 
     @Override
-    public <T extends Identity> List<T> toValueList( ManyAssociation<T> association )
+    public <T extends HasIdentity> List<T> toValueList(ManyAssociation<T> association )
     {
         @SuppressWarnings( "unchecked" )
         Class<T> primaryType = (Class<T>) api.associationDescriptorFor( association ).type();
@@ -480,7 +471,7 @@ public class ModuleUnitOfWork
     }
 
     @Override
-    public <T extends Identity> Set<T> toValueSet( ManyAssociation<T> association )
+    public <T extends HasIdentity> Set<T> toValueSet(ManyAssociation<T> association )
     {
         @SuppressWarnings( "unchecked" )
         Class<T> primaryType = (Class<T>) api.associationDescriptorFor( association ).type();
@@ -493,17 +484,16 @@ public class ModuleUnitOfWork
     }
 
     @Override
-    public <T extends Identity> T toEntity( Class<T> primaryType, T valueComposite )
+    public <T extends HasIdentity> T toEntity(Class<T> primaryType, T valueComposite )
     {
         Function<PropertyDescriptor, Object> propertyFunction = new ToEntityPropertyMappingFunction<>( valueComposite );
         Function<AssociationDescriptor, EntityReference> assocationFunction = new ToEntityAssociationMappingFunction<>( valueComposite );
         Function<AssociationDescriptor, Iterable<EntityReference>> manyAssocFunction = new ToEntityManyAssociationMappingFunction<>( valueComposite );
         Function<AssociationDescriptor, Map<String, EntityReference>> namedAssocFunction = new ToEntityNameAssociationMappingFunction<>( valueComposite );
 
-        String identity = valueComposite.identity().get();
         try
         {
-            T entity = get( primaryType, identity );
+            T entity = get( primaryType, valueComposite.identity().get() );
             // If successful, then this entity is to by modified.
             EntityInstance instance = EntityInstance.entityInstanceOf( (EntityComposite) entity );
             EntityState state = instance.entityState();
@@ -518,7 +508,7 @@ public class ModuleUnitOfWork
         catch( NoSuchEntityException e )
         {
             EntityBuilder<T> entityBuilder = newEntityBuilderWithState( primaryType,
-                                                                        identity,
+                                                                        valueComposite.identity().get(),
                                                                         propertyFunction,
                                                                         assocationFunction,
                                                                         manyAssocFunction,

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
index a294244..d7ffa9d 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
@@ -122,7 +122,7 @@ public final class UnitOfWorkInstance
         return uow;
     }
 
-    public <T> T get( EntityReference identity,
+    public <T> T get( EntityReference reference,
                       UnitOfWork uow,
                       Iterable<? extends EntityDescriptor> potentialModels,
                       Class<T> mixinType
@@ -131,7 +131,7 @@ public final class UnitOfWorkInstance
     {
         checkOpen();
 
-        EntityInstance entityInstance = instanceCache.get( identity );
+        EntityInstance entityInstance = instanceCache.get( reference );
         if( entityInstance == null )
         {   // Not yet in cache
 
@@ -146,7 +146,7 @@ public final class UnitOfWorkInstance
                 EntityStoreUnitOfWork storeUow = getEntityStoreUnitOfWork( store );
                 try
                 {
-                    entityState = storeUow.entityStateOf( potentialModel.module(), identity );
+                    entityState = storeUow.entityStateOf( potentialModel.module(), reference );
                 }
                 catch( EntityNotFoundException e )
                 {
@@ -164,7 +164,7 @@ public final class UnitOfWorkInstance
                 // Check if state was found
                 if( entityState == null )
                 {
-                    throw new NoSuchEntityException( identity, mixinType, usecase );
+                    throw new NoSuchEntityException( reference, mixinType, usecase );
                 }
                 else
                 {
@@ -173,14 +173,14 @@ public final class UnitOfWorkInstance
             }
             // Create instance
             entityInstance = new EntityInstance( uow, model, entityState );
-            instanceCache.put( identity, entityInstance );
+            instanceCache.put( reference, entityInstance );
         }
         else
         {
             // Check if it has been removed
             if( entityInstance.status() == EntityStatus.REMOVED )
             {
-                throw new NoSuchEntityException( identity, mixinType, usecase );
+                throw new NoSuchEntityException( reference, mixinType, usecase );
             }
         }
 
@@ -228,7 +228,7 @@ public final class UnitOfWorkInstance
                             {
                                 prunedInstances = new ArrayList<>();
                             }
-                            prunedInstances.add( entityInstance.identity() );
+                            prunedInstances.add( entityInstance.reference() );
                         }
                     }
                     if( prunedInstances != null )
@@ -336,7 +336,7 @@ public final class UnitOfWorkInstance
 
     public void addEntity( EntityInstance instance )
     {
-        instanceCache.put( instance.identity(), instance );
+        instanceCache.put( instance.reference(), instance );
     }
 
     private List<StateCommitter> applyChanges()
@@ -364,7 +364,7 @@ public final class UnitOfWorkInstance
                     for( EntityReference modifiedEntityIdentity : modifiedEntityIdentities )
                     {
                         instanceCache.values().stream()
-                            .filter( instance -> instance.identity().equals( modifiedEntityIdentity ) )
+                            .filter( instance -> instance.reference().equals( modifiedEntityIdentity ) )
                             .forEach( instance -> modifiedEntities.put( instance.<EntityComposite>proxy(), instance ) );
                     }
                     throw new ConcurrentEntityModificationException( modifiedEntities, usecase );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/api/common/RemovalTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/api/common/RemovalTest.java b/core/runtime/src/test/java/org/apache/zest/api/common/RemovalTest.java
index 18d662b..ea100e1 100644
--- a/core/runtime/src/test/java/org/apache/zest/api/common/RemovalTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/api/common/RemovalTest.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.api.common;
 
+import org.apache.zest.api.identity.StringIdentity;
 import org.junit.Test;
 import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.entity.EntityComposite;
@@ -47,7 +48,7 @@ public class RemovalTest
         throws Exception
     {
         UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
-        EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, "123" );
+        EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, new StringIdentity( "123" ) );
         builder.instance().test().set( "habba" );
         TestEntity test = builder.newInstance();
         uow.remove( test );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/bootstrap/ApplicationAssemblerTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/bootstrap/ApplicationAssemblerTest.java b/core/runtime/src/test/java/org/apache/zest/bootstrap/ApplicationAssemblerTest.java
index eadf397..7dad851 100644
--- a/core/runtime/src/test/java/org/apache/zest/bootstrap/ApplicationAssemblerTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/bootstrap/ApplicationAssemblerTest.java
@@ -19,6 +19,8 @@
  */
 package org.apache.zest.bootstrap;
 
+import org.apache.zest.api.identity.IdentityGenerator;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.junit.Assert;
 import org.junit.Test;
 import org.apache.zest.api.common.Visibility;
@@ -75,6 +77,10 @@ public class ApplicationAssemblerTest
                 if( visited instanceof ServiceDescriptor )
                 {
                     ServiceDescriptor serviceDescriptor = (ServiceDescriptor) visited;
+                    if( serviceDescriptor.hasType( UnitOfWorkFactory.class ) || serviceDescriptor.hasType( IdentityGenerator.class ) )
+                    {
+                        return false;
+                    }
                     Assert.assertTrue( serviceDescriptor.isInstantiateOnStartup() );
                     Assert.assertTrue( serviceDescriptor.visibility() == Visibility.layer );
                     return false;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java
index e460e0e..dcfc5e3 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi377/InterfaceCollisionWithRelatedReturnTypesTest.java
@@ -19,11 +19,12 @@
  */
 package org.apache.zest.regression.qi377;
 
+import org.apache.zest.api.identity.HasIdentity;
+import org.apache.zest.api.identity.Identity;
 import org.junit.Test;
 import org.apache.zest.api.association.Association;
 import org.apache.zest.api.association.ManyAssociation;
 import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.entity.Identity;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
@@ -52,12 +53,12 @@ public class InterfaceCollisionWithRelatedReturnTypesTest
     public void shouldBeAbleToSetNameToTheCompany()
         throws UnitOfWorkCompletionException
     {
-        String identity;
+        Identity identity;
         try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
         {
             Company startUp = uow.newEntity( Company.class );
             startUp.name().set( "Acme" );
-            identity = ( (Identity) startUp ).identity().get();
+            identity = ((HasIdentity) startUp).identity().get();
             uow.complete();
         }
         try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
@@ -77,14 +78,14 @@ public class InterfaceCollisionWithRelatedReturnTypesTest
     public void shouldBeAbleToSetLeadToTheCompany()
         throws UnitOfWorkCompletionException
     {
-        String identity;
+        Identity identity;
         try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
         {
             Company startUp = uow.newEntity( Company.class );
             Employee niclas = uow.newEntity( Employee.class );
 
             startUp.lead().set( niclas );
-            identity = ( (Identity) startUp ).identity().get();
+            identity = ((HasIdentity) startUp).identity().get();
 
             uow.complete();
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/regression/qi377/SetAssociationInSideEffectTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi377/SetAssociationInSideEffectTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi377/SetAssociationInSideEffectTest.java
index 3d444d7..c9c312d 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi377/SetAssociationInSideEffectTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi377/SetAssociationInSideEffectTest.java
@@ -22,6 +22,7 @@ package org.apache.zest.regression.qi377;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.reflect.Method;
+import org.apache.zest.api.identity.StringIdentity;
 import org.junit.Test;
 import org.apache.zest.api.association.Association;
 import org.apache.zest.api.common.AppliesTo;
@@ -60,14 +61,14 @@ public class SetAssociationInSideEffectTest
     {
         try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Purchase Steinway" ) ) )
         {
-            Pianist chris = uow.newEntity( Pianist.class, "Chris" );
-            Steinway modelD = uow.newEntity( Steinway.class, "ModelD-274" );
+            Pianist chris = uow.newEntity( Pianist.class, new StringIdentity( "Chris" ) );
+            Steinway modelD = uow.newEntity( Steinway.class, new StringIdentity( "ModelD-274" ) );
 
             assertThat( modelD.owner().get(), is( nullValue() ) );
 
             chris.purchase( modelD );
 
-            assertThat( modelD.owner().get(), is( theInstance( (Owner) chris ) ) );
+            assertThat( modelD.owner().get(), is( theInstance( chris ) ) );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
index 6058925..b90b1dc 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
@@ -19,8 +19,10 @@
  */
 package org.apache.zest.regression.qi377;
 
+import org.apache.zest.api.identity.HasIdentity;
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.junit.Test;
-import org.apache.zest.api.entity.Identity;
 import org.apache.zest.api.association.Association;
 import org.apache.zest.api.association.ManyAssociation;
 import org.apache.zest.api.common.Optional;
@@ -33,6 +35,9 @@ import org.apache.zest.test.AbstractZestTest;
 public class ValueCollisionWithRelatedReturnTypesTest
     extends AbstractZestTest
 {
+
+    public static final Identity NICLAS = new StringIdentity( "niclas" );
+
     @Override
     public void assemble( ModuleAssembly module )
         throws AssemblyException
@@ -53,7 +58,7 @@ public class ValueCollisionWithRelatedReturnTypesTest
     {
         Company startUp = valueBuilderFactory.newValue( Company.class );
         ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
-        builder.prototype().identity().set( "niclas" );
+        builder.prototype().identity().set(NICLAS);
         Employee niclas = builder.newInstance();
         startUp.lead().set( niclas );
     }
@@ -63,7 +68,7 @@ public class ValueCollisionWithRelatedReturnTypesTest
     {
         SalesTeam startUp = valueBuilderFactory.newValue( SalesTeam.class );
         ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
-        builder.prototype().identity().set( "niclas" );
+        builder.prototype().identity().set(NICLAS);
         Employee niclas = builder.newInstance();
         startUp.lead().set( niclas );
     }
@@ -73,7 +78,7 @@ public class ValueCollisionWithRelatedReturnTypesTest
     {
         ResearchTeam startUp = valueBuilderFactory.newValue( ResearchTeam.class );
         ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
-        builder.prototype().identity().set( "niclas" );
+        builder.prototype().identity().set(NICLAS);
         Employee niclas = builder.newInstance();
         startUp.lead().set( niclas );
     }
@@ -83,7 +88,7 @@ public class ValueCollisionWithRelatedReturnTypesTest
     {
         Company startUp = valueBuilderFactory.newValue( Company.class );
         ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
-        builder.prototype().identity().set( "niclas" );
+        builder.prototype().identity().set(NICLAS);
         Employee niclas = builder.newInstance();
         startUp.employees().add( niclas );
     }
@@ -93,7 +98,7 @@ public class ValueCollisionWithRelatedReturnTypesTest
     {
         SalesTeam startUp = valueBuilderFactory.newValue( SalesTeam.class );
         ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
-        builder.prototype().identity().set( "niclas" );
+        builder.prototype().identity().set(NICLAS);
         Employee niclas = builder.newInstance();
         startUp.employees().add( niclas );
     }
@@ -103,13 +108,13 @@ public class ValueCollisionWithRelatedReturnTypesTest
     {
         ResearchTeam startUp = valueBuilderFactory.newValue( ResearchTeam.class );
         ValueBuilder<Employee> builder = valueBuilderFactory.newValueBuilder( Employee.class );
-        builder.prototype().identity().set( "niclas" );
+        builder.prototype().identity().set( NICLAS );
         Employee niclas = builder.newInstance();
         startUp.employees().add( niclas );
     }
 
     public interface Employee
-        extends Identity
+        extends HasIdentity
     {
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/regression/qi382/Qi382Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi382/Qi382Test.java b/core/runtime/src/test/java/org/apache/zest/regression/qi382/Qi382Test.java
index 9e2c860..800d241 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi382/Qi382Test.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi382/Qi382Test.java
@@ -19,6 +19,8 @@
  */
 package org.apache.zest.regression.qi382;
 
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.junit.Test;
 import org.apache.zest.api.association.Association;
@@ -45,6 +47,9 @@ import static org.junit.Assert.assertThat;
 public class Qi382Test extends AbstractZestTest
 {
 
+    public static final Identity FERRARI = new StringIdentity( "Ferrari" );
+    public static final Identity NICLAS = new StringIdentity( "Niclas" );
+
     @Override
     public void assemble( ModuleAssembly module )
         throws AssemblyException
@@ -60,14 +65,14 @@ public class Qi382Test extends AbstractZestTest
     {
         try( UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork() )
         {
-            Car car = unitOfWork.newEntity( Car.class, "Ferrari" );
+            Car car = unitOfWork.newEntity( Car.class, FERRARI);
             unitOfWork.complete();
         }
         try( UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork() )
         {
-            Car car = unitOfWork.get( Car.class, "Ferrari" );
+            Car car = unitOfWork.get( Car.class, FERRARI);
             assertThat( car, notNullValue() );
-            Person p = unitOfWork.get( Person.class, "Niclas" );
+            Person p = unitOfWork.get( Person.class, NICLAS);
             assertThat( p, notNullValue() );
             assertThat( p.car().get(), equalTo( car ) );
         }
@@ -90,7 +95,7 @@ public class Qi382Test extends AbstractZestTest
                 throws LifecycleException
             {
                 UnitOfWork unitOfWork = uowf.currentUnitOfWork();
-                EntityBuilder<Person> builder = unitOfWork.newEntityBuilder( Person.class, "Niclas" );
+                EntityBuilder<Person> builder = unitOfWork.newEntityBuilder( Person.class, NICLAS);
                 builder.instance().car().set( me );
                 builder.newInstance();
             }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/regression/qi383/Qi383Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi383/Qi383Test.java b/core/runtime/src/test/java/org/apache/zest/regression/qi383/Qi383Test.java
index 0603d03..37cd7ce 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi383/Qi383Test.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi383/Qi383Test.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.regression.qi383;
 
+import org.apache.zest.api.identity.StringIdentity;
 import org.junit.Test;
 import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.unitofwork.EntityCompositeAlreadyExistsException;
@@ -48,9 +49,9 @@ public class Qi383Test extends AbstractZestTest
     {
         try( UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork() )
         {
-            unitOfWork.newEntity( Car.class, "Ferrari" );
-            unitOfWork.newEntity( Car.class, "Ford" );
-            unitOfWork.newEntity( Car.class, "Ferrari" );
+            unitOfWork.newEntity( Car.class, new StringIdentity( "Ferrari" ) );
+            unitOfWork.newEntity( Car.class, new StringIdentity( "Ford" ) );
+            unitOfWork.newEntity( Car.class, new StringIdentity( "Ferrari" ) );
             unitOfWork.complete();
         }
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/activation/ImportedServiceActivationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/activation/ImportedServiceActivationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/activation/ImportedServiceActivationTest.java
index 1be02aa..11be6ae 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/activation/ImportedServiceActivationTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/activation/ImportedServiceActivationTest.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.runtime.activation;
 
+import org.apache.zest.api.identity.StringIdentity;
 import org.junit.Before;
 import org.junit.Test;
 import org.apache.zest.api.activation.Activator;
@@ -193,7 +194,7 @@ public class ImportedServiceActivationTest
             {
                 module.importedServices( TestedService.class ).
                         importedBy( ImportedServiceDeclaration.SERVICE_IMPORTER ).
-                        setMetaInfo( "testimporter" ).
+                        setMetaInfo( new StringIdentity( "testimporter" ) ).
                         withActivators( TestedActivator.class ).
                         importOnStartup();
                 module.services( TestedServiceImporterService.class ).identifiedBy( "testimporter" );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationAssignmentTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationAssignmentTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationAssignmentTest.java
index c76d098..3ba2097 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationAssignmentTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/association/AssociationAssignmentTest.java
@@ -23,6 +23,8 @@ package org.apache.zest.runtime.association;
 import org.apache.zest.api.association.Association;
 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.identity.StringIdentity;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.value.ValueSerialization;
 import org.apache.zest.bootstrap.AssemblyException;
@@ -61,8 +63,8 @@ public class AssociationAssignmentTest extends AbstractZestTest
         EntityBuilder<TheMainType> builder = work.newEntityBuilder( TheMainType.class );
         builder.instance().assoc().set( entity1 );
         TheMainType entity2 = builder.newInstance();
-        String id1 = entity1.identity().get();
-        String id2 = entity2.identity().get();
+        Identity id1 = entity1.identity().get();
+        Identity id2 = entity2.identity().get();
         work.complete();
         assertThat(id1, notNullValue());
         assertThat(id2, notNullValue());

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityBuilderWithStateTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityBuilderWithStateTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityBuilderWithStateTest.java
index fa04a99..fddcf53 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityBuilderWithStateTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityBuilderWithStateTest.java
@@ -21,6 +21,7 @@ package org.apache.zest.runtime.entity;
 
 import java.util.Arrays;
 import java.util.Collections;
+import org.apache.zest.api.identity.Identity;
 import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.junit.Test;
 import org.apache.zest.api.association.Association;
@@ -29,7 +30,7 @@ import org.apache.zest.api.association.NamedAssociation;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
+import org.apache.zest.api.identity.HasIdentity;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
@@ -60,7 +61,7 @@ public class EntityBuilderWithStateTest
     public void test()
         throws UnitOfWorkCompletionException
     {
-        final String associatedIdentity;
+        final Identity associatedIdentity;
         try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
         {
             EntityBuilder<SomeEntity> builder = uow.newEntityBuilder( SomeEntity.class );
@@ -83,14 +84,14 @@ public class EntityBuilderWithStateTest
                 descriptor -> {
                     if( "ass".equals( descriptor.qualifiedName().name() ) )
                     {
-                        return EntityReference.parseEntityReference( associatedIdentity );
+                        return EntityReference.create( associatedIdentity );
                     }
                     return null;
                 },
                 descriptor -> {
                     if( "manyAss".equals( descriptor.qualifiedName().name() ) )
                     {
-                        return Arrays.asList( EntityReference.parseEntityReference( associatedIdentity ) );
+                        return Arrays.asList( EntityReference.create( associatedIdentity ) );
                     }
                     return null;
                 },
@@ -99,7 +100,7 @@ public class EntityBuilderWithStateTest
                     {
                         return Collections.singletonMap(
                             "foo",
-                            EntityReference.parseEntityReference( associatedIdentity )
+                            EntityReference.create( associatedIdentity )
                         );
                     }
                     return null;
@@ -114,7 +115,7 @@ public class EntityBuilderWithStateTest
     }
 
     public interface SomeEntity
-        extends Identity
+        extends HasIdentity
     {
         Property<String> prop();
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityTypeTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityTypeTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityTypeTest.java
index 6dc87ba..8b673ed 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityTypeTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityTypeTest.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.runtime.entity;
 
+import org.apache.zest.api.identity.StringIdentity;
 import org.junit.Test;
 import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.entity.EntityComposite;
@@ -39,9 +40,9 @@ public class EntityTypeTest
         UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
         try
         {
-            EntityBuilder<Rst> builder3 = uow.newEntityBuilder( Rst.class, "123" );
-            EntityBuilder<Def> builder2 = uow.newEntityBuilder( Def.class, "456" );
-            EntityBuilder<Abc> builder1 = uow.newEntityBuilder( Abc.class, "789" );
+            EntityBuilder<Rst> builder3 = uow.newEntityBuilder( Rst.class, new StringIdentity( "123" ) );
+            EntityBuilder<Def> builder2 = uow.newEntityBuilder( Def.class, new StringIdentity( "456" ) );
+            EntityBuilder<Abc> builder1 = uow.newEntityBuilder( Abc.class, new StringIdentity( "789" ) );
         }
         finally
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityVisibilityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityVisibilityTest.java
index 1a68721..09574cd 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/entity/EntityVisibilityTest.java
@@ -20,6 +20,8 @@
 
 package org.apache.zest.runtime.entity;
 
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.junit.After;
@@ -46,6 +48,8 @@ import org.apache.zest.test.EntityTestAssembler;
 public class EntityVisibilityTest
 {
 
+    public static final Identity TEST_IDENTITY = new StringIdentity( "123" );
+
     private Energy4Java zest;
     private Module module;
     private Application app;
@@ -183,7 +187,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.moduleApplicationVisible();
         }
         finally
@@ -201,7 +205,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.moduleLayerVisible();
         }
         finally
@@ -219,7 +223,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.moduleModuleVisible();
         }
         finally
@@ -237,7 +241,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.besideApplicationVisible();
         }
         finally
@@ -255,7 +259,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.besideLayerVisible();
         }
         finally
@@ -273,7 +277,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.besideModuleVisible();
         }
         finally
@@ -291,7 +295,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.belowApplicationVisible();
         }
         finally
@@ -309,7 +313,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.belowLayerVisible();
         }
         finally
@@ -327,7 +331,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.belowModuleVisible();
         }
         finally
@@ -345,7 +349,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.aboveApplicationVisible();
         }
         finally
@@ -363,7 +367,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.aboveLayerVisible();
         }
         finally
@@ -381,7 +385,7 @@ public class EntityVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.aboveModuleVisible();
         }
         finally

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/injection/ConstructorInjectionOfThisTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ConstructorInjectionOfThisTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ConstructorInjectionOfThisTest.java
index 490d8cf..6442d1e 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ConstructorInjectionOfThisTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ConstructorInjectionOfThisTest.java
@@ -73,7 +73,6 @@ public class ConstructorInjectionOfThisTest
             public void assemble( ModuleAssembly module )
                 throws AssemblyException
             {
-                module.withDefaultUnitOfWorkFactory();
                 module.values( Does.class ).withMixins( NoopMixin.class ).withConcerns( DoesConcern.class );
             }
         };
@@ -93,7 +92,6 @@ public class ConstructorInjectionOfThisTest
             public void assemble( ModuleAssembly module )
                 throws AssemblyException
             {
-                module.withDefaultUnitOfWorkFactory();
                 module.values( Does.class ).withMixins( NoopMixin.class ).withSideEffects( DoesSideEffect.class );
             }
         };

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/injection/ServiceInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ServiceInjectionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ServiceInjectionTest.java
index 7d82499..fdd0875 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/ServiceInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/ServiceInjectionTest.java
@@ -24,6 +24,8 @@ import java.io.Serializable;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.function.Predicate;
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.junit.Test;
 import org.apache.zest.api.activation.ActivationException;
 import org.apache.zest.api.common.ConstructionException;
@@ -44,9 +46,11 @@ import org.apache.zest.bootstrap.ModuleAssembly;
 import org.apache.zest.bootstrap.ServiceDeclaration;
 import org.apache.zest.bootstrap.SingletonAssembler;
 
+import static org.hamcrest.core.IsEqual.equalTo;
 import static org.junit.Assert.assertEquals;
 import static org.apache.zest.api.common.Visibility.application;
 import static org.apache.zest.api.common.Visibility.layer;
+import static org.junit.Assert.assertThat;
 
 /**
  * Test the @Service injection annotation
@@ -82,7 +86,7 @@ public class ServiceInjectionTest
         ServiceUser user = factory.newObject( ServiceUser.class );
 
         assertEquals( "X", user.testSingle() );
-        assertEquals( "Foo", user.testIdentity() );
+        assertThat( user.testIdentity(), equalTo( new StringIdentity( "Foo" ) ) );
         assertEquals( "FooX", user.testServiceReference() );
         assertEquals( "Bar", user.testQualifier() );
         assertEquals( "A", user.testStringIterable() );
@@ -234,7 +238,7 @@ public class ServiceInjectionTest
             return service.doStuff();
         }
 
-        public String testIdentity()
+        public Identity testIdentity()
         {
             return serviceComposite.identity().get();
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/injection/UnitOfWorkInjectionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UnitOfWorkInjectionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UnitOfWorkInjectionTest.java
index 0efadf5..381e9d6 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/injection/UnitOfWorkInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/injection/UnitOfWorkInjectionTest.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.runtime.injection;
 
+import org.apache.zest.api.identity.StringIdentity;
 import org.junit.Test;
 import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.injection.scope.State;
@@ -52,7 +53,7 @@ public class UnitOfWorkInjectionTest
         UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase );
         try
         {
-            Trial trial = uow.newEntity( Trial.class, "123" );
+            Trial trial = uow.newEntity( Trial.class, new StringIdentity( "123" ) );
             trial.doSomething();
             uow.complete();
             uow = unitOfWorkFactory.newUnitOfWork( usecase );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
index 5926417..77d8742 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyMixinTest.java
@@ -20,6 +20,8 @@
 
 package org.apache.zest.runtime.mixin;
 
+import org.apache.zest.api.identity.HasIdentity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.junit.Test;
 import org.apache.zest.api.composite.TransientComposite;
 import org.apache.zest.api.entity.EntityComposite;
@@ -61,11 +63,11 @@ public class AssemblyMixinTest
         throws UnitOfWorkCompletionException
     {
         UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
-        FooEntity entity = uow.newEntity( FooEntity.class, "123" );
+        FooEntity entity = uow.newEntity( FooEntity.class, new StringIdentity( "123" ) );
         uow.complete();
 
         uow = unitOfWorkFactory.newUnitOfWork();
-        Foo foo = uow.get( Foo.class, "123" );
+        Foo foo = uow.get( Foo.class, new StringIdentity( "123" ) );
 
         try
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
index 972f212..236700c 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/AssemblyRoleTest.java
@@ -20,6 +20,8 @@
 
 package org.apache.zest.runtime.mixin;
 
+import org.apache.zest.api.identity.HasIdentity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.junit.Test;
 import org.apache.zest.api.composite.TransientComposite;
 import org.apache.zest.api.entity.EntityComposite;
@@ -70,11 +72,11 @@ public class AssemblyRoleTest
         throws UnitOfWorkCompletionException
     {
         UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
-        uow.newEntity( FooEntity.class, "123" );
+        uow.newEntity( FooEntity.class, new StringIdentity( "123" ) );
         uow.complete();
 
         uow = unitOfWorkFactory.newUnitOfWork();
-        Foo foo = uow.get( Foo.class, "123" );
+        Foo foo = uow.get( Foo.class, new StringIdentity( "123" ) );
 
         try
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/mixin/JDKMixinTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/JDKMixinTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/JDKMixinTest.java
index d14839a..aaa9b33 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/mixin/JDKMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/mixin/JDKMixinTest.java
@@ -25,6 +25,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Predicate;
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.json.JSONObject;
 import org.junit.Before;
 import org.junit.Test;
@@ -105,8 +107,8 @@ public class JDKMixinTest
 
     }
 
-    private static final String EXTENDS_IDENTITY = ExtendsJDKMixin.class.getName();
-    private static final String COMPOSE_IDENTITY = ComposeWithJDKMixin.class.getName();
+    private static final Identity EXTENDS_IDENTITY = new StringIdentity( ExtendsJDKMixin.class.getName() );
+    private static final Identity COMPOSE_IDENTITY = new StringIdentity( ComposeWithJDKMixin.class.getName() );
     private static final Predicate<ServiceReference<?>> EXTENDS_IDENTITY_SPEC = new ServiceIdentitySpec( EXTENDS_IDENTITY );
     private static final Predicate<ServiceReference<?>> COMPOSE_IDENTITY_SPEC = new ServiceIdentitySpec( COMPOSE_IDENTITY );
     private static final List<String> CONCERN_RECORDS = new ArrayList<String>();
@@ -122,13 +124,13 @@ public class JDKMixinTest
         throws AssemblyException
     {
         module.services( JSONSerializableMap.class ).
-            identifiedBy( EXTENDS_IDENTITY ).
+            identifiedBy( EXTENDS_IDENTITY.toString() ).
             withMixins( ExtendsJDKMixin.class ).
             instantiateOnStartup();
 
         module.layer().module( "compose" ).services( JSONSerializableMap.class ).
             visibleIn( Visibility.layer ).
-            identifiedBy( COMPOSE_IDENTITY ).
+            identifiedBy( COMPOSE_IDENTITY.toString() ).
             withMixins( HashMap.class, ComposeWithJDKMixin.class ).
             instantiateOnStartup();
     }
@@ -177,9 +179,9 @@ public class JDKMixinTest
         implements Predicate<ServiceReference<?>>
     {
 
-        private final String identity;
+        private final Identity identity;
 
-        public ServiceIdentitySpec( String identity )
+        ServiceIdentitySpec(Identity identity)
         {
             this.identity = identity;
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/objects/ObjectVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/objects/ObjectVisibilityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/objects/ObjectVisibilityTest.java
index efac247..f048bc4 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/objects/ObjectVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/objects/ObjectVisibilityTest.java
@@ -20,6 +20,8 @@
 
 package org.apache.zest.runtime.objects;
 
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.junit.After;
@@ -46,6 +48,8 @@ import org.apache.zest.test.EntityTestAssembler;
 public class ObjectVisibilityTest
 {
 
+    public static final Identity TEST_IDENTITY = new StringIdentity( "123" );
+
     private Energy4Java zest;
     private Module module;
     private UnitOfWorkFactory uowf;
@@ -183,7 +187,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY );
             entity.moduleApplicationVisible();
         }
         finally
@@ -201,7 +205,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY );
             entity.moduleLayerVisible();
         }
         finally
@@ -219,7 +223,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.moduleModuleVisible();
         }
         finally
@@ -237,7 +241,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.besideApplicationVisible();
         }
         finally
@@ -255,7 +259,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.besideLayerVisible();
         }
         finally
@@ -273,7 +277,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.besideModuleVisible();
         }
         finally
@@ -291,7 +295,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.belowApplicationVisible();
         }
         finally
@@ -309,7 +313,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.belowLayerVisible();
         }
         finally
@@ -327,7 +331,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.belowModuleVisible();
         }
         finally
@@ -345,7 +349,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.aboveApplicationVisible();
         }
         finally
@@ -363,7 +367,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.aboveLayerVisible();
         }
         finally
@@ -381,7 +385,7 @@ public class ObjectVisibilityTest
         UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
-            FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" );
+            FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY);
             entity.aboveModuleVisible();
         }
         finally

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/query/IterableQuerySourceTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/query/IterableQuerySourceTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/query/IterableQuerySourceTest.java
index 0b2298c..2b35c48 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/query/IterableQuerySourceTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/query/IterableQuerySourceTest.java
@@ -22,6 +22,7 @@ package org.apache.zest.runtime.query;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.junit.After;
 import org.junit.Before;
@@ -226,7 +227,7 @@ public class IterableQuerySourceTest
     {
         QueryBuilder<Person> qb = qbf.newQueryBuilder( Person.class );
         Person person = templateFor( Person.class );
-        City kl = uow.get( City.class, "kualalumpur" );
+        City kl = uow.get( City.class, new StringIdentity( "kualalumpur" ));
         Query<Person> query = qb.where(
             eq( person.mother().get().placeOfBirth(), kl )
         ).newQuery( Network.persons() );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/query/Network.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/query/Network.java b/core/runtime/src/test/java/org/apache/zest/runtime/query/Network.java
index 120d7c7..3b847ac 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/query/Network.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/query/Network.java
@@ -21,6 +21,8 @@ package org.apache.zest.runtime.query;
 
 import java.util.ArrayList;
 import java.util.List;
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
 import org.apache.zest.api.value.ValueBuilder;
@@ -42,6 +44,8 @@ import org.apache.zest.runtime.query.model.values.ContactsValue;
  */
 class Network
 {
+    public static final Identity KUALALUMPUR = new StringIdentity( "kualalumpur" );
+    public static final Identity PENANG = new StringIdentity( "penang" );
     private static List<Domain> domains;
     private static List<Person> persons;
     private static List<Male> males;
@@ -52,12 +56,12 @@ class Network
     static void populate( final UnitOfWork uow, ValueBuilderFactory vbf )
         throws UnitOfWorkCompletionException
     {
-        domains = new ArrayList<Domain>();
-        persons = new ArrayList<Person>();
-        males = new ArrayList<Male>();
-        females = new ArrayList<Female>();
-        pets = new ArrayList<PetEntity>();
-        nameables = new ArrayList<Nameable>();
+        domains = new ArrayList<>();
+        persons = new ArrayList<>();
+        males = new ArrayList<>();
+        females = new ArrayList<>();
+        pets = new ArrayList<>();
+        nameables = new ArrayList<>();
 
         Domain gaming = uow.newEntity( Domain.class );
         setName( gaming, "Gaming" );
@@ -75,12 +79,12 @@ class Network
         setName( cars, "Cars" );
         cars.description().set( "Cars" );
 
-        City kualaLumpur = uow.newEntity( City.class, "kualalumpur" );
+        City kualaLumpur = uow.newEntity( City.class, KUALALUMPUR);
         setName( kualaLumpur, "Kuala Lumpur" );
         kualaLumpur.country().set( "Malaysia" );
         kualaLumpur.county().set( "Some Jaya" );
 
-        City penang = uow.newEntity( City.class, "penang" );
+        City penang = uow.newEntity( City.class, PENANG);
         setName( penang, "Penang" );
         penang.country().set( "Malaysia" );
         penang.county().set( "Some Other Jaya" );
@@ -92,7 +96,7 @@ class Network
         vivianSmith.interests().add( 0, gaming );
         vivianSmith.interests().add( 0, programming );
         vivianSmith.email().set( "viv@smith.edu" );
-        List<String> vivianTags = new ArrayList<String>();
+        List<String> vivianTags = new ArrayList<>();
         vivianTags.add( "Awesome" );
         vivianTags.add( "Pretty" );
         vivianTags.add( "Cool" );
@@ -103,7 +107,7 @@ class Network
         annDoe.placeOfBirth().set( kualaLumpur );
         annDoe.yearOfBirth().set( 1975 );
         annDoe.interests().add( 0, cooking );
-        List<String> annTags = new ArrayList<String>();
+        List<String> annTags = new ArrayList<>();
         annTags.add( "Conservative" );
         annTags.add( "Pretty" );
         annDoe.tags().set( annTags );
@@ -117,7 +121,7 @@ class Network
         joeDoe.interests().add( 0, programming );
         joeDoe.interests().add( 0, gaming );
         joeDoe.email().set( "joe@thedoes.net" );
-        List<String> joeTags = new ArrayList<String>();
+        List<String> joeTags = new ArrayList<>();
         joeTags.add( "Cool" );
         joeTags.add( "Hunk" );
         joeTags.add( "Awesome" );


Mime
View raw message