polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [23/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:04 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/assembly/MongoDBEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/assembly/MongoDBEntityStoreAssembler.java b/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/assembly/MongoDBEntityStoreAssembler.java
index 79ae84e..3546fe3 100644
--- a/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/assembly/MongoDBEntityStoreAssembler.java
+++ b/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/assembly/MongoDBEntityStoreAssembler.java
@@ -38,7 +38,7 @@ public class MongoDBEntityStoreAssembler
         ServiceDeclaration service = module.services( MongoMapEntityStoreService.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-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
index a540c1e..f76f8d3 100755
--- a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
+++ b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
@@ -25,7 +25,6 @@ import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.UUID;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.prefs.BackingStoreException;
@@ -34,6 +33,8 @@ import org.apache.zest.api.cache.CacheOptions;
 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.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
@@ -78,8 +79,8 @@ import org.slf4j.LoggerFactory;
  *
  * <p>@see Preferences</p>
  * <p>
- * Associations are stored as the identity of the referenced Entity, ManyAssociations are stored as multi-line strings
- * (one identity per line), and NamedAssociations are stored as multi-line strings (one name on a line, identity on the
+ * Associations are stored as the reference of the referenced Entity, ManyAssociations are stored as multi-line strings
+ * (one reference per line), and NamedAssociations are stored as multi-line strings (one name on a line, reference on the
  * next line).
  * </p>
  * <p>Nested ValuesComposites, Collections and Maps are stored using available ValueSerialization service.</p>
@@ -105,14 +106,13 @@ public class PreferencesEntityStoreMixin
 
     private Preferences root;
 
-    protected String uuid;
-
-    private int count;
-
     public Logger logger;
 
     public ScheduledThreadPoolExecutor reloadExecutor;
 
+    @Service
+    private IdentityGenerator identityGenerator;
+
     @Override
     public void activateService()
         throws Exception
@@ -120,7 +120,6 @@ public class PreferencesEntityStoreMixin
         root = getApplicationRoot();
         logger = LoggerFactory.getLogger( PreferencesEntityStoreService.class.getName() );
         logger.info( "Preferences store:" + root.absolutePath() );
-        uuid = UUID.randomUUID().toString() + "-";
 
         // Reload underlying store every 60 seconds
         reloadExecutor = new ScheduledThreadPoolExecutor( 1 );
@@ -217,27 +216,27 @@ public class PreferencesEntityStoreMixin
 
     @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 EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork,
                                       ModuleDescriptor module,
-                                      EntityReference identity
+                                      EntityReference reference
     )
     {
         try
         {
-            if( !root.nodeExists( identity.identity() ) )
+            if( !root.nodeExists( reference.identity().toString() ) )
             {
-                throw new NoSuchEntityException( identity, UnknownType.class, unitOfWork.usecase() );
+                throw new NoSuchEntityException( reference, UnknownType.class, unitOfWork.usecase() );
             }
 
-            Preferences entityPrefs = root.node( identity.identity() );
+            Preferences entityPrefs = root.node( reference.identity().toString() );
 
             String type = entityPrefs.get( "type", null );
             EntityStatus status = EntityStatus.LOADED;
@@ -253,10 +252,10 @@ public class PreferencesEntityStoreMixin
             entityDescriptor.state().properties().forEach(
                 persistentPropertyDescriptor ->
                 {
-                    if( persistentPropertyDescriptor.qualifiedName().name().equals( "identity" ) )
+                    if( persistentPropertyDescriptor.qualifiedName().name().equals( "reference" ) )
                     {
-                        // Fake identity property
-                        properties.put( persistentPropertyDescriptor.qualifiedName(), identity.identity() );
+                        // Fake reference property
+                        properties.put( persistentPropertyDescriptor.qualifiedName(), reference.identity().toString() );
                     }
                     else
                     {
@@ -417,7 +416,7 @@ public class PreferencesEntityStoreMixin
 
             return new DefaultEntityState( entityPrefs.get( "version", "" ),
                                            Instant.ofEpochMilli(entityPrefs.getLong( "modified", unitOfWork.currentTime().toEpochMilli() )),
-                                           identity,
+                                           reference,
                                            status,
                                            entityDescriptor,
                                            properties,
@@ -433,16 +432,16 @@ public class PreferencesEntityStoreMixin
     }
 
     @Override
-    public String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference identity )
+    public String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference reference )
     {
         try
         {
-            if( !root.nodeExists( identity.identity() ) )
+            if( !root.nodeExists( reference.identity().toString() ) )
             {
-                throw new NoSuchEntityException( identity, UnknownType.class, unitOfWork.usecase() );
+                throw new NoSuchEntityException( reference, UnknownType.class, unitOfWork.usecase() );
             }
 
-            Preferences entityPrefs = root.node( identity.identity() );
+            Preferences entityPrefs = root.node( reference.identity().toString() );
             return entityPrefs.get( "version", "" );
         }
         catch( BackingStoreException e )
@@ -469,17 +468,17 @@ public class PreferencesEntityStoreMixin
                             DefaultEntityState state = (DefaultEntityState) entityState;
                             if( state.status().equals( EntityStatus.NEW ) )
                             {
-                                Preferences entityPrefs = root.node( state.identity().identity() );
+                                Preferences entityPrefs = root.node( state.entityReference().identity().toString() );
                                 writeEntityState( state, entityPrefs, unitofwork.identity(), unitofwork.currentTime() );
                             }
                             else if( state.status().equals( EntityStatus.UPDATED ) )
                             {
-                                Preferences entityPrefs = root.node( state.identity().identity() );
+                                Preferences entityPrefs = root.node( state.entityReference().identity().toString() );
                                 writeEntityState( state, entityPrefs, unitofwork.identity(), unitofwork.currentTime() );
                             }
                             else if( state.status().equals( EntityStatus.REMOVED ) )
                             {
-                                root.node( state.identity().identity() ).removeNode();
+                                root.node( state.entityReference().identity().toString() ).removeNode();
                             }
                         }
                         root.flush();
@@ -500,7 +499,7 @@ public class PreferencesEntityStoreMixin
 
     protected void writeEntityState( DefaultEntityState state,
                                      Preferences entityPrefs,
-                                     String identity,
+                                     Identity identity,
                                      Instant lastModified
     )
         throws EntityStoreException
@@ -509,13 +508,13 @@ public class PreferencesEntityStoreMixin
         {
             // Store into Preferences API
             entityPrefs.put( "type", state.entityDescriptor().types().findFirst().get().getName() );
-            entityPrefs.put( "version", identity );
+            entityPrefs.put( "version", identity.toString() );
             entityPrefs.putLong( "modified", lastModified.toEpochMilli() );
 
             // Properties
             Preferences propsPrefs = entityPrefs.node( "properties" );
             state.entityDescriptor().state().properties()
-                .filter( property -> !property.qualifiedName().name().equals( "identity" ) )
+                .filter( property -> !property.qualifiedName().name().equals( "reference" ) )
                 .forEach( persistentProperty ->
                           {
                               Object value = state.properties().get( persistentProperty.qualifiedName() );
@@ -589,7 +588,7 @@ public class PreferencesEntityStoreMixin
                     }
                     else
                     {
-                        assocsPrefs.put( association.getKey().name(), association.getValue().identity() );
+                        assocsPrefs.put( association.getKey().name(), association.getValue().identity().toString() );
                     }
                 }
             }
@@ -608,7 +607,7 @@ public class PreferencesEntityStoreMixin
                         {
                             manyAssocs.append( "\n" );
                         }
-                        manyAssocs.append( entityReference.identity() );
+                        manyAssocs.append( entityReference.identity().toString() );
                     }
                     if( manyAssocs.length() > 0 )
                     {
@@ -631,7 +630,7 @@ public class PreferencesEntityStoreMixin
                         {
                             namedAssocs.append( "\n" );
                         }
-                        namedAssocs.append( namedRef.getKey() ).append( "\n" ).append( namedRef.getValue().identity() );
+                        namedAssocs.append( namedRef.getKey() ).append( "\n" ).append( namedRef.getValue().identity().toString() );
                     }
                     if( namedAssocs.length() > 0 )
                     {
@@ -646,9 +645,9 @@ public class PreferencesEntityStoreMixin
         }
     }
 
-    protected String newUnitOfWorkId()
+    protected Identity newUnitOfWorkId()
     {
-        return uuid + Integer.toHexString( count++ );
+        return identityGenerator.generate(EntityStore.class);
     }
 
     private interface NumberParser<T>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreService.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreService.java b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreService.java
index 9555400..544dd07 100644
--- a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreService.java
+++ b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreService.java
@@ -43,7 +43,7 @@ import org.apache.zest.spi.entitystore.EntityStore;
  * </p>
  * <p>
  * Associations are stored as the identity of the referenced Entity, ManyAssociations are stored as multi-line strings
- * (one identity per line), and NamedAssociations are stored as multi-line strings (one name on a line, identity on the
+ * (one reference per line), and NamedAssociations are stored as multi-line strings (one name on a line, reference on the
  * next line).
  * </p>
  * <p>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/assembly/PreferenceEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/assembly/PreferenceEntityStoreAssembler.java b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/assembly/PreferenceEntityStoreAssembler.java
index 1b0b111..5953d96 100644
--- a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/assembly/PreferenceEntityStoreAssembler.java
+++ b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/assembly/PreferenceEntityStoreAssembler.java
@@ -46,7 +46,7 @@ public class PreferenceEntityStoreAssembler
             .instantiateOnStartup();
         if( hasIdentity() )
         {
-            service.identifiedBy( identity() );
+            service.identifiedBy( identity().toString() );
         }
         module.services( UuidIdentityGeneratorService.class ).visibleIn( visibility() );
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreMixin.java b/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreMixin.java
index c4ecca4..dc43d97 100644
--- a/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreMixin.java
+++ b/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreMixin.java
@@ -92,7 +92,7 @@ public class RedisMapEntityStoreMixin
         Jedis jedis = pool.getResource();
         try
         {
-            String jsonState = jedis.get( entityReference.identity() );
+            String jsonState = jedis.get( entityReference.identity().toString() );
             if( notFound( jsonState ) )
             {
                 throw new EntityNotFoundException( entityReference );
@@ -125,7 +125,7 @@ public class RedisMapEntityStoreMixin
                             throws IOException
                         {
                             super.close();
-                            String statusCode = jedis.set( ref.identity(), toString(), "NX" );
+                            String statusCode = jedis.set( ref.identity().toString(), toString(), "NX" );
                             if( !"OK".equals( statusCode ) )
                             {
                                 throw new EntityAlreadyExistsException( ref );
@@ -145,7 +145,7 @@ public class RedisMapEntityStoreMixin
                             throws IOException
                         {
                             super.close();
-                            String statusCode = jedis.set( ref.identity(), toString(), "XX" );
+                            String statusCode = jedis.set( ref.identity().toString(), toString(), "XX" );
                             if( !"OK".equals( statusCode ) )
                             {
                                 throw new EntityNotFoundException( ref );
@@ -158,12 +158,12 @@ public class RedisMapEntityStoreMixin
                 public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor )
                     throws EntityNotFoundException
                 {
-                    String jsonState = jedis.get( ref.identity() );
+                    String jsonState = jedis.get( ref.identity().toString() );
                     if( notFound( jsonState ) )
                     {
                         throw new EntityNotFoundException( ref );
                     }
-                    jedis.del( ref.identity() );
+                    jedis.del( ref.identity().toString() );
                 }
             } );
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/assembly/RedisEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/assembly/RedisEntityStoreAssembler.java b/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/assembly/RedisEntityStoreAssembler.java
index ce32f3e..38ab411 100644
--- a/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/assembly/RedisEntityStoreAssembler.java
+++ b/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/assembly/RedisEntityStoreAssembler.java
@@ -41,7 +41,7 @@ public class RedisEntityStoreAssembler
         ServiceDeclaration service = module.services( RedisMapEntityStoreService.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-riak/src/main/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreMixin.java b/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreMixin.java
index 4402c0e..0160dfa 100644
--- a/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreMixin.java
+++ b/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreMixin.java
@@ -223,7 +223,7 @@ public class RiakMapEntityStoreMixin implements ServiceActivation, MapEntityStor
     {
         try
         {
-            Location location = new Location( namespace, entityReference.identity() );
+            Location location = new Location( namespace, entityReference.identity().toString() );
             FetchValue fetch = new FetchValue.Builder( location ).build();
             FetchValue.Response response = riakClient.execute( fetch );
             if( response.isNotFound() )
@@ -261,7 +261,7 @@ public class RiakMapEntityStoreMixin implements ServiceActivation, MapEntityStor
                             {
                                 super.close();
                                 StoreValue store = new StoreValue.Builder( toString() )
-                                        .withLocation( new Location( namespace, ref.identity() ) )
+                                        .withLocation( new Location( namespace, ref.identity().toString() ) )
                                         .build();
                                 riakClient.execute( store );
                             }
@@ -286,7 +286,7 @@ public class RiakMapEntityStoreMixin implements ServiceActivation, MapEntityStor
                             try
                             {
                                 super.close();
-                                Location location = new Location( namespace, ref.identity() );
+                                Location location = new Location( namespace, ref.identity().toString() );
                                 FetchValue fetch = new FetchValue.Builder( location ).build();
                                 FetchValue.Response response = riakClient.execute( fetch );
                                 if( response.isNotFound() )
@@ -310,7 +310,7 @@ public class RiakMapEntityStoreMixin implements ServiceActivation, MapEntityStor
                 {
                     try
                     {
-                        Location location = new Location( namespace, ref.identity() );
+                        Location location = new Location( namespace, ref.identity().toString() );
                         FetchValue fetch = new FetchValue.Builder( location ).build();
                         FetchValue.Response response = riakClient.execute( fetch );
                         if( response.isNotFound() )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/assembly/RiakEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/assembly/RiakEntityStoreAssembler.java b/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/assembly/RiakEntityStoreAssembler.java
index 8f5a969..b449f42 100644
--- a/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/assembly/RiakEntityStoreAssembler.java
+++ b/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/assembly/RiakEntityStoreAssembler.java
@@ -42,7 +42,7 @@ public class RiakEntityStoreAssembler
                 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-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
index c541621..a52b526 100755
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
@@ -40,6 +40,8 @@ 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.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
@@ -121,6 +123,9 @@ public class SQLEntityStoreMixin
 
     private final AtomicInteger count = new AtomicInteger();
 
+    @Service
+    private IdentityGenerator identityGenerator;
+
     @Override
     public void activateService()
         throws Exception
@@ -163,25 +168,25 @@ public class SQLEntityStoreMixin
                         Long entityPK = ( (SQLEntityState) state ).getEntityPK();
                         if( EntityStatus.REMOVED.equals( status ) )
                         {
-                            database.populateRemoveEntityStatement( removePS, entityPK, state.identity() );
+                            database.populateRemoveEntityStatement( removePS, entityPK, state.entityReference() );
                             removePS.addBatch();
                         }
                         else
                         {
                             StringWriter writer = new StringWriter();
-                            writeEntityState( defState, writer, unitofwork.identity() );
+                            writeEntityState( defState, writer, unitofwork.identity().toString() );
                             writer.flush();
                             if( EntityStatus.UPDATED.equals( status ) )
                             {
                                 Long entityOptimisticLock = ( (SQLEntityState) state ).getEntityOptimisticLock();
                                 database.populateUpdateEntityStatement( updatePS, entityPK, entityOptimisticLock,
-                                                                        defState.identity(), writer.toString(),
+                                                                        defState.entityReference(), writer.toString(),
                                                                         unitofwork.currentTime() );
                                 updatePS.addBatch();
                             }
                             else if( EntityStatus.NEW.equals( status ) )
                             {
-                                database.populateInsertEntityStatement( insertPS, defState.identity(),
+                                database.populateInsertEntityStatement( insertPS, defState.entityReference(),
                                                                         writer.toString(), unitofwork.currentTime() );
                                 insertPS.addBatch();
                             }
@@ -345,9 +350,9 @@ public class SQLEntityStoreMixin
     {
     }
 
-    protected String newUnitOfWorkId()
+    protected Identity newUnitOfWorkId()
     {
-        return uuid + Integer.toHexString( count.incrementAndGet() );
+        return identityGenerator.generate(EntityStore.class);
     }
 
     protected DefaultEntityState readEntityState( ModuleDescriptor module, Reader entityState )
@@ -549,7 +554,7 @@ public class SQLEntityStoreMixin
         {
             JSONWriter json = new JSONWriter( writer );
             JSONWriter properties = json.object().
-                key( JSONKeys.IDENTITY ).value( state.identity().identity() ).
+                key( JSONKeys.IDENTITY ).value( state.entityReference().identity().toString() ).
                 key( JSONKeys.APPLICATION_VERSION ).value( application.version() ).
                 key( JSONKeys.TYPE ).value( state.entityDescriptor().types().findFirst().get().getName() ).
                 key( JSONKeys.VERSION ).value( version ).
@@ -594,7 +599,7 @@ public class SQLEntityStoreMixin
             {
                 EntityReference value = stateNameEntityReferenceEntry.getValue();
                 associations.key( stateNameEntityReferenceEntry.getKey().name() ).
-                    value( value != null ? value.identity() : null );
+                    value( value != null ? value.identity().toString() : null );
             }
 
             JSONWriter manyAssociations = associations.endObject().key( JSONKeys.MANY_ASSOCIATIONS ).object();
@@ -604,7 +609,7 @@ public class SQLEntityStoreMixin
                 JSONWriter assocs = manyAssociations.key( stateNameListEntry.getKey().name() ).array();
                 for( EntityReference entityReference : stateNameListEntry.getValue() )
                 {
-                    assocs.value( entityReference.identity() );
+                    assocs.value( entityReference.identity().toString() );
                 }
                 assocs.endArray();
             }
@@ -616,7 +621,7 @@ public class SQLEntityStoreMixin
                 JSONWriter assocs = namedAssociations.key( stateNameMapEntry.getKey().name() ).object();
                 for( Map.Entry<String, EntityReference> entry : stateNameMapEntry.getValue().entrySet() )
                 {
-                    assocs.key( entry.getKey() ).value( entry.getValue().identity() );
+                    assocs.key( entry.getKey() ).value( entry.getValue().identity().toString() );
                 }
                 assocs.endObject();
             }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java
index a941418..a546f36 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java
@@ -21,6 +21,8 @@ package org.apache.zest.entitystore.sql.assembly;
 
 import java.io.IOException;
 import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.identity.Identity;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.bootstrap.Assemblers;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
@@ -43,7 +45,7 @@ abstract class AbstractSQLEntityStoreAssembler<AssemblerType>
     extends Assemblers.VisibilityIdentityConfig<AssemblerType>
 {
 
-    public static final String DEFAULT_ENTITYSTORE_IDENTITY = "entitystore-sql";
+    public static final Identity DEFAULT_ENTITYSTORE_IDENTITY = new StringIdentity( "entitystore-sql" );
 
     protected SQLVendor getSQLVendor()
         throws IOException
@@ -69,13 +71,13 @@ abstract class AbstractSQLEntityStoreAssembler<AssemblerType>
             {
                 throw new AssemblyException( "SQL Vendor could not be determined." );
             }
-            module.services( DatabaseSQLServiceComposite.class ).
-                withMixins( DatabaseSQLServiceCoreMixin.class,
+            module.services( DatabaseSQLServiceComposite.class )
+                    .withMixins( DatabaseSQLServiceCoreMixin.class,
                             DatabaseSQLServiceSpi.CommonMixin.class,
                             getDatabaseStringBuilderMixin(),
                             DatabaseSQLServiceStatementsMixin.class,
-                            getDatabaseSQLServiceSpecializationMixin() ).
-                identifiedBy( hasIdentity() ? identity() : DEFAULT_ENTITYSTORE_IDENTITY ).
+                            getDatabaseSQLServiceSpecializationMixin() )
+                    .identifiedBy( ( hasIdentity() ? identity().toString() : DEFAULT_ENTITYSTORE_IDENTITY ).toString() ).
                 visibleIn( Visibility.module ).
                 setMetaInfo( sqlVendor );
         }
@@ -92,5 +94,4 @@ abstract class AbstractSQLEntityStoreAssembler<AssemblerType>
                 visibleIn( configVisibility() );
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLServiceStatementsMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLServiceStatementsMixin.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLServiceStatementsMixin.java
index a755c19..920b14a 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLServiceStatementsMixin.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLServiceStatementsMixin.java
@@ -85,14 +85,14 @@ public abstract class DatabaseSQLServiceStatementsMixin
     public void populateGetEntityStatement( PreparedStatement ps, EntityReference ref )
             throws SQLException
     {
-        ps.setString( 1, ref.identity() );
+        ps.setString( 1, ref.identity().toString() );
     }
 
     @Override
     public void populateInsertEntityStatement( PreparedStatement ps, EntityReference ref, String entity, Instant lastModified )
             throws SQLException
     {
-        ps.setString( 1, ref.identity() );
+        ps.setString( 1, ref.identity().toString() );
         ps.setString( 2, entity );
         ps.setLong( 3, lastModified.toEpochMilli() );
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/SQLEntityState.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/SQLEntityState.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/SQLEntityState.java
index 3466cbc..72f4112 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/SQLEntityState.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/SQLEntityState.java
@@ -118,9 +118,9 @@ public interface SQLEntityState
         }
 
         @Override
-        public EntityReference identity()
+        public EntityReference entityReference()
         {
-            return state.identity();
+            return state.entityReference();
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
index eb9555f..871fa10 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java
@@ -84,8 +84,7 @@ public class DerbySQLEntityStoreTest
             "Delete " + getClass().getSimpleName() + " test data" ) );
         try
         {
-            SQLConfiguration config = uow.get( SQLConfiguration.class,
-                                               DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
+            SQLConfiguration config = uow.get( SQLConfiguration.class, DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
             Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
             connection.setAutoCommit( false );
             String schemaName = config.schemaName().get();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
index 2524c32..51c1797 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java
@@ -96,8 +96,7 @@ public class MySQLEntityStoreTest
         );
         try
         {
-            SQLConfiguration config = uow.get( SQLConfiguration.class,
-                                               MySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
+            SQLConfiguration config = uow.get( SQLConfiguration.class, MySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
             Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
             connection.setAutoCommit( false );
             String schemaName = config.schemaName().get();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
index c523a2a..f54b48b 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java
@@ -122,8 +122,7 @@ public class PostgreSQLEntityStoreTest
         );
         try
         {
-            SQLConfiguration config = uow.get( SQLConfiguration.class,
-                                               PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
+            SQLConfiguration config = uow.get( SQLConfiguration.class, PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
             Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
             connection.setAutoCommit( false );
             String schemaName = config.schemaName().get();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
index e05081b..852b303 100755
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.stream.Collectors;
 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.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
@@ -96,7 +97,7 @@ public interface ElasticSearchIndexer
             {
                 if( eState.status() == EntityStatus.UPDATED || eState.status() == EntityStatus.NEW )
                 {
-                    newStates.put( eState.identity().identity(), eState );
+                    newStates.put( eState.entityReference().identity().toString(), eState );
                 }
             }
 
@@ -118,20 +119,20 @@ public interface ElasticSearchIndexer
                     {
                     case REMOVED:
                         LOGGER.trace( "Removing Entity State from Index: {}", changedState );
-                        remove( bulkBuilder, changedState.identity().identity() );
+                        remove( bulkBuilder, changedState.entityReference().identity().toString() );
                         break;
                     case UPDATED:
                         LOGGER.trace( "Updating Entity State in Index: {}", changedState );
-                        remove( bulkBuilder, changedState.identity().identity() );
+                        remove( bulkBuilder, changedState.entityReference().identity().toString() );
                         String updatedJson = toJSON( changedState, newStates, uow );
                         LOGGER.trace( "Will index: {}", updatedJson );
-                        index( bulkBuilder, changedState.identity().identity(), updatedJson );
+                        index( bulkBuilder, changedState.entityReference().identity().toString(), updatedJson );
                         break;
                     case NEW:
                         LOGGER.trace( "Creating Entity State in Index: {}", changedState );
                         String newJson = toJSON( changedState, newStates, uow );
                         LOGGER.trace( "Will index: {}", newJson );
-                        index( bulkBuilder, changedState.identity().identity(), newJson );
+                        index( bulkBuilder, changedState.entityReference().identity().toString(), newJson );
                         break;
                     case LOADED:
                     default:
@@ -181,9 +182,9 @@ public interface ElasticSearchIndexer
          *  "_identity": "ENTITY-IDENTITY",
          *  "_types": [ "All", "Entity", "types" ],
          *  "property.name": property.value,
-         *  "association.name": { "identity": "ASSOCIATED-IDENTITY" }
-         *  "manyassociation.name": [ { "identity": "ASSOCIATED" }, { "identity": "IDENTITIES" } ]
-         *  "namedassociation.name": [ { "_named": "NAMED", "identity": "IDENTITY" } }
+         *  "association.name": { "reference": "ASSOCIATED-IDENTITY" }
+         *  "manyassociation.name": [ { "reference": "ASSOCIATED" }, { "reference": "IDENTITIES" } ]
+         *  "namedassociation.name": [ { "_named": "NAMED", "reference": "IDENTITY" } }
          * }
          * </pre>
          */
@@ -193,12 +194,11 @@ public interface ElasticSearchIndexer
 
             try
             {
-                json.put( "_identity", state.identity().identity() );
+                json.put( "_identity", state.entityReference().identity().toString() );
                 json.put( "_types", state.entityDescriptor()
                     .mixinTypes()
                     .map( Classes.toClassName() )
-                    .collect( Collectors
-                                  .toList() ) );
+                    .collect( Collectors.toList() ) );
             }
             catch( JSONException e )
             {
@@ -261,20 +261,20 @@ public interface ElasticSearchIndexer
                         {
                             if( assocDesc.isAggregated() || support.indexNonAggregatedAssociations() )
                             {
-                                if( newStates.containsKey( associated.identity() ) )
+                                if( newStates.containsKey( associated.identity().toString() ) )
                                 {
-                                    value = new JSONObject( toJSON( newStates.get( associated.identity() ), newStates, uow ) );
+                                    value = new JSONObject( toJSON( newStates.get( associated.identity().toString() ), newStates, uow ) );
                                 }
                                 else
                                 {
-                                    EntityReference reference = EntityReference.parseEntityReference( associated.identity() );
+                                    EntityReference reference = EntityReference.create( associated.identity() );
                                     EntityState assocState = uow.entityStateOf( module, reference );
                                     value = new JSONObject( toJSON( assocState, newStates, uow ) );
                                 }
                             }
                             else
                             {
-                                value = new JSONObject( Collections.singletonMap( "identity", associated.identity() ) );
+                                value = new JSONObject( Collections.singletonMap( "reference", associated.identity().toString() ) );
                             }
                         }
                         json.put( key, value );
@@ -299,20 +299,20 @@ public interface ElasticSearchIndexer
                         {
                             if( manyAssocDesc.isAggregated() || support.indexNonAggregatedAssociations() )
                             {
-                                if( newStates.containsKey( associated.identity() ) )
+                                if( newStates.containsKey( associated.identity().toString() ) )
                                 {
-                                    array.put( new JSONObject( toJSON( newStates.get( associated.identity() ), newStates, uow ) ) );
+                                    array.put( new JSONObject( toJSON( newStates.get( associated.identity().toString() ), newStates, uow ) ) );
                                 }
                                 else
                                 {
-                                    EntityReference reference = EntityReference.parseEntityReference( associated.identity() );
+                                    EntityReference reference = EntityReference.create( associated.identity() );
                                     EntityState assocState = uow.entityStateOf( module, reference );
                                     array.put( new JSONObject( toJSON( assocState, newStates, uow ) ) );
                                 }
                             }
                             else
                             {
-                                array.put( new JSONObject( Collections.singletonMap( "identity", associated.identity() ) ) );
+                                array.put( new JSONObject( Collections.singletonMap( "reference", associated.identity().toString() ) ) );
                             }
                         }
                         json.put( key, array );
@@ -335,18 +335,19 @@ public interface ElasticSearchIndexer
                         NamedAssociationState associateds = state.namedAssociationValueOf( namedAssocDesc.qualifiedName() );
                         for( String name : associateds )
                         {
+                            Identity identity = associateds.get(name).identity();
                             if( namedAssocDesc.isAggregated() || support.indexNonAggregatedAssociations() )
                             {
-                                String identity = associateds.get( name ).identity();
-                                if( newStates.containsKey( identity ) )
+                                String identityString = identity.toString();
+                                if( newStates.containsKey( identityString ) )
                                 {
-                                    JSONObject obj = new JSONObject( toJSON( newStates.get( identity ), newStates, uow ) );
+                                    JSONObject obj = new JSONObject( toJSON( newStates.get( identityString ), newStates, uow ) );
                                     obj.put( "_named", name );
                                     array.put( obj );
                                 }
                                 else
                                 {
-                                    EntityReference reference = EntityReference.parseEntityReference( identity );
+                                    EntityReference reference = EntityReference.create( identity );
                                     EntityState assocState = uow.entityStateOf( module, reference );
                                     JSONObject obj = new JSONObject( toJSON( assocState, newStates, uow ) );
                                     obj.put( "_named", name );
@@ -357,7 +358,7 @@ public interface ElasticSearchIndexer
                             {
                                 JSONObject obj = new JSONObject();
                                 obj.put( "_named", name );
-                                obj.put( "identity", associateds.get( name ).identity() );
+                                obj.put( "reference", identity.toString() );
                                 array.put( obj );
                             }
                         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESClusterIndexQueryAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESClusterIndexQueryAssembler.java b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESClusterIndexQueryAssembler.java
index c1b1810..ac2b5d3 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESClusterIndexQueryAssembler.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESClusterIndexQueryAssembler.java
@@ -35,7 +35,7 @@ public class ESClusterIndexQueryAssembler
         throws AssemblyException
     {
         module.services( ESClusterIndexQueryService.class ).
-            identifiedBy( identity() ).
+            identifiedBy( identity().toString() ).
             visibleIn( visibility() ).
             instantiateOnStartup();
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESFilesystemIndexQueryAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESFilesystemIndexQueryAssembler.java b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESFilesystemIndexQueryAssembler.java
index 6fed767..eb58163 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESFilesystemIndexQueryAssembler.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESFilesystemIndexQueryAssembler.java
@@ -35,7 +35,7 @@ public class ESFilesystemIndexQueryAssembler
         throws AssemblyException
     {
         module.services( ESFilesystemIndexQueryService.class ).
-            identifiedBy( identity() ).
+            identifiedBy( identity().toString() ).
             visibleIn( visibility() ).
             instantiateOnStartup();
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
index 2072bc8..4e2d601 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
@@ -20,11 +20,12 @@
 package org.apache.zest.index.elasticsearch.filesystem;
 
 import java.io.File;
+import org.apache.zest.api.identity.Identity;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.node.Node;
 import org.elasticsearch.node.NodeBuilder;
 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.Service;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.index.elasticsearch.ElasticSearchConfiguration;
@@ -39,7 +40,7 @@ public class ESFilesystemSupport
     private Configuration<ElasticSearchConfiguration> configuration;
 
     @This
-    private Identity hasIdentity;
+    private HasIdentity hasIdentity;
 
     @Service
     private FileConfiguration fileConfig;
@@ -57,13 +58,13 @@ public class ESFilesystemSupport
         index = config.index().get() == null ? DEFAULT_INDEX_NAME : config.index().get();
         indexNonAggregatedAssociations = config.indexNonAggregatedAssociations().get();
 
-        String identity = hasIdentity.identity().get();
+        Identity identity = hasIdentity.identity().get();
         Settings settings = Settings.settingsBuilder().
-                put( "path.work", new File( new File( fileConfig.temporaryDirectory(), identity ), "work" ).getAbsolutePath() ).
-                put( "path.home", new File( new File( fileConfig.temporaryDirectory(), identity ), "home" ).getAbsolutePath() ).
-                put( "path.logs", new File( fileConfig.logDirectory(), identity ).getAbsolutePath() ).
-                put( "path.data", new File( fileConfig.dataDirectory(), identity ).getAbsolutePath() ).
-                put( "path.conf", new File( fileConfig.configurationDirectory(), identity ).getAbsolutePath() ).
+                put( "path.work", new File( new File( fileConfig.temporaryDirectory(), identity.toString() ), "work" ).getAbsolutePath() ).
+                put( "path.home", new File( new File( fileConfig.temporaryDirectory(), identity.toString() ), "home" ).getAbsolutePath() ).
+                put( "path.logs", new File( fileConfig.logDirectory(), identity.toString() ).getAbsolutePath() ).
+                put( "path.data", new File( fileConfig.dataDirectory(), identity.toString() ).getAbsolutePath() ).
+                put( "path.conf", new File( fileConfig.configurationDirectory(), identity.toString() ).getAbsolutePath() ).
                 put( "http.enabled", false ).
                 put( "index.cache.type", "weak" ).
                 put( "index.number_of_shards", 1 ).

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
index 2f4ff6c..15399bb 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
@@ -21,6 +21,7 @@
 package org.apache.zest.index.elasticsearch;
 
 import java.io.File;
+import org.apache.zest.api.identity.HasIdentity;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
@@ -30,7 +31,6 @@ import org.apache.zest.api.common.UseDefaults;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.entity.Aggregated;
 import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.Identity;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.query.Query;
 import org.apache.zest.api.query.QueryBuilder;
@@ -68,9 +68,8 @@ public class ElasticSearchTest
     }
 
     public interface Post
-        extends Identity
+        extends HasIdentity
     {
-
         Property<String> title();
 
         @UseDefaults
@@ -83,13 +82,11 @@ public class ElasticSearchTest
         @Aggregated
         @UseDefaults
         ManyAssociation<Comment> comments();
-
     }
 
     public interface Page
-        extends Identity
+        extends HasIdentity
     {
-
         Property<String> title();
 
         @UseDefaults
@@ -98,31 +95,24 @@ public class ElasticSearchTest
         Property<Tagline> tagline();
 
         Association<Author> author();
-
     }
 
     public interface Tagline
     {
-
         @UseDefaults
         Property<String> tags();
-
     }
 
     public interface Author
-        extends Identity
+        extends HasIdentity
     {
-
         Property<String> nickname();
-
     }
 
     public interface Comment
-        extends Identity
+        extends HasIdentity
     {
-
         Property<String> content();
-
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-rdf/src/docs/index-rdf.txt
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/docs/index-rdf.txt b/extensions/indexing-rdf/src/docs/index-rdf.txt
index 7ef5f7e..56f2912 100644
--- a/extensions/indexing-rdf/src/docs/index-rdf.txt
+++ b/extensions/indexing-rdf/src/docs/index-rdf.txt
@@ -85,3 +85,148 @@ Here are the configuration properties for the RDBMS based RDF Index/Query:
 source=libraries/rdf/src/main/java/org/apache/zest/library/rdf/repository/RdbmsRepositoryConfiguration.java
 tag=config
 ----
+
+== Named RDF Queries ==
+RDF queries are rather difficult to create manually. Not only do you need to learn a difficult language and a new
+syntax, but also need to understand the indexing model that happens in Apache Zest RDF indexing system.
+
+Below follows a large set of working queries, which can be used as a starting point. See the testcases for
+details of the Entity model that is being indexed.
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query1
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query2
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query3
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query4
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query5
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query6
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query7
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query8
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query9
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query10
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query11
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query12
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query13
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query14
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query15
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query16
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query17
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query18
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query19
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query20
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query21
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query22
+----
+
+[snippet,java]
+----
+source=libraries/rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+tag=query24
+----

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/indexing/RdfIndexingService.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/indexing/RdfIndexingService.java b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/indexing/RdfIndexingService.java
index 9803e8c..2cb87c1 100644
--- a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/indexing/RdfIndexingService.java
+++ b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/indexing/RdfIndexingService.java
@@ -28,6 +28,7 @@ import java.util.Set;
 import org.apache.zest.api.activation.ActivatorAdapter;
 import org.apache.zest.api.activation.Activators;
 import org.apache.zest.api.entity.EntityDescriptor;
+import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Uses;
 import org.apache.zest.api.mixin.Mixins;
@@ -174,11 +175,11 @@ public interface RdfIndexingService
             {
                 if( entityState.status().equals( EntityStatus.REMOVED ) )
                 {
-                    removedStates.add( stateSerializer.createEntityURI( getValueFactory(), entityState.identity() ) );
+                    removedStates.add( stateSerializer.createEntityURI( getValueFactory(), entityState.entityReference() ) );
                 }
                 else if( entityState.status().equals( EntityStatus.UPDATED ) )
                 {
-                    removedStates.add( stateSerializer.createEntityURI( getValueFactory(), entityState.identity() ) );
+                    removedStates.add( stateSerializer.createEntityURI( getValueFactory(), entityState.entityReference() ) );
                 }
             }
 
@@ -196,7 +197,8 @@ public interface RdfIndexingService
         {
             if( entityState.entityDescriptor().queryable() )
             {
-                final URI entityURI = stateSerializer.createEntityURI( getValueFactory(), entityState.identity() );
+                EntityReference reference = entityState.entityReference();
+                final URI entityURI = stateSerializer.createEntityURI( getValueFactory(), reference);
                 Graph graph = new GraphImpl();
                 stateSerializer.serialize( entityState, false, graph );
                 connection.add( graph, entityURI );
@@ -210,8 +212,8 @@ public interface RdfIndexingService
         {
             if( entityType.queryable() )
             {
-                final URI compositeURI = getValueFactory().createURI(
-                    Classes.toURI( entityType.types().findFirst().orElse( null ) ) );
+                String uri = Classes.toURI(entityType.types().findFirst().orElse(null));
+                final URI compositeURI = getValueFactory().createURI( uri );
                 // remove composite type if already present
                 connection.clear( compositeURI );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/TupleQueryExecutor.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/TupleQueryExecutor.java b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/TupleQueryExecutor.java
index 794b50c..106e133 100644
--- a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/TupleQueryExecutor.java
+++ b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/TupleQueryExecutor.java
@@ -122,7 +122,7 @@ public interface TupleQueryExecutor
 
         private boolean processRow( long row, BindingSet bindingSet, QualifiedIdentityResultCallback callback )
         {
-            final Value identifier = bindingSet.getValue( "identity" );
+            final Value identifier = bindingSet.getValue( "reference" );
 
             //TODO Shall we throw an exception if there is no binding for identifier = query parser is not right
             if( identifier == null )
@@ -132,13 +132,13 @@ public interface TupleQueryExecutor
 
             final String identity = identifier.stringValue();
 
-            final EntityReference entityReference = new EntityReference( identity );
+            final EntityReference entityReference = EntityReference.parseEntityReference( identity );
             return callback.processRow( row, entityReference );
         }
 
         private Map<String, Value> getBindings(Map<String, Object> variables)
         {
-            Map<String, Value> bindings = new HashMap<String, Value>();
+            Map<String, Value> bindings = new HashMap<>();
             for (Map.Entry<String, Object> stringObjectEntry : variables.entrySet())
             {
                 if (!stringObjectEntry.getValue().getClass().equals(Object.class))

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
index 0d0cbff..8163237 100644
--- a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
+++ b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
@@ -132,7 +132,7 @@ public class RdfQueryParserImpl
         }
         else
         {
-            // Add type+identity triples last. This makes queries faster since the query engine can reduce the number
+            // Add type+reference triples last. This makes queries faster since the query engine can reduce the number
             // of triples to check faster
             triples.addDefaultTriples( resultType.getName() );
         }
@@ -149,7 +149,7 @@ public class RdfQueryParserImpl
         {
             query.append( format( "PREFIX %s: <%s> %n", namespaces.namespacePrefix( namespace ), namespace ) );
         }
-        query.append( "SELECT DISTINCT ?identity\n" );
+        query.append( "SELECT DISTINCT ?reference\n" );
         if( triples.hasTriples() )
         {
             query.append( "WHERE {\n" );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/Triples.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/Triples.java b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/Triples.java
index 33f44cb..b079c6f 100644
--- a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/Triples.java
+++ b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/Triples.java
@@ -23,7 +23,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.entity.Identity;
+import org.apache.zest.api.identity.HasIdentity;
 import org.apache.zest.api.query.grammar.AssociationFunction;
 import org.apache.zest.api.query.grammar.ManyAssociationFunction;
 import org.apache.zest.api.query.grammar.PropertyFunction;
@@ -62,8 +62,8 @@ public class Triples
         triples.add(
             new Triple(
                 "?entity",
-                addNamespace( QualifiedName.fromClass( Identity.class, "identity" ).toNamespace() ) + ":identity",
-                "?identity",
+                addNamespace( QualifiedName.fromClass( HasIdentity.class, "identity" ).toNamespace() ) + ":identity",
+                "?reference",
                 false
             )
         );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
index 2993ad0..d16d74e 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java
@@ -46,7 +46,6 @@ public class MultiLayeredTest extends AbstractMultiLayeredIndexingTest
         public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
             throws AssemblyException
         {
-            module.withDefaultUnitOfWorkFactory();
             new RdfMemoryStoreAssembler( Visibility.application, Visibility.module ).assemble( module );
             return module;
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
index 15a4d7a..bfaa9ca 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
@@ -34,6 +34,7 @@ import org.apache.zest.api.association.ManyAssociation;
 import org.apache.zest.api.common.UseDefaults;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.entity.EntityComposite;
+import org.apache.zest.api.identity.StringIdentity;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.query.Query;
 import org.apache.zest.api.query.QueryExpressions;
@@ -97,7 +98,7 @@ public class RDFPerformanceTest extends AbstractZestTest
         List<ExampleEntity> entities = new ArrayList<ExampleEntity>();
         for (Integer x = 0; x < howMany; ++x)
         {
-            ExampleEntity exampleEntity = this.unitOfWorkFactory.currentUnitOfWork().newEntity( ExampleEntity.class, "entity" + x );
+            ExampleEntity exampleEntity = this.unitOfWorkFactory.currentUnitOfWork().newEntity( ExampleEntity.class, new StringIdentity( "entity" + x ) );
 
             for (ExampleEntity entity : entities)
             {
@@ -183,8 +184,9 @@ public class RDFPerformanceTest extends AbstractZestTest
         UnitOfWork uow = this.unitOfWorkFactory.newUnitOfWork();
         for (int i = 0; i < 1000; i++)
         {
+            ExampleEntity entity50 = uow.get(ExampleEntity.class, new StringIdentity( "entity50" ) );
             Query<ExampleEntity> query = uow.newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class ).
-                    where( QueryExpressions.contains( QueryExpressions.templateFor( ExampleEntity.class ).manyAssoc(), uow.get( ExampleEntity.class, "entity50" ) ) ));
+                    where( QueryExpressions.contains( QueryExpressions.templateFor( ExampleEntity.class ).manyAssoc(), entity50) ));
             System.out.println(query.count());
         }
 


Mime
View raw message