polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [4/9] zest-java git commit: ZEST-132, ZEST-97 UnitOfWorkFactory as a customizable Service UnitOfWork as a customizable Transient Class can be a Transient directly, with itself as both the Composite Type and the Mixin. SideEffects declarations
Date Wed, 16 Dec 2015 06:17:41 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi95/Qi95IssueTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi95/Qi95IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi95/Qi95IssueTest.java
index bb7f78f..b67db87 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi95/Qi95IssueTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi95/Qi95IssueTest.java
@@ -21,6 +21,7 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.junit.Rule;
 import org.junit.Test;
 import org.apache.zest.api.common.Visibility;
@@ -61,7 +62,7 @@ public class Qi95IssueTest
         {
             application.activate();
             Module domain = application.findModule( "Domain", "Domain" );
-            UnitOfWorkFactory unitOfWorkFactory = domain;
+            UnitOfWorkFactory unitOfWorkFactory = domain.unitOfWorkFactory();
             createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
         }
         finally
@@ -79,7 +80,7 @@ public class Qi95IssueTest
         {
             application.activate();
             Module domain = application.findModule( "Domain", "Domain" );
-            UnitOfWorkFactory unitOfWorkFactory = domain;
+            UnitOfWorkFactory unitOfWorkFactory = domain.unitOfWorkFactory();
             createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
         }
         finally
@@ -97,7 +98,7 @@ public class Qi95IssueTest
         {
             application.activate();
             Module domain = application.findModule( "Domain", "Domain" );
-            UnitOfWorkFactory unitOfWorkFactory = domain;
+            UnitOfWorkFactory unitOfWorkFactory = domain.unitOfWorkFactory();
             createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
         }
         finally
@@ -116,7 +117,7 @@ public class Qi95IssueTest
             application.activate();
 
             Module domain = application.findModule( "Domain", "Domain" );
-            UnitOfWorkFactory unitOfWorkFactory = domain;
+            UnitOfWorkFactory unitOfWorkFactory = domain.unitOfWorkFactory();
             createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
         }
         finally
@@ -278,6 +279,7 @@ public class Qi95IssueTest
                     throws AssemblyException
                 {
                     module.entities( ItemTypeEntity.class );
+                    new DefaultUnitOfWorkAssembler().assemble( module );
                 }
             } );
             return domainLayer;
@@ -293,6 +295,7 @@ public class Qi95IssueTest
                 throws AssemblyException
             {
                 new EntityTestAssembler().assemble( module );
+                new DefaultUnitOfWorkAssembler().assemble( module );
 
                 module.entities( NativeConfiguration.class ).visibleIn( Visibility.application );
                 module.forMixin( NativeConfiguration.class )
@@ -320,6 +323,7 @@ public class Qi95IssueTest
             {
                 new OrgJsonValueSerializationAssembler().assemble( module );
                 new JdbmEntityStoreAssembler().visibleIn( Visibility.application ).assemble( module );
+                new DefaultUnitOfWorkAssembler().assemble( module );
             }
         };
     }
@@ -329,6 +333,7 @@ public class Qi95IssueTest
     {
         ModuleAssembly moduleAssembly = layerAssembly.module( name );
         assembler.assemble( moduleAssembly );
+        new DefaultUnitOfWorkAssembler().assemble( moduleAssembly );
         return moduleAssembly;
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java b/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
index 29509ea..621b02f 100644
--- a/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
+++ b/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
@@ -73,7 +73,7 @@ public class SolrQueryServiceTest
         throws UnitOfWorkCompletionException, InterruptedException
     {
         // Create and index an entity
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         TestEntity test = uow.newEntity( TestEntity.class );
         test.name().set( "Hello World" );
         uow.complete();
@@ -85,7 +85,7 @@ public class SolrQueryServiceTest
         throws UnitOfWorkCompletionException
     {
         // Search for it
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         Query<TestEntity> query = uow.newQuery( module.newQueryBuilder( TestEntity.class ).where( SolrExpressions.search( "hello" ) ) );
 
         TestEntity test = query.find();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java
index 3079c84..d9cd3d1 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLQuerying.java
@@ -62,7 +62,7 @@ import org.apache.zest.api.query.grammar.PropertyNotNullPredicate;
 import org.apache.zest.api.query.grammar.PropertyNullPredicate;
 import org.apache.zest.api.query.grammar.Variable;
 import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.value.ValueComposite;
 import org.apache.zest.functional.Iterables;
 import org.apache.zest.index.sql.support.api.SQLQuerying;
@@ -108,7 +108,7 @@ public abstract class AbstractSQLQuerying
     private PostgreSQLTypeHelper _typeHelper;
 
     @Structure
-    private Module module;
+    private UnitOfWorkFactory uowf;
 
     @Structure
     private ZestSPI spi;
@@ -1052,7 +1052,7 @@ public abstract class AbstractSQLQuerying
                     // EntityComposite?
                     if( value instanceof EntityComposite )
                     {
-                        value = module.currentUnitOfWork().get(
+                        value = uowf.currentUnitOfWork().get(
                             (EntityComposite) value ).identity().get();
                     }
                     else
@@ -1853,7 +1853,7 @@ public abstract class AbstractSQLQuerying
                                                               fromClause, groupBy, having, qNameJoins, variables, values, valueSQLTypes );
                 } );
 
-                          // @formatter:on
+            // @formatter:on
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
index d6b2bcb..2e1389d 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLDBIntegrityTest.java
@@ -80,11 +80,11 @@ public class PostgreSQLDBIntegrityTest
     public void createAndRemoveEntityAndVerifyNoExtraDataLeftInDB()
         throws Exception
     {
-        UnitOfWork uow = this.module.newUnitOfWork();
+        UnitOfWork uow = this.uowf.newUnitOfWork();
         TestEntity entity = uow.newEntity( TestEntity.class );
         uow.complete();
 
-        uow = this.module.newUnitOfWork();
+        uow = this.uowf.newUnitOfWork();
         entity = uow.get( entity );
         SQLConfiguration config = uow.get( SQLConfiguration.class, PostgreSQLIndexQueryAssembler.DEFAULT_IDENTITY );
         String schemaName = config.schemaName().get();
@@ -127,16 +127,16 @@ public class PostgreSQLDBIntegrityTest
     public void createAndModifyEntity()
         throws Exception
     {
-        UnitOfWork uow = this.module.newUnitOfWork();
+        UnitOfWork uow = this.uowf.newUnitOfWork();
         TestEntity entity = uow.newEntity( TestEntity.class );
         uow.complete();
 
-        uow = this.module.newUnitOfWork();
+        uow = this.uowf.newUnitOfWork();
         entity = uow.get( entity );
         entity.testString().set( "NewTestString" );
         uow.complete();
 
-        uow = this.module.newUnitOfWork();
+        uow = this.uowf.newUnitOfWork();
         entity = uow.get( entity );
         Assert.assertEquals( "New value did not store in indexing.", "NewTestString", entity
             .testString().get() );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/NoMetricsInstalledTest.java
----------------------------------------------------------------------
diff --git a/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/NoMetricsInstalledTest.java b/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/NoMetricsInstalledTest.java
index 8fc6cdc..672d32f 100644
--- a/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/NoMetricsInstalledTest.java
+++ b/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/NoMetricsInstalledTest.java
@@ -59,7 +59,7 @@ public class NoMetricsInstalledTest extends AbstractZestTest
 
     private void readEntity( int id )
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             Person p = uow.get( Person.class, "" + id );
@@ -74,7 +74,7 @@ public class NoMetricsInstalledTest extends AbstractZestTest
     private void createEntity( int id )
         throws UnitOfWorkCompletionException
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             uow.newEntity( Person.class, "" + id );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/YammerTest.java
----------------------------------------------------------------------
diff --git a/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/YammerTest.java b/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/YammerTest.java
index 3f13774..716ee1f 100644
--- a/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/YammerTest.java
+++ b/extensions/metrics-yammer/src/test/java/org/apache/zest/metrics/yammer/YammerTest.java
@@ -60,7 +60,7 @@ public class YammerTest extends AbstractZestTest
 
     private void readEntity( int id )
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             Person p = uow.get( Person.class, "" + id );
@@ -75,7 +75,7 @@ public class YammerTest extends AbstractZestTest
     private void createEntity( int id )
         throws UnitOfWorkCompletionException
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             uow.newEntity( Person.class, "" + id );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
----------------------------------------------------------------------
diff --git a/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java b/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
index 1e1f091..fe2b2fa 100644
--- a/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
+++ b/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
@@ -16,6 +16,7 @@ package org.apache.zest.migration;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.StringReader;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.hamcrest.CoreMatchers;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -53,6 +54,7 @@ public class MigrationTest
         throws AssemblyException
     {
         new EntityTestAssembler().assemble( module );
+        new DefaultUnitOfWorkAssembler().assemble( module );
 
         module.objects( MigrationEventLogger.class );
         module.importedServices( MigrationEventLogger.class ).importedBy( NewObjectImporter.class );
@@ -110,7 +112,7 @@ public class MigrationTest
                 }
             };
 
-            UnitOfWork uow = v1.module().newUnitOfWork();
+            UnitOfWork uow = v1.module().unitOfWorkFactory().newUnitOfWork();
             TestEntity1_0 entity = uow.newEntity( TestEntity1_0.class );
             entity.foo().set( "Some value" );
             entity.fooManyAssoc().add( entity );
@@ -141,7 +143,7 @@ public class MigrationTest
             BackupRestore testData = v1_1.module().findService( BackupRestore.class ).get();
             data_v1.transferTo( testData.restore() );
 
-            UnitOfWork uow = v1_1.module().newUnitOfWork();
+            UnitOfWork uow = v1_1.module().unitOfWorkFactory().newUnitOfWork();
             TestEntity1_1 entity = uow.get( TestEntity1_1.class, id );
             assertThat( "Property has been renamed", entity.newFoo().get(), CoreMatchers.equalTo( "Some value" ) );
             assertThat( "ManyAssociation has been renamed", entity.newFooManyAssoc().count(), CoreMatchers.equalTo( 1 ) );
@@ -169,7 +171,7 @@ public class MigrationTest
             // Test migration from 1.0 -> 2.0
             {
                 data_v1.transferTo( testData.restore() );
-                UnitOfWork uow = v2_0.module().newUnitOfWork();
+                UnitOfWork uow = v2_0.module().unitOfWorkFactory().newUnitOfWork();
                 TestEntity2_0 entity = uow.get( TestEntity2_0.class, id );
                 assertThat( "Property has been created", entity.bar().get(), CoreMatchers.equalTo( "Some value" ) );
                 assertThat( "Custom Property has been created", entity.customBar().get(), CoreMatchers.equalTo( "Hello Some value" ) );
@@ -198,7 +200,7 @@ public class MigrationTest
             // Test migration from 1.0 -> 3.0
             {
                 data_v1.transferTo( testData.restore() );
-                UnitOfWork uow = v3_0.module().newUnitOfWork();
+                UnitOfWork uow = v3_0.module().unitOfWorkFactory().newUnitOfWork();
                 org.apache.zest.migration.moved.TestEntity2_0 entity = uow.get( org.apache.zest.migration.moved.TestEntity2_0.class, id );
                 uow.complete();
             }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
----------------------------------------------------------------------
diff --git a/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java b/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
index 8fd67cf..c95a8bc 100644
--- a/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
+++ b/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java
@@ -93,7 +93,7 @@ public class ReindexerTest
 
         // ----> Create data and wipe index
 
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
 
         EntityBuilder<MyEntity> eBuilder = uow.newEntityBuilder( MyEntity.class );
         MyEntity e = eBuilder.instance();
@@ -110,7 +110,7 @@ public class ReindexerTest
 
         module.<ReindexerService>findService( ReindexerService.class ).get().reindex(); // Reindex
 
-        uow = module.newUnitOfWork();
+        uow = uowf.newUnitOfWork();
 
         QueryBuilder<MyEntity> qBuilder = module.newQueryBuilder( MyEntity.class );
         qBuilder = qBuilder.where( eq( templateFor( MyEntity.class ).name(), TEST_NAME ) );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmPointFactory.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmPointFactory.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmPointFactory.java
index f492b5c..934603c 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmPointFactory.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmPointFactory.java
@@ -20,27 +20,32 @@ import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
 
-@Mixins(AlarmPointFactory.Mixin.class)
+@Mixins( AlarmPointFactory.Mixin.class )
 public interface AlarmPointFactory extends ServiceComposite
 {
-    AlarmPoint create(String identity, String systemName, String categoryName, AlarmClass alarmClass );
-    
+    AlarmPoint create( String identity, String systemName, String categoryName, AlarmClass alarmClass );
+
     abstract class Mixin
-        implements AlarmPointFactory {
+        implements AlarmPointFactory
+    {
+
+        @Structure
+        private UnitOfWorkFactory uowf;
 
         @Structure
-        private Module module;
-        
+        private ValueBuilderFactory vbf;
+
         @Override
         public AlarmPoint create( String identity, String systemName, String categoryName, AlarmClass alarmClass )
         {
-            UnitOfWork uow = module.currentUnitOfWork();
+            UnitOfWork uow = uowf.currentUnitOfWork();
             EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class, identity );
-            builder.instance().category().set( createCategory(categoryName) );
+            builder.instance().category().set( createCategory( categoryName ) );
             builder.instance().alarmClass().set( alarmClass );
 
             AlarmPoint.AlarmState prototype = builder.instanceFor( AlarmPoint.AlarmState.class );
@@ -53,14 +58,14 @@ public interface AlarmPointFactory extends ServiceComposite
 
         private AlarmStatus createNormalAlarmStatus()
         {
-            ValueBuilder<AlarmStatus> builder = module.newValueBuilder( AlarmStatus.class );
-            builder.prototypeFor(AlarmStatus.State.class).name().set( AlarmPoint.STATUS_NORMAL );
+            ValueBuilder<AlarmStatus> builder = vbf.newValueBuilder( AlarmStatus.class );
+            builder.prototypeFor( AlarmStatus.State.class ).name().set( AlarmPoint.STATUS_NORMAL );
             return builder.newInstance();
         }
 
         private AlarmCategory createCategory( String categoryName )
         {
-            ValueBuilder<AlarmCategory> builder = module.newValueBuilder( AlarmCategory.class );
+            ValueBuilder<AlarmCategory> builder = vbf.newValueBuilder( AlarmCategory.class );
             builder.prototype().name().set( categoryName );
             return builder.newInstance();
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmProxy.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmProxy.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmProxy.java
index 6d2ef32..08f45bb 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmProxy.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmProxy.java
@@ -20,6 +20,7 @@ import java.util.List;
 import java.util.Locale;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.composite.TransientBuilder;
+import org.apache.zest.api.composite.TransientBuilderFactory;
 import org.apache.zest.api.composite.TransientComposite;
 import org.apache.zest.api.concern.Concerns;
 import org.apache.zest.api.injection.scope.Service;
@@ -27,9 +28,9 @@ import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.Uses;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.unitofwork.NoSuchEntityException;
 import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
 import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
 
@@ -38,9 +39,9 @@ import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
 public interface AlarmProxy extends AlarmPoint, TransientComposite
 {
     @Mixins( FactoryMixin.class )
-    public interface Factory extends ServiceComposite
+    interface Factory extends ServiceComposite
     {
-        @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.REQUIRED)
+        @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.REQUIRED )
         AlarmProxy create( String identity, String systemName, String categoryName, AlarmClass alarmClass );
     }
 
@@ -48,7 +49,10 @@ public interface AlarmProxy extends AlarmPoint, TransientComposite
         implements Factory
     {
         @Structure
-        private Module module;
+        private TransientBuilderFactory tbf;
+
+        @Structure
+        private UnitOfWorkFactory uowf;
 
         @Service
         private AlarmPointFactory factory;
@@ -56,7 +60,7 @@ public interface AlarmProxy extends AlarmPoint, TransientComposite
         @Override
         public AlarmProxy create( String identity, String systemName, String categoryName, AlarmClass alarmClass )
         {
-            UnitOfWork unitOfWork = module.currentUnitOfWork();
+            UnitOfWork unitOfWork = uowf.currentUnitOfWork();
             AlarmPoint alarmPoint;
             try
             {
@@ -66,7 +70,7 @@ public interface AlarmProxy extends AlarmPoint, TransientComposite
             {
                 alarmPoint = factory.create( identity, systemName, categoryName, alarmClass );
             }
-            TransientBuilder<AlarmProxy> builder = module.newTransientBuilder( AlarmProxy.class );
+            TransientBuilder<AlarmProxy> builder = tbf.newTransientBuilder( AlarmProxy.class );
             builder.prototype().category().set( alarmPoint.category().get() );
             builder.prototype().alarmClass().set( alarmClass );
             builder.use( identity );
@@ -79,7 +83,7 @@ public interface AlarmProxy extends AlarmPoint, TransientComposite
     {
 
         @Structure
-        private Module module;
+        private UnitOfWorkFactory uowf;
 
         @Uses
         String identity;
@@ -199,7 +203,7 @@ public interface AlarmProxy extends AlarmPoint, TransientComposite
 
         private AlarmPoint findAlarmPoint()
         {
-            return module.currentUnitOfWork().get( AlarmPoint.class, identity );
+            return uowf.currentUnitOfWork().get( AlarmPoint.class, identity );
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
index 2b27fc3..2589ed0 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmHistoryImplTest.java
@@ -66,16 +66,16 @@ public class AlarmHistoryImplTest
         throws Exception
     {
         super.setUp();
-        module.newUnitOfWork();
+        uowf.newUnitOfWork();
     }
 
     @Override
     public void tearDown()
         throws Exception
     {
-        if (module.isUnitOfWorkActive())
+        if (uowf.isUnitOfWorkActive())
         {
-            UnitOfWork uow = module.currentUnitOfWork();
+            UnitOfWork uow = uowf.currentUnitOfWork();
             uow.discard();
         }
         super.tearDown();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
index 1e0b3ca..fd79250 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmPointImplTest.java
@@ -64,16 +64,16 @@ public class AlarmPointImplTest extends AbstractZestTest
         throws Exception
     {
         super.setUp();
-        module.newUnitOfWork();
+        uowf.newUnitOfWork();
     }
 
     @Override
     public void tearDown()
         throws Exception
     {
-        if( module.isUnitOfWorkActive() )
+        if( uowf.isUnitOfWorkActive() )
         {
-            UnitOfWork uow = module.currentUnitOfWork();
+            UnitOfWork uow = uowf.currentUnitOfWork();
             uow.discard();
         }
         super.tearDown();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmProxyTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmProxyTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmProxyTest.java
index 718a822..8cd14b3 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmProxyTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmProxyTest.java
@@ -51,7 +51,7 @@ public class AlarmProxyTest extends AbstractZestTest
     public void givenAlarmPointWhenActivateExpectActivationEvent()
         throws Exception
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
 // START SNIPPET: documentation

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
index b08e189..e1d6ea0 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/AlarmServiceTest.java
@@ -67,16 +67,16 @@ public class AlarmServiceTest
         throws Exception
     {
         super.setUp();
-        module.newUnitOfWork();
+        uowf.newUnitOfWork();
     }
 
     @Override
     public void tearDown()
         throws Exception
     {
-        if (module.isUnitOfWorkActive())
+        if (uowf.isUnitOfWorkActive())
         {
-            UnitOfWork uow = module.currentUnitOfWork();
+            UnitOfWork uow = uowf.currentUnitOfWork();
             uow.discard();
         }
         super.tearDown();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
index 98079ac..0df9255 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
@@ -67,14 +67,14 @@ public class ExtendedAlarmModelTest
         throws Exception
     {
         super.setUp();
-        module.newUnitOfWork();
+        uowf.newUnitOfWork();
     }
 
     @Override
     public void tearDown()
         throws Exception
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         if( uow != null )
         {
             uow.discard();
@@ -942,7 +942,7 @@ public class ExtendedAlarmModelTest
 
     private AlarmPoint createAlarm( String name )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class );
         builder.instance().category().set( createCategory( "Testing" ) );
         AlarmPoint.AlarmState state = builder.instanceFor( AlarmPoint.AlarmState.class );
@@ -961,7 +961,7 @@ public class ExtendedAlarmModelTest
 
     private AlarmPoint getAlarm( String identity )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         return uow.get( AlarmPoint.class, identity );
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
index a7dd590..78ff217 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
@@ -67,14 +67,14 @@ public class SimpleAlarmModelTest
         throws Exception
     {
         super.setUp();
-        module.newUnitOfWork();
+        uowf.newUnitOfWork();
     }
 
     @Override
     public void tearDown()
         throws Exception
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         if( uow != null )
         {
             uow.discard();
@@ -327,7 +327,7 @@ public class SimpleAlarmModelTest
 
     private AlarmPoint createAlarm( String name )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class );
         builder.instance().category().set( createCategory( "SimpleModelTest" ) );
         AlarmPoint.AlarmState state = builder.instanceFor( AlarmPoint.AlarmState.class );
@@ -346,7 +346,7 @@ public class SimpleAlarmModelTest
 
     private AlarmPoint getAlarm( String identity )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         return uow.get( AlarmPoint.class, identity );
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
index 69dab9b..84d10b6 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
@@ -68,14 +68,14 @@ public class StandardAlarmModelTest
         throws Exception
     {
         super.setUp();
-        module.newUnitOfWork();
+        uowf.newUnitOfWork();
     }
 
     @Override
     public void tearDown()
         throws Exception
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         if( uow != null )
         {
             uow.discard();
@@ -453,7 +453,7 @@ public class StandardAlarmModelTest
 
     private AlarmPoint createAlarm( String name )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class );
         builder.instance().category().set( createCategory( "StandardModelTest" ) );
         AlarmPoint.AlarmState state = builder.instanceFor( AlarmPoint.AlarmState.class );
@@ -472,7 +472,7 @@ public class StandardAlarmModelTest
 
     private AlarmPoint getAlarm( String identity )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         return uow.get( AlarmPoint.class, identity );
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
index ae9cf5d..02eeb15 100644
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
+++ b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
@@ -39,11 +39,12 @@ import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.property.PropertyDescriptor;
 import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
 import org.apache.zest.api.unitofwork.NoSuchEntityException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.value.ValueComposite;
 import org.apache.zest.api.value.ValueDescriptor;
 import org.apache.zest.functional.Iterables;
 import org.apache.zest.spi.ZestSPI;
-import org.apache.zest.spi.module.ModelModule;
+import org.apache.zest.spi.structure.ModelModule;
 import org.apache.zest.spi.module.ModuleSpi;
 
 import static org.apache.zest.library.conversion.values.Shared.STRING_COLLECTION_TYPE_SPEC;
@@ -125,6 +126,9 @@ public class ValueToEntityMixin
     private ZestSPI spi;
 
     @Structure
+    private UnitOfWorkFactory uowf;
+
+    @Structure
     private ModuleSpi module;
 
     @Override
@@ -299,7 +303,7 @@ public class ValueToEntityMixin
                 }
             }
         };
-        return module.currentUnitOfWork().newEntityBuilderWithState(
+        return uowf.currentUnitOfWork().newEntityBuilderWithState(
             entityType, identity, props, assocs, manyAssocs, namedAssocs
         );
     }
@@ -405,7 +409,7 @@ public class ValueToEntityMixin
                 }
             }
         };
-        return module.currentUnitOfWork().newEntityBuilderWithState(
+        return uowf.currentUnitOfWork().newEntityBuilderWithState(
             entityType, identity, props, assocs, manyAssocs, namedAssocs
         );
     }
@@ -484,7 +488,7 @@ public class ValueToEntityMixin
                         String assocId = (String) vState.propertyFor( vPropDesc.accessor() ).get();
                         if( assocId != null )
                         {
-                            eAssoc.set( module.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocId ) );
+                            eAssoc.set( uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocId ) );
                         }
                         else
                         {
@@ -526,7 +530,7 @@ public class ValueToEntityMixin
                             for( String eachAssoc : vAssocState )
                             {
                                 eManyAssoc.add(
-                                    module.currentUnitOfWork().get( (Class) eAssocDesc.type(), eachAssoc )
+                                    uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), eachAssoc )
                                 );
                             }
                         }
@@ -570,7 +574,7 @@ public class ValueToEntityMixin
                             {
                                 eNamedAssoc.put(
                                     assocEntry.getKey(),
-                                    module.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocEntry.getValue() )
+                                    uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocEntry.getValue() )
                                 );
                             }
                         }
@@ -624,7 +628,7 @@ public class ValueToEntityMixin
                         String assocId = (String) vState.propertyFor( vPropDesc.accessor() ).get();
                         if( assocId != null )
                         {
-                            eAssoc.set( module.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocId ) );
+                            eAssoc.set( uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocId ) );
                         }
                         else
                         {
@@ -666,7 +670,7 @@ public class ValueToEntityMixin
                             vAssocState.forEach( eachAssoc ->
                             {
                                 eManyAssoc.add(
-                                    module.currentUnitOfWork().get( (Class<?>) eAssocDesc.type(), eachAssoc )
+                                    uowf.currentUnitOfWork().get( (Class<?>) eAssocDesc.type(), eachAssoc )
                                 );
                             } );
                         }
@@ -711,7 +715,7 @@ public class ValueToEntityMixin
                             {
                                 eNamedAssoc.put(
                                     assocEntry.getKey(),
-                                    module.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocEntry.getValue() )
+                                    uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocEntry.getValue() )
                                 );
                             }
                         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
index ef06960..b268a62 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
@@ -62,7 +62,7 @@ public class EntityToValueTest
     public void whenConvertingEntityToValueExpectCorrectValues()
         throws UnitOfWorkCompletionException
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             PersonEntity entity = setupPersonEntities( uow );
@@ -87,7 +87,7 @@ public class EntityToValueTest
     public void givenUnqualifiedValueWhenConvertingEntityExpectCorrectMapping()
         throws UnitOfWorkCompletionException
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             PersonEntity niclas = setupPersonEntities( uow );
@@ -112,7 +112,7 @@ public class EntityToValueTest
     public void givenUnqualifiedValue2WhenConvertingEntityExpectCorrectMapping()
         throws UnitOfWorkCompletionException
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             PersonEntity niclas = setupPersonEntities( uow );
@@ -137,7 +137,7 @@ public class EntityToValueTest
     public void givenQualifiedValueNotFromSameInterfaceWhenConvertingEntityExpectNonOptionalException()
         throws UnitOfWorkCompletionException
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             PersonEntity niclas = setupPersonEntities( uow );
@@ -158,7 +158,7 @@ public class EntityToValueTest
     public void whenConvertingEntityToValueUsingPrototypeOpportunityExpectCorrectValues()
         throws UnitOfWorkCompletionException
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             PersonEntity entity = setupPersonEntities( uow );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
index 4644d4d..4e8a087 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
@@ -52,7 +52,7 @@ public class NestedValuesConversionTest
     public void testNestedValuesConversion()
         throws UnitOfWorkCompletionException
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             FooEntity fooEntity = createFooEntity( uow, "Test nested values conversion" );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
index 8197ebe..0441b84 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
@@ -76,7 +76,7 @@ public class ValueToEntityTest
     {
         // See http://en.wikipedia.org/wiki/Template:Flintstones_family_tree
         someBirthDate = createBirthDate( 1, 1, 1 );
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "InitialData" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "InitialData" ) ) )
         {
             ednaIdentity = createPerson( uow, "Edna", "Flintstone", someBirthDate ).identity().get();
             zekeIdentity = createPerson( uow, "Zeke", "Flintstone", someBirthDate ).identity().get();
@@ -96,7 +96,7 @@ public class ValueToEntityTest
         builder.prototype().spouse().set( ednaIdentity );
         builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
         PersonValue edValue = builder.newInstance();
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreatingEntityFromQualifiedValue" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromQualifiedValue" ) ) )
         {
             // START SNIPPET: creation
             ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
@@ -129,7 +129,7 @@ public class ValueToEntityTest
         builder.prototype().spouse().set( ednaIdentity );
         builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
         PersonValue2 edValue = builder.newInstance();
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
         {
             ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
 
@@ -163,7 +163,7 @@ public class ValueToEntityTest
         builder.prototype().spouse().set( ednaIdentity );
         builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
         PersonValue3 edValue = builder.newInstance();
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
         {
             ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
 
@@ -197,7 +197,7 @@ public class ValueToEntityTest
         builder.prototype().spouse().set( ednaIdentity );
         builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
         PersonValue4 edValue = builder.newInstance();
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
         {
             ValueToEntity conversion = module.findService( ValueToEntity.class ).get();
 
@@ -213,7 +213,7 @@ public class ValueToEntityTest
         throws UnitOfWorkCompletionException
     {
         String rickyIdentity;
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
         {
             PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
             ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
@@ -228,7 +228,7 @@ public class ValueToEntityTest
         builder.prototype().lastName().set( "Slaghoople" );
         builder.prototype().dateOfBirth().set( someBirthDate );
         PersonValue rickyNewStateValue = builder.newInstance();
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
         {
             PersonEntity rickyEntity = uow.get( PersonEntity.class, rickyIdentity );
             // START SNIPPET: update
@@ -249,7 +249,7 @@ public class ValueToEntityTest
         throws UnitOfWorkCompletionException
     {
         String rickyIdentity;
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
         {
             PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
             ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
@@ -264,7 +264,7 @@ public class ValueToEntityTest
         builder.prototype().lastName().set( "Slaghoople" );
         builder.prototype().dateOfBirth().set( someBirthDate );
         PersonValue2 newStateValue = builder.newInstance();
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
         {
             PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
 
@@ -284,7 +284,7 @@ public class ValueToEntityTest
         throws UnitOfWorkCompletionException
     {
         String rickyIdentity;
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
         {
             PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
             ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
@@ -299,7 +299,7 @@ public class ValueToEntityTest
         builder.prototype().lastName().set( "Slaghoople" );
         builder.prototype().dateOfBirth().set( someBirthDate );
         PersonValue3 newStateValue = builder.newInstance();
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
         {
             PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
 
@@ -319,7 +319,7 @@ public class ValueToEntityTest
         throws UnitOfWorkCompletionException
     {
         String rickyIdentity;
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
         {
             PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
             ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
@@ -334,7 +334,7 @@ public class ValueToEntityTest
         builder.prototype().lastName().set( "Slaghoople" );
         builder.prototype().dateOfBirth().set( someBirthDate );
         PersonValue4 newStateValue = builder.newInstance();
-        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "UpdateRickySlaghoopleWontWork" ) ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "UpdateRickySlaghoopleWontWork" ) ) )
         {
             PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java b/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
index 858f29c..f0a2e11 100644
--- a/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
+++ b/libraries/eventsourcing-jdbm/src/test/java/org/apache/zest/library/eventsourcing/domain/source/jdbm/JdbmEventStoreServiceTest.java
@@ -66,14 +66,14 @@ public class JdbmEventStoreServiceTest
         @Test
         public void testDomainEvent() throws UnitOfWorkCompletionException, IOException
         {
-            UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Create entity" ));
+            UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Create entity" ));
             TestEntity entity = uow.newEntity( TestEntity.class );
             uow.complete();
 
             int count = 10;
             for (int i = 0; i < count; i++)
             {
-                uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
+                uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
                 uow.setMetaInfo( new Principal()
                 {
                     public String getName()

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing-rest/src/test/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing-rest/src/test/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java b/libraries/eventsourcing-rest/src/test/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
index d55dac2..b5b6030 100644
--- a/libraries/eventsourcing-rest/src/test/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
+++ b/libraries/eventsourcing-rest/src/test/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
@@ -77,7 +77,7 @@ public class DomainEventSourceResourceSample
         component.getDefaultHost().attach( "/ping", assembler.module().newObject( PingResource.class ) );
         component.start();
 
-        generateTestData(assembler.module());
+        generateTestData(assembler.module().unitOfWorkFactory());
     }
 
     private static void generateTestData(UnitOfWorkFactory unitOfWorkFactory) throws UnitOfWorkCompletionException

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
index 9f38d7f..911eeb7 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/application/ApplicationEventTest.java
@@ -103,21 +103,21 @@ public class ApplicationEventTest
             }
         };
 
-        UnitOfWork uow1 = module.newUnitOfWork( UsecaseBuilder.newUsecase( "User signup" ) );
+        UnitOfWork uow1 = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "User signup" ) );
         uow1.setMetaInfo( administratorPrincipal );
         users.signup( null, "user1", Arrays.asList( "news-a", "news-b" ) );
         uow1.complete();
 
         Thread.sleep( 1 ); // For UoWs not getting the same `currentTime`
 
-        UnitOfWork uow2 = module.newUnitOfWork();
+        UnitOfWork uow2 = uowf.newUnitOfWork();
         uow2.setMetaInfo( administratorPrincipal );
         users.signup( null, "user2", Collections.EMPTY_LIST );
         uow2.complete();
 
         Thread.sleep( 1 ); // For UoWs not getting the same `currentTime`
 
-        UnitOfWork uow3 = module.newUnitOfWork();
+        UnitOfWork uow3 = uowf.newUnitOfWork();
         uow3.setMetaInfo( administratorPrincipal );
         users.signup( null, "user3", Collections.singletonList( "news-c" ) );
         uow3.complete();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
index dcd5bee..c8fe3a6 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/DomainEventTest.java
@@ -78,7 +78,7 @@ public class DomainEventTest
         };
 
         // Perform UoW with usecase defined
-        UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
+        UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
         uow.setMetaInfo( administratorPrincipal );
 
         TestEntity entity = uow.newEntity( TestEntity.class );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
index 9f357f5..1e1ce5e 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/DomainEventTrackerTest.java
@@ -72,7 +72,7 @@ public class DomainEventTrackerTest
     @Test
     public void testDomainEvent() throws UnitOfWorkCompletionException, IOException
     {
-        UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
+        UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Change description" ));
         uow.setMetaInfo( new Principal()
         {
             public String getName()

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
index da2b1eb..b8785ee 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
@@ -18,6 +18,7 @@ package org.apache.zest.library.eventsourcing.domain.source.helper;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.junit.Before;
@@ -49,6 +50,7 @@ public class EventRouterTest
             public void assemble( ModuleAssembly module ) throws AssemblyException
             {
                 module.values( UnitOfWorkDomainEventsValue.class, DomainEventValue.class );
+                new DefaultUnitOfWorkAssembler().assemble( module );
             }
         };
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
index 575ab5b..0402c4f 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.zest.library.eventsourcing.domain.source.helper;
 
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.junit.Before;
 import org.junit.Test;
 import org.apache.zest.api.activation.ActivationException;
@@ -55,6 +56,7 @@ public class EventsTest
             public void assemble( ModuleAssembly module ) throws AssemblyException
             {
                 module.values( UnitOfWorkDomainEventsValue.class, DomainEventValue.class );
+                new DefaultUnitOfWorkAssembler().assemble( module );
             }
         };
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
index 0f6a970..94b1d56 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.zest.library.eventsourcing.domain.source.helper;
 
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.hamcrest.CoreMatchers;
 import org.junit.Assert;
 import org.junit.Before;
@@ -53,6 +54,7 @@ public class UnitOfWorkRouterTest
             public void assemble( ModuleAssembly module ) throws AssemblyException
             {
                 module.values( UnitOfWorkDomainEventsValue.class, DomainEventValue.class );
+                new DefaultUnitOfWorkAssembler().assemble( module );
             }
         };
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/lang-scala/src/test/scala/org/apache/zest/library/scala/HelloWorldCompositeTest.java
----------------------------------------------------------------------
diff --git a/libraries/lang-scala/src/test/scala/org/apache/zest/library/scala/HelloWorldCompositeTest.java b/libraries/lang-scala/src/test/scala/org/apache/zest/library/scala/HelloWorldCompositeTest.java
index a01b870..0f53355 100644
--- a/libraries/lang-scala/src/test/scala/org/apache/zest/library/scala/HelloWorldCompositeTest.java
+++ b/libraries/lang-scala/src/test/scala/org/apache/zest/library/scala/HelloWorldCompositeTest.java
@@ -18,6 +18,7 @@ import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
 import org.apache.zest.bootstrap.SingletonAssembler;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.apache.zest.index.rdf.assembly.RdfMemoryStoreAssembler;
 import org.apache.zest.spi.query.IndexExporter;
 import org.apache.zest.test.EntityTestAssembler;
@@ -84,11 +85,12 @@ public class HelloWorldCompositeTest
 
                 new EntityTestAssembler().assemble( module );
                 new RdfMemoryStoreAssembler().assemble( module );
+                new DefaultUnitOfWorkAssembler().assemble( module );
             }
         };
 
         // Create and update Entity
-        UnitOfWork uow = assembler.module().newUnitOfWork();
+        UnitOfWork uow = assembler.module().unitOfWorkFactory().newUnitOfWork();
         try
         {
             Commands entity = uow.newEntity( Commands.class );
@@ -106,7 +108,7 @@ public class HelloWorldCompositeTest
         assembler.module().findService( IndexExporter.class ).get().exportReadableToStream( System.out );
 
         // Find it
-        uow = assembler.module().newUnitOfWork();
+        uow = assembler.module().unitOfWorkFactory().newUnitOfWork();
         try
         {
             Data data = uow.newQuery( assembler.module()

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java b/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
index a424aba..b86ab71 100644
--- a/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
+++ b/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
@@ -60,7 +60,7 @@ public class DebuggingTest
     @Test
     public void whenCallingMethodThenExpectDebugEntityCreated()
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             // There is no Query capability available for Libraries, since that sits in Extensions.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java b/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
index 6438fc4..06dd6b9 100644
--- a/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
+++ b/libraries/logging/src/test/java/org/apache/zest/library/logging/TracingTest.java
@@ -70,7 +70,7 @@ public class TracingTest
         SomeService sc = module.findService( SomeService.class ).get();
         assertEquals( 123, sc.doSomethingImportant() );
         assertEquals( 456, sc.doSomethingLessImportant() );
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
         Query<TraceRecord> query = uow.newQuery( builder );
         // IS sorting needed??
@@ -91,7 +91,7 @@ public class TracingTest
         SomeService2 sc = module.findService( SomeService2.class ).get();
         assertEquals( 123, sc.doSomethingImportant() );
         assertEquals( 456, sc.doSomethingLessImportant() );
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
         Query<TraceRecord> query = uow.newQuery( builder );
         // IS sorting needed??
@@ -115,7 +115,7 @@ public class TracingTest
         SomeService sc = module.findService( SomeService.class ).get();
         assertEquals( 123, sc.doSomethingImportant() );
         assertEquals( 789, sc.doSomethingModeratelyImportant() );
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
@@ -154,7 +154,7 @@ public class TracingTest
         SomeService sc = module.findService( SomeService.class ).get();
         assertEquals( 123, sc.doSomethingImportant() );
         assertEquals( 753, sc.doSomethingInsanelyImportant() );
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         QueryBuilder<TraceRecord> builder = module.newQueryBuilder( TraceRecord.class );
         Query<TraceRecord> query = uow.newQuery( builder );
         // IS sorting needed??

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
index 49edb94..89054bb 100755
--- a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
@@ -95,7 +95,7 @@ public class EntitySerializerTest
     void createDummyData()
         throws UnitOfWorkCompletionException
     {
-        UnitOfWork unitOfWork = module.newUnitOfWork();
+        UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
             ValueBuilder<TestValue> valueBuilder = module.newValueBuilder( TestValue.class );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
index 23b4eca..dbdb77a 100644
--- a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntityTypeSerializerTest.java
@@ -81,7 +81,7 @@ public class EntityTypeSerializerTest
 
     void createDummyData() throws UnitOfWorkCompletionException
     {
-        UnitOfWork unitOfWork = module.newUnitOfWork();
+        UnitOfWork unitOfWork = uowf.newUnitOfWork();
         try
         {
             ValueBuilder<Test2Value> vb2 = module.newValueBuilder( Test2Value.class );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
index cab3481..c1d0595 100644
--- a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
+++ b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContextResourceClientFactoryTest.java
@@ -22,7 +22,9 @@ import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
 import org.apache.zest.api.type.HasTypes;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.usecase.UsecaseBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
 import org.hamcrest.CoreMatchers;
 import org.junit.After;
 import org.junit.Assert;
@@ -391,7 +393,7 @@ public class ContextResourceClientFactoryTest
         @Override
         protected Uniform createRoot( Request request, Response response )
         {
-            return module.newObject( RootResource.class, this );
+            return objectFactory.newObject( RootResource.class, this );
         }
     }
 
@@ -554,16 +556,19 @@ public class ContextResourceClientFactoryTest
         private static int count = 0;
 
         @Structure
-        Module module;
+        UnitOfWorkFactory uowf;
+
+        @Structure
+        ValueBuilderFactory vbf;
 
         public TestResult queryWithValue( TestQuery query )
         {
-            return module.newValueFromSerializedState( TestResult.class, "{'xyz':'"+query.abc().get()+"'}" );
+            return vbf.newValueFromSerializedState( TestResult.class, "{'xyz':'"+query.abc().get()+"'}" );
         }
 
         public TestResult queryWithoutValue()
         {
-            return module.newValueFromSerializedState( TestResult.class, "{'xyz':'bar'}" );
+            return vbf.newValueFromSerializedState( TestResult.class, "{'xyz':'bar'}" );
         }
 
         public String queryWithStringResult( TestQuery query )
@@ -594,7 +599,7 @@ public class ContextResourceClientFactoryTest
             count++;
             if( count % 3 != 0 )
             {
-                module.currentUnitOfWork().addUnitOfWorkCallback( new UnitOfWorkCallback()
+                uowf.currentUnitOfWork().addUnitOfWorkCallback( new UnitOfWorkCallback()
                 {
                     public void beforeCompletion()
                         throws UnitOfWorkCompletionException

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
index 365bd83..da652d1 100644
--- a/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
+++ b/libraries/rest-client/src/test/java/org/apache/zest/library/rest/client/ContinuousIntegrationTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.zest.library.rest.client;
 
+import org.apache.zest.api.composite.TransientBuilderFactory;
 import org.hamcrest.CoreMatchers;
 import org.junit.After;
 import org.junit.Assert;
@@ -372,7 +373,7 @@ public class ContinuousIntegrationTest
         @Override
         protected Uniform createRoot( Request request, Response response )
         {
-            return module.newObject( RootResource.class, this );
+            return objectFactory.newObject( RootResource.class, this );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
index f673e6e..67c8584 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextResource.java
@@ -1,12 +1,11 @@
 /**
- *
  * Copyright 2009-2011 Rickard Öberg AB
  *
  * 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
+ * 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,
@@ -37,10 +36,10 @@ import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.Uses;
-import org.apache.zest.api.property.PropertyDescriptor;
 import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.unitofwork.EntityTypeNotFoundException;
 import org.apache.zest.api.unitofwork.NoSuchEntityException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.value.ValueBuilder;
 import org.apache.zest.api.value.ValueComposite;
 import org.apache.zest.api.value.ValueDescriptor;
@@ -83,6 +82,9 @@ public class ContextResource
 
     // API fields
     @Structure
+    private UnitOfWorkFactory uowf;
+
+    @Structure
     protected Module module;
 
     // Private state
@@ -203,7 +205,7 @@ public class ContextResource
     {
         try
         {
-            T composite = module.currentUnitOfWork().get( entityClass, id );
+            T composite = uowf.currentUnitOfWork().get( entityClass, id );
             current().select( composite );
             return composite;
         }
@@ -216,7 +218,7 @@ public class ContextResource
     protected <T> T selectFromManyAssociation( ManyAssociation<T> manyAssociation, String id )
         throws ResourceException
     {
-        T entity = (T) module.currentUnitOfWork().get( Object.class, id );
+        T entity = (T) uowf.currentUnitOfWork().get( Object.class, id );
         if( !manyAssociation.contains( entity ) )
         {
             throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND );
@@ -225,13 +227,13 @@ public class ContextResource
         current().select( entity );
         return entity;
     }
-    
+
     protected <T> T selectFromNamedAssociation( NamedAssociation<T> namedAssociation, String id )
         throws ResourceException
     {
-        T entity = (T) module.currentUnitOfWork().get( Object.class, id );
+        T entity = (T) uowf.currentUnitOfWork().get( Object.class, id );
         String name = namedAssociation.nameOf( entity );
-        if(name == null)
+        if( name == null )
         {
             throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND );
         }
@@ -677,7 +679,7 @@ public class ContextResource
                                                                                    .isAvailable() || request
                                                                                                          .getResourceRef()
                                                                                                          .getQuery() != null || queryMethod
-                .getParameterTypes()[ 0 ].equals( Response.class ) ) ) )
+                                                                                   .getParameterTypes()[ 0 ].equals( Response.class ) ) ) )
         {
             // Show form
             try
@@ -871,7 +873,7 @@ public class ContextResource
         {
             ValueDescriptor valueDescriptor = module.valueDescriptor( valueType.getName() );
 
-            valueDescriptor.state().properties().forEach(propertyDescriptor -> {
+            valueDescriptor.state().properties().forEach( propertyDescriptor -> {
                 String value = getValue( propertyDescriptor.qualifiedName().name(), queryAsForm, entityAsForm );
                 if( value == null )
                 {
@@ -882,7 +884,7 @@ public class ContextResource
                     }
                 }
                 form.add( propertyDescriptor.qualifiedName().name(), value );
-            });
+            } );
         }
         else if( valueType.isInterface() && interactionMethod.getParameterTypes().length == 1 )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextRestlet.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextRestlet.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextRestlet.java
index 7931255..100e639 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextRestlet.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ContextRestlet.java
@@ -1,12 +1,11 @@
 /**
- *
  * Copyright 2009-2011 Rickard Öberg AB
  *
  * 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
+ * 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,
@@ -24,9 +23,10 @@ import java.util.Map;
 import org.apache.zest.api.cache.CacheOptions;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.object.ObjectFactory;
 import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
 import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.usecase.Usecase;
 import org.apache.zest.api.usecase.UsecaseBuilder;
 import org.apache.zest.library.rest.server.restlet.ResponseWriterDelegator;
@@ -53,7 +53,10 @@ public abstract class ContextRestlet
     extends Restlet
 {
     @Structure
-    protected Module module;
+    protected ObjectFactory objectFactory;
+
+    @Structure
+    protected UnitOfWorkFactory uowf;
 
     @Service
     private CommandResult commandResult;
@@ -61,7 +64,7 @@ public abstract class ContextRestlet
     @Service
     private ResponseWriterDelegator responseWriter;
 
-    private Map<Class, Uniform> subResources = Collections.synchronizedMap( new HashMap<Class, Uniform>() );
+    private Map<Class, Uniform> subResources = Collections.synchronizedMap( new HashMap<>() );
 
     @Override
     public void handle( Request request, Response response )
@@ -83,7 +86,7 @@ public abstract class ContextRestlet
                 Reference ref = request.getResourceRef();
                 List<String> segments = ref.getScheme()
                                             .equals( "riap" ) ? ref.getRelativeRef( new Reference( "riap://application/" ) )
-                    .getSegments() : ref.getRelativeRef().getSegments();
+                                            .getSegments() : ref.getRelativeRef().getSegments();
 
                 // Handle conversion of verbs into standard interactions
                 if( segments.get( segments.size() - 1 ).equals( "" ) )
@@ -106,7 +109,7 @@ public abstract class ContextRestlet
                 Usecase usecase = UsecaseBuilder.buildUsecase( getUsecaseName( request ) )
                     .withMetaInfo( request.getMethod().isSafe() ? CacheOptions.ALWAYS : CacheOptions.NEVER )
                     .newUsecase();
-                UnitOfWork uow = module.newUnitOfWork( usecase );
+                UnitOfWork uow = uowf.newUnitOfWork( usecase );
 
                 ObjectSelection.newSelection();
 
@@ -194,7 +197,7 @@ public abstract class ContextRestlet
                                 // Check if last modified and tag should be set
                                 if( validity != null )
                                 {
-                                    UnitOfWork lastModifiedUoW = module.newUnitOfWork();
+                                    UnitOfWork lastModifiedUoW = uowf.newUnitOfWork();
 
                                     try
                                     {
@@ -244,7 +247,7 @@ public abstract class ContextRestlet
         if( subResource == null )
         {
             // Instantiate and store subresource instance
-            subResource = module.newObject( subResourceClass, this );
+            subResource = objectFactory.newObject( subResourceClass, this );
             subResources.put( subResourceClass, subResource );
         }
 


Mime
View raw message