polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [05/34] 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 declaratio
Date Thu, 14 Apr 2016 06:13:11 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
index 8482f0f..eb6e2db 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
@@ -60,7 +60,7 @@ public class RegisterHandlingEventTest extends TestApplication
         throws Exception
     {
         super.prepareTest();
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
         CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
 
@@ -129,11 +129,11 @@ public class RegisterHandlingEventTest extends TestApplication
         throws Exception
     {
         deviation_3c_VoyageNumber_Unknown();
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
 
         // Receive 1st time (store event so that it turns up in query)
         uow.complete();
-        tempUow = module.newUnitOfWork();
+        tempUow = uowf.newUnitOfWork();
         handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, RECEIVE, HONGKONG, noVoyage );
         tempUow.complete();
 
@@ -148,11 +148,11 @@ public class RegisterHandlingEventTest extends TestApplication
         throws Exception
     {
         deviation_4a_DuplicateEvent_Receive();
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
 
         uow.complete();
         // In customs 1st time
-        tempUow = module.newUnitOfWork();
+        tempUow = uowf.newUnitOfWork();
         handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, CUSTOMS, HONGKONG, noVoyage );
         tempUow.complete();
 
@@ -167,11 +167,11 @@ public class RegisterHandlingEventTest extends TestApplication
         throws Exception
     {
         deviation_4a_DuplicateEvent_Customs();
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
 
         uow.complete();
         // Claimed 1st time
-        tempUow = module.newUnitOfWork();
+        tempUow = uowf.newUnitOfWork();
         handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY1, DAY1, trackingId, CLAIM, HONGKONG, noVoyage );
         tempUow.complete();
 
@@ -200,8 +200,8 @@ public class RegisterHandlingEventTest extends TestApplication
         deviation_5a_NoHandlingAfterClaim();
 
         // Delete handling events from memory
-        tempUow = module.newUnitOfWork();
-        Query<HandlingEventEntity> events = tempUow.newQuery( module.newQueryBuilder( HandlingEventEntity.class ) );
+        tempUow = uowf.newUnitOfWork();
+        Query<HandlingEventEntity> events = tempUow.newQuery( qbf.newQueryBuilder( HandlingEventEntity.class ) );
         for( HandlingEvent event : events )
         {
             tempUow.remove( event );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest.java
----------------------------------------------------------------------
diff --git a/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest.java b/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest.java
index 76c82e9..78f470b 100644
--- a/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest.java
+++ b/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest.java
@@ -14,6 +14,8 @@
 
 package org.apache.zest.dci.moneytransfer.test;
 
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -45,6 +47,7 @@ public class TransferMoneyTest
     public static final String CHECKING_ACCOUNT_ID = "CheckingAccountId";
     public static final String CREDITOR_ID1 = "BakerAccount";
     public static final String CREDITOR_ID2 = "ButcherAccount";
+    private static UnitOfWorkFactory uowf;
 
     @BeforeClass
     public static void setup()
@@ -55,6 +58,7 @@ public class TransferMoneyTest
             public void assemble( ModuleAssembly module )
                 throws AssemblyException
             {
+                module.withDefaultUnitOfWorkFactory();
                 module.entities(
                     CheckingAccountRolemap.class,
                     SavingsAccountRolemap.class,
@@ -63,7 +67,7 @@ public class TransferMoneyTest
                 new EntityTestAssembler().assemble( module );
             }
         };
-
+        uowf = assembler.module().unitOfWorkFactory();
         bootstrapData( assembler );
     }
 
@@ -85,7 +89,7 @@ public class TransferMoneyTest
 
     public void printBalances()
     {
-        UnitOfWork uow = assembler.module().newUnitOfWork( UsecaseBuilder.newUsecase( "Print balances" ) );
+        UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Print balances" ) );
 
         try
         {
@@ -105,7 +109,7 @@ public class TransferMoneyTest
     private static void bootstrapData( SingletonAssembler assembler )
         throws Exception
     {
-        UnitOfWork uow = assembler.module().newUnitOfWork( newUsecase( "Bootstrap data" ) );
+        UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Bootstrap data" ) );
         try
         {
             SavingsAccountEntity savingsAccount = uow.newEntity( SavingsAccountEntity.class, SAVINGS_ACCOUNT_ID );
@@ -134,8 +138,7 @@ public class TransferMoneyTest
     public void transferHalfOfMoneyFromSavingsToChecking()
         throws Exception
     {
-        UnitOfWork uow = assembler.module()
-            .newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
+        UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
 
         try
         {
@@ -163,8 +166,7 @@ public class TransferMoneyTest
     public void transferTwiceOfMoneyFromSavingsToChecking()
         throws Exception
     {
-        UnitOfWork uow = assembler.module()
-            .newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
+        UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
 
         try
         {
@@ -192,7 +194,7 @@ public class TransferMoneyTest
     public void payAllBills()
         throws Exception
     {
-        UnitOfWork uow = assembler.module().newUnitOfWork( newUsecase( "Pay all bills from checking to creditors" ) );
+        UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Pay all bills from checking to creditors" ) );
         try
         {
             BalanceData source = uow.get( BalanceData.class, CHECKING_ACCOUNT_ID );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest2.java
----------------------------------------------------------------------
diff --git a/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest2.java b/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest2.java
index 8507b8b..7d4a11c 100644
--- a/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest2.java
+++ b/samples/dci/src/test/java/org/apache/zest/dci/moneytransfer/test/TransferMoneyTest2.java
@@ -14,6 +14,8 @@
 
 package org.apache.zest.dci.moneytransfer.test;
 
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -44,6 +46,7 @@ public class TransferMoneyTest2
     public static final String CHECKING_ACCOUNT_ID = "CheckingAccountId";
     public static final String CREDITOR_ID1 = "BakerAccount";
     public static final String CREDITOR_ID2 = "ButcherAccount";
+    private static UnitOfWorkFactory uowf;
 
     @BeforeClass
     public static void setup()
@@ -54,6 +57,7 @@ public class TransferMoneyTest2
             public void assemble( ModuleAssembly module )
                 throws AssemblyException
             {
+                module.withDefaultUnitOfWorkFactory();
                 module.entities(
                     CheckingAccountEntity.class,
                     SavingsAccountEntity.class,
@@ -67,7 +71,7 @@ public class TransferMoneyTest2
         };
 
         module = assembler.module();
-
+        uowf = module.unitOfWorkFactory();
         bootstrapData();
     }
 
@@ -89,7 +93,7 @@ public class TransferMoneyTest2
 
     private void printBalances()
     {
-        UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Print balances" ) );
+        UnitOfWork uow = module.unitOfWorkFactory().newUnitOfWork( UsecaseBuilder.newUsecase( "Print balances" ) );
 
         try
         {
@@ -109,7 +113,7 @@ public class TransferMoneyTest2
     private static void bootstrapData()
         throws Exception
     {
-        UnitOfWork uow = module.newUnitOfWork( newUsecase( "Bootstrap data" ) );
+        UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Bootstrap data" ) );
         try
         {
             SavingsAccountEntity account = uow.newEntity( SavingsAccountEntity.class, SAVINGS_ACCOUNT_ID );
@@ -138,7 +142,7 @@ public class TransferMoneyTest2
     public void transferHalfOfMoneyFromSavingsToChecking()
         throws Exception
     {
-        UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
+        UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
 
         try
         {
@@ -166,7 +170,7 @@ public class TransferMoneyTest2
     public void transferTwiceOfMoneyFromSavingsToChecking()
         throws Exception
     {
-        UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
+        UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Transfer from savings to checking" ) );
 
         try
         {
@@ -194,7 +198,7 @@ public class TransferMoneyTest2
     public void payAllBills()
         throws Exception
     {
-        UnitOfWork uow = module.newUnitOfWork( newUsecase( "Pay all bills from checking to creditors" ) );
+        UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Pay all bills from checking to creditors" ) );
         try
         {
             BalanceData source = uow.get( BalanceData.class, CHECKING_ACCOUNT_ID );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/EventsService.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/EventsService.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/EventsService.java
index e232e59..d120cc5 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/EventsService.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/EventsService.java
@@ -25,11 +25,12 @@ 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.Application;
-import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkCallback;
 import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
 import org.apache.zest.functional.Iterables;
 import org.apache.zest.library.rest.server.api.ObjectSelection;
 import org.apache.zest.sample.forum.domainevent.DomainEventValue;
@@ -47,7 +48,11 @@ public interface EventsService
         implements InvocationHandler
     {
         @Structure
-        Module module;
+        UnitOfWorkFactory uowf;
+
+        @Structure
+        ValueBuilderFactory vbf;
+
         @Structure
         Application application;
 
@@ -55,9 +60,9 @@ public interface EventsService
         public Object invoke( Object proxy, Method method, Object[] args )
             throws Throwable
         {
-            UnitOfWork unitOfWork = module.currentUnitOfWork();
+            UnitOfWork unitOfWork = uowf.currentUnitOfWork();
 
-            ValueBuilder<DomainEventValue> builder = module.newValueBuilder( DomainEventValue.class );
+            ValueBuilder<DomainEventValue> builder = vbf.newValueBuilder( DomainEventValue.class );
             DomainEventValue prototype = builder.prototype();
             prototype.version().set( application.version() );
             prototype.timestamp().set( unitOfWork.currentTime() );
@@ -69,7 +74,7 @@ public interface EventsService
             {
                 idx++;
                 String name = "param" + idx;
-                ValueBuilder<ParameterValue> parameterBuilder = module.newValueBuilder( ParameterValue.class );
+                ValueBuilder<ParameterValue> parameterBuilder = vbf.newValueBuilder( ParameterValue.class );
                 parameterBuilder.prototype().name().set( name );
                 parameterBuilder.prototype().value().set( arg );
                 prototype.parameters().get().add( parameterBuilder.newInstance() );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumAdministration.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumAdministration.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumAdministration.java
index f4f61f7..8280726 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumAdministration.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumAdministration.java
@@ -22,7 +22,9 @@ import org.apache.zest.api.constraint.Name;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.Uses;
 import org.apache.zest.api.query.Query;
+import org.apache.zest.api.query.QueryBuilderFactory;
 import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.library.rest.server.api.ResourceIndex;
 import org.apache.zest.library.rest.server.api.dci.Role;
 import org.apache.zest.sample.forum.data.entity.Board;
@@ -36,7 +38,10 @@ public class ForumAdministration
     implements ResourceIndex<Query<Board>>
 {
     @Structure
-    Module module;
+    UnitOfWorkFactory uowf;
+
+    @Structure
+    QueryBuilderFactory qbf;
 
     ForumAdmin forumAdmin = new ForumAdmin();
     Administrator administrator = new Administrator();
@@ -61,17 +66,15 @@ public class ForumAdministration
     protected class ForumAdmin
         extends Role<Forum>
     {
-        @Structure
-        Module module;
 
         public Query<Board> boards()
         {
-            return module.newQueryBuilder( Board.class ).newQuery( self.boards() );
+            return qbf.newQueryBuilder( Board.class ).newQuery( self.boards() );
         }
 
         public Board createBoard( String name )
         {
-            Board board = module.currentUnitOfWork().newEntity( Board.class );
+            Board board = uowf.currentUnitOfWork().newEntity( Board.class );
             board.name().set( name );
             administrator.makeModerator( board );
             return board;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumsAdministration.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumsAdministration.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumsAdministration.java
index 7ed4e4e..64654b9 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumsAdministration.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/administration/ForumsAdministration.java
@@ -22,7 +22,7 @@ import org.apache.zest.api.constraint.Name;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.Uses;
 import org.apache.zest.api.query.Query;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.library.rest.server.api.ResourceIndex;
 import org.apache.zest.library.rest.server.api.dci.Role;
 import org.apache.zest.sample.forum.data.entity.Forum;
@@ -36,7 +36,7 @@ public class ForumsAdministration
     implements ResourceIndex<Query<Forum>>
 {
     @Structure
-    Module module;
+    UnitOfWorkFactory uowf;
 
     ForumsAdmin forumsAdmin = new ForumsAdmin();
     Administrator administrator = new Administrator();
@@ -68,7 +68,7 @@ public class ForumsAdministration
 
         public Forum createForum( String name )
         {
-            Forum forum = module.currentUnitOfWork().newEntity( Forum.class );
+            Forum forum = uowf.currentUnitOfWork().newEntity( Forum.class );
             forum.name().set( name );
             administrator.makeModerator( forum );
             return forum;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/login/Login.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/login/Login.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/login/Login.java
index bac5019..d18005f 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/login/Login.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/login/Login.java
@@ -20,23 +20,33 @@ package org.apache.zest.sample.forum.context.login;
 
 import org.apache.zest.api.constraint.Name;
 import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.query.QueryBuilder;
+import org.apache.zest.api.query.QueryBuilderFactory;
 import org.apache.zest.api.query.QueryExpressions;
 import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.sample.forum.data.entity.User;
 
+import static org.apache.zest.api.query.QueryExpressions.*;
+
 /**
  * TODO
  */
 public class Login
 {
     @Structure
-    Module module;
+    UnitOfWorkFactory uowf;
+
+    @Structure
+    QueryBuilderFactory qbf;
 
     public void login( @Name( "name" ) String name, @Name( "password" ) String password )
     {
-        User user = module.currentUnitOfWork()
-            .newQuery( module.newQueryBuilder( User.class )
-                           .where( QueryExpressions.eq( QueryExpressions.templateFor( User.class ).name(), name ) ) )
+        QueryBuilder<User> builder = qbf.newQueryBuilder( User.class )
+            .where( eq( templateFor( User.class ).name(), name ) );
+
+        User user = uowf.currentUnitOfWork()
+            .newQuery( builder )
             .find();
 
         if( user == null || !user.isCorrectPassword( password ) )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewBoard.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewBoard.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewBoard.java
index 563f6b0..3730b11 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewBoard.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewBoard.java
@@ -20,14 +20,14 @@ package org.apache.zest.sample.forum.context.view;
 
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.Uses;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.library.rest.server.api.ResourceIndex;
 import org.apache.zest.library.rest.server.api.dci.Role;
 import org.apache.zest.sample.forum.data.Moderators;
 import org.apache.zest.sample.forum.data.entity.Board;
-import org.apache.zest.sample.forum.data.entity.Topic;
 import org.apache.zest.sample.forum.data.entity.Forum;
 import org.apache.zest.sample.forum.data.entity.Post;
+import org.apache.zest.sample.forum.data.entity.Topic;
 import org.apache.zest.sample.forum.data.entity.User;
 
 import static org.apache.zest.api.property.Numbers.add;
@@ -94,15 +94,15 @@ public class ViewBoard
         extends Role<Board>
     {
         @Structure
-        Module module;
+        UnitOfWorkFactory uowf;
 
         Topic createTopic( String subject, String message, BoardViewer poster )
         {
-            Topic topic = module.currentUnitOfWork().newEntity( Topic.class );
+            Topic topic = uowf.currentUnitOfWork().newEntity( Topic.class );
 
             topic.subject().set( subject );
 
-            Post post = module.currentUnitOfWork().newEntity( Post.class );
+            Post post = uowf.currentUnitOfWork().newEntity( Post.class );
             post.message().set( message );
 
             // Moderation checks

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
index 09adc3c..7df3a0e 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
@@ -22,7 +22,7 @@ import java.util.Date;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.Uses;
 import org.apache.zest.api.property.Numbers;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.library.rest.server.api.ResourceIndex;
 import org.apache.zest.library.rest.server.api.dci.Role;
 import org.apache.zest.sample.forum.data.entity.Post;
@@ -62,14 +62,14 @@ public class ViewPost
         extends Role<Topic>
     {
         @Structure
-        Module module;
+        UnitOfWorkFactory uowf;
 
         public Post reply( String message, PostView viewPost )
         {
-            Post post = module.currentUnitOfWork().newEntity( Post.class );
+            Post post = uowf.currentUnitOfWork().newEntity( Post.class );
             post.message().set( message );
             post.createdBy().set( poster.self() );
-            post.createdOn().set( new Date( module.currentUnitOfWork().currentTime() ) );
+            post.createdOn().set( new Date( uowf.currentUnitOfWork().currentTime() ) );
             post.replyTo().set( viewPost.self() );
 
             self().lastPost().set( post );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Forums.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Forums.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Forums.java
index 6c5e785..fe446f8 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Forums.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Forums.java
@@ -22,7 +22,8 @@ import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.query.Query;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.sample.forum.data.Administrators;
 
 import static org.apache.zest.api.query.QueryExpressions.templateFor;
@@ -42,12 +43,15 @@ public interface Forums
         implements Forums
     {
         @Structure
-        Module module;
+        UnitOfWorkFactory uowf;
+
+        @Structure
+        QueryBuilderFactory qbf;
 
         public Query<Forum> forums()
         {
-            return module.currentUnitOfWork()
-                .newQuery( module.newQueryBuilder( Forum.class ) )
+            return uowf.currentUnitOfWork()
+                .newQuery( qbf.newQueryBuilder( Forum.class ) )
                 .orderBy( templateFor( Forum.class ).name() );
         }
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Users.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Users.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Users.java
index b41f56f..0f18cfe 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Users.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Users.java
@@ -23,7 +23,8 @@ import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.query.Query;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.sample.forum.context.Events;
 import org.apache.zest.sample.forum.context.signup.Registration;
 
@@ -47,28 +48,31 @@ public interface Users
         implements Users
     {
         @Structure
-        Module module;
+        UnitOfWorkFactory uowf;
+
+        @Structure
+        QueryBuilderFactory qbf;
 
         @Override
         public Query<User> users()
         {
-            return module.currentUnitOfWork()
-                .newQuery( module.newQueryBuilder( User.class ) )
+            return uowf.currentUnitOfWork()
+                .newQuery( qbf.newQueryBuilder( User.class ) )
                 .orderBy( templateFor( User.class ).realName() );
         }
 
         @Override
         public User userNamed( String name )
         {
-            return module.currentUnitOfWork().newQuery(
-                module.newQueryBuilder( User.class ).where( eq( templateFor( User.class ).name(), name ) )
+            return uowf.currentUnitOfWork().newQuery(
+                qbf.newQueryBuilder( User.class ).where( eq( templateFor( User.class ).name(), name ) )
             ).find();
         }
 
         @Override
         public void signedup( Registration registration )
         {
-            EntityBuilder<User> builder = module.currentUnitOfWork().newEntityBuilder( User.class );
+            EntityBuilder<User> builder = uowf.currentUnitOfWork().newEntityBuilder( User.class );
             builder.instance().name().set( registration.name().get() );
             builder.instance().realName().set( registration.realName().get() );
             builder.instance().email().set( registration.email().get() );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/domainevent/DomainEvent.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/domainevent/DomainEvent.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/domainevent/DomainEvent.java
index ed347f2..6cbec1a 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/domainevent/DomainEvent.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/domainevent/DomainEvent.java
@@ -26,11 +26,12 @@ import org.apache.zest.api.concern.Concerns;
 import org.apache.zest.api.concern.GenericConcern;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkCallback;
 import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
 import org.apache.zest.functional.Iterables;
 import org.apache.zest.library.rest.server.api.ObjectSelection;
 import org.restlet.Request;
@@ -46,7 +47,10 @@ public @interface DomainEvent
         extends GenericConcern
     {
         @Structure
-        Module module;
+        ValueBuilderFactory vbf;
+
+        @Structure
+        UnitOfWorkFactory uowf;
 
         @Structure
         Application application;
@@ -57,9 +61,9 @@ public @interface DomainEvent
         {
             Object result = next.invoke( proxy, method, args );
 
-            UnitOfWork unitOfWork = module.currentUnitOfWork();
+            UnitOfWork unitOfWork = uowf.currentUnitOfWork();
 
-            ValueBuilder<DomainEventValue> builder = module.newValueBuilder( DomainEventValue.class );
+            ValueBuilder<DomainEventValue> builder = vbf.newValueBuilder( DomainEventValue.class );
             DomainEventValue prototype = builder.prototype();
             prototype.version().set( application.version() );
             prototype.timestamp().set( unitOfWork.currentTime() );
@@ -71,7 +75,7 @@ public @interface DomainEvent
             {
                 idx++;
                 String name = "param" + idx;
-                ValueBuilder<ParameterValue> parameterBuilder = module.newValueBuilder( ParameterValue.class );
+                ValueBuilder<ParameterValue> parameterBuilder = vbf.newValueBuilder( ParameterValue.class );
                 parameterBuilder.prototype().name().set( name );
                 parameterBuilder.prototype().value().set( arg );
                 prototype.parameters().get().add( parameterBuilder.newInstance() );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/forum/src/main/java/org/apache/zest/sample/forum/rest/ForumRestlet.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/rest/ForumRestlet.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/rest/ForumRestlet.java
index c63077d..edf6fb1 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/rest/ForumRestlet.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/rest/ForumRestlet.java
@@ -33,6 +33,6 @@ public class ForumRestlet
     @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/samples/forum/src/main/java/org/apache/zest/sample/forum/service/BootstrapData.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/service/BootstrapData.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/service/BootstrapData.java
index c220d91..c635717 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/service/BootstrapData.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/service/BootstrapData.java
@@ -25,10 +25,10 @@ import org.apache.zest.api.mixin.InitializationException;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.service.ServiceComposite;
 import org.apache.zest.api.service.ServiceReference;
-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.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.sample.forum.data.entity.Forums;
 import org.apache.zest.sample.forum.data.entity.Users;
 
@@ -40,28 +40,27 @@ import org.apache.zest.sample.forum.data.entity.Users;
 public interface BootstrapData
     extends ServiceComposite
 {
-    
+
     void insertInitialData()
-            throws Exception;
+        throws Exception;
 
     class Activator
-            extends ActivatorAdapter<ServiceReference<BootstrapData>>
+        extends ActivatorAdapter<ServiceReference<BootstrapData>>
     {
 
         @Override
         public void afterActivation( ServiceReference<BootstrapData> activated )
-                throws Exception
+            throws Exception
         {
             activated.get().insertInitialData();
         }
-
     }
-    
+
     abstract class Mixin
         implements BootstrapData
     {
         @Structure
-        Module module;
+        private UnitOfWorkFactory module;
 
         @Override
         public void insertInitialData()
@@ -96,6 +95,5 @@ public interface BootstrapData
                 throw new InitializationException( e );
             }
         }
-
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/sql-support/src/main/java/org/apache/zest/sample/sqlsupport/Main.java
----------------------------------------------------------------------
diff --git a/samples/sql-support/src/main/java/org/apache/zest/sample/sqlsupport/Main.java b/samples/sql-support/src/main/java/org/apache/zest/sample/sqlsupport/Main.java
index ddb2d3e..4592e17 100644
--- a/samples/sql-support/src/main/java/org/apache/zest/sample/sqlsupport/Main.java
+++ b/samples/sql-support/src/main/java/org/apache/zest/sample/sqlsupport/Main.java
@@ -72,14 +72,14 @@ public class Main
 
         try {
 
-            UnitOfWork uow = domainModule.newUnitOfWork();
+            UnitOfWork uow = domainModule.unitOfWorkFactory().newUnitOfWork();
             EntityBuilder<PretextEntity> builder = uow.newEntityBuilder( PretextEntity.class );
             PretextEntity pretext = builder.instance();
             pretext.reason().set( "Testing purpose" );
             builder.newInstance();
             uow.complete();
 
-            uow = domainModule.newUnitOfWork();
+            uow = domainModule.unitOfWorkFactory().newUnitOfWork();
             QueryBuilder<PretextEntity> queryBuilder = domainModule.newQueryBuilder( PretextEntity.class );
             queryBuilder = queryBuilder.where( eq( templateFor( PretextEntity.class ).reason(), "Testing purpose" ) );
             Query<PretextEntity> query = uow.newQuery( queryBuilder );
@@ -107,7 +107,7 @@ public class Main
     {
         // EntityStore Data
         {
-            UnitOfWork uow = persistenceModule.newUnitOfWork();
+            UnitOfWork uow = persistenceModule.unitOfWorkFactory().newUnitOfWork();
             try {
                 SQLConfiguration config = uow.get( SQLConfiguration.class,
                                                    PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
@@ -134,7 +134,7 @@ public class Main
 
         // Indexing Data
         {
-            UnitOfWork uow = persistenceModule.newUnitOfWork();
+            UnitOfWork uow = persistenceModule.unitOfWorkFactory().newUnitOfWork();
             try {
                 SQLConfiguration config = uow.get( SQLConfiguration.class, PostgreSQLIndexQueryAssembler.DEFAULT_IDENTITY );
                 Connection connection = persistenceModule.findService( DataSource.class ).get().getConnection();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tests/performance/src/main/java/org/apache/zest/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/main/java/org/apache/zest/test/performance/entitystore/AbstractEntityStorePerformanceTest.java b/tests/performance/src/main/java/org/apache/zest/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
index b35ace8..93eafd0 100644
--- a/tests/performance/src/main/java/org/apache/zest/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
+++ b/tests/performance/src/main/java/org/apache/zest/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
@@ -25,16 +25,16 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.util.Random;
 import java.util.concurrent.Callable;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.zest.api.service.ServiceFinder;
 import org.apache.zest.api.structure.Application;
 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.bootstrap.ApplicationAssemblerAdapter;
 import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.Energy4Java;
-import org.apache.zest.bootstrap.ModuleAssembly;
+import org.junit.Before;
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,7 +49,8 @@ public abstract class AbstractEntityStorePerformanceTest
     private final Assembler infrastructure;
     private final Logger logger;
     private Application application;
-    protected Module module;
+    protected UnitOfWorkFactory uowf;
+    protected ServiceFinder serviceFinder;
 
     private final int ITERATIONS = 20000;
 
@@ -66,23 +67,15 @@ public abstract class AbstractEntityStorePerformanceTest
     {
         try
         {
-            Assembler assembler = new Assembler()
-            {
-                @Override
-                public void assemble( ModuleAssembly module )
-                    throws AssemblyException
-                {
-                    module.entities( SimpleProduct.class );
-                }
-            };
+            Assembler assembler = module -> module.entities( SimpleProduct.class );
             createZestRuntime( assembler );
 
             for( int i = 0; i < 10000; i++ )
             {
-                try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "Warmup " + i ) ) )
+                try (UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Warmup " + i ) ))
                 {
                     SimpleProduct product = uow.newEntity( SimpleProduct.class );
-                    String id = product.identity().get();
+                    product.identity().get();
                 }
             }
         }
@@ -103,42 +96,28 @@ public abstract class AbstractEntityStorePerformanceTest
     {
         try
         {
-            Assembler assembler = new Assembler()
-            {
-                @Override
-                public void assemble( ModuleAssembly module )
-                    throws AssemblyException
-                {
-                    module.entities( SimpleProduct.class );
-                }
-            };
+            Assembler assembler = module -> module.entities( SimpleProduct.class );
             createZestRuntime( assembler );
 
-            profile( new Callable<Void>()
-            {
-                @Override
-                public Void call()
-                    throws Exception
+            profile( () -> {
+                Report report = new Report( storeName );
+                report.start( "createEntityWithSingleProperty" );
+                for( int i = 0; i < ITERATIONS; i++ )
                 {
-                    Report report = new Report( storeName );
-                    report.start( "createEntityWithSingleProperty" );
-                    for( int i = 0; i < ITERATIONS; i++ )
+                    try (UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "createEntityWithSingleProperty " + i ) ))
                     {
-                        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "createEntityWithSingleProperty " + i ) ) )
-                        {
-                            SimpleProduct product = uow.newEntity( SimpleProduct.class );
-                            String id = product.identity().get();
-                            uow.complete();
-                        }
-                        if( i % 1000 == 0 )
-                        {
-                            logger.info( "Iteration {}", i );
-                        }
+                        SimpleProduct product = uow.newEntity( SimpleProduct.class );
+                        product.identity().get();
+                        uow.complete();
+                    }
+                    if( i % 1000 == 0 )
+                    {
+                        logger.info( "Iteration {}", i );
                     }
-                    report.stop( ITERATIONS );
-                    writeReport( report );
-                    return null;
                 }
+                report.stop( ITERATIONS );
+                writeReport( report );
+                return null;
             } );
         }
         finally
@@ -153,42 +132,28 @@ public abstract class AbstractEntityStorePerformanceTest
     {
         try
         {
-            Assembler assembler = new Assembler()
-            {
-                @Override
-                public void assemble( ModuleAssembly module )
-                    throws AssemblyException
-                {
-                    module.entities( SimpleProduct.class );
-                }
-            };
+            Assembler assembler = module -> module.entities( SimpleProduct.class );
             createZestRuntime( assembler );
-            profile( new Callable<Void>()
-            {
-                @Override
-                public Void call()
-                    throws Exception
+            profile( () -> {
+                Report report = new Report( storeName );
+                report.start( "createEntityInBulkWithSingleProperty" );
+                int bulk = 0;
+                UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "createEntityInBulkWithSingleProperty " + bulk ) );
+                for( int i = 0; i < ITERATIONS; i++ )
                 {
-                    Report report = new Report( storeName );
-                    report.start( "createEntityInBulkWithSingleProperty" );
-                    int bulk = 0;
-                    UnitOfWork uow = module.newUnitOfWork( newUsecase( "createEntityInBulkWithSingleProperty " + bulk ) );
-                    for( int i = 0; i < ITERATIONS; i++ )
+                    SimpleProduct product = uow.newEntity( SimpleProduct.class );
+                    product.identity().get();
+                    if( i % 1000 == 0 )
                     {
-                        SimpleProduct product = uow.newEntity( SimpleProduct.class );
-                        String id = product.identity().get();
-                        if( i % 1000 == 0 )
-                        {
-                            uow.complete();
-                            bulk++;
-                            uow = module.newUnitOfWork( newUsecase( "createEntityInBulkWithSingleProperty " + bulk ) );
-                        }
+                        uow.complete();
+                        bulk++;
+                        uow = uowf.newUnitOfWork( newUsecase( "createEntityInBulkWithSingleProperty " + bulk ) );
                     }
-                    uow.complete();
-                    report.stop( ITERATIONS );
-                    writeReport( report );
-                    return null;
                 }
+                uow.complete();
+                report.stop( ITERATIONS );
+                writeReport( report );
+                return null;
             } );
         }
         finally
@@ -203,37 +168,23 @@ public abstract class AbstractEntityStorePerformanceTest
     {
         try
         {
-            Assembler assembler = new Assembler()
-            {
-                @Override
-                public void assemble( ModuleAssembly module )
-                    throws AssemblyException
-                {
-                    module.entities( ComplexProduct.class );
-                }
-            };
+            Assembler assembler = module -> module.entities( ComplexProduct.class );
             createZestRuntime( assembler );
-            profile( new Callable<Void>()
-            {
-                @Override
-                public Void call()
-                    throws Exception
+            profile( () -> {
+                Report report = new Report( storeName );
+                report.start( "createEntityWithComplexType" );
+                for( int i = 0; i < ITERATIONS; i++ )
                 {
-                    Report report = new Report( storeName );
-                    report.start( "createEntityWithComplexType" );
-                    for( int i = 0; i < ITERATIONS; i++ )
+                    try (UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "createEntityWithComplexType " + i ) ))
                     {
-                        try( UnitOfWork uow = module.newUnitOfWork( newUsecase( "createEntityWithComplexType " + i ) ) )
-                        {
-                            ComplexProduct product = uow.newEntity( ComplexProduct.class );
-                            String id = product.identity().get();
-                            uow.complete();
-                        }
+                        ComplexProduct product = uow.newEntity( ComplexProduct.class );
+                        product.identity().get();
+                        uow.complete();
                     }
-                    report.stop( ITERATIONS );
-                    writeReport( report );
-                    return null;
                 }
+                report.stop( ITERATIONS );
+                writeReport( report );
+                return null;
             } );
         }
         finally
@@ -248,42 +199,28 @@ public abstract class AbstractEntityStorePerformanceTest
     {
         try
         {
-            Assembler assembler = new Assembler()
-            {
-                @Override
-                public void assemble( ModuleAssembly module )
-                    throws AssemblyException
-                {
-                    module.entities( ComplexProduct.class );
-                }
-            };
+            Assembler assembler = module -> module.entities( ComplexProduct.class );
             createZestRuntime( assembler );
-            profile( new Callable<Void>()
-            {
-                @Override
-                public Void call()
-                    throws Exception
+            profile( () -> {
+                Report report = new Report( storeName );
+                report.start( "createEntityInBulkWithComplexType" );
+                int bulk = 0;
+                UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "createEntityInBulkWithComplexType " + bulk ) );
+                for( int i = 0; i < ITERATIONS; i++ )
                 {
-                    Report report = new Report( storeName );
-                    report.start( "createEntityInBulkWithComplexType" );
-                    int bulk = 0;
-                    UnitOfWork uow = module.newUnitOfWork( newUsecase( "createEntityInBulkWithComplexType " + bulk ) );
-                    for( int i = 0; i < ITERATIONS; i++ )
+                    ComplexProduct product = uow.newEntity( ComplexProduct.class );
+                    product.identity().get();
+                    if( i % 1000 == 0 )
                     {
-                        ComplexProduct product = uow.newEntity( ComplexProduct.class );
-                        String id = product.identity().get();
-                        if( i % 1000 == 0 )
-                        {
-                            uow.complete();
-                            bulk++;
-                            uow = module.newUnitOfWork( newUsecase( "createEntityInBulkWithComplexType " + bulk ) );
-                        }
+                        uow.complete();
+                        bulk++;
+                        uow = uowf.newUnitOfWork( newUsecase( "createEntityInBulkWithComplexType " + bulk ) );
                     }
-                    uow.complete();
-                    report.stop( ITERATIONS );
-                    writeReport( report );
-                    return null;
                 }
+                uow.complete();
+                report.stop( ITERATIONS );
+                writeReport( report );
+                return null;
             } );
         }
         finally
@@ -298,19 +235,11 @@ public abstract class AbstractEntityStorePerformanceTest
     {
         try
         {
-            Assembler assembler = new Assembler()
-            {
-                @Override
-                public void assemble( ModuleAssembly module )
-                    throws AssemblyException
-                {
-                    module.entities( ComplexProduct.class );
-                }
-            };
+            Assembler assembler = module -> module.entities( ComplexProduct.class );
             createZestRuntime( assembler );
             {
                 int bulk = 0;
-                UnitOfWork uow = module.newUnitOfWork( newUsecase( "readEntityWithComplexType PREPARE " + bulk ) );
+                UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "readEntityWithComplexType PREPARE " + bulk ) );
                 for( int i = 0; i < ITERATIONS; i++ )
                 {
                     ComplexProduct product = uow.newEntity( ComplexProduct.class, "product" + i );
@@ -320,42 +249,34 @@ public abstract class AbstractEntityStorePerformanceTest
                     {
                         uow.complete();
                         bulk++;
-                        uow = module.newUnitOfWork( newUsecase( "readEntityWithComplexType PREPARE " + bulk ) );
+                        uow = uowf.newUnitOfWork( newUsecase( "readEntityWithComplexType PREPARE " + bulk ) );
                     }
                 }
                 uow.complete();
             }
 
-            profile( new Callable<Void>()
-            {
-                @Override
-                public Void call()
-                    throws Exception
+            profile( () -> {
+                Report report = new Report( storeName );
+                int bulk = 0;
+                UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "readEntityWithComplexType " + bulk ) );
+                Random rnd = new Random();
+                report.start( "readEntityWithComplexType" );
+                String id = rnd.nextInt( ITERATIONS ) + "";
+                for( int i = 0; i < ITERATIONS; i++ )
                 {
-                    Report report = new Report( storeName );
-                    int bulk = 0;
-                    UnitOfWork uow = module.newUnitOfWork( newUsecase( "readEntityWithComplexType " + bulk ) );
-                    Random rnd = new Random();
-                    report.start( "readEntityWithComplexType" );
-                    String id = rnd.nextInt( ITERATIONS ) + "";
-                    for( int i = 0; i < ITERATIONS; i++ )
+                    ComplexProduct product = uow.get( ComplexProduct.class, "product" + id );
+                    product.name().get();
+                    if( i % 100 == 0 )
                     {
-                        ComplexProduct product = uow.get( ComplexProduct.class, "product" + id );
-
-                        String name = product.name().get();
-
-                        if( i % 100 == 0 )
-                        {
-                            uow.discard();
-                            bulk++;
-                            uow = module.newUnitOfWork( newUsecase( "readEntityWithComplexType " + bulk ) );
-                        }
+                        uow.discard();
+                        bulk++;
+                        uow = uowf.newUnitOfWork( newUsecase( "readEntityWithComplexType " + bulk ) );
                     }
-                    uow.complete();
-                    report.stop( ITERATIONS );
-                    writeReport( report );
-                    return null;
                 }
+                uow.complete();
+                report.stop( ITERATIONS );
+                writeReport( report );
+                return null;
             } );
         }
         finally
@@ -376,10 +297,13 @@ public abstract class AbstractEntityStorePerformanceTest
         throws IOException
     {
         File dir = new File( "build/reports/perf/" );
-        dir.mkdirs();
+        if( !dir.mkdirs() )
+        {
+            System.out.println( "Couldn't create Performance result directory." );
+        }
         String name = dir.getAbsolutePath() + "/result-" + report.name() + ".xml";
         FileWriter writer = new FileWriter( name, true );
-        try( BufferedWriter out = new BufferedWriter( writer ) )
+        try (BufferedWriter out = new BufferedWriter( writer ))
         {
             report.writeTo( out );
             out.flush();
@@ -392,20 +316,21 @@ public abstract class AbstractEntityStorePerformanceTest
     {
         Energy4Java zest = new Energy4Java();
         Assembler[][][] assemblers = new Assembler[][][]
-        {
             {
                 {
-                    infrastructure, testSetup
+                    {
+                        infrastructure, testSetup
+                    }
                 }
-            }
-        };
+            };
         application = zest.newApplication( new ApplicationAssemblerAdapter( assemblers )
         {
         } );
         application.activate();
 
         Module moduleInstance = application.findModule( "Layer 1", "Module 1" );
-        module = moduleInstance;
+        uowf = moduleInstance.unitOfWorkFactory();
+        serviceFinder = moduleInstance;
     }
 
     protected void cleanUp()
@@ -413,10 +338,10 @@ public abstract class AbstractEntityStorePerformanceTest
     {
         try
         {
-            if( module != null && module.isUnitOfWorkActive() )
+            if( uowf != null && uowf.isUnitOfWorkActive() )
             {
                 UnitOfWork current;
-                while( module.isUnitOfWorkActive() && ( current = module.currentUnitOfWork() ) != null )
+                while( uowf.isUnitOfWorkActive() && ( current = uowf.currentUnitOfWork() ) != null )
                 {
                     if( current.isOpen() )
                     {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java b/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
index 180ee27..3abd538 100644
--- a/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
+++ b/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
@@ -87,17 +87,17 @@ public class DerbySQLEntityStorePerformanceTest
     protected void cleanUp()
         throws Exception
     {
-        if( module == null )
+        if( uowf == null )
         {
             return;
         }
-        UnitOfWork uow = this.module.newUnitOfWork( UsecaseBuilder.newUsecase(
+        UnitOfWork uow = this.uowf.newUnitOfWork( UsecaseBuilder.newUsecase(
             "Delete " + getClass().getSimpleName() + " test data" ) );
         try
         {
             SQLConfiguration config = uow.get( SQLConfiguration.class,
                                                DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
-            Connection connection = module.findService( DataSource.class ).get().getConnection();
+            Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
             String schemaName = config.schemaName().get();
             if( schemaName == null )
             {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java b/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
index 47238a8..3e04c01 100644
--- a/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
+++ b/tests/performance/src/perf/java/org/apache/zest/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
@@ -115,7 +115,7 @@ public class PostgreSQLEntityStorePerformanceTest
             application.activate();
 
             Module moduleInstance = application.findModule( "Layer 1", "config" );
-            UnitOfWorkFactory uowf = moduleInstance;
+            UnitOfWorkFactory uowf = moduleInstance.unitOfWorkFactory();
             UnitOfWork uow = uowf.newUnitOfWork();
             try
             {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tests/performance/src/perf/java/org/apache/zest/test/performance/indexing/rdf/QueryPerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/perf/java/org/apache/zest/test/performance/indexing/rdf/QueryPerformanceTest.java b/tests/performance/src/perf/java/org/apache/zest/test/performance/indexing/rdf/QueryPerformanceTest.java
index 321f30f..912172e 100644
--- a/tests/performance/src/perf/java/org/apache/zest/test/performance/indexing/rdf/QueryPerformanceTest.java
+++ b/tests/performance/src/perf/java/org/apache/zest/test/performance/indexing/rdf/QueryPerformanceTest.java
@@ -20,6 +20,8 @@ package org.apache.zest.test.performance.indexing.rdf;
 
 import java.io.File;
 import org.apache.derby.iapi.services.io.FileUtil;
+import org.apache.zest.api.query.QueryBuilderFactory;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -70,6 +72,7 @@ public class QueryPerformanceTest
 
     private Application application;
     private Module module;
+    private UnitOfWorkFactory uowf;
     private static final String QUERY1 = "PREFIX ns0: <urn:zest:type:org.apache.zest.api.entity.Identity#> \n"
                                          + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
                                          + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
@@ -136,6 +139,7 @@ public class QueryPerformanceTest
         module = application.findModule( LAYER_DOMAIN, MODULE_DOMAIN );
         application.activate();
         indexingDataDir = module.findService( RdfIndexingService.class ).get().dataDir();
+        uowf = module.unitOfWorkFactory();
     }
 
     @After
@@ -196,7 +200,7 @@ public class QueryPerformanceTest
     private LeadRepository populateEntityStore()
         throws UnitOfWorkCompletionException
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             LeadRepository leadRepo = module.findService( LeadRepositoryService.class ).get();
@@ -212,7 +216,7 @@ public class QueryPerformanceTest
                     {
                         System.out.print( "\r" + i );
                         uow.complete();
-                        uow = module.newUnitOfWork();
+                        uow = uowf.newUnitOfWork();
                     }
                     leadFactory.create( "Lead" + i );
                 }
@@ -237,7 +241,7 @@ public class QueryPerformanceTest
     {
         long start;
         long end;
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             start = System.currentTimeMillis();
             Lead lead = leadRepo.findByName( nameOfEntity );
@@ -258,7 +262,7 @@ public class QueryPerformanceTest
     {
         long start;
         long end;
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             start = System.currentTimeMillis();
             Lead lead = leadRepo.findByFixedQuery( queryName );
@@ -338,12 +342,12 @@ public class QueryPerformanceTest
         implements LeadEntityFactory
     {
         @Structure
-        private Module module;
+        private UnitOfWorkFactory uowf;
 
         @Override
         public Lead create( String name )
         {
-            UnitOfWork uow = module.currentUnitOfWork();
+            UnitOfWork uow = uowf.currentUnitOfWork();
             EntityBuilder<LeadEntity> builder = uow.newEntityBuilder( LeadEntity.class );
             Lead prototype = builder.instanceFor( LeadEntity.class );
             prototype.name().set( name );
@@ -368,21 +372,24 @@ public class QueryPerformanceTest
         implements LeadRepository
     {
         @Structure
-        private Module module;
+        private QueryBuilderFactory qbf;
+
+        @Structure
+        private UnitOfWorkFactory uowf;
 
         @Override
         public Lead findByFixedQuery( String queryString )
         {
-            UnitOfWork uow = module.currentUnitOfWork();
-            Query<Lead> query = uow.newQuery( module.newQueryBuilder( Lead.class ).where( SesameExpressions.sparql( queryString ) ) );
+            UnitOfWork uow = uowf.currentUnitOfWork();
+            Query<Lead> query = uow.newQuery( qbf.newQueryBuilder( Lead.class ).where( SesameExpressions.sparql( queryString ) ) );
             return query.find();
         }
 
         @Override
         public Lead findByName( String name )
         {
-            UnitOfWork uow = module.currentUnitOfWork();
-            QueryBuilder<Lead> builder = module.newQueryBuilder( Lead.class );
+            UnitOfWork uow = uowf.currentUnitOfWork();
+            QueryBuilder<Lead> builder = qbf.newQueryBuilder( Lead.class );
             Lead template = templateFor( Lead.class );
 
             Query<Lead> query = uow.newQuery( builder.where( eq( template.name(), name ) ) );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tools/envisage/src/main/resources/org/apache/zest/envisage/tree/TreeModelCellRenderer.properties
----------------------------------------------------------------------
diff --git a/tools/envisage/src/main/resources/org/apache/zest/envisage/tree/TreeModelCellRenderer.properties b/tools/envisage/src/main/resources/org/apache/zest/envisage/tree/TreeModelCellRenderer.properties
index b694372..4e5c3f6 100644
--- a/tools/envisage/src/main/resources/org/apache/zest/envisage/tree/TreeModelCellRenderer.properties
+++ b/tools/envisage/src/main/resources/org/apache/zest/envisage/tree/TreeModelCellRenderer.properties
@@ -15,7 +15,7 @@
 
 ICON_Application=application.png
 ICON_Layer=layer.png
-ICON_Module=module.png
+ICON_Module=unitOfWorkFactory.png
 ICON_Service=service.png
 ICON_ImportedService=importedService.png
 ICON_Entity=entity.png

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tools/envisage/src/test/java/org/apache/zest/envisage/sample/EnvisageSample.java
----------------------------------------------------------------------
diff --git a/tools/envisage/src/test/java/org/apache/zest/envisage/sample/EnvisageSample.java b/tools/envisage/src/test/java/org/apache/zest/envisage/sample/EnvisageSample.java
index ddf04b3..80a2cd6 100644
--- a/tools/envisage/src/test/java/org/apache/zest/envisage/sample/EnvisageSample.java
+++ b/tools/envisage/src/test/java/org/apache/zest/envisage/sample/EnvisageSample.java
@@ -75,7 +75,7 @@ public class EnvisageSample
 
     public void createTestData()
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             createCar( "Volvo", "S80", 2007 );
@@ -101,7 +101,7 @@ public class EnvisageSample
 
     private String createCar( String manufacturer, String model, int year )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         EntityBuilder<Car> builder = uow.newEntityBuilder( Car.class );
         Car prototype = builder.instanceFor( CarEntity.class );
         prototype.manufacturer().set( manufacturer );
@@ -113,7 +113,7 @@ public class EnvisageSample
 
     private String createAnimal( String name, String sound )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         EntityBuilder<Animal> builder = uow.newEntityBuilder( Animal.class );
         Animal prototype = builder.instanceFor( AnimalEntity.class );
         prototype.name().set( name );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java b/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
index e91636b..98e4a7d 100644
--- a/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
+++ b/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
@@ -51,24 +51,18 @@ public class VisitableDetailTest
         throws AssemblyException, ActivationException
     {
         ApplicationDescriptor application = new Energy4Java().newApplicationModel(
-            new ApplicationAssembler()
-            {
-                @Override
-                public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
-                throws AssemblyException
-                {
-                    ApplicationAssembly app = applicationFactory.newApplicationAssembly();
-                    app.setName( "UnderTestApp" );
-                    app.withActivators( ApplicationActivator.class );
+            applicationFactory -> {
+                ApplicationAssembly app = applicationFactory.newApplicationAssembly();
+                app.setName( "UnderTestApp" );
+                app.withActivators( ApplicationActivator.class );
 
-                    LayerAssembly layer = app.layer( "LayerName" );
-                    layer.withActivators( LayerActivator.class );
+                LayerAssembly layer = app.layer( "LayerName" );
+                layer.withActivators( LayerActivator.class );
 
-                    ModuleAssembly module = layer.module( "ModuleName" );
-                    module.withActivators( ModuleActivator.class );
+                ModuleAssembly module = layer.module( "ModuleName" );
+                module.withActivators( ModuleActivator.class );
 
-                    return app;
-                }
+                return app;
             }
         );
         ApplicationDetailDescriptor detail = createApplicationDetailDescriptor( application );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest4.java
----------------------------------------------------------------------
diff --git a/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest4.java b/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest4.java
index 3ce8125..8c31e1b 100644
--- a/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest4.java
+++ b/tutorials/hello/src/test/java/org/apache/zest/tutorials/hello/HelloTest4.java
@@ -37,7 +37,7 @@ public class HelloTest4 extends AbstractZestTest
     @Test
     public void givenHelloValueInitializedToHelloWorldWhenCallingSayExpectHelloWorld()
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             EntityBuilder<Hello> builder = uow.newEntityBuilder( Hello.class, "123" );
@@ -45,7 +45,7 @@ public class HelloTest4 extends AbstractZestTest
             builder.instanceFor( Hello.State.class ).name().set( "World" );
             builder.newInstance();
             uow.complete();
-            uow = module.newUnitOfWork();
+            uow = uowf.newUnitOfWork();
             Hello underTest = uow.get( Hello.class, "123" );
             String result = underTest.say();
             uow.complete();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
----------------------------------------------------------------------
diff --git a/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java b/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
index d71b98c..26a0a92 100644
--- a/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
+++ b/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
@@ -33,10 +33,11 @@ import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.query.Query;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.query.QueryBuilderFactory;
 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;
 import org.apache.zest.api.value.ValueComposite;
 import org.apache.zest.demo.tenminute.Confirmable;
 import org.apache.zest.demo.tenminute.HasCustomer;
@@ -56,7 +57,9 @@ import org.apache.zest.api.query.QueryBuilder;
 // END SNIPPET: 6
 public class ThirtyMinutesDocs
 {
-    Module module;
+    private QueryBuilderFactory queryBuilderFactory;
+    private ValueBuilderFactory valueBuilderFactory;
+    private UnitOfWorkFactory unitOfWorkFactory;
 
 // START SNIPPET: 6
     @Structure private UnitOfWorkFactory uowFactory; //Injected
@@ -65,7 +68,7 @@ public class ThirtyMinutesDocs
     {
 // START SNIPPET: 6
         UnitOfWork uow = uowFactory.currentUnitOfWork();
-        QueryBuilder<Order> builder = module.newQueryBuilder( Order.class );
+        QueryBuilder<Order> builder = queryBuilderFactory.newQueryBuilder( Order.class );
 
         String orderNumber = "12345";
         HasSequenceNumber template = templateFor( HasSequenceNumber.class );
@@ -94,10 +97,10 @@ public class ThirtyMinutesDocs
 
     {
         Report report = null;
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = unitOfWorkFactory.currentUnitOfWork();
 
 // START SNIPPET: 7
-        QueryBuilder<Order> builder = module.newQueryBuilder( Order.class );
+        QueryBuilder<Order> builder = queryBuilderFactory.newQueryBuilder( Order.class );
 
         Calendar cal = Calendar.getInstance();
         cal.setTime( new Date() );
@@ -116,10 +119,10 @@ public class ThirtyMinutesDocs
 
     {
         Report report = null;
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = unitOfWorkFactory.currentUnitOfWork();
 
 // START SNIPPET: 8
-        QueryBuilder<HasCustomer> builder = module.newQueryBuilder( HasCustomer.class );
+        QueryBuilder<HasCustomer> builder = queryBuilderFactory.newQueryBuilder( HasCustomer.class );
 
         Calendar cal = Calendar.getInstance();
         cal.setTime( new Date() );
@@ -200,7 +203,7 @@ public class ThirtyMinutesDocs
         private Action<M> addAction( M item, Action.Type type )
         {
             ValueBuilder<Action> builder =
-                    module.newValueBuilder(Action.class);       // [4]
+                    valueBuilderFactory.newValueBuilder( Action.class);       // [4]
             Action<M> prototype = builder.prototypeFor( Action.class );
             prototype.item().set( item );
             prototype.action().set( type );


Mime
View raw message