polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [17/34] zest-java git commit: ZEST-136 - Massive changes to the Runtime, refactoring the Model and Instance relationship.
Date Thu, 14 Apr 2016 06:13:23 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/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 f34fdd4..5ee9f81 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
@@ -42,6 +42,7 @@ import org.apache.zest.api.service.ServiceActivation;
 import org.apache.zest.api.service.ServiceDescriptor;
 import org.apache.zest.api.service.qualifier.Tagged;
 import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.type.CollectionType;
 import org.apache.zest.api.type.EnumType;
 import org.apache.zest.api.type.MapType;
@@ -67,8 +68,6 @@ import org.apache.zest.spi.entitystore.EntityStoreSPI;
 import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
 import org.apache.zest.spi.entitystore.StateCommitter;
 import org.apache.zest.spi.entitystore.helpers.DefaultEntityState;
-import org.apache.zest.spi.structure.ModelModule;
-import org.apache.zest.spi.module.ModuleSpi;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -169,13 +168,13 @@ public class PreferencesEntityStoreMixin
     }
 
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
+    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, long currentTime )
     {
-        return new DefaultEntityStoreUnitOfWork( entityStoreSpi, newUnitOfWorkId(), usecase, currentTime );
+        return new DefaultEntityStoreUnitOfWork( module, entityStoreSpi, newUnitOfWorkId(), usecase, currentTime );
     }
 
     @Override
-    public Input<EntityState, EntityStoreException> entityStates( final ModuleSpi module )
+    public Input<EntityState, EntityStoreException> entityStates( final ModuleDescriptor module )
     {
         return new Input<EntityState, EntityStoreException>()
         {
@@ -192,7 +191,7 @@ public class PreferencesEntityStoreMixin
                         UsecaseBuilder builder = UsecaseBuilder.buildUsecase( "zest.entitystore.preferences.visit" );
                         Usecase visitUsecase = builder.withMetaInfo( CacheOptions.NEVER ).newUsecase();
                         final EntityStoreUnitOfWork uow =
-                            newUnitOfWork( visitUsecase, System.currentTimeMillis() );
+                            newUnitOfWork( module, visitUsecase, System.currentTimeMillis() );
 
                         try
                         {
@@ -224,7 +223,10 @@ public class PreferencesEntityStoreMixin
     }
 
     @Override
-    public EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleSpi module, EntityReference identity )
+    public EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork,
+                                      ModuleDescriptor module,
+                                      EntityReference identity
+    )
     {
         try
         {
@@ -241,51 +243,74 @@ public class PreferencesEntityStoreMixin
             EntityDescriptor entityDescriptor = module.entityDescriptor( type );
             if( entityDescriptor == null )
             {
-                throw new EntityTypeNotFoundException( type,
-                                                       module.name(),
-                                                       module.findVisibleEntityTypes()
-                                                           .map( ModelModule.toStringFunction )
-                );
+                throw EntityTypeNotFoundException.create( type, module );
             }
 
             Map<QualifiedName, Object> properties = new HashMap<>();
             final Preferences propsPrefs = entityPrefs.node( "properties" );
-            entityDescriptor.state().properties().forEach( persistentPropertyDescriptor ->
-            {
-                if( persistentPropertyDescriptor.qualifiedName().name().equals( "identity" ) )
+            entityDescriptor.state().properties().forEach(
+                persistentPropertyDescriptor ->
                 {
-                    // Fake identity property
-                    properties.put( persistentPropertyDescriptor.qualifiedName(), identity.identity() );
-                }
-                else
-                {
-                    ValueType propertyType = persistentPropertyDescriptor.valueType();
-                    Class<?> mainType = propertyType.mainType();
-                    if( Number.class.isAssignableFrom( mainType ) )
+                    if( persistentPropertyDescriptor.qualifiedName().name().equals( "identity" ) )
                     {
-                        if( mainType.equals( Long.class ) )
-                        {
-                            properties.put( persistentPropertyDescriptor.qualifiedName(),
-                                            this.getNumber( propsPrefs, persistentPropertyDescriptor, LONG_PARSER ) );
-                        }
-                        else if( mainType.equals( Integer.class ) )
-                        {
-                            properties.put( persistentPropertyDescriptor.qualifiedName(),
-                                            this.getNumber( propsPrefs, persistentPropertyDescriptor, INT_PARSER ) );
-                        }
-                        else if( mainType.equals( Double.class ) )
+                        // Fake identity property
+                        properties.put( persistentPropertyDescriptor.qualifiedName(), identity.identity() );
+                    }
+                    else
+                    {
+                        ValueType propertyType = persistentPropertyDescriptor.valueType();
+                        Class<?> mainType = propertyType.mainType();
+                        if( Number.class.isAssignableFrom( mainType ) )
                         {
-                            properties.put( persistentPropertyDescriptor.qualifiedName(),
-                                            this.getNumber( propsPrefs, persistentPropertyDescriptor, DOUBLE_PARSER ) );
+                            if( mainType.equals( Long.class ) )
+                            {
+                                properties.put( persistentPropertyDescriptor.qualifiedName(),
+                                                this.getNumber( propsPrefs, persistentPropertyDescriptor, LONG_PARSER ) );
+                            }
+                            else if( mainType.equals( Integer.class ) )
+                            {
+                                properties.put( persistentPropertyDescriptor.qualifiedName(),
+                                                this.getNumber( propsPrefs, persistentPropertyDescriptor, INT_PARSER ) );
+                            }
+                            else if( mainType.equals( Double.class ) )
+                            {
+                                properties.put( persistentPropertyDescriptor.qualifiedName(),
+                                                this.getNumber( propsPrefs, persistentPropertyDescriptor, DOUBLE_PARSER ) );
+                            }
+                            else if( mainType.equals( Float.class ) )
+                            {
+                                properties.put( persistentPropertyDescriptor.qualifiedName(),
+                                                this.getNumber( propsPrefs, persistentPropertyDescriptor, FLOAT_PARSER ) );
+                            }
+                            else
+                            {
+                                // Load as string even though it's a number
+                                String json = propsPrefs.get( persistentPropertyDescriptor.qualifiedName()
+                                                                  .name(), null );
+                                Object value;
+                                if( json == null )
+                                {
+                                    value = null;
+                                }
+                                else
+                                {
+                                    value = valueSerialization.deserialize( module, persistentPropertyDescriptor.valueType(), json );
+                                }
+                                properties.put( persistentPropertyDescriptor.qualifiedName(), value );
+                            }
                         }
-                        else if( mainType.equals( Float.class ) )
+                        else if( mainType.equals( Boolean.class ) )
                         {
+                            Boolean initialValue = (Boolean) persistentPropertyDescriptor.initialValue( module );
                             properties.put( persistentPropertyDescriptor.qualifiedName(),
-                                            this.getNumber( propsPrefs, persistentPropertyDescriptor, FLOAT_PARSER ) );
+                                            propsPrefs.getBoolean( persistentPropertyDescriptor.qualifiedName().name(),
+                                                                   initialValue == null ? false : initialValue ) );
                         }
-                        else
+                        else if( propertyType instanceof ValueCompositeType
+                                 || propertyType instanceof MapType
+                                 || propertyType instanceof CollectionType
+                                 || propertyType instanceof EnumType )
                         {
-                            // Load as string even though it's a number
                             String json = propsPrefs.get( persistentPropertyDescriptor.qualifiedName().name(), null );
                             Object value;
                             if( json == null )
@@ -294,58 +319,33 @@ public class PreferencesEntityStoreMixin
                             }
                             else
                             {
-                                value = valueSerialization.deserialize( persistentPropertyDescriptor.valueType(), json );
+                                value = valueSerialization.deserialize( module, persistentPropertyDescriptor.valueType(), json );
                             }
                             properties.put( persistentPropertyDescriptor.qualifiedName(), value );
                         }
-                    }
-                    else if( mainType.equals( Boolean.class ) )
-                    {
-                        Boolean initialValue = (Boolean) persistentPropertyDescriptor.initialValue( module );
-                        properties.put( persistentPropertyDescriptor.qualifiedName(),
-                                        propsPrefs.getBoolean( persistentPropertyDescriptor.qualifiedName().name(),
-                                                               initialValue == null ? false : initialValue ) );
-                    }
-                    else if( propertyType instanceof ValueCompositeType
-                             || propertyType instanceof MapType
-                             || propertyType instanceof CollectionType
-                             || propertyType instanceof EnumType )
-                    {
-                        String json = propsPrefs.get( persistentPropertyDescriptor.qualifiedName().name(), null );
-                        Object value;
-                        if( json == null )
-                        {
-                            value = null;
-                        }
                         else
                         {
-                            value = valueSerialization.deserialize( persistentPropertyDescriptor.valueType(), json );
-                        }
-                        properties.put( persistentPropertyDescriptor.qualifiedName(), value );
-                    }
-                    else
-                    {
-                        String json = propsPrefs.get( persistentPropertyDescriptor.qualifiedName().name(), null );
-                        if( json == null )
-                        {
-                            if( persistentPropertyDescriptor.initialValue( module ) != null )
+                            String json = propsPrefs.get( persistentPropertyDescriptor.qualifiedName().name(), null );
+                            if( json == null )
                             {
-                                properties.put( persistentPropertyDescriptor.qualifiedName(), persistentPropertyDescriptor
-                                    .initialValue( module ) );
+                                if( persistentPropertyDescriptor.initialValue( module ) != null )
+                                {
+                                    properties.put( persistentPropertyDescriptor.qualifiedName(), persistentPropertyDescriptor
+                                        .initialValue( module ) );
+                                }
+                                else
+                                {
+                                    properties.put( persistentPropertyDescriptor.qualifiedName(), null );
+                                }
                             }
                             else
                             {
-                                properties.put( persistentPropertyDescriptor.qualifiedName(), null );
+                                Object value = valueSerialization.deserialize( module, propertyType, json );
+                                properties.put( persistentPropertyDescriptor.qualifiedName(), value );
                             }
                         }
-                        else
-                        {
-                            Object value = valueSerialization.deserialize( propertyType, json );
-                            properties.put( persistentPropertyDescriptor.qualifiedName(), value );
-                        }
                     }
-                }
-            } );
+                } );
 
             // Associations
             Map<QualifiedName, EntityReference> associations = new HashMap<>();
@@ -441,9 +441,7 @@ public class PreferencesEntityStoreMixin
             }
 
             Preferences entityPrefs = root.node( identity.identity() );
-
-            String version = entityPrefs.get( "version", "" );
-            return version;
+            return entityPrefs.get( "version", "" );
         }
         catch( BackingStoreException e )
         {
@@ -515,7 +513,7 @@ public class PreferencesEntityStoreMixin
             // Properties
             Preferences propsPrefs = entityPrefs.node( "properties" );
             state.entityDescriptor().state().properties()
-                .filter(property -> ! property.qualifiedName().name().equals( "identity" ))
+                .filter( property -> !property.qualifiedName().name().equals( "identity" ) )
                 .forEach( persistentProperty ->
                           {
                               Object value = state.properties().get( persistentProperty.qualifiedName() );
@@ -573,9 +571,9 @@ public class PreferencesEntityStoreMixin
                                   {
                                       String jsonString = valueSerialization.serialize( value );
                                       propsPrefs.put( persistentProperty.qualifiedName().name(), jsonString );
-                    }
-                }
-            });
+                                  }
+                              }
+                          } );
 
             // Associations
             if( !state.associations().isEmpty() )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreTest.java b/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreTest.java
index bbfeb08..2731293 100644
--- a/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreTest.java
+++ b/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreTest.java
@@ -59,7 +59,7 @@ public class RedisMapEntityStoreTest
         throws Exception
     {
         super.setUp();
-        RedisMapEntityStoreService es = module.findService( RedisMapEntityStoreService.class ).get();
+        RedisMapEntityStoreService es = serviceFinder.findService( RedisMapEntityStoreService.class ).get();
         jedisPool = es.jedisPool();
 
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreWithCacheTest.java b/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreWithCacheTest.java
index fccd9b0..167932c 100644
--- a/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreWithCacheTest.java
+++ b/extensions/entitystore-redis/src/test/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreWithCacheTest.java
@@ -55,7 +55,7 @@ public class RedisMapEntityStoreWithCacheTest
         throws Exception
     {
         super.setUp();
-        RedisMapEntityStoreService es = module.findService( RedisMapEntityStoreService.class ).get();
+        RedisMapEntityStoreService es = serviceFinder.findService( RedisMapEntityStoreService.class ).get();
         jedisPool = es.jedisPool();
 
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakHttpMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakHttpMapEntityStoreTest.java b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakHttpMapEntityStoreTest.java
index e0b36ac..ff6c5e6 100644
--- a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakHttpMapEntityStoreTest.java
+++ b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakHttpMapEntityStoreTest.java
@@ -60,7 +60,7 @@ public class RiakHttpMapEntityStoreTest
         throws Exception
     {
         super.setUp();
-        RiakMapEntityStoreService es = module.findService( RiakMapEntityStoreService.class ).get();
+        RiakMapEntityStoreService es = serviceFinder.findService( RiakMapEntityStoreService.class ).get();
         riakClient = es.riakClient();
         bucketKey = es.bucket();
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreWithCacheTest.java b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
index 8bd136e..4c3e391 100644
--- a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
+++ b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreWithCacheTest.java
@@ -56,7 +56,7 @@ public class RiakMapEntityStoreWithCacheTest
         throws Exception
     {
         super.setUp();
-        RiakMapEntityStoreService es = module.findService( RiakMapEntityStoreService.class ).get();
+        RiakMapEntityStoreService es = serviceFinder.findService( RiakMapEntityStoreService.class ).get();
         riakClient = es.riakClient();
         bucketKey = es.bucket();
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakProtobufMapEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakProtobufMapEntityStoreTest.java b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakProtobufMapEntityStoreTest.java
index 4c7ac64..34a78fb 100644
--- a/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakProtobufMapEntityStoreTest.java
+++ b/extensions/entitystore-riak/src/test/java/org/apache/zest/entitystore/riak/RiakProtobufMapEntityStoreTest.java
@@ -60,7 +60,7 @@ public class RiakProtobufMapEntityStoreTest
         throws Exception
     {
         super.setUp();
-        RiakMapEntityStoreService es = module.findService( RiakMapEntityStoreService.class ).get();
+        RiakMapEntityStoreService es = serviceFinder.findService( RiakMapEntityStoreService.class ).get();
         riakClient = es.riakClient();
         bucketKey = es.bucket();
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/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 95ce3fe..0442a5c 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,7 @@ import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.service.ServiceActivation;
 import org.apache.zest.api.service.qualifier.Tagged;
 import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.type.ValueType;
 import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
 import org.apache.zest.api.usecase.Usecase;
@@ -68,8 +69,6 @@ import org.apache.zest.spi.entitystore.helpers.DefaultEntityState;
 import org.apache.zest.spi.entitystore.helpers.JSONKeys;
 import org.apache.zest.spi.entitystore.helpers.Migration;
 import org.apache.zest.spi.entitystore.helpers.StateStore;
-import org.apache.zest.spi.structure.ModelModule;
-import org.apache.zest.spi.module.ModuleSpi;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -229,7 +228,10 @@ public class SQLEntityStoreMixin
     }
 
     @Override
-    public EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleSpi module, EntityReference entityRef )
+    public EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork,
+                                      ModuleDescriptor module,
+                                      EntityReference entityRef
+    )
     {
         EntityValueResult valueResult = getValue( entityRef );
         DefaultEntityState state = readEntityState( module, valueResult.getReader() );
@@ -263,13 +265,13 @@ public class SQLEntityStoreMixin
     }
 
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
+    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, long currentTime )
     {
-        return new DefaultEntityStoreUnitOfWork( entityStoreSPI, newUnitOfWorkId(), usecase, currentTime );
+        return new DefaultEntityStoreUnitOfWork( module, entityStoreSPI, newUnitOfWorkId(), usecase, currentTime );
     }
 
     @Override
-    public Input<EntityState, EntityStoreException> entityStates( final ModuleSpi module )
+    public Input<EntityState, EntityStoreException> entityStates( final ModuleDescriptor module )
     {
         return new Input<EntityState, EntityStoreException>()
         {
@@ -300,7 +302,7 @@ public class SQLEntityStoreMixin
         };
     }
 
-    private void queryAllEntities( ModuleSpi module, EntityStatesVisitor entityStatesVisitor )
+    private void queryAllEntities( ModuleDescriptor module, EntityStatesVisitor entityStatesVisitor )
     {
         Connection connection = null;
         PreparedStatement ps = null;
@@ -342,13 +344,13 @@ public class SQLEntityStoreMixin
         return uuid + Integer.toHexString( count.incrementAndGet() );
     }
 
-    protected DefaultEntityState readEntityState( ModuleSpi module, Reader entityState )
+    protected DefaultEntityState readEntityState( ModuleDescriptor module, Reader entityState )
         throws EntityStoreException
     {
         try
         {
             JSONObject jsonObject = new JSONObject( new JSONTokener( entityState ) );
-            final EntityStatus[] status = {EntityStatus.LOADED};
+            final EntityStatus[] status = { EntityStatus.LOADED };
 
             String version = jsonObject.getString( JSONKeys.VERSION );
             long modified = jsonObject.getLong( JSONKeys.MODIFIED );
@@ -372,7 +374,7 @@ public class SQLEntityStoreMixin
                               identity, currentAppVersion, application.version() );
 
                 // State changed
-                status[0] = EntityStatus.UPDATED;
+                status[ 0 ] = EntityStatus.UPDATED;
             }
 
             String type = jsonObject.getString( JSONKeys.TYPE );
@@ -380,11 +382,7 @@ public class SQLEntityStoreMixin
             EntityDescriptor entityDescriptor = module.entityDescriptor( type );
             if( entityDescriptor == null )
             {
-                throw new EntityTypeNotFoundException( type,
-                                                       module.name(),
-                                                       module.findVisibleEntityTypes()
-                                                           .map( ModelModule.toStringFunction )
-                );
+                throw EntityTypeNotFoundException.create( type, module );
             }
 
             Map<QualifiedName, Object> properties = new HashMap<>();
@@ -400,7 +398,8 @@ public class SQLEntityStoreMixin
                     }
                     else
                     {
-                        Object value = valueSerialization.deserialize( propertyDescriptor.valueType(), jsonValue.toString() );
+                        Object value = valueSerialization.deserialize( module, propertyDescriptor.valueType(), jsonValue
+                            .toString() );
                         properties.put( propertyDescriptor.qualifiedName(), value );
                     }
                 }
@@ -409,7 +408,7 @@ public class SQLEntityStoreMixin
                     // Value not found, default it
                     Object initialValue = propertyDescriptor.initialValue( module );
                     properties.put( propertyDescriptor.qualifiedName(), initialValue );
-                    status[0] = EntityStatus.UPDATED;
+                    status[ 0 ] = EntityStatus.UPDATED;
                 }
             } );
 
@@ -427,7 +426,7 @@ public class SQLEntityStoreMixin
                 {
                     // Association not found, default it to null
                     associations.put( associationType.qualifiedName(), null );
-                    status[0] = EntityStatus.UPDATED;
+                    status[ 0 ] = EntityStatus.UPDATED;
                 }
             } );
 
@@ -480,10 +479,10 @@ public class SQLEntityStoreMixin
                     // NamedAssociation not found, default to empty one
                     namedAssociations.put( namedAssociationType.qualifiedName(), references );
                 }
-            });
+            } );
 
             return new DefaultEntityState( version, modified,
-                                           EntityReference.parseEntityReference( identity ), status[0], entityDescriptor,
+                                           EntityReference.parseEntityReference( identity ), status[ 0 ], entityDescriptor,
                                            properties, associations, manyAssociations, namedAssociations );
         }
         catch( JSONException e )
@@ -584,7 +583,8 @@ public class SQLEntityStoreMixin
             } );
 
             JSONWriter associations = properties.endObject().key( JSONKeys.ASSOCIATIONS ).object();
-            for( Map.Entry<QualifiedName, EntityReference> stateNameEntityReferenceEntry : state.associations().entrySet() )
+            for( Map.Entry<QualifiedName, EntityReference> stateNameEntityReferenceEntry : state.associations()
+                .entrySet() )
             {
                 EntityReference value = stateNameEntityReferenceEntry.getValue();
                 associations.key( stateNameEntityReferenceEntry.getKey().name() ).
@@ -592,7 +592,8 @@ public class SQLEntityStoreMixin
             }
 
             JSONWriter manyAssociations = associations.endObject().key( JSONKeys.MANY_ASSOCIATIONS ).object();
-            for( Map.Entry<QualifiedName, List<EntityReference>> stateNameListEntry : state.manyAssociations().entrySet() )
+            for( Map.Entry<QualifiedName, List<EntityReference>> stateNameListEntry : state.manyAssociations()
+                .entrySet() )
             {
                 JSONWriter assocs = manyAssociations.key( stateNameListEntry.getKey().name() ).array();
                 for( EntityReference entityReference : stateNameListEntry.getValue() )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/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 c33ddd0..8ccb56a 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
@@ -81,7 +81,7 @@ public class DerbySQLEntityStoreTest
         {
             SQLConfiguration config = uow.get( SQLConfiguration.class,
                                                DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
-            Connection connection = module.findService( DataSource.class ).get().getConnection();
+            Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
             connection.setAutoCommit( false );
             String schemaName = config.schemaName().get();
             if( schemaName == null )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/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 cb263ec..80459e8 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
@@ -93,7 +93,7 @@ public class MySQLEntityStoreTest
         {
             SQLConfiguration config = uow.get( SQLConfiguration.class,
                                                MySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
-            Connection connection = module.findService( DataSource.class ).get().getConnection();
+            Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
             connection.setAutoCommit( false );
             String schemaName = config.schemaName().get();
             if( schemaName == null )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/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 5504e36..8064a7d 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
@@ -119,7 +119,7 @@ public class PostgreSQLEntityStoreTest
         {
             SQLConfiguration config = uow.get( SQLConfiguration.class,
                                                PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
-            Connection connection = module.findService( DataSource.class ).get().getConnection();
+            Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
             connection.setAutoCommit( false );
             String schemaName = config.schemaName().get();
             if( schemaName == null )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/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 3d9fdf2..008ecb0 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
@@ -28,6 +28,7 @@ import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.service.qualifier.Tagged;
+import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.type.ValueType;
 import org.apache.zest.api.usecase.UsecaseBuilder;
 import org.apache.zest.api.util.Classes;
@@ -41,7 +42,6 @@ import org.apache.zest.spi.entity.NamedAssociationState;
 import org.apache.zest.spi.entitystore.EntityStore;
 import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
 import org.apache.zest.spi.entitystore.StateChangeListener;
-import org.apache.zest.spi.module.ModuleSpi;
 import org.elasticsearch.action.bulk.BulkRequestBuilder;
 import org.elasticsearch.action.bulk.BulkResponse;
 import org.json.JSONArray;
@@ -67,7 +67,7 @@ public interface ElasticSearchIndexer
         private static final Logger LOGGER = LoggerFactory.getLogger( ElasticSearchIndexer.class );
 
         @Structure
-        private ModuleSpi module;
+        private ModuleDescriptor module;
 
         @Service
         private EntityStore entityStore;
@@ -98,7 +98,7 @@ public interface ElasticSearchIndexer
             }
 
             EntityStoreUnitOfWork uow = entityStore.newUnitOfWork(
-                UsecaseBuilder.newUsecase( "Load associations for indexing" ),
+                module, UsecaseBuilder.newUsecase( "Load associations for indexing" ),
                 System.currentTimeMillis()
             );
 
@@ -190,8 +190,11 @@ public interface ElasticSearchIndexer
             try
             {
                 json.put( "_identity", state.identity().identity() );
-                json.put( "_types", state.entityDescriptor().mixinTypes().map( Classes.toClassName() ).collect( Collectors
-                                                                                                                   .toList() ) );
+                json.put( "_types", state.entityDescriptor()
+                    .mixinTypes()
+                    .map( Classes.toClassName() )
+                    .collect( Collectors
+                                  .toList() ) );
             }
             catch( JSONException e )
             {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/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 6bf8c83..45e8086 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
@@ -180,7 +180,7 @@ public class ElasticSearchTest
         Post post = postBuilder.instance();
         post.title().set( title );
         post.author().set( author );
-        post.tagline().set( module.newValue( Tagline.class ) );
+        post.tagline().set( valueBuilderFactory.newValue( Tagline.class ) );
         post.comments().add( comment1 );
         post.comments().add( comment2 );
         post = postBuilder.newInstance();
@@ -189,7 +189,7 @@ public class ElasticSearchTest
         Page page = pageBuilder.instance();
         page.title().set( title );
         page.author().set( author );
-        page.tagline().set( module.newValue( Tagline.class ) );
+        page.tagline().set( valueBuilderFactory.newValue( Tagline.class ) );
         page = pageBuilder.newInstance();
 
         System.out.println( "########################################" );
@@ -201,7 +201,7 @@ public class ElasticSearchTest
 
         uow = uowf.newUnitOfWork();
 
-        QueryBuilder<Post> queryBuilder = module.newQueryBuilder( Post.class );
+        QueryBuilder<Post> queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class );
         Query<Post> query = uow.newQuery( queryBuilder );
         assertEquals( 1, query.count() );
         post = query.find();
@@ -209,7 +209,7 @@ public class ElasticSearchTest
         assertEquals( title, post.title().get() );
 
         post = templateFor( Post.class );
-        queryBuilder = module.newQueryBuilder( Post.class ).where( eq( post.title(), title ) );
+        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( eq( post.title(), title ) );
         query = uow.newQuery( queryBuilder );
         assertEquals( 1, query.count() );
         post = query.find();
@@ -217,24 +217,24 @@ public class ElasticSearchTest
         assertEquals( title, post.title().get() );
 
         post = templateFor( Post.class );
-        queryBuilder = module.newQueryBuilder( Post.class ).where( eq( post.title(), "Not available" ) );
+        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( eq( post.title(), "Not available" ) );
         query = uow.newQuery( queryBuilder );
         assertEquals( 0, query.count() );
 
         post = templateFor( Post.class );
-        queryBuilder = module.newQueryBuilder( Post.class ).where( ne( post.title(), "Not available" ) );
+        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( ne( post.title(), "Not available" ) );
         query = uow.newQuery( queryBuilder );
         assertEquals( 1, query.count() );
 
         post = templateFor( Post.class );
-        queryBuilder = module.newQueryBuilder( Post.class ).where( not( eq( post.title(), "Not available" ) ) );
+        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( not( eq( post.title(), "Not available" ) ) );
         query = uow.newQuery( queryBuilder );
         post = query.find();
         assertNotNull( post );
         assertEquals( title, post.title().get() );
 
         post = templateFor( Post.class );
-        queryBuilder = module.newQueryBuilder( Post.class ).where( eq( post.author().get().nickname(), "eskatos" ) );
+        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( eq( post.author().get().nickname(), "eskatos" ) );
         query = uow.newQuery( queryBuilder );
         assertEquals( 1, query.count() );
         post = query.find();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
index b6b41f1..cdfb80c 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
@@ -132,7 +132,7 @@ public class ImmenseTermTest
         {
             testEntity = uow.get( testEntity );
             Query<TestEntity2> query = uow.newQuery(
-                module.newQueryBuilder( TestEntity2.class ).where(
+                queryBuilderFactory.newQueryBuilder( TestEntity2.class ).where(
                     eq( templateFor( TestEntity2.class ).property(), "test" )
                 )
             );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
index c0092a1..f405dbc 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java
@@ -307,7 +307,7 @@ public class ContainsAllTest
 
     private ExampleEntity findEntity( String... strings )
     {
-        QueryBuilder<ExampleEntity> builder = this.module.newQueryBuilder( ExampleEntity.class );
+        QueryBuilder<ExampleEntity> builder = this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class );
 
         builder = builder.where( QueryExpressions.containsAll(
                 QueryExpressions.templateFor( ExampleEntity.class ).strings(),
@@ -320,10 +320,10 @@ public class ContainsAllTest
         Set<ExampleValue> values = new HashSet<ExampleValue>();
         for( String value : valueStrings )
         {
-            ValueBuilder<ExampleValue2> vBuilder = this.module.newValueBuilder( ExampleValue2.class );
+            ValueBuilder<ExampleValue2> vBuilder = this.valueBuilderFactory.newValueBuilder( ExampleValue2.class );
             vBuilder.prototype().stringProperty().set( value );
 
-            ValueBuilder<ExampleValue> vBuilder2 = this.module.newValueBuilder( ExampleValue.class );
+            ValueBuilder<ExampleValue> vBuilder2 = this.valueBuilderFactory.newValueBuilder( ExampleValue.class );
             vBuilder2.prototype().valueProperty().set( vBuilder.newInstance() );
             values.add( vBuilder2.newInstance() );
         }
@@ -333,7 +333,7 @@ public class ContainsAllTest
 
     private Query<ExampleEntity> createComplexQuery( Set<ExampleValue> valuez )
     {
-        QueryBuilder<ExampleEntity> builder = this.module.newQueryBuilder( ExampleEntity.class );
+        QueryBuilder<ExampleEntity> builder = this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class );
         builder = builder.where( QueryExpressions.containsAll(
                 QueryExpressions.templateFor( ExampleEntity.class ).complexValue(),
                 valuez
@@ -348,7 +348,7 @@ public class ContainsAllTest
     {
         UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
         String[] entityStringsArray = new String[entityStrings.size()];
-        createEntityWithStrings( creatingUOW, this.module, entityStrings.toArray( entityStringsArray ) );
+        createEntityWithStrings( creatingUOW, this.valueBuilderFactory, entityStrings.toArray( entityStringsArray ) );
         creatingUOW.complete();
 
         UnitOfWork queryingUOW = this.uowf.newUnitOfWork();
@@ -369,7 +369,7 @@ public class ContainsAllTest
     {
         UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
         String[] entityStringsArray = new String[entityStrings.size()];
-        createEntityWithComplexValues( creatingUOW, this.module, entityStrings.toArray( entityStringsArray ) );
+        createEntityWithComplexValues( creatingUOW, this.valueBuilderFactory, entityStrings.toArray( entityStringsArray ) );
         creatingUOW.complete();
 
         UnitOfWork queryingUOW = this.uowf.newUnitOfWork();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
index 9fd4e54..84f5406 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java
@@ -136,7 +136,7 @@ public class ContainsTest extends AbstractZestTest
 
    private ExampleEntity findEntity(String string)
    {
-      QueryBuilder<ExampleEntity> builder = this.module.newQueryBuilder(ExampleEntity.class);
+      QueryBuilder<ExampleEntity> builder = this.queryBuilderFactory.newQueryBuilder(ExampleEntity.class);
 
       builder = builder.where(QueryExpressions.contains(
             QueryExpressions.templateFor(ExampleEntity.class).strings(),
@@ -149,10 +149,10 @@ public class ContainsTest extends AbstractZestTest
 
    private ExampleEntity findEntityBasedOnValueString(String valueString)
    {
-      ValueBuilder<ExampleValue2> vBuilder = this.module.newValueBuilder(ExampleValue2.class);
+      ValueBuilder<ExampleValue2> vBuilder = this.valueBuilderFactory.newValueBuilder(ExampleValue2.class);
          vBuilder.prototype().stringProperty().set(valueString);
 
-         ValueBuilder<ExampleValue> vBuilder2 = this.module.newValueBuilder(ExampleValue.class);
+         ValueBuilder<ExampleValue> vBuilder2 = this.valueBuilderFactory.newValueBuilder(ExampleValue.class);
          vBuilder2.prototype().valueProperty().set(vBuilder.newInstance());
 
       return this.createComplexQuery(vBuilder2.newInstance()).find();
@@ -160,7 +160,7 @@ public class ContainsTest extends AbstractZestTest
 
    private Query<ExampleEntity> createComplexQuery(ExampleValue value)
    {
-      QueryBuilder<ExampleEntity> builder = this.module.newQueryBuilder(ExampleEntity.class);
+      QueryBuilder<ExampleEntity> builder = this.queryBuilderFactory.newQueryBuilder(ExampleEntity.class);
       builder = builder.where(QueryExpressions.contains(
             QueryExpressions.templateFor(ExampleEntity.class).complexValue(),
             value
@@ -174,7 +174,7 @@ public class ContainsTest extends AbstractZestTest
    {
       UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
       String[] entityStringsArray = new String[entityStrings.size()];
-      ContainsAllTest.createEntityWithStrings(creatingUOW, this.module, entityStrings.toArray(entityStringsArray));
+      ContainsAllTest.createEntityWithStrings(creatingUOW, this.valueBuilderFactory, entityStrings.toArray(entityStringsArray));
       creatingUOW.complete();
 
       UnitOfWork queryingUOW = this.uowf.newUnitOfWork();
@@ -193,7 +193,7 @@ public class ContainsTest extends AbstractZestTest
    {
       UnitOfWork creatingUOW = this.uowf.newUnitOfWork();
       String[] entityStringsArray = new String[entityStrings.size()];
-      ContainsAllTest.createEntityWithComplexValues(creatingUOW, this.module, entityStrings.toArray(entityStringsArray));
+      ContainsAllTest.createEntityWithComplexValues(creatingUOW, this.valueBuilderFactory, entityStrings.toArray(entityStringsArray));
       creatingUOW.complete();
 
       UnitOfWork queryingUOW = this.uowf.newUnitOfWork();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/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 c005360..6974e90 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
@@ -118,7 +118,7 @@ public class RDFPerformanceTest extends AbstractZestTest
     {
         List<ExampleEntity> list = new ArrayList<ExampleEntity>();
         UnitOfWork uow = this.uowf.newUnitOfWork();
-        Iterator<ExampleEntity> iter = uow.newQuery( this.module.newQueryBuilder( ExampleEntity.class ) ).iterator();
+        Iterator<ExampleEntity> iter = uow.newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class ) ).iterator();
         int found = 0;
         while (iter.hasNext())
         {
@@ -141,7 +141,7 @@ public class RDFPerformanceTest extends AbstractZestTest
 
     private void doRemove( int howMany )
     {
-        Iterator<ExampleEntity> iter = this.uowf.currentUnitOfWork().newQuery( this.module.newQueryBuilder( ExampleEntity.class )).maxResults( howMany ).iterator();
+        Iterator<ExampleEntity> iter = this.uowf.currentUnitOfWork().newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class )).maxResults( howMany ).iterator();
         Integer removed = 0;
         while (iter.hasNext())
         {
@@ -175,7 +175,7 @@ public class RDFPerformanceTest extends AbstractZestTest
         UnitOfWork uow = this.uowf.newUnitOfWork();
         for (int i = 0; i < 1000; i++)
         {
-            Query<ExampleEntity> query = uow.newQuery( this.module.newQueryBuilder( ExampleEntity.class ).
+            Query<ExampleEntity> query = uow.newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class ).
                     where( QueryExpressions.contains( QueryExpressions.templateFor( ExampleEntity.class ).manyAssoc(), uow.get( ExampleEntity.class, "entity50" ) ) ));
             System.out.println(query.count());
         }
@@ -219,7 +219,7 @@ public class RDFPerformanceTest extends AbstractZestTest
         this.performTest( 200 );
 
         IndexExporter indexerExporter =
-                module.findService( IndexExporter.class ).get();
+                serviceFinder.findService( IndexExporter.class ).get();
         indexerExporter.exportReadableToStream( System.out );
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
index 1d83240..22985e5 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java
@@ -74,7 +74,7 @@ public class Qi173IssueTest
         }
 
         uow = uowf.newUnitOfWork();
-        QueryBuilder<Car> qb = module.newQueryBuilder( Car.class );
+        QueryBuilder<Car> qb = queryBuilderFactory.newQueryBuilder( Car.class );
         Car template = QueryExpressions.templateFor( Car.class );
         qb = qb.where( QueryExpressions.eq( template.year(), 2007 ) );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
index ed7c460..be637fd 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java
@@ -42,7 +42,7 @@ public final class IssueTest
     {
         super.setUp();
 
-        accountService = module.findService( AccountService.class ).get();
+        accountService = serviceFinder.findService( AccountService.class ).get();
     }
 
     @Test( expected = IllegalStateException.class )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
index 23a1d8b..f3cb7d3 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java
@@ -38,7 +38,7 @@ public final class IssueTest
     {
         super.setUp();
 
-        accountService = module.findService( AccountService.class ).get();
+        accountService = serviceFinder.findService( AccountService.class ).get();
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
index 1675973..b354031 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java
@@ -38,7 +38,7 @@ public class IssueTest
     {
         super.setUp();
 
-        accountService = module.findService( AccountService.class ).get();
+        accountService = serviceFinder.findService( AccountService.class ).get();
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java b/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
index 621b02f..789b122 100644
--- a/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
+++ b/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
@@ -86,7 +86,7 @@ public class SolrQueryServiceTest
     {
         // Search for it
         UnitOfWork uow = uowf.newUnitOfWork();
-        Query<TestEntity> query = uow.newQuery( module.newQueryBuilder( TestEntity.class ).where( SolrExpressions.search( "hello" ) ) );
+        Query<TestEntity> query = uow.newQuery( queryBuilderFactory.newQueryBuilder( TestEntity.class ).where( SolrExpressions.search( "hello" ) ) );
 
         TestEntity test = query.find();
         Assert.assertThat( test.name().get(), equalTo( "Hello World" ) );
@@ -99,7 +99,7 @@ public class SolrQueryServiceTest
         throws UnitOfWorkCompletionException, SolrServerException
     {
         // Search for it using search interface
-        SolrSearch search = (SolrSearch) module.findService( SolrSearch.class ).get();
+        SolrSearch search = serviceFinder.findService( SolrSearch.class ).get();
 
         SolrDocumentList results = search.search( "hello" );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
index 1bbae97..5832447 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
@@ -27,6 +27,7 @@ import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.property.PropertyDescriptor;
+import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.type.CollectionType;
 import org.apache.zest.api.type.ValueCompositeType;
 import org.apache.zest.api.type.ValueType;
@@ -194,6 +195,12 @@ import org.slf4j.LoggerFactory;
         }
 
         @Override
+        public ModuleDescriptor module()
+        {
+            return wrappedEntityDescriptor.module();
+        }
+
+        @Override
         public AssociationStateDescriptor state()
         {
             return new CompatAssociationStateDescriptorWrapper( wrappedEntityDescriptor.state() );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLComplexQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLComplexQueryTest.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLComplexQueryTest.java
index 1a0f826..d7f9f37 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLComplexQueryTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLComplexQueryTest.java
@@ -51,7 +51,7 @@ public class PostgreSQLComplexQueryTest
             // Let's check if exception was because database was not available
             if( this.module != null )
             {
-                SQLTestHelper.setUpTest( this.module );
+                SQLTestHelper.setUpTest( this.serviceFinder );
             }
 
             // If we got this far, the database must have been available, and exception must have

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
index 2e1389d..88d4b54 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
@@ -72,7 +72,7 @@ public class PostgreSQLDBIntegrityTest
         super.setUp();
         if( this.module != null )
         {
-            SQLTestHelper.setUpTest( this.module );
+            SQLTestHelper.setUpTest( this.serviceFinder );
         }
     }
 
@@ -95,7 +95,7 @@ public class PostgreSQLDBIntegrityTest
         uow.remove( entity );
         uow.complete();
 
-        Connection connection = this.module.findService( DataSource.class ).get().getConnection();
+        Connection connection = this.serviceFinder.findService( DataSource.class ).get().getConnection();
         try
         {
             GenericDatabaseExplorer.visitDatabaseTables(

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLEntityFinderTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLEntityFinderTest.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLEntityFinderTest.java
index 3f07e2b..7ad7bc0 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLEntityFinderTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLEntityFinderTest.java
@@ -51,7 +51,7 @@ public class PostgreSQLEntityFinderTest
             // Let's check if exception was because database was not available
             if( this.module != null )
             {
-                SQLTestHelper.setUpTest( this.module );
+                SQLTestHelper.setUpTest( this.serviceFinder );
             }
 
             // If we got this far, the database must have been available, and exception must have

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
index a0945e9..282d05b 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
@@ -59,7 +59,7 @@ public class PostgreSQLQueryTest
             // Let's check if exception was because database was not available
             if( this.module != null )
             {
-                SQLTestHelper.setUpTest( this.module );
+                SQLTestHelper.setUpTest( this.serviceFinder );
             }
 
             // If we got this far, the database must have been available, and exception must have

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/SQLTestHelper.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/SQLTestHelper.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/SQLTestHelper.java
index e2254dc..7e3cd18 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/SQLTestHelper.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/SQLTestHelper.java
@@ -16,6 +16,7 @@ package org.apache.zest.index.sql.postgresql;
 
 import java.sql.Connection;
 import javax.sql.DataSource;
+import org.apache.zest.api.service.ServiceFinder;
 import org.junit.Assume;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.structure.Module;
@@ -87,13 +88,13 @@ public class SQLTestHelper
             visibleIn( Visibility.layer );
     }
 
-    public static void setUpTest( Module module )
+    public static void setUpTest( ServiceFinder serviceFinder )
     {
         Connection connection = null;
         try
         {
 
-            DataSource ds = module.findService( DataSource.class ).get();
+            DataSource ds = serviceFinder.findService( DataSource.class ).get();
             connection = ds.getConnection();
             Assume.assumeNotNull( connection );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
----------------------------------------------------------------------
diff --git a/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java b/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
index fad2722..e6ff329 100644
--- a/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
+++ b/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
@@ -26,6 +26,7 @@ import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.service.ServiceReference;
+import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.index.reindexer.Reindexer;
 import org.apache.zest.index.reindexer.ReindexerConfiguration;
 import org.apache.zest.io.Output;
@@ -34,7 +35,6 @@ import org.apache.zest.io.Sender;
 import org.apache.zest.spi.entity.EntityState;
 import org.apache.zest.spi.entitystore.EntityStore;
 import org.apache.zest.spi.entitystore.StateChangeListener;
-import org.apache.zest.spi.module.ModuleSpi;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -65,7 +65,7 @@ public class ReindexerMixin
     private Iterable<ServiceReference<StateChangeListener>> listeners;
 
     @Structure
-    private ModuleSpi module;
+    private ModuleDescriptor module;
 
     private Logger logger = LoggerFactory.getLogger( Reindexer.class );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
----------------------------------------------------------------------
diff --git a/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java b/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
index c95a8bc..b014abd 100644
--- a/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
+++ b/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
@@ -108,11 +108,11 @@ public class ReindexerTest
 
         // ----> Reindex and assert data
 
-        module.<ReindexerService>findService( ReindexerService.class ).get().reindex(); // Reindex
+        serviceFinder.findService( ReindexerService.class ).get().reindex(); // Reindex
 
         uow = uowf.newUnitOfWork();
 
-        QueryBuilder<MyEntity> qBuilder = module.newQueryBuilder( MyEntity.class );
+        QueryBuilder<MyEntity> qBuilder = queryBuilderFactory.newQueryBuilder( MyEntity.class );
         qBuilder = qBuilder.where( eq( templateFor( MyEntity.class ).name(), TEST_NAME ) );
         Query<MyEntity> q = uow.newQuery( qBuilder );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
index 1ff5cd8..05ca607 100644
--- a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
+++ b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
@@ -27,13 +27,8 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.function.Function;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.type.ValueType;
-import org.apache.zest.api.value.ValueDeserializer;
 import org.apache.zest.api.value.ValueSerializationException;
 import org.apache.zest.spi.value.ValueDeserializerAdapter;
 
@@ -46,29 +41,22 @@ public class JacksonValueDeserializer
 
     private final JsonFactory jsonFactory = new MappingJsonFactory();
 
-    public JacksonValueDeserializer( @Structure Application application,
-                                     @Structure Module module,
-                                     @Service ServiceReference<ValueDeserializer> serviceRef )
-    {
-        super( application, module, serviceRef );
-    }
-
     @Override
-    protected JsonParser adaptInput( InputStream input )
+    protected JsonParser adaptInput( ModuleDescriptor module, InputStream input )
         throws Exception
     {
         return jsonFactory.createParser( input );
     }
 
     @Override
-    protected void onDeserializationEnd( ValueType valueType, JsonParser input )
+    protected void onDeserializationEnd( ModuleDescriptor module, ValueType valueType, JsonParser input )
         throws Exception
     {
         input.close();
     }
 
     @Override
-    protected Object readPlainValue( JsonParser input )
+    protected Object readPlainValue( ModuleDescriptor module, JsonParser input )
         throws Exception
     {
         JsonNode jsonNode = input.readValueAsTree();
@@ -101,9 +89,11 @@ public class JacksonValueDeserializer
     }
 
     @Override
-    protected <T> Collection<T> readArrayInCollection( JsonParser input,
+    protected <T> Collection<T> readArrayInCollection( ModuleDescriptor module,
+                                                       JsonParser input,
                                                        Function<JsonParser, T> deserializer,
-                                                       Collection<T> collection )
+                                                       Collection<T> collection
+    )
         throws Exception
     {
         JsonToken token = input.getCurrentToken();
@@ -133,10 +123,12 @@ public class JacksonValueDeserializer
     }
 
     @Override
-    protected <K, V> Map<K, V> readMapInMap( JsonParser input,
+    protected <K, V> Map<K, V> readMapInMap( ModuleDescriptor module,
+                                             JsonParser input,
                                              Function<JsonParser, K> keyDeserializer,
                                              Function<JsonParser, V> valueDeserializer,
-                                             Map<K, V> map )
+                                             Map<K, V> map
+    )
         throws Exception
     {
         JsonToken token = input.getCurrentToken();
@@ -197,7 +189,7 @@ public class JacksonValueDeserializer
     }
 
     @Override
-    protected ObjectNode readObjectTree( JsonParser input )
+    protected ObjectNode readObjectTree( ModuleDescriptor module, JsonParser input )
         throws Exception
     {
         JsonToken token = input.getCurrentToken();
@@ -218,7 +210,7 @@ public class JacksonValueDeserializer
     }
 
     @Override
-    protected Object asSimpleValue( JsonNode inputNode )
+    protected Object asSimpleValue( ModuleDescriptor module, JsonNode inputNode )
         throws Exception
     {
         if( isNullOrMissing( inputNode ) )
@@ -249,7 +241,8 @@ public class JacksonValueDeserializer
     }
 
     @Override
-    protected boolean isObjectValue( JsonNode inputNode )
+    @SuppressWarnings( "SimplifiableIfStatement" )
+    protected boolean isObjectValue( ModuleDescriptor module, JsonNode inputNode )
         throws Exception
     {
         if( isNullOrMissing( inputNode ) )
@@ -260,7 +253,7 @@ public class JacksonValueDeserializer
     }
 
     @Override
-    protected boolean objectHasField( JsonNode inputNode, String key )
+    protected boolean objectHasField( ModuleDescriptor module, JsonNode inputNode, String key )
         throws Exception
     {
         if( isNullOrMissing( inputNode ) )
@@ -275,7 +268,11 @@ public class JacksonValueDeserializer
     }
 
     @Override
-    protected <T> T getObjectFieldValue( JsonNode inputNode, String key, Function<JsonNode, T> valueDeserializer )
+    protected <T> T getObjectFieldValue( ModuleDescriptor module,
+                                         JsonNode inputNode,
+                                         String key,
+                                         Function<JsonNode, T> valueDeserializer
+    )
         throws Exception
     {
         JsonNode valueNode = inputNode.get( key );
@@ -283,14 +280,15 @@ public class JacksonValueDeserializer
         {
             return null;
         }
-        T value = valueDeserializer.apply( valueNode );
-        return value;
+        return valueDeserializer.apply( valueNode );
     }
 
     @Override
-    protected <T> void putArrayNodeInCollection( JsonNode inputNode,
+    protected <T> void putArrayNodeInCollection( ModuleDescriptor module,
+                                                 JsonNode inputNode,
                                                  Function<JsonNode, T> deserializer,
-                                                 Collection<T> collection )
+                                                 Collection<T> collection
+    )
         throws Exception
     {
         if( isNullOrMissing( inputNode ) )
@@ -310,10 +308,12 @@ public class JacksonValueDeserializer
     }
 
     @Override
-    protected <K, V> void putArrayNodeInMap( JsonNode inputNode,
+    protected <K, V> void putArrayNodeInMap( ModuleDescriptor module,
+                                             JsonNode inputNode,
                                              Function<JsonNode, K> keyDeserializer,
                                              Function<JsonNode, V> valueDeserializer,
-                                             Map<K, V> map )
+                                             Map<K, V> map
+    )
         throws Exception
     {
         if( isNullOrMissing( inputNode ) )
@@ -343,7 +343,8 @@ public class JacksonValueDeserializer
     }
 
     @Override
-    protected <V> void putObjectNodeInMap( JsonNode inputNode,
+    protected <V> void putObjectNodeInMap( ModuleDescriptor module,
+                                           JsonNode inputNode,
                                            Function<JsonNode, V> valueDeserializer,
                                            Map<String, V> map
     )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java b/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
index 3f86b64..df859c5 100644
--- a/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
+++ b/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
@@ -35,12 +35,7 @@ import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.stream.StreamSource;
 import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.value.ValueDeserializer;
+import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.value.ValueSerializationException;
 import org.apache.zest.spi.value.ValueDeserializerAdapter;
 import org.w3c.dom.Document;
@@ -58,11 +53,8 @@ public class StaxValueDeserializer
     private final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
     private final TransformerFactory transformerFactory = TransformerFactory.newInstance();
 
-    public StaxValueDeserializer( @Structure Application application,
-                                  @Structure Module module,
-                                  @Service ServiceReference<ValueDeserializer> serviceRef )
+    public StaxValueDeserializer()
     {
-        super( application, module, serviceRef );
         // Input Factory setup
         inputFactory.setProperty( "javax.xml.stream.isValidating", Boolean.FALSE );
         inputFactory.setProperty( "javax.xml.stream.isNamespaceAware", Boolean.FALSE );
@@ -72,14 +64,14 @@ public class StaxValueDeserializer
     }
 
     @Override
-    protected XMLEventReader adaptInput( InputStream input )
+    protected XMLEventReader adaptInput( ModuleDescriptor module, InputStream input )
         throws Exception
     {
         return inputFactory.createXMLEventReader( input, "UTF-8" );
     }
 
     @Override
-    protected Object readPlainValue( XMLEventReader input )
+    protected Object readPlainValue( ModuleDescriptor module, XMLEventReader input )
         throws Exception
     {
         if( !input.hasNext() )
@@ -102,9 +94,11 @@ public class StaxValueDeserializer
     }
 
     @Override
-    protected <T> Collection<T> readArrayInCollection( XMLEventReader input,
+    protected <T> Collection<T> readArrayInCollection( ModuleDescriptor module,
+                                                       XMLEventReader input,
                                                        Function<XMLEventReader, T> deserializer,
-                                                       Collection<T> collection )
+                                                       Collection<T> collection
+    )
         throws Exception
     {
         if( !input.hasNext() )
@@ -130,10 +124,10 @@ public class StaxValueDeserializer
                 String endElementName = currentTag.asEndElement().getName().getLocalPart();
                 switch( endElementName )
                 {
-                    case "array":
-                        break WHILE;
-                    case "value":
-                        continue;
+                case "array":
+                    break WHILE;
+                case "value":
+                    continue;
                 }
             }
             if( !"value".equals( currentTag.asStartElement().getName().getLocalPart() ) )
@@ -147,10 +141,12 @@ public class StaxValueDeserializer
     }
 
     @Override
-    protected <K, V> Map<K, V> readMapInMap( XMLEventReader input,
+    protected <K, V> Map<K, V> readMapInMap( ModuleDescriptor module,
+                                             XMLEventReader input,
                                              Function<XMLEventReader, K> keyDeserializer,
                                              Function<XMLEventReader, V> valueDeserializer,
-                                             Map<K, V> map )
+                                             Map<K, V> map
+    )
         throws Exception
     {
         if( !input.hasNext() )
@@ -170,14 +166,18 @@ public class StaxValueDeserializer
         XMLEvent currentTag = input.nextTag(); // <object>
         while( !currentTag.isEndElement() || !"array".equals( currentTag.asEndElement().getName().getLocalPart() ) )
         {
-            if( !currentTag.isStartElement() || !"object".equals( currentTag.asStartElement().getName().getLocalPart() ) )
+            if( !currentTag.isStartElement() || !"object".equals( currentTag.asStartElement()
+                                                                      .getName()
+                                                                      .getLocalPart() ) )
             {
                 throw new ValueSerializationException( "Expected an <object/> but got: " + nextTag );
             }
             currentTag = input.nextTag(); // <field>
             K key = null;
             V value = null;
-            while( !currentTag.isEndElement() || !"object".equals( currentTag.asEndElement().getName().getLocalPart() ) )
+            while( !currentTag.isEndElement() || !"object".equals( currentTag.asEndElement()
+                                                                       .getName()
+                                                                       .getLocalPart() ) )
             {
                 input.nextTag(); // <name>
                 String keyOrValue = input.nextEvent().asCharacters().getData();
@@ -185,15 +185,15 @@ public class StaxValueDeserializer
                 input.nextTag(); // <value>
                 switch( keyOrValue )
                 {
-                    case "key":
-                        key = keyDeserializer.apply( input );
-                        break;
-                    case "value":
-                        value = valueDeserializer.apply( input );
-                        break;
-                    default:
-                        readObjectTree( input );
-                        break;
+                case "key":
+                    key = keyDeserializer.apply( input );
+                    break;
+                case "value":
+                    value = valueDeserializer.apply( input );
+                    break;
+                default:
+                    readObjectTree( module, input );
+                    break;
                 }
                 input.nextTag(); // </value>
                 input.nextTag(); // </field>
@@ -209,7 +209,7 @@ public class StaxValueDeserializer
     }
 
     @Override
-    protected Node readObjectTree( XMLEventReader input )
+    protected Node readObjectTree( ModuleDescriptor module, XMLEventReader input )
         throws Exception
     {
         XMLEvent peek = input.peek();
@@ -224,7 +224,6 @@ public class StaxValueDeserializer
         DOMResult domResult = new DOMResult();
         transformer.transform( new StreamSource( new StringReader( elementBody ) ), domResult );
         return ( (Document) domResult.getNode() ).getDocumentElement();
-
     }
 
     private static String readElementBody( XMLEventReader input )
@@ -259,7 +258,7 @@ public class StaxValueDeserializer
     }
 
     @Override
-    protected Object asSimpleValue( Node inputNode )
+    protected Object asSimpleValue( ModuleDescriptor module, Node inputNode )
         throws Exception
     {
         if( inputNode == null )
@@ -279,7 +278,8 @@ public class StaxValueDeserializer
     }
 
     @Override
-    protected boolean isObjectValue( Node inputNode )
+    @SuppressWarnings( "SimplifiableIfStatement" )
+    protected boolean isObjectValue( ModuleDescriptor module, Node inputNode )
         throws Exception
     {
         if( inputNode == null )
@@ -298,7 +298,7 @@ public class StaxValueDeserializer
     }
 
     @Override
-    protected boolean objectHasField( Node inputNode, String key )
+    protected boolean objectHasField( ModuleDescriptor module, Node inputNode, String key )
         throws Exception
     {
         if( inputNode == null )
@@ -327,9 +327,11 @@ public class StaxValueDeserializer
 
     @Override
     @SuppressWarnings( "unchecked" )
-    protected <T> T getObjectFieldValue( Node inputNode,
+    protected <T> T getObjectFieldValue( ModuleDescriptor module,
+                                         Node inputNode,
                                          String key,
-                                         Function<Node, T> valueDeserializer )
+                                         Function<Node, T> valueDeserializer
+    )
         throws Exception
     {
         if( inputNode == null )
@@ -359,6 +361,10 @@ public class StaxValueDeserializer
             return null;
         }
         Node valueElement = getDirectChildNode( fieldNode, "value" );
+        if( valueElement == null )
+        {
+            return null;
+        }
         Node valueNode = valueElement.getFirstChild();
         if( valueNode == null )
         {
@@ -368,14 +374,15 @@ public class StaxValueDeserializer
         {
             return null;
         }
-        T value = valueDeserializer.apply( valueNode );
-        return value;
+        return valueDeserializer.apply( valueNode );
     }
 
     @Override
-    protected <T> void putArrayNodeInCollection( Node inputNode,
+    protected <T> void putArrayNodeInCollection( ModuleDescriptor module,
+                                                 Node inputNode,
                                                  Function<Node, T> deserializer,
-                                                 Collection<T> collection )
+                                                 Collection<T> collection
+    )
         throws Exception
     {
         if( inputNode == null )
@@ -396,9 +403,11 @@ public class StaxValueDeserializer
     }
 
     @Override
-    protected <K, V> void putArrayNodeInMap( Node inputNode,
+    protected <K, V> void putArrayNodeInMap( ModuleDescriptor module,
+                                             Node inputNode,
                                              Function<Node, K> keyDeserializer,
-                                             Function<Node, V> valueDeserializer, Map<K, V> map )
+                                             Function<Node, V> valueDeserializer, Map<K, V> map
+    )
         throws Exception
     {
         if( inputNode == null )
@@ -413,8 +422,8 @@ public class StaxValueDeserializer
         for( int idx = 0; idx < entriesNodes.getLength(); idx++ )
         {
             Node entryNode = entriesNodes.item( idx );
-            K key = getObjectFieldValue( entryNode, "key", keyDeserializer );
-            V value = getObjectFieldValue( entryNode, "value", valueDeserializer );
+            K key = getObjectFieldValue( module, entryNode, "key", keyDeserializer );
+            V value = getObjectFieldValue( module, entryNode, "value", valueDeserializer );
             if( key != null )
             {
                 map.put( key, value );
@@ -423,9 +432,11 @@ public class StaxValueDeserializer
     }
 
     @Override
-    protected <V> void putObjectNodeInMap( Node inputNode,
+    protected <V> void putObjectNodeInMap( ModuleDescriptor module,
+                                           Node inputNode,
                                            Function<Node, V> valueDeserializer,
-                                           Map<String, V> map )
+                                           Map<String, V> map
+    )
         throws Exception
     {
         if( inputNode == null )
@@ -440,10 +451,11 @@ public class StaxValueDeserializer
         for( int idx = 0; idx < fieldsNodes.getLength(); idx++ )
         {
             Node fieldNode = fieldsNodes.item( idx );
-            String key = getDirectChildNode( fieldNode, "name" ).getTextContent();
+            Node node = getDirectChildNode( fieldNode, "name" );
+            String key = node != null ? node.getTextContent() : null;
             if( key != null && key.length() > 0 )
             {
-                V value = getObjectFieldValue( inputNode, key, valueDeserializer );
+                V value = getObjectFieldValue( module, inputNode, key, valueDeserializer );
                 map.put( key, value );
             }
         }


Mime
View raw message