You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2017/03/13 10:35:25 UTC

[33/50] [abbrv] polygene-java git commit: New (de)serialization API and SPI & new implementations

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/api/src/test/java/org/apache/polygene/api/value/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/value/DocumentationSupport.java b/core/api/src/test/java/org/apache/polygene/api/value/DocumentationSupport.java
index c822f68..4de963b 100644
--- a/core/api/src/test/java/org/apache/polygene/api/value/DocumentationSupport.java
+++ b/core/api/src/test/java/org/apache/polygene/api/value/DocumentationSupport.java
@@ -19,11 +19,7 @@
  */
 package org.apache.polygene.api.value;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Arrays;
@@ -32,16 +28,16 @@ import java.util.function.Function;
 import java.util.stream.Stream;
 import org.apache.polygene.api.injection.scope.Service;
 import org.apache.polygene.api.property.Property;
+import org.apache.polygene.api.serialization.Deserializer;
+import org.apache.polygene.api.serialization.Serialization;
+import org.apache.polygene.api.serialization.Serializer;
 import org.apache.polygene.api.structure.Application;
 import org.apache.polygene.api.structure.Module;
-import org.apache.polygene.api.type.CollectionType;
 import org.apache.polygene.bootstrap.Assembler;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.Energy4Java;
 import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.apache.polygene.test.AbstractPolygeneTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
 import org.junit.Test;
 
 import static java.util.stream.Collectors.toList;
@@ -52,17 +48,14 @@ import static org.junit.Assert.assertThat;
  * Snippets:
  * - default : default ValueSerialization
  * - service : assembled service ValueSerialization
- * - lookup  : ValueSerialization values module finder
+ * - io : i/o usage
  */
-public class DocumentationSupport
-    extends AbstractPolygeneTest
+public class DocumentationSupport extends AbstractPolygeneTest
 {
-
     // START SNIPPET: default
     // START SNIPPET: service
     public interface SomeValue // (1)
     {
-
         Property<String> foo();
     }
 
@@ -71,10 +64,6 @@ public class DocumentationSupport
         throws AssemblyException
     {
         module.values( SomeValue.class ); // (2)
-        // END SNIPPET: default
-        new OrgJsonValueSerializationAssembler().assemble( module ); // (3)
-        new DefaultUnitOfWorkAssembler().assemble( module );
-        // START SNIPPET: default
     }
     // END SNIPPET: default
     // END SNIPPET: service
@@ -97,9 +86,9 @@ public class DocumentationSupport
     // END SNIPPET: default
     // START SNIPPET: service
     @Service
-    private ValueSerializer valueSerializer; // (4)
+    private Serializer serializer; // (4)
     @Service
-    private ValueDeserializer valueDeserializer; // (4)
+    private Deserializer deserializer; // (4)
 
     // END SNIPPET: service
     @Test
@@ -107,8 +96,8 @@ public class DocumentationSupport
     public void assembledDefaultServiceSerialization()
     {
         SomeValue someValue = someNewValueInstance(); // (5)
-        String json = valueSerializer.serialize( someValue ); // (6)
-        SomeValue someNewValue = valueDeserializer.deserialize( module, SomeValue.class, json ); // (7)
+        String json = serializer.serialize( someValue ); // (6)
+        SomeValue someNewValue = deserializer.deserialize( module, SomeValue.class, json ); // (7)
         // END SNIPPET: service
 
         assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );
@@ -120,46 +109,11 @@ public class DocumentationSupport
 
     static enum AcmeValue
     {
-
-        foo, bar
+        foo,
+        bar
     }
 
     @Test
-    // START SNIPPET: stream
-    public void assembledServiceStreamingSerialization()
-    {
-        // END SNIPPET: stream
-
-        List<AcmeValue> dataSource = Arrays.asList( AcmeValue.values() );
-        ByteArrayOutputStream targetStream = new ByteArrayOutputStream();
-
-        // START SNIPPET: stream
-        // (1)
-        Iterable<AcmeValue> data = dataSource; // Eg. Entities converted to Values
-        OutputStream output = targetStream; // Eg. streaming JSON over HTTP
-
-        // (2)
-        valueSerializer.serialize( data, output );
-        // END SNIPPET: stream
-
-        byte[] serialized = targetStream.toByteArray();
-        ByteArrayInputStream sourceStream = new ByteArrayInputStream( serialized );
-
-        // START SNIPPET: stream
-        // (3)
-        InputStream input = sourceStream; // Eg. reading incoming JSON
-
-        // (4)
-        List<AcmeValue> values = valueDeserializer.deserialize( module, CollectionType.listOf( AcmeValue.class ), input );
-        // END SNIPPET: stream
-
-        assertThat( values, equalTo( dataSource ) );
-
-        // START SNIPPET: stream
-    }
-    // END SNIPPET: stream
-
-    @Test
     // START SNIPPET: io
     public void assembledServiceIOSerialization()
         throws IOException
@@ -177,7 +131,7 @@ public class DocumentationSupport
         Stream<AcmeValue> queryResult = dataSource.stream();
 
         // (2)
-        Function<AcmeValue, String> serialize = valueSerializer.serialize();
+        Function<AcmeValue, String> serialize = serializer.serializeFunction();
 
         // (3)
         // Eg. pipe data to another process or to a file
@@ -193,7 +147,7 @@ public class DocumentationSupport
         Stream<String> lines = input.stream();
 
         // (5)
-        Function<String, AcmeValue> deserialize = valueDeserializer.deserialize( module, AcmeValue.class );
+        Function<String, AcmeValue> deserialize = deserializer.deserializeFunction( module, AcmeValue.class );
 
         // Deserialization of a collection of AcmeValue from a String.
         // One serialized AcmeValue per line.
@@ -209,47 +163,44 @@ public class DocumentationSupport
 
     @Test
     // TODO Move to SPI !
-    // TODO Include in each ValueSerialization extensions documentation
+    // TODO Include in each Serialization extensions documentation
     public void assembledWithValuesModuleSerialization()
         throws Exception
     {
-        Application app = new Energy4Java().newApplication( applicationFactory -> {
-            Assembler[][][] pancakes = new Assembler[][][]
-                {
+        Application app = new Energy4Java().newApplication(
+            applicationFactory ->
+            {
+                Assembler[][][] pancakes = new Assembler[][][]
                     {
                         {
-                            valuesModule -> {
-                                valuesModule.layer().setName( "SINGLE-Layer" );
-                                valuesModule.setName( "VALUES-Module" );
-
-                                valuesModule.values( SomeValue.class );
-                                new DefaultUnitOfWorkAssembler().assemble( valuesModule );
-                            }
-                        },
-                        {
-                            servicesModule -> {
-                                servicesModule.setName( "SERVICES-Module" );
-                                new OrgJsonValueSerializationAssembler().
-                                    assemble( servicesModule );
+                            {
+                                valuesModule ->
+                                {
+                                    valuesModule.layer().setName( "SINGLE-Layer" );
+                                    valuesModule.setName( "VALUES-Module" );
+
+                                    valuesModule.values( SomeValue.class );
+                                }
+                            },
+                            {
+                                servicesModule -> servicesModule.setName( "SERVICES-Module" )
                             }
                         }
-                    }
-                };
-            return applicationFactory.newApplicationAssembly( pancakes );
-        } );
+                    };
+                return applicationFactory.newApplicationAssembly( pancakes );
+            } );
         app.activate();
         try
         {
-            Module valuesModule = app.findModule( "SINGLE-Layer", "VALUES-Module" );
             SomeValue someValue = someNewValueInstance();
 
             Module servicesModule = app.findModule( "SINGLE-Layer", "SERVICES-Module" );
-            ValueSerialization valueSerialization = servicesModule.findService( ValueSerialization.class ).get();
+            Serialization stateSerialization = servicesModule.findService( Serialization.class ).get();
 
-            String json = valueSerialization.serialize( someValue );
+            String json = stateSerialization.serialize( someValue );
             assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );
 
-            SomeValue someNewValue = valueSerialization.deserialize( module, SomeValue.class, json );
+            SomeValue someNewValue = stateSerialization.deserialize( module, SomeValue.class, json );
             assertThat( someNewValue, equalTo( someValue ) );
         }
         finally
@@ -258,7 +209,7 @@ public class DocumentationSupport
         }
     }
 
-    private SomeValue someNewValueInstance(  )
+    private SomeValue someNewValueInstance()
     {
         ValueBuilder<SomeValue> builder = valueBuilderFactory.newValueBuilder( SomeValue.class );
         builder.prototype().foo().set( "bar" );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/api/src/test/resources/org/apache/polygene/api/configuration/MyService.properties
----------------------------------------------------------------------
diff --git a/core/api/src/test/resources/org/apache/polygene/api/configuration/MyService.properties b/core/api/src/test/resources/org/apache/polygene/api/configuration/MyService.properties
index 600ed6f..c0639c1 100644
--- a/core/api/src/test/resources/org/apache/polygene/api/configuration/MyService.properties
+++ b/core/api/src/test/resources/org/apache/polygene/api/configuration/MyService.properties
@@ -18,4 +18,4 @@
 #
 #
 
-me = { name : Niclas, address={ street1 : "Henan Lu 555", street2 : "Block 15", city : { cityName : "Shanghai", country : { countryName : "China" } } } }
\ No newline at end of file
+me = { "name" : "Niclas", "address" : { "street1" : "Henan Lu 555", "street2" : "Block 15", "city" : { "cityName" : "Shanghai", "country" : { "countryName" : "China" } } } }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/builder/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/builder/ApplicationBuilder.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/builder/ApplicationBuilder.java
index 3a064e5..6159686 100644
--- a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/builder/ApplicationBuilder.java
+++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/builder/ApplicationBuilder.java
@@ -20,14 +20,16 @@
 package org.apache.polygene.bootstrap.builder;
 
 import java.io.InputStream;
+import java.io.StringReader;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Scanner;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonObject;
+import javax.json.JsonValue;
 import org.apache.polygene.api.activation.ActivationEventListener;
 import org.apache.polygene.api.activation.ActivationEventListenerRegistration;
 import org.apache.polygene.api.activation.ActivationException;
@@ -74,10 +76,7 @@ public class ApplicationBuilder
 
     public ApplicationBuilder metaInfo( Object... metaInfos )
     {
-        for( Object metaInfo : metaInfos )
-        {
-            this.metaInfos.add( metaInfo );
-        }
+        Collections.addAll( this.metaInfos, metaInfos );
         return this;
     }
 
@@ -199,13 +198,11 @@ public class ApplicationBuilder
      * Load an ApplicationBuilder from a JSON String.
      * @param json JSON String
      * @return Application Builder loaded from JSON
-     * @throws JSONException if unable to read JSON
      * @throws AssemblyException if unable to declare the assembly
      */
     public static ApplicationBuilder fromJson( String json )
-        throws JSONException, AssemblyException
     {
-        JSONObject root = new JSONObject( json );
+        JsonObject root = Json.createReader( new StringReader( json ) ).readObject();
         return fromJson( root );
     }
 
@@ -213,25 +210,23 @@ public class ApplicationBuilder
      * Load an ApplicationBuilder from a JSON InputStream.
      * @param json JSON input
      * @return Application Builder loaded from JSON
-     * @throws JSONException if unable to read JSON
      * @throws AssemblyException if unable to declare the assembly
      */
     public static ApplicationBuilder fromJson( InputStream json )
-        throws JSONException, AssemblyException
+        throws AssemblyException
     {
-        String jsonString = new Scanner( json, "UTF-8" ).useDelimiter( "\\A" ).next();
-        return fromJson( jsonString );
+        JsonObject root = Json.createReader( json ).readObject();
+        return fromJson( root );
     }
 
     /**
      * Load an ApplicationBuilder from a JSONObject.
      * @param root JSON object
      * @return Application Builder loaded from JSON
-     * @throws JSONException if unable to read JSON
      * @throws AssemblyException if unable to declare the assembly
      */
-    public static ApplicationBuilder fromJson( JSONObject root )
-        throws JSONException, AssemblyException
+    public static ApplicationBuilder fromJson( JsonObject root )
+        throws AssemblyException
     {
         String applicationName = root.getString( "name" );
         ApplicationBuilder builder = new ApplicationBuilder( applicationName );
@@ -242,40 +237,43 @@ public class ApplicationBuilder
     /** Configures the application struucture from a JSON document.
      *
      * @param root The JSON document root.
-     * @throws JSONException if the JSON document isn't valid.
      * @throws AssemblyException if probelms in the Assemblers provided in the JSON document.
      */
-    protected void configureWithJson( JSONObject root )
-        throws JSONException, AssemblyException
+    protected void configureWithJson( JsonObject root )
+        throws AssemblyException
     {
-        JSONArray layers = root.optJSONArray( "layers" );
-        if( layers != null )
+        JsonValue optLayers = root.get( "layers" );
+        if( optLayers != null && optLayers.getValueType() == JsonValue.ValueType.ARRAY )
         {
-            for( int i = 0; i < layers.length(); i++ )
+            JsonArray layers = (JsonArray) optLayers;
+            for( int i = 0; i < layers.size(); i++ )
             {
-                JSONObject layerObject = layers.getJSONObject( i );
+                JsonObject layerObject = layers.getJsonObject( i );
                 String layerName = layerObject.getString( "name" );
                 LayerDeclaration layerDeclaration = withLayer( layerName );
-                JSONArray using = layerObject.optJSONArray( "uses" );
-                if( using != null )
+                JsonValue optUsing = layerObject.get( "uses" );
+                if( optUsing != null && optUsing.getValueType() == JsonValue.ValueType.ARRAY )
                 {
-                    for( int j = 0; j < using.length(); j++ )
+                    JsonArray using = (JsonArray) optUsing;
+                    for( int j = 0; j < using.size(); j++ )
                     {
                         layerDeclaration.using( using.getString( j ) );
                     }
                 }
-                JSONArray modules = layerObject.optJSONArray( "modules" );
-                if( modules != null )
+                JsonValue optModules = layerObject.get( "modules" );
+                if( optModules != null && optModules.getValueType() == JsonValue.ValueType.ARRAY )
                 {
-                    for( int k = 0; k < modules.length(); k++ )
+                    JsonArray modules = (JsonArray) optModules;
+                    for( int k = 0; k < modules.size(); k++ )
                     {
-                        JSONObject moduleObject = modules.getJSONObject( k );
+                        JsonObject moduleObject = modules.getJsonObject( k );
                         String moduleName = moduleObject.getString( "name" );
                         ModuleDeclaration moduleDeclaration = layerDeclaration.withModule( moduleName );
-                        JSONArray assemblers = moduleObject.optJSONArray( "assemblers" );
-                        if( assemblers != null )
+                        JsonValue optAssemblers = moduleObject.get( "assemblers" );
+                        if( optAssemblers != null && optAssemblers.getValueType() == JsonValue.ValueType.ARRAY )
                         {
-                            for( int m = 0; m < assemblers.length(); m++ )
+                            JsonArray assemblers = (JsonArray) optAssemblers;
+                            for( int m = 0; m < assemblers.size(); m++ )
                             {
                                 String string = assemblers.getString( m );
                                 moduleDeclaration.withAssembler( string );
@@ -291,12 +289,11 @@ public class ApplicationBuilder
      * {@literal main} method that read JSON from STDIN.
      * <p>Passivation exceptions are written to STDERR if any.</p>
      * @param args Unused
-     * @throws JSONException if unable to read JSON
      * @throws AssemblyException if the assembly failed
      * @throws ActivationException if the activation failed
      */
     public static void main( String[] args )
-        throws JSONException, ActivationException, AssemblyException
+        throws ActivationException, AssemblyException
     {
         fromJson( System.in ).withPassivationShutdownHook().newApplication();
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/serialization/DefaultSerializationAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/serialization/DefaultSerializationAssembler.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/serialization/DefaultSerializationAssembler.java
new file mode 100644
index 0000000..9b877cc
--- /dev/null
+++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/serialization/DefaultSerializationAssembler.java
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.polygene.bootstrap.serialization;
+
+import org.apache.polygene.api.serialization.Deserializer;
+import org.apache.polygene.api.serialization.Serialization;
+import org.apache.polygene.api.serialization.Serializer;
+import org.apache.polygene.bootstrap.Assembler;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.serialization.javaxjson.JavaxJsonSerializationService;
+import org.apache.polygene.spi.serialization.JsonDeserializer;
+import org.apache.polygene.spi.serialization.JsonSerialization;
+import org.apache.polygene.spi.serialization.JsonSerializer;
+
+public class DefaultSerializationAssembler
+    implements Assembler
+{
+    @Override
+    public void assemble( ModuleAssembly module ) throws AssemblyException
+    {
+        module.services( JavaxJsonSerializationService.class )
+              .withTypes( Serialization.class, Serializer.class, Deserializer.class,
+                          JsonSerialization.class, JsonSerializer.class, JsonDeserializer.class )
+              .taggedWith( Serialization.Formats.JSON );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/builder/ApplicationBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/builder/ApplicationBuilderTest.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/builder/ApplicationBuilderTest.java
index d0ca6e5..c7c1e6c 100644
--- a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/builder/ApplicationBuilderTest.java
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/builder/ApplicationBuilderTest.java
@@ -29,7 +29,6 @@ import org.apache.polygene.api.structure.Module;
 import org.apache.polygene.bootstrap.Assembler;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.json.JSONException;
 import org.junit.Test;
 
 import static java.util.stream.Collectors.toList;
@@ -59,7 +58,7 @@ public class ApplicationBuilderTest
 
     @Test
     public void givenJsonWhenBuildingApplicationExpectSuccess()
-        throws JSONException, ActivationException, AssemblyException
+        throws ActivationException, AssemblyException
     {
         ApplicationBuilder builder = ApplicationBuilder.fromJson( APPLICATION );
         Application application = builder.newApplication();
@@ -70,7 +69,7 @@ public class ApplicationBuilderTest
 
     @Test
     public void givenJsonInputStreamWhenBuildingApplicationExpectSuccess()
-        throws IOException, JSONException, ActivationException, AssemblyException
+        throws IOException, ActivationException, AssemblyException
     {
         InputStream input = new ByteArrayInputStream( APPLICATION.getBytes( "UTF-8" ) );
         ApplicationBuilder builder = ApplicationBuilder.fromJson( input );

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
index 62220a6..43478bf 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
@@ -40,10 +40,11 @@ import org.apache.polygene.api.identity.HasIdentity;
 import org.apache.polygene.api.identity.Identity;
 import org.apache.polygene.api.identity.IdentityGenerator;
 import org.apache.polygene.api.identity.StringIdentity;
+import org.apache.polygene.api.serialization.Serialization;
 import org.apache.polygene.api.service.DuplicateServiceIdentityException;
 import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.api.type.HasEqualOrAssignableFromType;
 import org.apache.polygene.api.type.HasTypes;
-import org.apache.polygene.api.type.MatchTypeSpecification;
 import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
 import org.apache.polygene.api.value.ValueComposite;
 import org.apache.polygene.bootstrap.Assembler;
@@ -68,6 +69,7 @@ import org.apache.polygene.bootstrap.TransientDeclaration;
 import org.apache.polygene.bootstrap.ValueAssembly;
 import org.apache.polygene.bootstrap.ValueDeclaration;
 import org.apache.polygene.bootstrap.identity.DefaultIdentityGeneratorAssembler;
+import org.apache.polygene.bootstrap.serialization.DefaultSerializationAssembler;
 import org.apache.polygene.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.apache.polygene.runtime.activation.ActivatorsModel;
 import org.apache.polygene.runtime.composite.TransientModel;
@@ -119,8 +121,9 @@ final class ModuleAssemblyImpl
     static
     {
         defaultAssemblers = new HashMap<>();
-        defaultAssemblers.put(UnitOfWorkFactory.class, new DefaultUnitOfWorkAssembler());
-        defaultAssemblers.put(IdentityGenerator.class, new DefaultIdentityGeneratorAssembler());
+        defaultAssemblers.put( UnitOfWorkFactory.class, new DefaultUnitOfWorkAssembler() );
+        defaultAssemblers.put( IdentityGenerator.class, new DefaultIdentityGeneratorAssembler() );
+        defaultAssemblers.put( Serialization.class, new DefaultSerializationAssembler() );
     }
 
     ModuleAssemblyImpl(LayerAssembly layerAssembly, String name)
@@ -307,27 +310,27 @@ final class ModuleAssemblyImpl
     }
 
     @Override
-    public ConfigurationDeclaration configurations(Predicate<HasTypes> specification)
+    public ConfigurationDeclaration configurations( Predicate<HasTypes> specification )
     {
-        Predicate<HasTypes> isConfigurationComposite = new MatchTypeSpecification(HasIdentity.class);
-        specification = specification.and(isConfigurationComposite);
-        List<EntityAssemblyImpl> entityAssmblyList = new ArrayList<>();
-        for (EntityAssemblyImpl entityAssembly : entityAssemblies.values())
+        Predicate<HasTypes> isConfigurationComposite = new HasEqualOrAssignableFromType<>( HasIdentity.class );
+        specification = specification.and( isConfigurationComposite );
+        List<EntityAssemblyImpl> entityAssemblyList = new ArrayList<>();
+        for( EntityAssemblyImpl entityAssembly : entityAssemblies.values() )
         {
-            if (specification.test(entityAssembly))
+            if( specification.test( entityAssembly ) )
             {
-                entityAssmblyList.add(entityAssembly);
+                entityAssemblyList.add( entityAssembly );
             }
         }
         List<ValueAssemblyImpl> valueAssemblyList = new ArrayList<>();
-        for (ValueAssemblyImpl transientAssembly : valueAssemblies.values())
+        for( ValueAssemblyImpl transientAssembly : valueAssemblies.values() )
         {
-            if (specification.test(transientAssembly))
+            if( specification.test( transientAssembly ) )
             {
-                valueAssemblyList.add(transientAssembly);
+                valueAssemblyList.add( transientAssembly );
             }
         }
-        return new ConfigurationDeclarationImpl(entityAssmblyList, valueAssemblyList);
+        return new ConfigurationDeclarationImpl( entityAssemblyList, valueAssemblyList );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/main/java/org/apache/polygene/runtime/property/PropertyModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/property/PropertyModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/property/PropertyModel.java
index 565b218..64a7b77 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/property/PropertyModel.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/property/PropertyModel.java
@@ -39,22 +39,20 @@ import org.apache.polygene.api.property.InitialValueProvider;
 import org.apache.polygene.api.property.InvalidPropertyTypeException;
 import org.apache.polygene.api.property.Property;
 import org.apache.polygene.api.property.PropertyDescriptor;
-import org.apache.polygene.api.service.NoSuchServiceException;
 import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.api.serialization.Deserializer;
+import org.apache.polygene.api.service.ServiceFinder;
 import org.apache.polygene.api.structure.ModuleDescriptor;
-import org.apache.polygene.api.type.Serialization;
 import org.apache.polygene.api.type.ValueCompositeType;
 import org.apache.polygene.api.type.ValueType;
 import org.apache.polygene.api.util.Classes;
-import org.apache.polygene.api.value.MissingValueSerializationException;
-import org.apache.polygene.api.value.ValueDeserializer;
 import org.apache.polygene.api.util.Visitable;
 import org.apache.polygene.api.util.Visitor;
 import org.apache.polygene.bootstrap.BindingException;
 import org.apache.polygene.runtime.composite.ValueConstraintsInstance;
 import org.apache.polygene.runtime.model.Binder;
 import org.apache.polygene.runtime.model.Resolution;
-import org.apache.polygene.runtime.types.ValueTypeFactory;
+import org.apache.polygene.runtime.type.ValueTypeFactoryInstance;
 
 /**
  * Model for a Property.
@@ -187,11 +185,10 @@ public class PropertyModel
     public void bind( Resolution resolution )
         throws BindingException
     {
-        ValueTypeFactory factory = ValueTypeFactory.instance();
+        ValueTypeFactoryInstance factory = ValueTypeFactoryInstance.instance();
         Class<?> declaringClass = ( (Member) accessor() ).getDeclaringClass();
         Class<?> mainType = resolution.model().types().findFirst().orElse( null );
-        Serialization.Variant variant = findVariant();
-        valueType = factory.newValueType( type(), declaringClass, mainType, resolution.layer(), resolution.module(), variant );
+        valueType = factory.newValueType( type(), declaringClass, mainType, resolution.module() );
         builderInfo = new BuilderPropertyInfo();
         if( type instanceof TypeVariable )
         {
@@ -199,21 +196,6 @@ public class PropertyModel
         }
     }
 
-    private Serialization.Variant findVariant()
-    {
-        Serialization serialization = metaInfo.get( Serialization.class );
-        Serialization.Variant variant = null;
-        if( serialization != null )
-        {
-            variant = serialization.value();
-        }
-        if( variant == null )
-        {
-            variant = Serialization.Variant.entry;
-        }
-        return variant;
-    }
-
     @Override
     public <ThrowableType extends Throwable> boolean accept( Visitor<? super PropertyModel, ThrowableType> visitor )
         throws ThrowableType
@@ -356,21 +338,11 @@ public class PropertyModel
                     Class<?> propertyType = valueType().types().findFirst().orElse( null );
                     if( value instanceof String && !propertyType.equals( String.class ) )
                     {
-                        try
-                        {
-                            // here we could possibly deserialize json to other types...
-                            ValueDeserializer deserializer = module.instance()
-                                    .serviceFinder()
-                                    .findService( ValueDeserializer.class )
-                                    .get();
-                            if( deserializer != null )
-                            {
-                                value = deserializer.deserialize( module, propertyType ).apply( (String) value );
-                            }
-                        }
-                        catch( NoSuchServiceException e )
+                        ServiceFinder serviceFinder = module.instance().serviceFinder();
+                        Deserializer deserializer = serviceFinder.findService( Deserializer.class ).get();
+                        if( deserializer != null )
                         {
-                            throw new MissingValueSerializationException( "@UseDefaults with initialization value requires that there is a visible ValueDeserializer service available.", e);
+                            value = deserializer.deserialize( module, valueType, (String) value );
                         }
                     }
                 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
index 246f0ab..64b5f72 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
@@ -51,6 +51,8 @@ import org.apache.polygene.api.property.Property;
 import org.apache.polygene.api.property.PropertyDescriptor;
 import org.apache.polygene.api.query.QueryBuilder;
 import org.apache.polygene.api.query.QueryBuilderFactory;
+import org.apache.polygene.api.serialization.Serialization;
+import org.apache.polygene.api.serialization.SerializationException;
 import org.apache.polygene.api.service.NoSuchServiceException;
 import org.apache.polygene.api.service.ServiceFinder;
 import org.apache.polygene.api.service.ServiceReference;
@@ -66,8 +68,6 @@ import org.apache.polygene.api.value.ValueBuilder;
 import org.apache.polygene.api.value.ValueBuilderFactory;
 import org.apache.polygene.api.value.ValueComposite;
 import org.apache.polygene.api.value.ValueDescriptor;
-import org.apache.polygene.api.value.ValueSerialization;
-import org.apache.polygene.api.value.ValueSerializationException;
 import org.apache.polygene.runtime.activation.ActivationDelegate;
 import org.apache.polygene.runtime.composite.FunctionStateResolver;
 import org.apache.polygene.runtime.composite.StateResolver;
@@ -83,6 +83,7 @@ import org.apache.polygene.runtime.service.ImportedServicesInstance;
 import org.apache.polygene.runtime.service.ImportedServicesModel;
 import org.apache.polygene.runtime.service.ServicesInstance;
 import org.apache.polygene.runtime.service.ServicesModel;
+import org.apache.polygene.runtime.type.ValueTypeFactoryInstance;
 import org.apache.polygene.runtime.value.ValueBuilderInstance;
 import org.apache.polygene.runtime.value.ValueBuilderWithPrototype;
 import org.apache.polygene.runtime.value.ValueBuilderWithState;
@@ -112,7 +113,7 @@ public class ModuleInstance
     // Lazy assigned on accessors
     private EntityStore store;
     private IdentityGenerator generator;
-    private ValueSerialization valueSerialization;
+    private Serialization serialization;
     private MetricsProvider metrics;
     private UnitOfWorkFactory uowf;
 
@@ -296,7 +297,7 @@ public class ModuleInstance
         @Override
         public Object getPropertyState( PropertyDescriptor propertyDescriptor )
         {
-            return propertyDescriptor.resolveInitialValue(module);
+            return propertyDescriptor.resolveInitialValue( module );
         }
 
         @Override
@@ -312,7 +313,8 @@ public class ModuleInstance
         }
 
         @Override
-        public Stream<Map.Entry<String, EntityReference>> getNamedAssociationState( AssociationDescriptor associationDescriptor )
+        public Stream<Map.Entry<String, EntityReference>>
+        getNamedAssociationState( AssociationDescriptor associationDescriptor )
         {
             return new HashMap<String, EntityReference>().entrySet().stream();
         }
@@ -351,9 +353,9 @@ public class ModuleInstance
 
         try
         {
-            return valueSerialization().deserialize( model.module(), model.valueType(), serializedState );
+            return serialization().deserialize( model.module(), model.valueType(), serializedState );
         }
-        catch( ValueSerializationException ex )
+        catch( SerializationException ex )
         {
             throw new ConstructionException( "Could not create value from serialized state", ex );
         }
@@ -379,7 +381,7 @@ public class ModuleInstance
         ModelDescriptor serviceModel = typeLookup.lookupServiceModel( serviceType );
         if( serviceModel == null )
         {
-            throw new NoSuchServiceException( serviceType.getTypeName(), name(),typeLookup );
+            throw new NoSuchServiceException( serviceType.getTypeName(), name(), typeLookup );
         }
         return findServiceReferenceInstance( serviceModel );
     }
@@ -423,7 +425,6 @@ public class ModuleInstance
 
     // Implementation of Activation
     @Override
-    @SuppressWarnings( "unchecked" )
     public void activate()
         throws ActivationException
     {
@@ -455,6 +456,7 @@ public class ModuleInstance
         return model;
     }
 
+    @Override
     public LayerDescriptor layer()
     {
         return layer;
@@ -466,6 +468,7 @@ public class ModuleInstance
         return typeLookup;
     }
 
+    @Override
     public EntityStore entityStore()
     {
         if( store == null )
@@ -489,6 +492,7 @@ public class ModuleInstance
         return store;
     }
 
+    @Override
     public UnitOfWorkFactory unitOfWorkFactory()
     {
         if( uowf == null )
@@ -536,6 +540,7 @@ public class ModuleInstance
         return this;
     }
 
+    @Override
     public IdentityGenerator identityGenerator()
     {
         if( generator == null )
@@ -552,29 +557,24 @@ public class ModuleInstance
         return generator;
     }
 
-    public ValueSerialization valueSerialization()
+    @Override
+    public Serialization serialization()
     {
-        if( valueSerialization == null )
+        if( serialization == null )
         {
             synchronized( this )
             {
-                if( valueSerialization == null )
+                if( serialization == null )
                 {
-                    try
-                    {
-                        ServiceReference<ValueSerialization> service = findService( ValueSerialization.class );
-                        valueSerialization = service.get();
-                    }
-                    catch( NoSuchServiceException e )
-                    {
-                        throw new ValueSerializationException( "No ValueSeriaservice available in module " + name() );
-                    }
+                    ServiceReference<Serialization> service = findService( Serialization.class );
+                    serialization = service.get();
                 }
             }
         }
-        return valueSerialization;
+        return serialization;
     }
 
+    @Override
     public MetricsProvider metricsProvider()
     {
         if( metrics == null )
@@ -597,4 +597,10 @@ public class ModuleInstance
         }
         return metrics;
     }
+
+    @Override
+    public ValueTypeFactoryInstance valueTypeFactory()
+    {
+        return ValueTypeFactoryInstance.instance();
+    }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/main/java/org/apache/polygene/runtime/structure/TypeLookupImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/TypeLookupImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/TypeLookupImpl.java
index 9df92c9..6f55c88 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/TypeLookupImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/TypeLookupImpl.java
@@ -19,10 +19,7 @@
  */
 package org.apache.polygene.runtime.structure;
 
-import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.lang.reflect.WildcardType;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Predicate;
@@ -36,14 +33,15 @@ import org.apache.polygene.api.entity.EntityDescriptor;
 import org.apache.polygene.api.object.ObjectDescriptor;
 import org.apache.polygene.api.structure.ModuleDescriptor;
 import org.apache.polygene.api.structure.TypeLookup;
-import org.apache.polygene.api.type.HasTypes;
+import org.apache.polygene.api.type.HasAssignableFromType;
+import org.apache.polygene.api.type.HasEqualType;
+import org.apache.polygene.api.type.HasTypesCollectors;
 import org.apache.polygene.api.value.ValueDescriptor;
 
 import static java.util.stream.Collectors.toList;
 import static java.util.stream.Stream.concat;
 import static org.apache.polygene.api.common.Visibility.application;
 import static org.apache.polygene.api.common.Visibility.layer;
-import static org.apache.polygene.api.util.Classes.interfacesOf;
 
 /**
  * Central place for Composite Type lookups.
@@ -64,16 +62,16 @@ class TypeLookupImpl
     private final ConcurrentHashMap<Type, ModelDescriptor> serviceModels;
     private final ConcurrentHashMap<Type, List<? extends ModelDescriptor>> servicesReferences;
 
-    private final ModuleDescriptor moduleModel;
+    private final ModuleDescriptor module;
 
     /**
-     * Create a new TypeLookup bound to the given ModuleModel.
+     * Create a new TypeLookup bound to the given Module.
      *
-     * @param module ModuleModel bound to this TypeLookup
+     * @param module Module bound to this TypeLookup
      */
-    TypeLookupImpl( ModuleModel module )
+    TypeLookupImpl( ModuleDescriptor module )
     {
-        moduleModel = module;
+        this.module = module;
 
         // Instance caches
         allObjects = new LazyValue<>();
@@ -96,10 +94,10 @@ class TypeLookupImpl
         return objectModels.computeIfAbsent( type, key ->
         {
             List<? extends ObjectDescriptor> allModels = getAllObjects();
-            ObjectDescriptor model = ambiguityMatching( key, allModels, new ExactTypeMatching<>( key ) );
+            ObjectDescriptor model = ambiguityMatching( key, allModels, new HasEqualType<>( key ) );
             if( model == null )
             {
-                model = ambiguityMatching( key, allModels, new AssignableFromTypeMatching<>( key ) );
+                model = ambiguityMatching( key, allModels, new HasAssignableFromType<>( key ) );
             }
             return model;
         } );
@@ -111,10 +109,10 @@ class TypeLookupImpl
         return transientModels.computeIfAbsent( type, key ->
         {
             List<? extends TransientDescriptor> allModels = getAllTransients();
-            TransientDescriptor model = ambiguityMatching( key, allModels, new ExactTypeMatching<>( key ) );
+            TransientDescriptor model = ambiguityMatching( key, allModels, new HasEqualType<>( key ) );
             if( model == null )
             {
-                model = ambiguityMatching( key, allModels, new AssignableFromTypeMatching<>( key ) );
+                model = ambiguityMatching( key, allModels, new HasAssignableFromType<>( key ) );
             }
             return model;
         } );
@@ -126,10 +124,10 @@ class TypeLookupImpl
         return valueModels.computeIfAbsent( type, key ->
         {
             List<? extends ValueDescriptor> allModels = getAllValues();
-            ValueDescriptor model = ambiguityMatching( key, allModels, new ExactTypeMatching<>( key ) );
+            ValueDescriptor model = ambiguityMatching( key, allModels, new HasEqualType<>( key ) );
             if( model == null )
             {
-                model = ambiguityMatching( key, allModels, new AssignableFromTypeMatching<>( key ) );
+                model = ambiguityMatching( key, allModels, new HasAssignableFromType<>( key ) );
             }
             return model;
         } );
@@ -141,10 +139,10 @@ class TypeLookupImpl
         return unambiguousEntityModels.computeIfAbsent( type, key ->
         {
             List<? extends EntityDescriptor> allModels = getAllEntities();
-            EntityDescriptor model = ambiguityMatching( key, allModels, new ExactTypeMatching<>( key ) );
+            EntityDescriptor model = ambiguityMatching( key, allModels, new HasEqualType<>( key ) );
             if( model == null )
             {
-                model = ambiguityMatching( key, allModels, new AssignableFromTypeMatching<>( key ) );
+                model = ambiguityMatching( key, allModels, new HasAssignableFromType<>( key ) );
             }
             return model;
         } );
@@ -155,7 +153,7 @@ class TypeLookupImpl
     {
         return entityModels.computeIfAbsent(
             type,
-            key -> new TypeMatchesSelector<EntityDescriptor>( key ).selectFrom( allEntities() ) );
+            key -> allEntities().collect( HasTypesCollectors.matchingTypes( key ) ) );
     }
 
     @Override
@@ -163,8 +161,7 @@ class TypeLookupImpl
     {
         return serviceModels.computeIfAbsent(
             serviceType,
-            key -> new BestTypeMatchSelector<ModelDescriptor>( key ).selectFrom( allServices() )
-                                                                    .bestMatchOrElse( null ) );
+            key -> allServices().collect( HasTypesCollectors.matchingType( key ) ).orElse( null ) );
     }
 
     @Override
@@ -172,7 +169,7 @@ class TypeLookupImpl
     {
         return servicesReferences.computeIfAbsent(
             type,
-            key -> new TypeMatchesSelector<ModelDescriptor>( key ).selectFrom( allServices() ) );
+            key -> allServices().collect( HasTypesCollectors.matchingTypes( key ) ) );
     }
 
     @Override
@@ -184,17 +181,14 @@ class TypeLookupImpl
     private List<ObjectDescriptor> getAllObjects()
     {
         return allObjects.computeIfAbsent(
-            () -> concat( moduleModel.objects(),
+            () -> concat( module.objects(),
                           concat(
                               concat(
-                                  moduleModel.layer().visibleObjects( layer ),
-                                  moduleModel.layer()
-                                             .visibleObjects( application )
+                                  module.layer().visibleObjects( layer ),
+                                  module.layer().visibleObjects( application )
                               ),
-                              moduleModel.layer()
-                                         .usedLayers()
-                                         .layers()
-                                         .flatMap( layer -> layer.visibleObjects( application ) )
+                              module.layer().usedLayers().layers()
+                                    .flatMap( layer -> layer.visibleObjects( application ) )
                           )
             ).collect( toList() )
         );
@@ -209,16 +203,14 @@ class TypeLookupImpl
     private List<TransientDescriptor> getAllTransients()
     {
         return allTransients.computeIfAbsent(
-            () -> concat( moduleModel.transientComposites(),
+            () -> concat( module.transientComposites(),
                           concat(
                               concat(
-                                  moduleModel.layer().visibleTransients( layer ),
-                                  moduleModel.layer().visibleTransients( application )
+                                  module.layer().visibleTransients( layer ),
+                                  module.layer().visibleTransients( application )
                               ),
-                              moduleModel.layer()
-                                         .usedLayers()
-                                         .layers()
-                                         .flatMap( layer -> layer.visibleTransients( application ) )
+                              module.layer().usedLayers().layers()
+                                    .flatMap( layer -> layer.visibleTransients( application ) )
                           )
             ).collect( toList() )
         );
@@ -233,15 +225,13 @@ class TypeLookupImpl
     private List<ValueDescriptor> getAllValues()
     {
         return allValues.computeIfAbsent(
-            () -> concat( moduleModel.valueComposites(),
+            () -> concat( module.valueComposites(),
                           concat(
-                              concat( moduleModel.layer().visibleValues( layer ),
-                                      moduleModel.layer().visibleValues( application )
+                              concat( module.layer().visibleValues( layer ),
+                                      module.layer().visibleValues( application )
                               ),
-                              moduleModel.layer()
-                                         .usedLayers()
-                                         .layers()
-                                         .flatMap( layer1 -> layer1.visibleValues( application ) )
+                              module.layer().usedLayers().layers()
+                                    .flatMap( layer1 -> layer1.visibleValues( application ) )
                           )
             ).collect( toList() )
         );
@@ -256,16 +246,14 @@ class TypeLookupImpl
     private List<EntityDescriptor> getAllEntities()
     {
         return allEntities.computeIfAbsent(
-            () -> concat( moduleModel.entityComposites(),
+            () -> concat( module.entityComposites(),
                           concat(
                               concat(
-                                  moduleModel.layer().visibleEntities( layer ),
-                                  moduleModel.layer().visibleEntities( application )
+                                  module.layer().visibleEntities( layer ),
+                                  module.layer().visibleEntities( application )
                               ),
-                              moduleModel.layer()
-                                         .usedLayers()
-                                         .layers()
-                                         .flatMap( layer -> layer.visibleEntities( application ) )
+                              module.layer().usedLayers().layers()
+                                    .flatMap( layer -> layer.visibleEntities( application ) )
                           )
             ).collect( toList() )
         );
@@ -281,28 +269,24 @@ class TypeLookupImpl
     {
         return allServices.computeIfAbsent(
             () -> concat(
-                concat( moduleModel.serviceComposites(),
+                concat( module.serviceComposites(),
                         concat(
                             concat(
-                                moduleModel.layer().visibleServices( layer ),
-                                moduleModel.layer().visibleServices( application )
+                                module.layer().visibleServices( layer ),
+                                module.layer().visibleServices( application )
                             ),
-                            moduleModel.layer()
-                                       .usedLayers()
-                                       .layers()
-                                       .flatMap( layer -> layer.visibleServices( application ) )
+                            module.layer().usedLayers().layers()
+                                  .flatMap( layer -> layer.visibleServices( application ) )
                         )
                 ),
-                concat( moduleModel.importedServices(),
+                concat( module.importedServices(),
                         concat(
                             concat(
-                                moduleModel.layer().visibleServices( layer ),
-                                moduleModel.layer().visibleServices( application )
+                                module.layer().visibleServices( layer ),
+                                module.layer().visibleServices( application )
                             ),
-                            moduleModel.layer()
-                                       .usedLayers()
-                                       .layers()
-                                       .flatMap( layer -> layer.visibleServices( application ) )
+                            module.layer().usedLayers().layers()
+                                  .flatMap( layer -> layer.visibleServices( application ) )
                         )
                 )
             ).collect( toList() )
@@ -312,7 +296,7 @@ class TypeLookupImpl
     private static <T extends ModelDescriptor> T ambiguityMatching(
         Class type,
         List<T> modelModules,
-        TypeMatching<T> matching
+        Predicate<T> matching
     )
     {
         List<T> models = modelModules.stream()
@@ -330,177 +314,6 @@ class TypeLookupImpl
         return models.get( 0 );
     }
 
-    private static abstract class TypeMatching<T extends HasTypes>
-        implements Predicate<T>
-    {
-        protected final Type lookedUpType;
-
-        protected TypeMatching( Type lookedUpType )
-        {
-            this.lookedUpType = lookedUpType;
-        }
-
-        @Override
-        public final boolean test( T model )
-        {
-            if( lookedUpType instanceof Class )
-            {
-                return model.types().anyMatch( checkMatch( lookedUpType ) );
-            }
-            else
-            {
-                if( lookedUpType instanceof ParameterizedType )
-                {
-                    // Foo<Bar> check
-                    // First check Foo
-                    ParameterizedType parameterizedType = (ParameterizedType) lookedUpType;
-                    Type rawType = parameterizedType.getRawType();
-                    if( model.types().noneMatch( checkMatch( rawType ) ) )
-                    {
-                        return false;
-                    }
-                    // Then check Bar
-                    return interfacesOf( model.types() ).anyMatch( intf -> intf.equals( lookedUpType ) );
-                }
-                else if( lookedUpType instanceof WildcardType )
-                {
-                    return true;
-                }
-                return false;
-            }
-        }
-
-        protected abstract Predicate<Type> checkMatch( Type matchTo );
-    }
-
-    private static class ExactTypeMatching<T extends HasTypes> extends TypeMatching<T>
-    {
-        private ExactTypeMatching( Type lookedUpType )
-        {
-            super( lookedUpType );
-        }
-
-        protected Predicate<Type> checkMatch( Type matchTo )
-        {
-            return matchTo::equals;
-        }
-    }
-
-    private static class AssignableFromTypeMatching<T extends HasTypes> extends TypeMatching<T>
-    {
-        private AssignableFromTypeMatching( Type lookedUpType )
-        {
-            super( lookedUpType );
-        }
-
-        protected Predicate<Type> checkMatch( Type matchTo )
-        {
-            // TODO; what to do if there is ParameterizedType here?? Now set to ClassCastException and see if anything surfaces
-//            if( matchTo instanceof Class )
-            {
-                Class<?> clazz = (Class<?>) matchTo;
-                return candidate -> !candidate.equals( matchTo ) && clazz.isAssignableFrom( (Class<?>) candidate );
-            }
-//            return candidate -> candidate.equals( matchTo );
-        }
-    }
-
-    /**
-     * Selects descriptors by combining {@link ExactTypeMatching} and {@link AssignableFromTypeMatching}.
-     *
-     * Selected descriptors are sorted, exact matches first, assignable ones second.
-     * Other than that, original order is preserved.
-     *
-     * <code>
-     *     [ assignable1, matching1, assignable2, assignable3, matching2, non-matching-nor-assignable ]
-     * </code>
-     * results in
-     * <code>
-     *     [ matching1, matching2, assignable1, assignable2, assignable3 ]
-     * </code>
-     *
-     * @param <T> Descriptor type
-     */
-    private static class TypeMatchesSelector<T extends HasTypes> extends ArrayList<T>
-    {
-        private final ExactTypeMatching<T> exactMatchPredicate;
-        private final AssignableFromTypeMatching<T> assignablePredicate;
-        private Integer lastMatchIndex;
-
-        private TypeMatchesSelector( Type type )
-        {
-            this.exactMatchPredicate = new ExactTypeMatching<>( type );
-            this.assignablePredicate = new AssignableFromTypeMatching<>( type );
-        }
-
-        List<T> selectFrom( Stream<? extends T> candidates )
-        {
-            candidates.forEach( this::addDescriptor );
-            return this;
-        }
-
-        private void addDescriptor( T descriptor )
-        {
-            if( contains( descriptor ) )
-            {
-                return;
-            }
-            if( exactMatchPredicate.test( descriptor ) )
-            {
-                Integer nextMatchIndex = lastMatchIndex == null ? 0 : lastMatchIndex + 1;
-                add( nextMatchIndex, descriptor );
-                lastMatchIndex = nextMatchIndex;
-            }
-            else if( assignablePredicate.test( descriptor ) )
-            {
-                add( descriptor );
-            }
-        }
-
-        boolean containsExactMatches()
-        {
-            return lastMatchIndex != null;
-        }
-    }
-
-    /**
-     * Selects the best matching descriptor by combining {@link ExactTypeMatching} and {@link AssignableFromTypeMatching}.
-     *
-     * Selected descriptor is the first exact match if it exists, the first assignable otherwise.
-     *
-     * @param <T> Descriptor type
-     */
-    private static class BestTypeMatchSelector<T extends HasTypes>
-    {
-        private TypeMatchesSelector<T> descriptors;
-
-        BestTypeMatchSelector( Type type )
-        {
-            this.descriptors = new TypeMatchesSelector<>( type );
-        }
-
-        BestTypeMatchSelector<T> selectFrom( Stream<? extends T> candidates )
-        {
-            candidates.forEach( this::addDescriptor );
-            return this;
-        }
-
-        T bestMatchOrElse( T or )
-        {
-            return !descriptors.isEmpty() ? descriptors.get( 0 ) : or;
-        }
-
-        private void addDescriptor( T descriptor )
-        {
-            // Until an exact match is found, even if we already found assignable ones,
-            // keep selecting in case the last element is an exact match.
-            if( !descriptors.containsExactMatches() )
-            {
-                descriptors.addDescriptor( descriptor );
-            }
-        }
-    }
-
     /**
      * This Predicate will filter out all Models that doesn't have the same visibility as the first one.
      */
@@ -525,7 +338,7 @@ class TypeLookupImpl
     {
         private volatile T value;
 
-        public T computeIfAbsent( Supplier<T> supplier )
+        private T computeIfAbsent( Supplier<T> supplier )
         {
             if( value == null )
             {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/main/java/org/apache/polygene/runtime/type/ValueTypeFactoryInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/type/ValueTypeFactoryInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/type/ValueTypeFactoryInstance.java
new file mode 100644
index 0000000..37a1b91
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/type/ValueTypeFactoryInstance.java
@@ -0,0 +1,147 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.polygene.runtime.type;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import org.apache.polygene.api.common.InvalidApplicationException;
+import org.apache.polygene.api.structure.ModuleDescriptor;
+import org.apache.polygene.api.type.CollectionType;
+import org.apache.polygene.api.type.EnumType;
+import org.apache.polygene.api.type.MapType;
+import org.apache.polygene.api.type.ValueCompositeType;
+import org.apache.polygene.api.type.ValueType;
+import org.apache.polygene.api.util.Classes;
+import org.apache.polygene.api.value.ValueComposite;
+import org.apache.polygene.api.value.ValueDescriptor;
+import org.apache.polygene.runtime.value.ValueInstance;
+import org.apache.polygene.spi.type.ValueTypeFactory;
+
+public class ValueTypeFactoryInstance implements ValueTypeFactory
+{
+    private static final ValueTypeFactoryInstance INSTANCE = new ValueTypeFactoryInstance();
+
+    public static ValueTypeFactoryInstance instance()
+    {
+        return INSTANCE;
+    }
+
+    @Override
+    public ValueType valueTypeOf( ModuleDescriptor module, Object object )
+    {
+        if( object instanceof ValueComposite )
+        {
+            return ValueInstance.valueInstanceOf( (ValueComposite) object ).descriptor().valueType();
+        }
+        if( object instanceof Enum )
+        {
+            return EnumType.of( ( (Enum) object ).getDeclaringClass() );
+        }
+        return valueTypeOf( module, object.getClass() );
+    }
+
+    @Override
+    public ValueType valueTypeOf( ModuleDescriptor module, Class<?> type )
+    {
+        ValueDescriptor valueDescriptor = module.typeLookup().lookupValueModel( type );
+        if( valueDescriptor != null )
+        {
+            return valueDescriptor.valueType();
+        }
+        return newValueType( type, type, type, module );
+    }
+
+    public ValueType newValueType( Type type, Class declaringClass, Class compositeType, ModuleDescriptor module )
+    {
+        ValueType valueType;
+        if( EnumType.isEnum( type ) )
+        {
+            valueType = EnumType.of( Classes.RAW_CLASS.apply( type ) );
+        }
+        else if( CollectionType.isCollection( type ) )
+        {
+            if( type instanceof ParameterizedType )
+            {
+                ParameterizedType pt = (ParameterizedType) type;
+                Type collectionType = pt.getActualTypeArguments()[ 0 ];
+                if( collectionType instanceof TypeVariable && declaringClass != null )
+                {
+                    TypeVariable collectionTypeVariable = (TypeVariable) collectionType;
+                    collectionType = Classes.resolveTypeVariable( collectionTypeVariable, declaringClass,
+                                                                  compositeType );
+                }
+                ValueType collectedType = newValueType( collectionType, declaringClass, compositeType, module );
+                valueType = CollectionType.of( Classes.RAW_CLASS.apply( type ), collectedType );
+            }
+            else
+            {
+                ValueType collectedType = newValueType( Object.class, declaringClass, compositeType, module );
+                valueType = CollectionType.of( Classes.RAW_CLASS.apply( type ), collectedType );
+            }
+        }
+        else if( MapType.isMap( type ) )
+        {
+            if( type instanceof ParameterizedType )
+            {
+                ParameterizedType pt = (ParameterizedType) type;
+                Type keyType = pt.getActualTypeArguments()[ 0 ];
+                if( keyType instanceof TypeVariable && declaringClass != null )
+                {
+                    TypeVariable keyTypeVariable = (TypeVariable) keyType;
+                    keyType = Classes.resolveTypeVariable( keyTypeVariable, declaringClass, compositeType );
+                }
+                ValueType keyedType = newValueType( keyType, declaringClass, compositeType, module );
+                Type valType = pt.getActualTypeArguments()[ 1 ];
+                if( valType instanceof TypeVariable && declaringClass != null )
+                {
+                    TypeVariable valueTypeVariable = (TypeVariable) valType;
+                    valType = Classes.resolveTypeVariable( valueTypeVariable, declaringClass, compositeType );
+                }
+                ValueType valuedType = newValueType( valType, declaringClass, compositeType, module );
+                valueType = MapType.of( Classes.RAW_CLASS.apply( type ), keyedType, valuedType );
+            }
+            else
+            {
+                ValueType keyType = newValueType( Object.class, declaringClass, compositeType, module );
+                ValueType valuesType = newValueType( Object.class, declaringClass, compositeType, module );
+                valueType = MapType.of( Classes.RAW_CLASS.apply( type ), keyType, valuesType );
+            }
+        }
+        else if( ValueCompositeType.isValueComposite( type ) )
+        {
+            ValueDescriptor model = module.typeLookup().lookupValueModel( Classes.RAW_CLASS.apply( type ) );
+            if( model == null )
+            {
+                throw new InvalidApplicationException(
+                    "[" + module.name() + "] Could not find ValueComposite of type " + type );
+            }
+
+            valueType = model.valueType();
+        }
+        else
+        {
+            valueType = ValueType.of( Classes.RAW_CLASS.apply( type ) );
+        }
+
+        return valueType;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/main/java/org/apache/polygene/runtime/types/ValueTypeFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/types/ValueTypeFactory.java b/core/runtime/src/main/java/org/apache/polygene/runtime/types/ValueTypeFactory.java
deleted file mode 100644
index a3538c0..0000000
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/types/ValueTypeFactory.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you 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.polygene.runtime.types;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.polygene.api.common.InvalidApplicationException;
-import org.apache.polygene.api.common.MetaInfo;
-import org.apache.polygene.api.common.Visibility;
-import org.apache.polygene.api.type.CollectionType;
-import org.apache.polygene.api.type.EnumType;
-import org.apache.polygene.api.type.MapType;
-import org.apache.polygene.api.type.Serialization;
-import org.apache.polygene.api.type.ValueCompositeType;
-import org.apache.polygene.api.type.ValueType;
-import org.apache.polygene.api.util.Classes;
-import org.apache.polygene.api.util.HierarchicalVisitorAdapter;
-import org.apache.polygene.api.value.ValueComposite;
-import org.apache.polygene.runtime.association.AssociationsModel;
-import org.apache.polygene.runtime.association.ManyAssociationsModel;
-import org.apache.polygene.runtime.association.NamedAssociationsModel;
-import org.apache.polygene.runtime.composite.CompositeMethodsModel;
-import org.apache.polygene.runtime.composite.MixinsModel;
-import org.apache.polygene.runtime.property.PropertiesModel;
-import org.apache.polygene.runtime.structure.LayerModel;
-import org.apache.polygene.runtime.structure.ModuleModel;
-import org.apache.polygene.runtime.structure.UsedLayersModel;
-import org.apache.polygene.runtime.value.ValueModel;
-import org.apache.polygene.runtime.value.ValueStateModel;
-import org.apache.polygene.runtime.value.ValuesModel;
-
-public class ValueTypeFactory
-{
-    private static final ValueTypeFactory instance = new ValueTypeFactory();
-
-    public static ValueTypeFactory instance()
-    {
-        return instance;
-    }
-
-    @SuppressWarnings( { "raw", "unchecked" } )
-    public ValueType newValueType( Type type,
-                                   Class declaringClass,
-                                   Class compositeType,
-                                   LayerModel layer,
-                                   ModuleModel module,
-                                   Serialization.Variant variant
-    )
-    {
-        ValueType valueType;
-        if( CollectionType.isCollection( type ) )
-        {
-            if( type instanceof ParameterizedType )
-            {
-                ParameterizedType pt = (ParameterizedType) type;
-                Type collectionType = pt.getActualTypeArguments()[ 0 ];
-                if( collectionType instanceof TypeVariable )
-                {
-                    TypeVariable collectionTypeVariable = (TypeVariable) collectionType;
-                    collectionType = Classes.resolveTypeVariable( collectionTypeVariable, declaringClass, compositeType );
-                }
-                ValueType collectedType = newValueType( collectionType, declaringClass, compositeType, layer, module, variant );
-                valueType = new CollectionType( Classes.RAW_CLASS.apply( type ), collectedType );
-            }
-            else
-            {
-                ValueType collectedType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
-                valueType = new CollectionType( Classes.RAW_CLASS.apply( type ), collectedType );
-            }
-        }
-        else if( MapType.isMap( type ) )
-        {
-            if( type instanceof ParameterizedType )
-            {
-                ParameterizedType pt = (ParameterizedType) type;
-                Type keyType = pt.getActualTypeArguments()[ 0 ];
-                if( keyType instanceof TypeVariable )
-                {
-                    TypeVariable keyTypeVariable = (TypeVariable) keyType;
-                    keyType = Classes.resolveTypeVariable( keyTypeVariable, declaringClass, compositeType );
-                }
-                ValueType keyedType = newValueType( keyType, declaringClass, compositeType, layer, module, variant );
-                Type valType = pt.getActualTypeArguments()[ 1 ];
-                if( valType instanceof TypeVariable )
-                {
-                    TypeVariable valueTypeVariable = (TypeVariable) valType;
-                    valType = Classes.resolveTypeVariable( valueTypeVariable, declaringClass, compositeType );
-                }
-                ValueType valuedType = newValueType( valType, declaringClass, compositeType, layer, module, variant );
-                valueType = new MapType( Classes.RAW_CLASS.apply( type ), keyedType, valuedType, variant );
-            }
-            else
-            {
-                ValueType keyType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
-                ValueType valuesType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
-                valueType = new MapType( Classes.RAW_CLASS.apply( type ), keyType, valuesType, variant );
-            }
-        }
-        else if( ValueCompositeType.isValueComposite( type ) )
-        {
-            // Find ValueModel in module/layer/used layers
-            ValueModel model = new ValueFinder( layer, module, Classes.RAW_CLASS.apply( type ) ).getFoundModel();
-
-            if( model == null )
-            {
-                if( type.equals( ValueComposite.class ) )
-                {
-                    // Create default model
-                    MixinsModel mixinsModel = new MixinsModel();
-                    List<Class<?>> valueComposite = new ArrayList<>();
-                    valueComposite.add( ValueComposite.class );
-                    ValueStateModel valueStateModel = new ValueStateModel( new PropertiesModel(),
-                                                                           new AssociationsModel(),
-                                                                           new ManyAssociationsModel(),
-                                                                           new NamedAssociationsModel() );
-                    model = new ValueModel( module, valueComposite, Visibility.application, new MetaInfo(),
-                                            mixinsModel, valueStateModel, new CompositeMethodsModel( mixinsModel ) );
-                }
-                else
-                {
-                    throw new InvalidApplicationException( "[" + module.name() + "] Could not find ValueComposite of type " + type );
-                }
-            }
-
-            return model.valueType();
-        }
-        else if( EnumType.isEnum( type ) )
-        {
-            valueType = new EnumType( Classes.RAW_CLASS.apply( type ) );
-        }
-        else
-        {
-            valueType = new ValueType( Classes.RAW_CLASS.apply( type ) );
-        }
-
-        return valueType;
-    }
-
-    @SuppressWarnings( "raw" )
-    private static class ValueFinder
-        extends HierarchicalVisitorAdapter<Object, Object, RuntimeException>
-    {
-        private Class<?> type;
-        private ValueModel foundModel;
-        private Visibility visibility;
-
-        private ValueFinder( LayerModel layer, ModuleModel module, Class type )
-        {
-            this.type = type;
-
-            visibility = Visibility.module;
-            module.accept( this );
-
-            if( foundModel == null )
-            {
-                visibility = Visibility.layer;
-                layer.accept( this );
-
-                if( foundModel == null )
-                {
-                    visibility = Visibility.application;
-                    layer.usedLayers().accept( this );
-                }
-            }
-        }
-
-        public ValueModel getFoundModel()
-        {
-            return foundModel;
-        }
-
-        @Override
-        public boolean visitEnter( Object visited )
-            throws RuntimeException
-        {
-            if( visited instanceof ValuesModel )
-            {
-                return true;
-            }
-            else if( visited instanceof ModuleModel )
-            {
-                return true;
-            }
-            else if( visited instanceof LayerModel )
-            {
-                return true;
-            }
-            else if( visited instanceof UsedLayersModel )
-            {
-                return true;
-            }
-            else if( visited instanceof ValueModel )
-            {
-                ValueModel valueModel = (ValueModel) visited;
-                boolean typeEquality = valueModel.types().anyMatch( t -> t.equals( type ) );
-                if( typeEquality && valueModel.visibility().ordinal() >= visibility.ordinal() )
-                {
-                    foundModel = valueModel;
-                }
-            }
-
-            return false;
-        }
-
-        @Override
-        public boolean visitLeave( Object visited )
-            throws RuntimeException
-        {
-            return foundModel == null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueInstance.java
index 573d659..04846e9 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueInstance.java
@@ -164,6 +164,6 @@ public final class ValueInstance
     @Override
     public String toString()
     {
-        return ( (ModuleSpi) module().instance() ).valueSerialization().serialize( this.<ValueComposite>proxy() );
+        return ( (ModuleSpi) module().instance() ).serialization().serialize( proxy() );
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java
index 2148095..4fee793 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/value/ValueModel.java
@@ -58,7 +58,7 @@ public final class ValueModel extends CompositeModel
     {
         super( module, types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );
 
-        valueType = new ValueCompositeType( this );
+        valueType = ValueCompositeType.of( this );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/test/java/org/apache/polygene/bootstrap/ApplicationAssemblerTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/bootstrap/ApplicationAssemblerTest.java b/core/runtime/src/test/java/org/apache/polygene/bootstrap/ApplicationAssemblerTest.java
index 6729cf9..f924408 100644
--- a/core/runtime/src/test/java/org/apache/polygene/bootstrap/ApplicationAssemblerTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/bootstrap/ApplicationAssemblerTest.java
@@ -20,6 +20,7 @@
 package org.apache.polygene.bootstrap;
 
 import org.apache.polygene.api.identity.IdentityGenerator;
+import org.apache.polygene.api.serialization.Serialization;
 import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
 import org.junit.Assert;
 import org.junit.Test;
@@ -77,7 +78,9 @@ public class ApplicationAssemblerTest
                 if( visited instanceof ServiceDescriptor )
                 {
                     ServiceDescriptor serviceDescriptor = (ServiceDescriptor) visited;
-                    if( serviceDescriptor.hasType( UnitOfWorkFactory.class ) || serviceDescriptor.hasType( IdentityGenerator.class ) )
+                    if( serviceDescriptor.hasType( UnitOfWorkFactory.class )
+                        || serviceDescriptor.hasType( IdentityGenerator.class )
+                        || serviceDescriptor.hasType( Serialization.class ) )
                     {
                         return false;
                     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
index 4a846dc..f09aa1c 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
@@ -31,12 +31,10 @@ import org.apache.polygene.api.mixin.Mixins;
 import org.apache.polygene.api.unitofwork.UnitOfWork;
 import org.apache.polygene.api.unitofwork.UnitOfWorkCompletionException;
 import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
-import org.apache.polygene.api.value.ValueSerialization;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.entitystore.memory.MemoryEntityStoreService;
 import org.apache.polygene.test.AbstractPolygeneTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationService;
 import org.junit.Test;
 
 import static org.hamcrest.core.IsEqual.equalTo;
@@ -53,7 +51,6 @@ public class Qi382Test extends AbstractPolygeneTest
     public void assemble( ModuleAssembly module )
         throws AssemblyException
     {
-        module.addServices( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON );
         module.addServices( MemoryEntityStoreService.class );
         module.entities( Car.class, Person.class );
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
index a44f20a..8ed138c 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
@@ -19,18 +19,16 @@
  */
 package org.apache.polygene.regression.qi383;
 
-import org.apache.polygene.api.identity.StringIdentity;
-import org.apache.polygene.test.AbstractPolygeneTest;
-import org.junit.Test;
 import org.apache.polygene.api.entity.EntityComposite;
+import org.apache.polygene.api.identity.StringIdentity;
 import org.apache.polygene.api.unitofwork.EntityCompositeAlreadyExistsException;
 import org.apache.polygene.api.unitofwork.UnitOfWork;
 import org.apache.polygene.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.polygene.api.value.ValueSerialization;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.entitystore.memory.MemoryEntityStoreService;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationService;
+import org.apache.polygene.test.AbstractPolygeneTest;
+import org.junit.Test;
 
 public class Qi383Test extends AbstractPolygeneTest
 {
@@ -38,7 +36,6 @@ public class Qi383Test extends AbstractPolygeneTest
     public void assemble( ModuleAssembly module )
         throws AssemblyException
     {
-        module.addServices( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON );
         module.addServices( MemoryEntityStoreService.class );
         module.entities( Car.class );
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationAssignmentTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationAssignmentTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationAssignmentTest.java
index 051b3bc..c3131eb 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationAssignmentTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/association/AssociationAssignmentTest.java
@@ -25,12 +25,10 @@ import org.apache.polygene.api.entity.EntityBuilder;
 import org.apache.polygene.api.entity.EntityComposite;
 import org.apache.polygene.api.identity.Identity;
 import org.apache.polygene.api.unitofwork.UnitOfWork;
-import org.apache.polygene.api.value.ValueSerialization;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.entitystore.memory.MemoryEntityStoreService;
 import org.apache.polygene.test.AbstractPolygeneTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationService;
 import org.junit.Test;
 
 import static org.hamcrest.core.IsEqual.equalTo;
@@ -45,8 +43,6 @@ public class AssociationAssignmentTest extends AbstractPolygeneTest
         throws AssemblyException
     {
         module.services( MemoryEntityStoreService.class );
-        module.services( OrgJsonValueSerializationService.class )
-            .taggedWith( ValueSerialization.Formats.JSON );
         module.entities( TheAssociatedType.class );
         module.entities( TheMainType.class );
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c9dd7229/core/runtime/src/test/java/org/apache/polygene/runtime/defaults/UseDefaultsTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/defaults/UseDefaultsTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/defaults/UseDefaultsTest.java
index d0b0863..ab1feb9 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/defaults/UseDefaultsTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/defaults/UseDefaultsTest.java
@@ -28,11 +28,9 @@ import org.apache.polygene.api.common.UseDefaults;
 import org.apache.polygene.api.composite.TransientBuilder;
 import org.apache.polygene.api.composite.TransientComposite;
 import org.apache.polygene.api.property.Property;
-import org.apache.polygene.api.value.ValueDeserializer;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.test.AbstractPolygeneTest;
-import org.apache.polygene.valueserialization.orgjson.OrgJsonValueDeserializer;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.equalTo;
@@ -42,14 +40,12 @@ import static org.junit.Assert.assertThat;
 /**
  * JAVADOC
  */
-public class UseDefaultsTest
-    extends AbstractPolygeneTest
+public class UseDefaultsTest extends AbstractPolygeneTest
 {
     public void assemble( ModuleAssembly module )
         throws AssemblyException
     {
         module.transients( TestComposite.class );
-        module.services( ValueDeserializer.class ).withMixins( OrgJsonValueDeserializer.class );
         module.forMixin( TestComposite.class ).declareDefaults().assemblyString().set( "habba" );
     }
 
@@ -76,9 +72,9 @@ public class UseDefaultsTest
         assertThat( testComposite.initializedIntegerDefaultValue().get(), equalTo( 123 ) );
         assertThat( testComposite.initializedFloatDefaultValue().get(), equalTo( 123.45f ) );
         List<String> expectedList = Collections.singletonList( "abcde" );
-//        assertThat( testComposite.initializedStringListDefultString().get(), equalTo( expectedList) );
+        assertThat( testComposite.initializedStringListDefultString().get(), equalTo( expectedList ) );
         Map<String, Integer> expectedMap = Collections.singletonMap( "abcd", 345 );
-//        assertThat( testComposite.initializedMapDefaultValue().get(), equalTo( expectedMap) );
+        assertThat( testComposite.initializedMapDefaultValue().get(), equalTo( expectedMap ) );
     }
 
     interface TestComposite
@@ -109,12 +105,10 @@ public class UseDefaultsTest
         @UseDefaults( "123.45" )
         Property<Float> initializedFloatDefaultValue();
 
-// TODO: Seems that OrgJsonValueDeserializer has problem with arrays.
-//        @UseDefaults( "[\"abcde\"]" )
-//        Property<List<String>> initializedStringListDefultString();
+        @UseDefaults( "[\"abcde\"]" )
+        Property<List<String>> initializedStringListDefultString();
 
-// TODO: Seems that OrgJsonValueDeserializer has problem with arrays.
-//        @UseDefaults( "{\"abcd\" : 345 }" )
-//        Property<Map<String, Integer>> initializedMapDefaultValue();
+        @UseDefaults( "{\"abcd\": 345}" )
+        Property<Map<String, Integer>> initializedMapDefaultValue();
     }
 }