polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [05/12] zest-java git commit: ZEST-136 - Massive changes to the Runtime, refactoring the Model and Instance relationship.
Date Thu, 17 Dec 2015 13:16:21 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
index 5d67aa2..02448d3 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
@@ -33,14 +33,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.Scanner;
 import java.util.Set;
-import java.util.function.BiFunction;
 import java.util.function.Function;
 import org.apache.zest.api.entity.EntityReference;
-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.CollectionType;
 import org.apache.zest.api.type.EnumType;
 import org.apache.zest.api.type.MapType;
@@ -105,10 +100,6 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
     private static final String UTF_8 = "UTF-8";
     private final Map<Class<?>, Function<Object, Object>> deserializers = new HashMap<>( 16 );
     private final Map<Class<?>, ComplexDeserializer<Object, InputType, InputNodeType>> complexDeserializers = new HashMap<>( 2 );
-    private final Application application;
-    private final Module module;
-    private Function<Application, Module> valuesModuleFinder;
-    private Module valuesModule;
 
     /**
      * Register a Plain Value type deserialization Function.
@@ -131,24 +122,8 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
         complexDeserializers.put( type, (ComplexDeserializer<Object, InputType, InputNodeType>) deserializer );
     }
 
-    @SuppressWarnings( "unchecked" )
-    public ValueDeserializerAdapter( @Structure Application application,
-                                     @Structure Module module,
-                                     @Service ServiceReference<ValueDeserializer> serviceRef
-    )
+    protected ValueDeserializerAdapter()
     {
-        this( application, module, serviceRef.metaInfo( Function.class ) );
-    }
-
-    protected ValueDeserializerAdapter( Application application,
-                                        Module module,
-                                        Function<Application, Module> valuesModuleFinder
-    )
-    {
-
-        this.application = application;
-        this.module = module;
-        setValuesModuleFinder( valuesModuleFinder );
 
         // Primitive Value types
         registerDeserializer( String.class, Object::toString );
@@ -189,84 +164,58 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
         registerDeserializer( EntityReference.class, input -> EntityReference.parseEntityReference( input.toString() ) );
     }
 
-    private void setValuesModuleFinder( Function<Application, Module> valuesModuleFinder )
-    {
-        this.valuesModuleFinder = valuesModuleFinder;
-        this.valuesModule = null;
-    }
-
-    private Module valuesModule()
-    {
-        if( valuesModule == null )
-        {
-            if( valuesModuleFinder == null )
-            {
-                valuesModule = module;
-            }
-            else
-            {
-                valuesModule = valuesModuleFinder.apply( application );
-                if( valuesModule == null )
-                {
-                    throw new ValueSerializationException( "Values Module provided by the finder Function was null." );
-                }
-            }
-        }
-        return valuesModule;
-    }
-
     @Override
-    public <T> Function<String, T> deserialize( Class<T> type )
+    public <T> Function<String, T> deserialize( ModuleDescriptor module, Class<T> type )
     {
         if( CollectionType.isCollection( type ) )
         {
             ValueType objectValueType = new ValueType( Object.class );
-            return deserialize( new CollectionType( type, objectValueType ) );
+            return deserialize( module, new CollectionType( type, objectValueType ) );
         }
         if( MapType.isMap( type ) )
         {
             ValueType objectValueType = new ValueType( Object.class );
-            return deserialize( new MapType( type, objectValueType, objectValueType ) );
+            return deserialize( module, new MapType( type, objectValueType, objectValueType ) );
         }
-        return deserialize( new ValueType( type ) );
+        return deserialize( module, new ValueType( type ) );
     }
 
     @Override
-    public final <T> Function<String, T> deserialize( final ValueType valueType )
+    public final <T> Function<String, T> deserialize( ModuleDescriptor module, ValueType valueType )
     {
-        return input -> deserialize( valueType, input );
+        return input -> deserialize( module, valueType, input );
     }
 
-    @Override
-    public final <T> BiFunction<ValueType, String, T> deserialize()
-    {
-        return this::deserialize;
-    }
+//    @Override
+//    public final <T> BiFunction<ValueType, String, T> deserialize()
+//    {
+//        return this::deserialize;
+//    }
 
     @Override
-    public final <T> T deserialize( Class<?> type, String input )
+    public final <T> T deserialize( ModuleDescriptor module, Class<?> type, String input )
         throws ValueSerializationException
     {
         if( CollectionType.isCollection( type ) )
         {
             ValueType objectValueType = new ValueType( Object.class );
-            return deserialize( new CollectionType( type, objectValueType ), input );
+            return deserialize( module, new CollectionType( type, objectValueType ), input );
         }
         if( MapType.isMap( type ) )
         {
             ValueType objectValueType = new ValueType( Object.class );
-            return deserialize( new MapType( type, objectValueType, objectValueType ), input );
+            return deserialize( module, new MapType( type, objectValueType, objectValueType ), input );
         }
-        return deserialize( new ValueType( type ), input );
+        return deserialize( module, new ValueType( type ), input );
     }
 
     @Override
-    public final <T> T deserialize( ValueType valueType, String input )
+    public final <T> T deserialize( ModuleDescriptor module, ValueType valueType, String input )
         throws ValueSerializationException
     {
         try
         {
-            return deserializeRoot( valueType, new ByteArrayInputStream( input.getBytes( UTF_8 ) ) );
+            return deserializeRoot( module, valueType, new ByteArrayInputStream( input.getBytes( UTF_8 ) ) );
         }
         catch( ValueSerializationException ex )
         {
@@ -279,29 +228,29 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
     }
 
     @Override
-    public final <T> T deserialize( Class<?> type, InputStream input )
+    public final <T> T deserialize( ModuleDescriptor module, Class<?> type, InputStream input )
         throws ValueSerializationException
     {
         if( CollectionType.isCollection( type ) )
         {
             ValueType objectValueType = new ValueType( Object.class );
-            return deserialize( new CollectionType( type, objectValueType ), input );
+            return deserialize( module, new CollectionType( type, objectValueType ), input );
         }
         if( MapType.isMap( type ) )
         {
             ValueType objectValueType = new ValueType( Object.class );
-            return deserialize( new MapType( type, objectValueType, objectValueType ), input );
+            return deserialize( module, new MapType( type, objectValueType, objectValueType ), input );
         }
-        return deserialize( new ValueType( type ), input );
+        return deserialize( module, new ValueType( type ), input );
     }
 
     @Override
-    public final <T> T deserialize( ValueType valueType, InputStream input )
+    public final <T> T deserialize( ModuleDescriptor module, ValueType valueType, InputStream input )
         throws ValueSerializationException
     {
         try
         {
-            return deserializeRoot( valueType, input );
+            return deserializeRoot( module, valueType, input );
         }
         catch( ValueSerializationException ex )
         {
@@ -314,7 +263,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
     }
 
     @SuppressWarnings( "unchecked" )
-    private <T> T deserializeRoot( ValueType valueType, InputStream input )
+    private <T> T deserializeRoot( ModuleDescriptor module, ValueType valueType, InputStream input )
         throws Exception
     {
         final Class<?> type = valueType.types().findFirst().orElse( null );
@@ -338,27 +287,27 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
                     return null;
                 }
                 String string = scanner.next();
-                return (T) deserializeBase64Serialized( string );
+                return (T) deserializeBase64Serialized( module, string );
             }
             else // Complex ValueType
             {
-                InputType adaptedInput = adaptInput( input );
-                onDeserializationStart( valueType, adaptedInput );
-                T deserialized = doDeserialize( valueType, adaptedInput );
-                onDeserializationEnd( valueType, adaptedInput );
+                InputType adaptedInput = adaptInput( module, input );
+                onDeserializationStart( module, valueType, adaptedInput );
+                T deserialized = doDeserialize( module, valueType, adaptedInput );
+                onDeserializationEnd( module, valueType, adaptedInput );
                 return deserialized;
             }
     }
 
     @SuppressWarnings( "unchecked" )
-    private <T> T doDeserialize( ValueType valueType, InputType input )
+    private <T> T doDeserialize( ModuleDescriptor module, ValueType valueType, InputType input )
         throws Exception
     {
         final Class<?> type = valueType.types().findFirst().orElse( null );
         // Registered deserializers
         if( deserializers.get( type ) != null )
         {
-            Object value = readPlainValue( input );
+            Object value = readPlainValue( module, input );
             if( value == null )
             {
                 return null;
@@ -372,38 +321,38 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
         else // Explicit ValueComposite
             if( ValueCompositeType.class.isAssignableFrom( valueType.getClass() ) )
             {
-                return (T) deserializeValueComposite( valueType, input );
+                return (T) deserializeValueComposite( module, valueType, input );
             }
             else // Explicit Collections
                 if( CollectionType.class.isAssignableFrom( valueType.getClass() ) )
                 {
-                    return (T) deserializeCollection( (CollectionType) valueType, input );
+                    return (T) deserializeCollection( module, (CollectionType) valueType, input );
                 }
                 else // Explicit Map
                     if( MapType.class.isAssignableFrom( valueType.getClass() ) )
                     {
-                        return (T) deserializeMap( (MapType) valueType, input );
+                        return (T) deserializeMap( module, (MapType) valueType, input );
                     }
                     else // Enum
                         if( EnumType.class.isAssignableFrom( valueType.getClass() ) || type.isEnum() )
                         {
-                            return (T) Enum.valueOf( (Class) type, readPlainValue( input ).toString() );
+                            return (T) Enum.valueOf( (Class) type, readPlainValue( module, input ).toString() );
                         }
                         else // Array
                             if( type.isArray() )
                             {
-                                return (T) deserializeBase64Serialized( readPlainValue( input ).toString() );
+                                return (T) deserializeBase64Serialized( module, readPlainValue( module, input ).toString() );
                             }
         // Guessed Deserialization
-        return (T) deserializeGuessed( valueType, input );
+        return (T) deserializeGuessed( module, valueType, input );
     }
 
-    private <T> Function<InputType, T> buildDeserializeInputFunction( final ValueType valueType )
+    private <T> Function<InputType, T> buildDeserializeInputFunction( ModuleDescriptor module, ValueType valueType )
     {
         return input -> {
             try
             {
-                return doDeserialize( valueType, input );
+                return doDeserialize( module, valueType, input );
             }
             catch( ValueSerializationException ex )
             {
@@ -416,7 +365,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
         };
     }
 
-    private <T> Collection<T> deserializeCollection( CollectionType collectionType, InputType input )
+    private <T> Collection<T> deserializeCollection( ModuleDescriptor module, CollectionType collectionType, InputType input )
         throws Exception
     {
         Collection<T> collection;
@@ -429,43 +378,46 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
         {
             collection = new ArrayList<>();
         }
-        return readArrayInCollection( input,
-                                      this.<T>buildDeserializeInputFunction( collectionType.collectedType() ),
+        return readArrayInCollection( module,
+                                      input,
+                                      this.<T>buildDeserializeInputFunction( module, collectionType.collectedType() ),
                                       collection );
     }
 
-    private <K, V> Map<K, V> deserializeMap( MapType mapType, InputType input )
+    private <K, V> Map<K, V> deserializeMap( ModuleDescriptor module, MapType mapType, InputType input )
         throws Exception
     {
-        return readMapInMap( input,
-                             this.<K>buildDeserializeInputFunction( mapType.keyType() ),
-                             this.<V>buildDeserializeInputFunction( mapType.valueType() ),
+        return readMapInMap( module,
+                             input,
+                             this.<K>buildDeserializeInputFunction( module, mapType.keyType() ),
+                             this.<V>buildDeserializeInputFunction( module, mapType.valueType() ),
                              new HashMap<>() );
     }
 
-    private <T> T deserializeValueComposite( ValueType valueType, InputType input )
+    private <T> T deserializeValueComposite( ModuleDescriptor module, ValueType valueType, InputType input )
         throws Exception
     {
-        InputNodeType inputNode = readObjectTree( input );
+        InputNodeType inputNode = readObjectTree( module, input );
         if( inputNode == null )
         {
             return null;
         }
-        return deserializeNodeValueComposite( valueType, inputNode );
+        return deserializeNodeValueComposite( module, valueType, inputNode );
     }
 
-    private <T> T deserializeNodeValueComposite( ValueType valueType, InputNodeType inputNode )
+    private <T> T deserializeNodeValueComposite( ModuleDescriptor module, ValueType valueType, InputNodeType inputNode )
         throws Exception
     {
         ValueCompositeType valueCompositeType = (ValueCompositeType) valueType;
         Class<?> valueBuilderType = valueCompositeType.types().findFirst().orElse( null );
         String typeInfo = this.getObjectFieldValue(
+            module,
             inputNode,
             "_type",
-            this.<String>buildDeserializeInputNodeFunction( new ValueType( String.class ) ) );
+            this.<String>buildDeserializeInputNodeFunction( module, new ValueType( String.class ) ) );
         if( typeInfo != null )
         {
-            ValueDescriptor valueDescriptor = valuesModule().valueDescriptor( typeInfo );
+            ValueDescriptor valueDescriptor = module.valueDescriptor( typeInfo );
             if( valueDescriptor == null )
             {
                 throw new ValueSerializationException( "Specified value type could not be resolved: " + typeInfo );
@@ -473,11 +425,12 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
             valueCompositeType = valueDescriptor.valueType();
             valueBuilderType = Class.forName( typeInfo );
         }
-        return deserializeValueComposite( valueCompositeType, valueBuilderType, inputNode );
+        return deserializeValueComposite( module, valueCompositeType, valueBuilderType, inputNode );
     }
 
     @SuppressWarnings( "unchecked" )
-    private <T> T deserializeValueComposite( ValueCompositeType valueCompositeType,
+    private <T> T deserializeValueComposite( ModuleDescriptor module,
+                                             ValueCompositeType valueCompositeType,
                                              Class<?> valueBuilderType,
                                              InputNodeType inputNode
     )
@@ -492,12 +445,13 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
             try
             {
                 propertyName = property.qualifiedName().name();
-                if( objectHasField( inputNode, propertyName ) )
+                if( objectHasField( module, inputNode, propertyName ) )
                 {
                     value = getObjectFieldValue(
+                        module,
                         inputNode,
                         propertyName,
-                        buildDeserializeInputNodeFunction( property.valueType() ) );
+                        buildDeserializeInputNodeFunction( module, property.valueType() ) );
                     if( property.isImmutable() )
                     {
                         if( value instanceof Set )
@@ -517,7 +471,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
                 else
                 {
                     // Serialized object does not contain the field, try to default it
-                    value = property.initialValue( valuesModule() );
+                    value = property.initialValue( module );
                 }
             }
             catch( Exception e )
@@ -532,12 +486,13 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
             try
             {
                 String associationName = association.qualifiedName().name();
-                if( objectHasField( inputNode, associationName ) )
+                if( objectHasField( module, inputNode, associationName ) )
                 {
                     Object value = getObjectFieldValue(
+                        module,
                         inputNode,
                         associationName,
-                        buildDeserializeInputNodeFunction( new ValueType( EntityReference.class ) ) );
+                        buildDeserializeInputNodeFunction( module, new ValueType( EntityReference.class ) ) );
                     stateMap.put( associationName, value );
                 }
             }
@@ -552,14 +507,17 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
             try
             {
                 String manyAssociationName = manyAssociation.qualifiedName().name();
-                if( objectHasField( inputNode, manyAssociationName ) )
+                if( objectHasField( module, inputNode, manyAssociationName ) )
                 {
                     Object value = getObjectFieldValue(
+                        module,
                         inputNode,
                         manyAssociationName,
-                        buildDeserializeInputNodeFunction( new CollectionType(
-                            Collection.class,
-                            new ValueType( EntityReference.class ) ) ) );
+                        buildDeserializeInputNodeFunction(
+                            module,
+                            new CollectionType(
+                                Collection.class,
+                                new ValueType( EntityReference.class ) ) ) );
                     stateMap.put( manyAssociationName, value );
                 }
             }
@@ -574,12 +532,13 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
             try
             {
                 String namedAssociationName = namedAssociation.qualifiedName().name();
-                if( objectHasField( inputNode, namedAssociationName ) )
+                if( objectHasField( module, inputNode, namedAssociationName ) )
                 {
                     Object value = getObjectFieldValue(
+                        module,
                         inputNode,
                         namedAssociationName,
-                        buildDeserializeInputNodeFunction( MapType.of( String.class, EntityReference.class, Serialization.Variant.object ) ) );
+                        buildDeserializeInputNodeFunction( module, MapType.of( String.class, EntityReference.class, Serialization.Variant.object ) ) );
                     stateMap.put( namedAssociationName, value );
                 }
             }
@@ -589,16 +548,16 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
             }
         } );
 
-        ValueBuilder<?> valueBuilder = buildNewValueBuilderWithState( valueBuilderType, stateMap );
+        ValueBuilder<?> valueBuilder = buildNewValueBuilderWithState( module, valueBuilderType, stateMap );
         return (T) valueBuilder.newInstance(); // Unchecked cast because the builder could use a type != T
     }
 
-    private <T> Function<InputNodeType, T> buildDeserializeInputNodeFunction( final ValueType valueType )
+    private <T> Function<InputNodeType, T> buildDeserializeInputNodeFunction( ModuleDescriptor module, final ValueType valueType )
     {
         return inputNode -> {
             try
             {
-                return doDeserializeInputNodeValue( valueType, inputNode );
+                return doDeserializeInputNodeValue( module, valueType, inputNode );
             }
             catch( ValueSerializationException ex )
             {
@@ -612,7 +571,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
     }
 
     @SuppressWarnings( "unchecked" )
-    private <T> T doDeserializeInputNodeValue( ValueType valueType, InputNodeType inputNode )
+    private <T> T doDeserializeInputNodeValue( ModuleDescriptor module, ValueType valueType, InputNodeType inputNode )
         throws Exception
     {
         if( inputNode == null )
@@ -623,7 +582,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
         // Registered deserializers
         if( deserializers.get( type ) != null )
         {
-            Object value = asSimpleValue( inputNode );
+            Object value = asSimpleValue( module, inputNode );
             if( value == null )
             {
                 return null;
@@ -637,12 +596,12 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
         else // Explicit ValueComposite
             if( ValueCompositeType.class.isAssignableFrom( valueType.getClass() ) )
             {
-                return (T) deserializeNodeValueComposite( valueType, inputNode );
+                return (T) deserializeNodeValueComposite( module, valueType, inputNode );
             }
             else // Explicit Collections
                 if( CollectionType.class.isAssignableFrom( valueType.getClass() ) )
                 {
-                    return (T) deserializeNodeCollection( (CollectionType) valueType, inputNode );
+                    return (T) deserializeNodeCollection( module, (CollectionType) valueType, inputNode );
                 }
                 else // Explicit Map
                     if( MapType.class.isAssignableFrom( valueType.getClass() ) )
@@ -650,17 +609,17 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
                         MapType mapType = (MapType) valueType;
                         if( mapType.variant().equals( Serialization.Variant.entry ) )
                         {
-                            return (T) deserializeNodeEntryMap( (MapType) valueType, inputNode );
+                            return (T) deserializeNodeEntryMap( module, (MapType) valueType, inputNode );
                         }
                         else
                         {
-                            return (T) deserializeNodeObjectMap( (MapType) valueType, inputNode );
+                            return (T) deserializeNodeObjectMap( module, (MapType) valueType, inputNode );
                         }
                     }
                     else // Enum
                         if( EnumType.class.isAssignableFrom( valueType.getClass() ) || type.isEnum() )
                         {
-                            Object value = asSimpleValue( inputNode );
+                            Object value = asSimpleValue( module, inputNode );
                             if( value == null )
                             {
                                 return null;
@@ -668,12 +627,15 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
                             return (T) Enum.valueOf( (Class) type, value.toString() );
                         }
         // Guessed deserialization
-        return (T) deserializeNodeGuessed( valueType, inputNode );
+        return (T) deserializeNodeGuessed( module, valueType, inputNode );
     }
 
-    private ValueBuilder<?> buildNewValueBuilderWithState( Class<?> type, final Map<String, Object> stateMap )
+    private ValueBuilder<?> buildNewValueBuilderWithState( ModuleDescriptor module,
+                                                           Class<?> type,
+                                                           final Map<String, Object> stateMap
+    )
     {
-        return valuesModule().newValueBuilderWithState(
+        return module.instance().newValueBuilderWithState(
             type,
             property -> stateMap.get( property.qualifiedName().name() ),
             association -> {
@@ -705,18 +667,21 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
     }
 
     @SuppressWarnings( "unchecked" )
-    private <T> T deserializeGuessed( ValueType valueType, InputType input )
+    private <T> T deserializeGuessed( ModuleDescriptor module, ValueType valueType, InputType input )
         throws Exception
     {
-        InputNodeType inputNode = readObjectTree( input );
+        InputNodeType inputNode = readObjectTree( module, input );
         if( inputNode == null )
         {
             return null;
         }
-        return deserializeNodeGuessed( valueType, inputNode );
+        return deserializeNodeGuessed( module, valueType, inputNode );
     }
 
-    private <T> Collection<T> deserializeNodeCollection( CollectionType collectionType, InputNodeType inputNode )
+    private <T> Collection<T> deserializeNodeCollection( ModuleDescriptor module,
+                                                         CollectionType collectionType,
+                                                         InputNodeType inputNode
+    )
         throws Exception
     {
         Collection<T> collection;
@@ -729,48 +694,52 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
         {
             collection = new ArrayList<>();
         }
-        putArrayNodeInCollection( inputNode,
-                                  this.<T>buildDeserializeInputNodeFunction( collectionType.collectedType() ),
+        putArrayNodeInCollection( module,
+                                  inputNode,
+                                  this.<T>buildDeserializeInputNodeFunction( module, collectionType.collectedType() ),
                                   collection );
         return collection;
     }
 
-    private <K, V> Map<K, V> deserializeNodeEntryMap( MapType mapType, InputNodeType inputNode )
+    private <K, V> Map<K, V> deserializeNodeEntryMap( ModuleDescriptor module, MapType mapType, InputNodeType inputNode )
         throws Exception
     {
         Map<K, V> map = new HashMap<>();
-        putArrayNodeInMap( inputNode,
-                           this.<K>buildDeserializeInputNodeFunction( mapType.keyType() ),
-                           this.<V>buildDeserializeInputNodeFunction( mapType.valueType() ),
+        putArrayNodeInMap( module,
+                           inputNode,
+                           this.<K>buildDeserializeInputNodeFunction( module, mapType.keyType() ),
+                           this.<V>buildDeserializeInputNodeFunction( module, mapType.valueType() ),
                            map );
         return map;
     }
 
-    private <V> Map<String, V> deserializeNodeObjectMap( MapType mapType, InputNodeType inputNode )
+    private <V> Map<String, V> deserializeNodeObjectMap( ModuleDescriptor module, MapType mapType, InputNodeType inputNode )
         throws Exception
     {
         Map<String, V> map = new HashMap<>();
-        putObjectNodeInMap( inputNode,
-                            this.<V>buildDeserializeInputNodeFunction( mapType.valueType() ),
+        putObjectNodeInMap( module,
+                            inputNode,
+                            this.<V>buildDeserializeInputNodeFunction( module, mapType.valueType() ),
                             map );
         return map;
     }
 
     @SuppressWarnings( "unchecked" )
-    private <T> T deserializeNodeGuessed( ValueType valueType, InputNodeType inputNode )
+    private <T> T deserializeNodeGuessed( ModuleDescriptor module, ValueType valueType, InputNodeType inputNode )
         throws Exception
     {
-        if( isObjectValue( inputNode ) )
+        if( isObjectValue( module, inputNode ) )
         {
             // Attempt ValueComposite deserialization
             ValueCompositeType valueCompositeType;
-            if( objectHasField( inputNode, "_type" ) ) // with _type info
+            if( objectHasField( module, inputNode, "_type" ) ) // with _type info
             {
                 String typeInfo = this.getObjectFieldValue(
+                    module,
                     inputNode,
                     "_type",
-                    this.<String>buildDeserializeInputNodeFunction( new ValueType( String.class ) ) );
-                ValueDescriptor valueDescriptor = valuesModule().valueDescriptor( typeInfo );
+                    this.<String>buildDeserializeInputNodeFunction( module, new ValueType( String.class ) ) );
+                ValueDescriptor valueDescriptor = module.valueDescriptor( typeInfo );
                 if( valueDescriptor == null )
                 {
                     throw new ValueSerializationException( "Specified value type could not be resolved: " + typeInfo );
@@ -779,10 +748,10 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
             }
             else // without _type info
             {
-                ValueDescriptor valueDescriptor = valuesModule().valueDescriptor( valueType.types()
-                                                                                      .findFirst()
-                                                                                      .get()
-                                                                                      .getName() );
+                ValueDescriptor valueDescriptor = module.valueDescriptor( valueType.types()
+                                                                              .findFirst()
+                                                                              .get()
+                                                                              .getName() );
                 if( valueDescriptor == null )
                 {
                     throw new ValueSerializationException( "Don't know how to deserialize " + inputNode );
@@ -790,27 +759,27 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
                 valueCompositeType = valueDescriptor.valueType();
             }
             Class<?> valueBuilderType = valueCompositeType.types().findFirst().orElse( null );
-            return deserializeValueComposite( valueCompositeType, valueBuilderType, inputNode );
+            return deserializeValueComposite( module, valueCompositeType, valueBuilderType, inputNode );
         }
         // Last resort : base64 java deserialization
-        return (T) deserializeBase64Serialized( inputNode );
+        return (T) deserializeBase64Serialized( module, inputNode );
     }
 
     @SuppressWarnings( "unchecked" )
-    private <T> T deserializeBase64Serialized( InputNodeType inputNode )
+    private <T> T deserializeBase64Serialized( ModuleDescriptor module, InputNodeType inputNode )
         throws Exception
     {
-        Object value = asSimpleValue( inputNode );
+        Object value = asSimpleValue( module, inputNode );
         if( value == null )
         {
             return null;
         }
         String base64 = value.toString();
-        return deserializeBase64Serialized( base64 );
+        return deserializeBase64Serialized( module, base64 );
     }
 
     @SuppressWarnings( "unchecked" )
-    private <T> T deserializeBase64Serialized( String inputString )
+    private <T> T deserializeBase64Serialized( ModuleDescriptor module, String inputString )
         throws Exception
     {
         byte[] bytes = inputString.getBytes( UTF_8 );
@@ -828,7 +797,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
     //
 
     /**
-     * Called by the adapter on deserialization start, after {@link #adaptInput(java.io.InputStream)}.
+     * Called by the adapter on deserialization start, after {@link #adaptInput(ModuleDescriptor, java.io.InputStream)}.
      *
      * @param valueType ValueType
      * @param input     Input
@@ -836,7 +805,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
      * @throws Exception that will be wrapped in a {@link ValueSerializationException}
      */
     @SuppressWarnings( "UnusedParameters" )
-    protected void onDeserializationStart( ValueType valueType, InputType input )
+    protected void onDeserializationStart( ModuleDescriptor module, ValueType valueType, InputType input )
         throws Exception
     {
         // NOOP
@@ -850,7 +819,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
      *
      * @throws Exception that will be wrapped in a {@link ValueSerializationException}
      */
-    protected void onDeserializationEnd( ValueType valueType, InputType input )
+    protected void onDeserializationEnd( ModuleDescriptor module, ValueType valueType, InputType input )
         throws Exception
     {
         // NOOP
@@ -869,7 +838,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
      *
      * @throws Exception that will be wrapped in a {@link ValueSerializationException}
      */
-    protected abstract InputType adaptInput( InputStream input )
+    protected abstract InputType adaptInput( ModuleDescriptor module, InputStream input )
         throws Exception;
 
     /**
@@ -879,7 +848,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
      *
      * @throws Exception that will be wrapped in a {@link ValueSerializationException}
      */
-    protected abstract Object readPlainValue( InputType input )
+    protected abstract Object readPlainValue( ModuleDescriptor module, InputType input )
         throws Exception;
 
     /**
@@ -892,7 +861,8 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
      *
      * @throws Exception that will be wrapped in a {@link ValueSerializationException}
      */
-    protected abstract <T> Collection<T> readArrayInCollection( InputType input,
+    protected abstract <T> Collection<T> readArrayInCollection( ModuleDescriptor module,
+                                                                InputType input,
                                                                 Function<InputType, T> deserializer,
                                                                 Collection<T> collection
     )
@@ -926,7 +896,8 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
      *
      * @throws Exception that will be wrapped in a {@link ValueSerializationException}
      */
-    protected abstract <K, V> Map<K, V> readMapInMap( InputType input,
+    protected abstract <K, V> Map<K, V> readMapInMap( ModuleDescriptor module,
+                                                      InputType input,
                                                       Function<InputType, K> keyDeserializer,
                                                       Function<InputType, V> valueDeserializer,
                                                       Map<K, V> map
@@ -940,19 +911,19 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
      *
      * @throws Exception that will be wrapped in a {@link ValueSerializationException}
      */
-    protected abstract InputNodeType readObjectTree( InputType input )
+    protected abstract InputNodeType readObjectTree( ModuleDescriptor module, InputType input )
         throws Exception;
 
     //
     // Tree Parsing Deserialization
     //
-    protected abstract Object asSimpleValue( InputNodeType inputNode )
+    protected abstract Object asSimpleValue( ModuleDescriptor module, InputNodeType inputNode )
         throws Exception;
 
-    protected abstract boolean isObjectValue( InputNodeType inputNode )
+    protected abstract boolean isObjectValue( ModuleDescriptor module, InputNodeType inputNode )
         throws Exception;
 
-    protected abstract boolean objectHasField( InputNodeType inputNode, String key )
+    protected abstract boolean objectHasField( ModuleDescriptor module, InputNodeType inputNode, String key )
         throws Exception;
 
     /**
@@ -967,26 +938,30 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
      *
      * @throws Exception that will be wrapped in a {@link ValueSerializationException}
      */
-    protected abstract <T> T getObjectFieldValue( InputNodeType inputNode,
+    protected abstract <T> T getObjectFieldValue( ModuleDescriptor module,
+                                                  InputNodeType inputNode,
                                                   String key,
                                                   Function<InputNodeType, T> valueDeserializer
     )
         throws Exception;
 
-    protected abstract <T> void putArrayNodeInCollection( InputNodeType inputNode,
+    protected abstract <T> void putArrayNodeInCollection( ModuleDescriptor module,
+                                                          InputNodeType inputNode,
                                                           Function<InputNodeType, T> deserializer,
                                                           Collection<T> collection
     )
         throws Exception;
 
-    protected abstract <K, V> void putArrayNodeInMap( InputNodeType inputNode,
+    protected abstract <K, V> void putArrayNodeInMap( ModuleDescriptor module,
+                                                      InputNodeType inputNode,
                                                       Function<InputNodeType, K> keyDeserializer,
                                                       Function<InputNodeType, V> valueDeserializer,
                                                       Map<K, V> map
     )
         throws Exception;
 
-    protected abstract <V> void putObjectNodeInMap( InputNodeType inputNode,
+    protected abstract <V> void putObjectNodeInMap( ModuleDescriptor module,
+                                                    InputNodeType inputNode,
                                                     Function<InputNodeType, V> valueDeserializer,
                                                     Map<String, V> map
     )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java b/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
index 6dd152e..f74c5f4 100644
--- a/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
+++ b/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
@@ -23,17 +23,12 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.function.Function;
+import org.apache.zest.api.structure.ModuleDescriptor;
+import org.apache.zest.api.value.ValueSerializationException;
+import org.apache.zest.spi.value.ValueDeserializerAdapter;
 import org.json.JSONArray;
 import org.json.JSONObject;
 import org.json.JSONTokener;
-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.value.ValueSerializationException;
-import org.apache.zest.spi.value.ValueDeserializerAdapter;
 
 /**
  * ValueDeserializer reading Values from JSON documents using org.json.
@@ -42,31 +37,15 @@ public class OrgJsonValueDeserializer
     extends ValueDeserializerAdapter<JSONTokener, Object>
 {
 
-    public OrgJsonValueDeserializer(
-        @Structure Application application,
-        @Structure Module module,
-        @Service ServiceReference<ValueDeserializer> serviceRef )
-    {
-        super( application, module, serviceRef );
-    }
-
-    /* package */ OrgJsonValueDeserializer(
-        Application application,
-        Module module,
-        Function<Application, Module> valuesModuleFinder )
-    {
-        super( application, module, valuesModuleFinder );
-    }
-
     @Override
-    protected JSONTokener adaptInput( InputStream input )
+    protected JSONTokener adaptInput( ModuleDescriptor module, InputStream input )
         throws Exception
     {
         return new JSONTokener( new InputStreamReader( input, "UTF-8" ) );
     }
 
     @Override
-    protected Object readPlainValue( JSONTokener input )
+    protected Object readPlainValue( ModuleDescriptor module, JSONTokener input )
         throws Exception
     {
         Object nextValue = input.nextValue();
@@ -75,18 +54,20 @@ public class OrgJsonValueDeserializer
             return null;
         }
         else // Object or Array
-        if( JSONObject.class.isAssignableFrom( nextValue.getClass() )
-            || JSONArray.class.isAssignableFrom( nextValue.getClass() ) )
-        {
-            throw new ValueSerializationException( "Asked for a Value but found an Object or an Array." );
-        }
+            if( JSONObject.class.isAssignableFrom( nextValue.getClass() )
+                || JSONArray.class.isAssignableFrom( nextValue.getClass() ) )
+            {
+                throw new ValueSerializationException( "Asked for a Value but found an Object or an Array." );
+            }
         return nextValue;
     }
 
     @Override
-    protected <T> Collection<T> readArrayInCollection( JSONTokener input,
+    protected <T> Collection<T> readArrayInCollection( ModuleDescriptor module,
+                                                       JSONTokener input,
                                                        Function<JSONTokener, T> deserializer,
-                                                       Collection<T> collection )
+                                                       Collection<T> collection
+    )
         throws Exception
     {
         char c = input.nextClean();
@@ -129,7 +110,7 @@ public class OrgJsonValueDeserializer
             return collection;
         }
         input.back();
-        for( ;; )
+        for(; ; )
         {
             if( input.nextClean() == ',' )
             {
@@ -144,32 +125,34 @@ public class OrgJsonValueDeserializer
             c = input.nextClean();
             switch( c )
             {
-                case ';':
-                case ',':
-                    if( input.nextClean() == ']' )
-                    {
-                        return collection;
-                    }
-                    input.back();
-                    break;
-                case ']':
-                case ')':
-                    if( q != c )
-                    {
-                        throw input.syntaxError( "Expected a '" + Character.valueOf( q ) + "'" );
-                    }
+            case ';':
+            case ',':
+                if( input.nextClean() == ']' )
+                {
                     return collection;
-                default:
-                    throw input.syntaxError( "Expected a ',' or ']'" );
+                }
+                input.back();
+                break;
+            case ']':
+            case ')':
+                if( q != c )
+                {
+                    throw input.syntaxError( "Expected a '" + Character.valueOf( q ) + "'" );
+                }
+                return collection;
+            default:
+                throw input.syntaxError( "Expected a ',' or ']'" );
             }
         }
     }
 
     @Override
-    protected <K, V> Map<K, V> readMapInMap( JSONTokener input,
+    protected <K, V> Map<K, V> readMapInMap( ModuleDescriptor module,
+                                             JSONTokener input,
                                              Function<JSONTokener, K> keyDeserializer,
                                              Function<JSONTokener, V> valueDeserializer,
-                                             Map<K, V> map )
+                                             Map<K, V> map
+    )
         throws Exception
     {
         char c = input.nextClean();
@@ -213,7 +196,7 @@ public class OrgJsonValueDeserializer
         }
         input.back();
 
-        for( ;; )
+        for(; ; )
         {
             if( input.nextClean() == ',' )
             {
@@ -238,14 +221,14 @@ public class OrgJsonValueDeserializer
                     c = input.nextClean();
                     switch( c )
                     {
-                        case 0:
-                            throw input.syntaxError( "A JSONObject text must end with '}'" );
-                        case '}':
-                            breakIteration = true;
-                            continue;
-                        default:
-                            input.back();
-                            objectKey = input.nextValue().toString();
+                    case 0:
+                        throw input.syntaxError( "A JSONObject text must end with '}'" );
+                    case '}':
+                        breakIteration = true;
+                        continue;
+                    default:
+                        input.back();
+                        objectKey = input.nextValue().toString();
                     }
 
                     /*
@@ -282,20 +265,20 @@ public class OrgJsonValueDeserializer
                      */
                     switch( input.nextClean() )
                     {
-                        case ';':
-                        case ',':
-                            if( input.nextClean() == '}' )
-                            {
-                                breakIteration = true;
-                                continue;
-                            }
-                            input.back();
-                            continue;
-                        case '}':
+                    case ';':
+                    case ',':
+                        if( input.nextClean() == '}' )
+                        {
                             breakIteration = true;
                             continue;
-                        default:
-                            throw input.syntaxError( "Expected a ',' or '}'" );
+                        }
+                        input.back();
+                        continue;
+                    case '}':
+                        breakIteration = true;
+                        continue;
+                    default:
+                        throw input.syntaxError( "Expected a ',' or '}'" );
                     }
                 }
                 if( key != null )
@@ -306,23 +289,23 @@ public class OrgJsonValueDeserializer
             c = input.nextClean();
             switch( c )
             {
-                case ';':
-                case ',':
-                    if( input.nextClean() == ']' )
-                    {
-                        return map;
-                    }
-                    input.back();
-                    break;
-                case ']':
-                case ')':
-                    if( q != c )
-                    {
-                        throw input.syntaxError( "Expected a '" + Character.valueOf( q ) + "'" );
-                    }
+            case ';':
+            case ',':
+                if( input.nextClean() == ']' )
+                {
                     return map;
-                default:
-                    throw input.syntaxError( "Expected a ',' or ']'" );
+                }
+                input.back();
+                break;
+            case ']':
+            case ')':
+                if( q != c )
+                {
+                    throw input.syntaxError( "Expected a '" + Character.valueOf( q ) + "'" );
+                }
+                return map;
+            default:
+                throw input.syntaxError( "Expected a ',' or ']'" );
             }
         }
     }
@@ -331,7 +314,9 @@ public class OrgJsonValueDeserializer
     // Deserialization - Tree parsing
     //
     @Override
-    protected JSONObject readObjectTree( JSONTokener input )
+    protected JSONObject readObjectTree( ModuleDescriptor module,
+                                         JSONTokener input
+    )
         throws Exception
     {
         Object objectTree = input.nextValue();
@@ -343,7 +328,7 @@ public class OrgJsonValueDeserializer
     }
 
     @Override
-    protected Object asSimpleValue( Object inputNode )
+    protected Object asSimpleValue( ModuleDescriptor module, Object inputNode )
         throws Exception
     {
         if( JSONObject.NULL.equals( inputNode ) )
@@ -358,7 +343,7 @@ public class OrgJsonValueDeserializer
     }
 
     @Override
-    protected boolean isObjectValue( Object inputNode )
+    protected boolean isObjectValue( ModuleDescriptor module, Object inputNode )
         throws Exception
     {
         if( JSONObject.NULL.equals( inputNode ) )
@@ -369,7 +354,7 @@ public class OrgJsonValueDeserializer
     }
 
     @Override
-    protected boolean objectHasField( Object inputNode, String key )
+    protected boolean objectHasField( ModuleDescriptor module, Object inputNode, String key )
         throws Exception
     {
         if( JSONObject.NULL.equals( inputNode ) )
@@ -385,7 +370,11 @@ public class OrgJsonValueDeserializer
     }
 
     @Override
-    protected <T> T getObjectFieldValue( Object inputNode, String key, Function<Object, T> valueDeserializer )
+    protected <T> T getObjectFieldValue( ModuleDescriptor module,
+                                         Object inputNode,
+                                         String key,
+                                         Function<Object, T> valueDeserializer
+    )
         throws Exception
     {
         JSONObject json = (JSONObject) inputNode;
@@ -399,7 +388,11 @@ public class OrgJsonValueDeserializer
     }
 
     @Override
-    protected <T> void putArrayNodeInCollection( Object inputNode, Function<Object, T> deserializer, Collection<T> collection )
+    protected <T> void putArrayNodeInCollection( ModuleDescriptor module,
+                                                 Object inputNode,
+                                                 Function<Object, T> deserializer,
+                                                 Collection<T> collection
+    )
         throws Exception
     {
         if( JSONObject.NULL.equals( inputNode ) )
@@ -420,7 +413,12 @@ public class OrgJsonValueDeserializer
     }
 
     @Override
-    protected <K, V> void putArrayNodeInMap( Object inputNode, Function<Object, K> keyDeserializer, Function<Object, V> valueDeserializer, Map<K, V> map )
+    protected <K, V> void putArrayNodeInMap( ModuleDescriptor module,
+                                             Object inputNode,
+                                             Function<Object, K> keyDeserializer,
+                                             Function<Object, V> valueDeserializer,
+                                             Map<K, V> map
+    )
         throws Exception
     {
         if( JSONObject.NULL.equals( inputNode ) )
@@ -452,7 +450,11 @@ public class OrgJsonValueDeserializer
     }
 
     @Override
-    protected <V> void putObjectNodeInMap( Object inputNode, Function<Object, V> valueDeserializer, Map<String, V> map )
+    protected <V> void putObjectNodeInMap( ModuleDescriptor module,
+                                           Object inputNode,
+                                           Function<Object, V> valueDeserializer,
+                                           Map<String, V> map
+    )
         throws Exception
     {
         if( JSONObject.NULL.equals( inputNode ) )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueSerialization.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueSerialization.java b/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueSerialization.java
deleted file mode 100644
index 9ce1892..0000000
--- a/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueSerialization.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2012, Paul Merlin. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- *
- *     You may obtain a copy of the License at
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zest.valueserialization.orgjson;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.type.ValueType;
-import org.apache.zest.api.value.ValueSerialization;
-import org.apache.zest.api.value.ValueSerializationException;
-
-/**
- * ValueSerialization producing and consuming JSON documents using org.json.
- *
- * <p>
- *     This class is used internally by the Zest Runtime to provide default ValueSerialization when no
- *     ValueSerialization Service is available.
- * </p>
- * <p>
- *     In application code, prefer the use of {@link OrgJsonValueSerializationService}.
- * </p>
- */
-public class OrgJsonValueSerialization
-    implements ValueSerialization
-{
-
-    private final OrgJsonValueSerializer serializer;
-    private final OrgJsonValueDeserializer deserializer;
-
-    public OrgJsonValueSerialization( Application application, Module module, final Module valuesModule )
-    {
-        this.serializer = new OrgJsonValueSerializer();
-        this.deserializer = new OrgJsonValueDeserializer( application, module, from -> valuesModule );
-    }
-
-    @Override
-    public <T> Function<T, String> serialize()
-    {
-        return serializer.serialize();
-    }
-
-    @Override
-    public <T> Function<T, String> serialize( Options options )
-    {
-        return serializer.serialize( options );
-    }
-
-    @Override
-    @Deprecated
-    public <T> Function<T, String> serialize( boolean includeTypeInfo )
-    {
-        return serializer.serialize( includeTypeInfo );
-    }
-
-    @Override
-    public String serialize( Object object )
-        throws ValueSerializationException
-    {
-        return serializer.serialize( object );
-    }
-
-    @Override
-    public String serialize( Options options, Object object )
-        throws ValueSerializationException
-    {
-        return serializer.serialize( options, object );
-    }
-
-    @Override
-    @Deprecated
-    public String serialize( Object object, boolean includeTypeInfo )
-        throws ValueSerializationException
-    {
-        return serializer.serialize( object, includeTypeInfo );
-    }
-
-    @Override
-    public void serialize( Object object, OutputStream output )
-        throws ValueSerializationException
-    {
-        serializer.serialize( object, output );
-    }
-
-    @Override
-    public void serialize( Options options, Object object, OutputStream output )
-        throws ValueSerializationException
-    {
-        serializer.serialize( options, object, output );
-    }
-
-    @Override
-    @Deprecated
-    public void serialize( Object object, OutputStream output, boolean includeTypeInfo )
-        throws ValueSerializationException
-    {
-        serializer.serialize( object, output, includeTypeInfo );
-    }
-
-    @Override
-    public <T> Function<String, T> deserialize( Class<T> type )
-    {
-        return deserializer.deserialize( type );
-    }
-
-    @Override
-    public <T> Function<String, T> deserialize( ValueType valueType )
-    {
-        return deserializer.deserialize( valueType );
-    }
-
-    @Override
-    public <T> BiFunction<ValueType, String, T> deserialize()
-    {
-        return deserializer.deserialize();
-    }
-
-    @Override
-    public <T> T deserialize( Class<?> type, String input )
-        throws ValueSerializationException
-    {
-        return deserializer.deserialize( type, input );
-    }
-
-    @Override
-    public <T> T deserialize( ValueType type, String input )
-        throws ValueSerializationException
-    {
-        return deserializer.deserialize( type, input );
-    }
-
-    @Override
-    public <T> T deserialize( Class<?> type, InputStream input )
-        throws ValueSerializationException
-    {
-        return deserializer.deserialize( new ValueType( type ), input );
-    }
-
-    @Override
-    public <T> T deserialize( ValueType type, InputStream input )
-        throws ValueSerializationException
-    {
-        return deserializer.deserialize( type, input );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
----------------------------------------------------------------------
diff --git a/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java b/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
index 4d7dec3..1cbce1d 100644
--- a/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
+++ b/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
@@ -45,6 +45,7 @@ public class JSONManyAssociationStateTest
         state.put( JSONKeys.MANY_ASSOCIATIONS, new JSONObject() );
         state.put( JSONKeys.NAMED_ASSOCIATIONS, new JSONObject() );
         JSONEntityState entityState = new JSONEntityState( null,
+                                                           null,
                                                            "0",
                                                            System.currentTimeMillis(),
                                                            EntityReference.parseEntityReference( "123" ),
@@ -70,6 +71,7 @@ public class JSONManyAssociationStateTest
         state.put( JSONKeys.MANY_ASSOCIATIONS, new JSONObject() );
         state.put( JSONKeys.NAMED_ASSOCIATIONS, new JSONObject() );
         JSONEntityState entityState = new JSONEntityState( null,
+                                                           null,
                                                            "0",
                                                            System.currentTimeMillis(),
                                                            EntityReference.parseEntityReference( "123" ),

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
index 29c27aa..6254de9 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java
@@ -14,18 +14,24 @@
 
 package org.apache.zest.test;
 
+import org.apache.zest.api.composite.TransientBuilderFactory;
 import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-import org.junit.After;
-import org.junit.Before;
+import org.apache.zest.api.object.ObjectFactory;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.service.ServiceFinder;
+import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.api.value.ValueBuilderFactory;
 import org.apache.zest.bootstrap.ApplicationAssembly;
 import org.apache.zest.bootstrap.Assembler;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.LayerAssembly;
 import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.spi.module.ModuleSpi;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
+import org.junit.After;
+import org.junit.Before;
 
 /**
  * Base class for Composite tests.
@@ -36,7 +42,23 @@ public abstract class AbstractZestTest extends AbstractZestBaseTest
     @Structure
     protected UnitOfWorkFactory uowf;
 
-    protected ModuleSpi module;
+    @Structure
+    protected TransientBuilderFactory transientBuilderFactory;
+
+    @Structure
+    protected ValueBuilderFactory valueBuilderFactory;
+
+    @Structure
+    protected ServiceFinder serviceFinder;
+
+    @Structure
+    protected ObjectFactory objectFactory;
+
+    @Structure
+    protected QueryBuilderFactory queryBuilderFactory;
+
+    @Structure
+    protected ModuleDescriptor module;
 
     @Before
     @Override
@@ -48,7 +70,7 @@ public abstract class AbstractZestTest extends AbstractZestBaseTest
         {
             return; // failure in Assembly.
         }
-        module = (ModuleSpi) application.findModule( "Layer 1", "Module 1" );
+        Module module = application.findModule( "Layer 1", "Module 1" );
         module.injectTo( this );
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java b/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
index e697375..ebacb42 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java
@@ -45,7 +45,7 @@ public abstract class AbstractCachePoolTest
         throws Exception
     {
         super.setUp();
-        cachePool = module.findService( CachePool.class ).get();
+        cachePool = module.instance().findService( CachePool.class ).get();
         cache = cachePool.fetchCache( "1", String.class );
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
index 8712911..a6fff82 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractConfigurationDeserializationTest.java
@@ -45,6 +45,7 @@ public abstract class AbstractConfigurationDeserializationTest extends AbstractZ
         throws AssemblyException
     {
 //        ModuleAssembly storageModule = module.layer().module( "storage" );
+        @SuppressWarnings( "UnnecessaryLocalVariable" )
         ModuleAssembly storageModule = module; // Disable the more complex set up. The entire value serialization has gotten the deserialization type lookup problem wrong.
         module.configurations( ConfigSerializationConfig.class );
         module.values( Host.class );
@@ -57,7 +58,7 @@ public abstract class AbstractConfigurationDeserializationTest extends AbstractZ
     @Test
     public void givenServiceWhenInitializingExpectCorrectDeserialization()
     {
-        ServiceReference<MyService> ref = module.findService( MyService.class );
+        ServiceReference<MyService> ref = module.instance().findService( MyService.class );
         assertThat( ref, notNullValue() );
         assertThat( ref.isAvailable(), equalTo( true ) );
         MyService myService = ref.get();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
index de6956d..ad7a116 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
@@ -25,11 +25,12 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.structure.Module;
 import org.joda.time.DateTime;
 import org.joda.time.LocalDate;
 import org.joda.time.LocalDateTime;
 import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 import org.apache.zest.api.association.Association;
 import org.apache.zest.api.association.ManyAssociation;
@@ -69,6 +70,9 @@ public abstract class AbstractEntityStoreTest
     @Service
     private EntityStore store;
 
+    @Structure
+    private Module moduleInstance;
+
     @Override
     public void assemble( ModuleAssembly module )
         throws AssemblyException
@@ -79,12 +83,6 @@ public abstract class AbstractEntityStoreTest
         module.objects( getClass() );
     }
 
-    @Before
-    public void init()
-    {
-        module.injectTo( this );
-    }
-
     @Override
     @After
     public void tearDown()
@@ -115,23 +113,23 @@ public abstract class AbstractEntityStoreTest
         instance.localDateValue().set( new LocalDate( "2020-03-04" ) );
         instance.association().set( instance );
 
-        ValueBuilder<Tjabba> valueBuilder4 = module.newValueBuilder( Tjabba.class );
+        ValueBuilder<Tjabba> valueBuilder4 = moduleInstance.newValueBuilder( Tjabba.class );
         final Tjabba prototype4 = valueBuilder4.prototype();
         prototype4.bling().set( "BlinkLjus" );
 
         // Set value
-        ValueBuilder<TestValue2> valueBuilder2 = module.newValueBuilder( TestValue2.class );
+        ValueBuilder<TestValue2> valueBuilder2 = moduleInstance.newValueBuilder( TestValue2.class );
         TestValue2 prototype2 = valueBuilder2.prototype();
         prototype2.stringValue().set( "Bar" );
         Tjabba newValue = valueBuilder4.newInstance();
         prototype2.anotherValue().set( newValue );
         prototype2.anotherValue().set( newValue );
 
-        ValueBuilder<Tjabba> valueBuilder3 = module.newValueBuilder( Tjabba.class );
+        ValueBuilder<Tjabba> valueBuilder3 = moduleInstance.newValueBuilder( Tjabba.class );
         final Tjabba prototype3 = valueBuilder3.prototype();
         prototype3.bling().set( "Brakfis" );
 
-        ValueBuilder<TestValue> valueBuilder1 = module.newValueBuilder( TestValue.class );
+        ValueBuilder<TestValue> valueBuilder1 = moduleInstance.newValueBuilder( TestValue.class );
         TestValue prototype = valueBuilder1.prototype();
         prototype.enumProperty().set( TestEnum.VALUE3 );
         prototype.listProperty().get().add( "Foo" );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
index e9c18b5..527b4bf 100755
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
@@ -80,9 +80,9 @@ public class AbstractAnyQueryTest
         throws Exception
     {
         super.setUp();
-        TestData.populate( module );
+        TestData.populate( module.instance() );
 
-        this.unitOfWork = this.module.unitOfWorkFactory().newUnitOfWork();
+        this.unitOfWork = this.module.instance().unitOfWorkFactory().newUnitOfWork();
     }
 
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
index 4698753..d9704ce 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractComplexQueryTest.java
@@ -22,6 +22,8 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.structure.Module;
 import org.junit.Test;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.query.Query;
@@ -52,24 +54,28 @@ public abstract class AbstractComplexQueryTest
     private static final String JOE = "Joe Doe";
     private static final String JACK = "Jack Doe";
 
+    @Structure
+    Module moduleInstance;
+
+
     @Test
     public void showNetwork()
         throws IOException
     {
-        IndexExporter indexerExporter = module.findService( IndexExporter.class ).get();
+        IndexExporter indexerExporter = moduleInstance.findService( IndexExporter.class ).get();
         indexerExporter.exportReadableToStream( System.out );
     }
 
     @Test
     public void script01()
     {
-        ValueBuilder<Address> addressBuilder = this.module.newValueBuilder( Address.class );
+        ValueBuilder<Address> addressBuilder = this.moduleInstance.newValueBuilder( Address.class );
         Address address = addressBuilder.prototype();
         address.line1().set( "Qi Street 4j" );
         address.line2().set( "Off main Java Street" );
         address.zipcode().set( "12345" );
 
-        QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+        QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Property<Address> addressProp = templateFor( Person.class ).address();
         qb = qb.where( eq( addressProp, addressBuilder.newInstance() ) );
         Query<Person> query = unitOfWork.newQuery( qb );
@@ -81,13 +87,13 @@ public abstract class AbstractComplexQueryTest
     @Test
     public void script02()
     {
-        ValueBuilder<Address> addressBuilder = this.module.newValueBuilder( Address.class );
+        ValueBuilder<Address> addressBuilder = this.moduleInstance.newValueBuilder( Address.class );
         Address address = addressBuilder.prototype();
         address.line1().set( "Qi Street 4j" );
         address.line2().set( "Off main Java Street" );
         address.zipcode().set( "12345" );
 
-        QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+        QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Property<Address> addressProp = templateFor( Person.class ).address();
         qb = qb.where( not( eq( addressProp, addressBuilder.newInstance() ) ) );
         Query<Person> query = unitOfWork.newQuery( qb );
@@ -99,20 +105,20 @@ public abstract class AbstractComplexQueryTest
     @Test
     public void script03()
     {
-        ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
         List<QueryParam> queryParams = new ArrayList<>( 2 );
         QueryParam param = queryParamBuilder.prototype();
         param.name().set( "user" );
         param.value().set( "jackdoe" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
         param = queryParamBuilder.prototype();
         param.name().set( "password" );
         param.value().set( "somepassword" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+        QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
         qb = qb.where( eq( paramsProp, queryParams ) );
         Query<Person> query = unitOfWork.newQuery( qb );
@@ -124,7 +130,7 @@ public abstract class AbstractComplexQueryTest
     @Test
     public void script04()
     {
-        ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
         List<QueryParam> queryParams = new ArrayList<>( 2 );
         QueryParam param = queryParamBuilder.prototype();
         // Different order
@@ -132,13 +138,13 @@ public abstract class AbstractComplexQueryTest
         param.value().set( "somepassword" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
         param = queryParamBuilder.prototype();
         param.name().set( "user" );
         param.value().set( "jackdoe" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+        QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
         qb = qb.where( eq( paramsProp, queryParams ) );
         Query<Person> query = unitOfWork.newQuery( qb );
@@ -150,20 +156,20 @@ public abstract class AbstractComplexQueryTest
     @Test
     public void script05()
     {
-        ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
         List<QueryParam> queryParams = new ArrayList<>( 2 );
         QueryParam param = queryParamBuilder.prototype();
         param.name().set( "user" );
         param.value().set( "jackdoe" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
         param = queryParamBuilder.prototype();
         param.name().set( "password" );
         param.value().set( "somepassword" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+        QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
         qb = qb.where( not( eq( paramsProp, queryParams ) ) );
         Query<Person> query = unitOfWork.newQuery( qb );
@@ -175,9 +181,9 @@ public abstract class AbstractComplexQueryTest
     @Test
     public void script06()
     {
-        ValueBuilder<URL> urlBuilder = this.module.newValueBuilder( URL.class );
-        ValueBuilder<Protocol> protocolBuilder = this.module.newValueBuilder( Protocol.class );
-        ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        ValueBuilder<URL> urlBuilder = this.moduleInstance.newValueBuilder( URL.class );
+        ValueBuilder<Protocol> protocolBuilder = this.moduleInstance.newValueBuilder( Protocol.class );
+        ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
 
         Protocol protocol = protocolBuilder.prototype();
         protocol.value().set( "http" );
@@ -188,7 +194,7 @@ public abstract class AbstractComplexQueryTest
         param.value().set( "jackdoe" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
         param = queryParamBuilder.prototype();
         param.name().set( "password" );
         param.value().set( "somepassword" );
@@ -198,7 +204,7 @@ public abstract class AbstractComplexQueryTest
         url.protocol().set( protocolBuilder.newInstance() );
         url.queryParams().set( queryParams );
 
-        QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+        QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Property<URL> websiteProp = templateFor( Person.class ).personalWebsite();
         qb = qb.where( eq( websiteProp, urlBuilder.newInstance() ) );
         Query<Person> query = unitOfWork.newQuery( qb );
@@ -210,9 +216,9 @@ public abstract class AbstractComplexQueryTest
     @Test
     public void script07()
     {
-        ValueBuilder<URL> urlBuilder = this.module.newValueBuilder( URL.class );
-        ValueBuilder<Protocol> protocolBuilder = this.module.newValueBuilder( Protocol.class );
-        ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        ValueBuilder<URL> urlBuilder = this.moduleInstance.newValueBuilder( URL.class );
+        ValueBuilder<Protocol> protocolBuilder = this.moduleInstance.newValueBuilder( Protocol.class );
+        ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
 
         Protocol protocol = protocolBuilder.prototype();
         protocol.value().set( "http" );
@@ -223,7 +229,7 @@ public abstract class AbstractComplexQueryTest
         param.value().set( "jackdoe" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
         param = queryParamBuilder.prototype();
         param.name().set( "password" );
         param.value().set( "somepassword" );
@@ -233,7 +239,7 @@ public abstract class AbstractComplexQueryTest
         url.protocol().set( protocolBuilder.newInstance() );
         url.queryParams().set( queryParams );
 
-        QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+        QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Property<URL> websiteProp = templateFor( Person.class ).personalWebsite();
         qb = qb.where( not( eq( websiteProp, urlBuilder.newInstance() ) ) );
         Query<Person> query = unitOfWork.newQuery( qb );
@@ -245,12 +251,12 @@ public abstract class AbstractComplexQueryTest
     @Test
     public void script08()
     {
-        ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
         QueryParam param = queryParamBuilder.prototype();
         param.name().set( "user" );
         param.value().set( "jackdoe" );
 
-        QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+        QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
         qb = qb.where( contains( paramsProp, queryParamBuilder.newInstance() ) );
         Query<Person> query = unitOfWork.newQuery( qb );
@@ -261,13 +267,13 @@ public abstract class AbstractComplexQueryTest
     @Test
     public void script09()
     {
-        ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
 
         QueryParam param = queryParamBuilder.prototype();
         param.name().set( "user" );
         param.value().set( "jackdoe" );
 
-        QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+        QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
         qb = qb.where( not( contains( paramsProp, queryParamBuilder.newInstance() ) ) );
         Query<Person> query = unitOfWork.newQuery( qb );
@@ -278,7 +284,7 @@ public abstract class AbstractComplexQueryTest
     @Test
     public void script10()
     {
-        ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
 
         List<QueryParam> queryParams = new ArrayList<>( 2 );
         QueryParam param = queryParamBuilder.prototype();
@@ -286,13 +292,13 @@ public abstract class AbstractComplexQueryTest
         param.value().set( "jackdoe" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
         param = queryParamBuilder.prototype();
         param.name().set( "password" );
         param.value().set( "somepassword" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+        QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
         qb = qb.where( containsAll( paramsProp, queryParams ) );
         Query<Person> query = unitOfWork.newQuery( qb );
@@ -303,7 +309,7 @@ public abstract class AbstractComplexQueryTest
     @Test
     public void script11()
     {
-        ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        ValueBuilder<QueryParam> queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
 
         List<QueryParam> queryParams = new ArrayList<>( 2 );
         QueryParam param = queryParamBuilder.prototype();
@@ -311,13 +317,13 @@ public abstract class AbstractComplexQueryTest
         param.value().set( "jackdoe" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        queryParamBuilder = this.module.newValueBuilder( QueryParam.class );
+        queryParamBuilder = this.moduleInstance.newValueBuilder( QueryParam.class );
         param = queryParamBuilder.prototype();
         param.name().set( "password" );
         param.value().set( "somepassword" );
         queryParams.add( queryParamBuilder.newInstance() );
 
-        QueryBuilder<Person> qb = this.module.newQueryBuilder( Person.class );
+        QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
         Property<Collection<QueryParam>> paramsProp = templateFor( Person.class ).personalWebsite().get().queryParams();
         qb = qb.where( not( containsAll( paramsProp, queryParams ) ) );
         Query<Person> query = unitOfWork.newQuery( qb );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/dedb068e/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
index f02c0f9..1c5a4c0 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractEntityFinderTest.java
@@ -27,6 +27,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Predicate;
+import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.structure.Module;
 import org.junit.Before;
 import org.junit.Test;
 import org.apache.zest.api.composite.Composite;
@@ -81,6 +83,10 @@ public abstract class AbstractEntityFinderTest
 
     private static final String ANN = "Ann Doe";
 
+    @Structure
+    Module moduleInstance;
+
+
     private EntityFinder entityFinder;
 
     @Before
@@ -89,14 +95,14 @@ public abstract class AbstractEntityFinderTest
         throws Exception
     {
         super.setUp();
-        entityFinder = this.module.findService( EntityFinder.class ).get();
+        entityFinder = this.moduleInstance.findService( EntityFinder.class ).get();
     }
 
     @Test
     public void showNetwork()
         throws IOException
     {
-        final ServiceReference<IndexExporter> indexerService = this.module.findService( IndexExporter.class );
+        final ServiceReference<IndexExporter> indexerService = this.moduleInstance.findService( IndexExporter.class );
         final IndexExporter exporter = indexerService.get();
         exporter.exportReadableToStream( System.out );
         // todo asserts


Mime
View raw message