polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [07/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:13 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
index 6174483..fed3812 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
@@ -32,9 +32,10 @@ import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.property.PropertyDescriptor;
 import org.apache.zest.api.service.qualifier.Tagged;
-import org.apache.zest.api.structure.Module;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.util.Dates;
 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.api.value.ValueDeserializer;
 import org.apache.zest.api.value.ValueSerialization;
@@ -72,7 +73,10 @@ public class DefaultRequestReader
 {
     private static final Logger LOGGER = LoggerFactory.getLogger( DefaultRequestReader.class );
     @Structure
-    private Module module;
+    private UnitOfWorkFactory uowf;
+
+    @Structure
+    private ValueBuilderFactory vbf;
 
     @Service
     @Tagged( ValueSerialization.Formats.JSON )
@@ -187,7 +191,7 @@ public class DefaultRequestReader
                                                          "Bug in Restlet encountered; notify developers!" );
                         }
 
-                        Object command = module.newValueFromSerializedState( commandType, json );
+                        Object command = vbf.newValueFromSerializedState( commandType, json );
                         args[0] = command;
                         return args;
                     }
@@ -209,8 +213,7 @@ public class DefaultRequestReader
 
                         Form queryAsForm = Request.getCurrent().getResourceRef().getQueryAsForm();
                         Form entityAsForm;
-                        if( representation != null
-                            && !EmptyRepresentation.class.isInstance( representation )
+                        if( !EmptyRepresentation.class.isInstance( representation )
                             && representation.isAvailable() )
                         {
                             entityAsForm = new Form( representation );
@@ -234,8 +237,7 @@ public class DefaultRequestReader
                 {
                     Form queryAsForm = Request.getCurrent().getResourceRef().getQueryAsForm();
                     Form entityAsForm;
-                    if( representation != null
-                        && !EmptyRepresentation.class.isInstance( representation )
+                    if( !EmptyRepresentation.class.isInstance( representation )
                         && representation.isAvailable() )
                     {
                         entityAsForm = new Form( representation );
@@ -245,8 +247,8 @@ public class DefaultRequestReader
                         entityAsForm = new Form();
                     }
 
-                    args[0] = module.currentUnitOfWork().get( method.getParameterTypes()[0],
-                                                              getValue( "entity", queryAsForm, entityAsForm ) );
+                    args[0] = uowf.currentUnitOfWork().get( method.getParameterTypes()[0],
+                                                           getValue( "entity", queryAsForm, entityAsForm ) );
 
                     return args;
                 }
@@ -254,8 +256,7 @@ public class DefaultRequestReader
                 {
                     Form queryAsForm = Request.getCurrent().getResourceRef().getQueryAsForm();
                     Form entityAsForm;
-                    if( representation != null
-                        && !EmptyRepresentation.class.isInstance( representation )
+                    if( !EmptyRepresentation.class.isInstance( representation )
                         && representation.isAvailable() )
                     {
                         entityAsForm = new Form( representation );
@@ -278,13 +279,9 @@ public class DefaultRequestReader
                                              final Form entityAsForm
     )
     {
-        ValueBuilder<? extends ValueComposite> builder = module.newValueBuilderWithState(
+        ValueBuilder<? extends ValueComposite> builder = vbf.newValueBuilderWithState(
             valueType,
-            new Function<PropertyDescriptor, Object>()
-        {
-            @Override
-            public Object apply( PropertyDescriptor propertyDescriptor )
-            {
+            (Function<PropertyDescriptor, Object>) propertyDescriptor -> {
                 Parameter param = queryAsForm.getFirst( propertyDescriptor.qualifiedName().name() );
 
                 if( param == null )
@@ -309,39 +306,28 @@ public class DefaultRequestReader
                 }
 
                 return null;
-            }
             },
-            new Function<AssociationDescriptor, EntityReference>()
-            {
-                @Override
-                public EntityReference apply( AssociationDescriptor associationDescriptor )
-                {
-                    Parameter param = queryAsForm.getFirst( associationDescriptor.qualifiedName().name() );
+            (Function<AssociationDescriptor, EntityReference>) associationDescriptor -> {
+                Parameter param = queryAsForm.getFirst( associationDescriptor.qualifiedName().name() );
 
-                    if( param == null )
-                    {
-                        param = entityAsForm.getFirst( associationDescriptor.qualifiedName().name() );
-                    }
+                if( param == null )
+                {
+                    param = entityAsForm.getFirst( associationDescriptor.qualifiedName().name() );
+                }
 
-                    if( param != null )
-                    {
-                        return EntityReference.parseEntityReference( param.getValue() );
-                    }
-                    else
-                    {
-                        return null;
-                    }
+                if( param != null )
+                {
+                    return EntityReference.parseEntityReference( param.getValue() );
                 }
-            },
-            new Function<AssociationDescriptor, Iterable<EntityReference>>()
-            {
-                @Override
-                public Iterable<EntityReference> apply( AssociationDescriptor associationDescriptor )
+                else
                 {
-                    // TODO
-                    return Iterables.empty();
+                    return null;
                 }
             },
+            (Function<AssociationDescriptor, Iterable<EntityReference>>) associationDescriptor -> {
+                // TODO
+                return Iterables.empty();
+            },
             new Function<AssociationDescriptor, Map<String, EntityReference>>()
             {
                 @Override
@@ -470,7 +456,7 @@ public class DefaultRequestReader
             }
             else if( parameterType.isInterface() )
             {
-                arg = module.currentUnitOfWork().get( parameterType, argString );
+                arg = uowf.currentUnitOfWork().get( parameterType, argString );
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/RestApplication.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/RestApplication.java b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/RestApplication.java
index aa28069..206c71f 100644
--- a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/RestApplication.java
+++ b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/RestApplication.java
@@ -19,9 +19,17 @@ package org.apache.zest.library.rest.admin;
 
 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.*;
-import org.restlet.*;
+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.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.restlet.Application;
+import org.restlet.Context;
+import org.restlet.Request;
+import org.restlet.Response;
+import org.restlet.Restlet;
 import org.restlet.data.MediaType;
 import org.restlet.data.Status;
 import org.restlet.resource.Finder;
@@ -34,7 +42,10 @@ public class RestApplication
     public static final MediaType APPLICATION_SPARQL_JSON = new MediaType( "application/sparql-results+json", "SPARQL JSON" );
 
     @Structure
-    private Module module;
+    private ObjectFactory objectFactory;
+
+    @Structure
+    private UnitOfWorkFactory uowf;
 
     public RestApplication( @Uses Context parentContext )
     {
@@ -48,7 +59,7 @@ public class RestApplication
     @Override
     public void handle( Request request, Response response )
     {
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             super.handle( request, response );
@@ -96,7 +107,7 @@ public class RestApplication
 
     private Finder newFinder( Class<? extends ServerResource> resource )
     {
-        Finder finder = module.newObject( Finder.class );
+        Finder finder = objectFactory.newObject( Finder.class );
         finder.setTargetClass( resource );
         return finder;
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java b/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
index 543ecf3..bb75c84 100644
--- a/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
+++ b/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
@@ -27,8 +27,6 @@ import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.methods.DeleteMethod;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
-import org.junit.Before;
-import org.junit.Test;
 import org.apache.zest.api.association.Association;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.entity.EntityBuilder;
@@ -42,14 +40,19 @@ import org.apache.zest.bootstrap.ApplicationAssemblerAdapter;
 import org.apache.zest.bootstrap.Assembler;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.apache.zest.entitystore.memory.MemoryEntityStoreService;
 import org.apache.zest.index.rdf.assembly.RdfMemoryStoreAssembler;
 import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
 import org.apache.zest.test.AbstractZestTest;
+import org.junit.Before;
+import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
 
 public class RestTest
     extends AbstractZestTest
@@ -59,18 +62,20 @@ public class RestTest
     protected ApplicationDescriptor newApplication()
         throws AssemblyException
     {
-        return zest.newApplicationModel( new ApplicationAssemblerAdapter( new Assembler[][][]
-            {
+        return zest.newApplicationModel( new ApplicationAssemblerAdapter(
+            new Assembler[][][]
                 {
                     {
-                        RestTest.this,
-                        new RestAssembler(),
-                        new RdfMemoryStoreAssembler()
+                        {
+                            RestTest.this,
+                            new RestAssembler(),
+                            new RdfMemoryStoreAssembler(),
+                            new DefaultUnitOfWorkAssembler()
+                        }
                     }
-                }
-            } )
-        {
-        } );
+                } )
+        {}  // subclassing ApplicationAssemblerAdapter
+        );
     }
 
     @Override
@@ -90,7 +95,7 @@ public class RestTest
         throws Exception
     {
         super.setUp();
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
         try
         {
             EntityBuilder<PersonEntity> builder1 = uow.newEntityBuilder( PersonEntity.class, "P2" );
@@ -141,7 +146,7 @@ public class RestTest
         properties.put( "firstname", "Jack" );
         properties.put( "lastname", "Doe" );
         restTester.putEntity( "P1", properties );
-        UnitOfWork work = module.newUnitOfWork();
+        UnitOfWork work = uowf.newUnitOfWork();
         try
         {
             PersonEntity entity = work.get( PersonEntity.class, "P1" );
@@ -161,7 +166,7 @@ public class RestTest
     {
         RestTester restTester = module.newObject( RestTester.class );
         restTester.deleteEntity( "P1" );
-        UnitOfWork work = module.newUnitOfWork();
+        UnitOfWork work = uowf.newUnitOfWork();
         try
         {
             PersonEntity entity = null;
@@ -191,10 +196,10 @@ public class RestTest
         assertThat(
             "Returned RDF", result,
             anyOf(
-            equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n</rdf:RDF>\n" ),
-            equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\\\"no\\\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n</rdf:RDF>\n" ),
-            equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n</rdf:RDF>\n" ),
-            equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\\\"no\\\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n</rdf:RDF>\n" ) ) );
+                equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n</rdf:RDF>\n" ),
+                equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\\\"no\\\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n</rdf:RDF>\n" ),
+                equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n</rdf:RDF>\n" ),
+                equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\\\"no\\\"?>\n<rdf:RDF\n\txmlns=\"urn:zest:\"\n\txmlns:zest=\"http://zest.apache.org/rdf/model/1.0/\"\n\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<zest:entity rdf:about=\"/entity/P1.rdf\"/>\n<zest:entity rdf:about=\"/entity/P2.rdf\"/>\n</rdf:RDF>\n" ) ) );
     }
 
     public static class RestTester
@@ -214,7 +219,8 @@ public class RestTest
                 int status = client.executeMethod( method );
                 if( status != 200 )
                 {
-                    throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method.getStatusText() + "'" );
+                    throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method
+                        .getStatusText() + "'" );
                 }
                 InputStream input = method.getResponseBodyAsStream();
                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -241,7 +247,8 @@ public class RestTest
                 int status = client.executeMethod( method );
                 if( status != 205 )
                 {
-                    throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method.getStatusText() + "'" );
+                    throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method
+                        .getStatusText() + "'" );
                 }
             }
             finally
@@ -260,7 +267,8 @@ public class RestTest
                 int status = client.executeMethod( method );
                 if( status != 204 )
                 {
-                    throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method.getStatusText() + "'" );
+                    throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method
+                        .getStatusText() + "'" );
                 }
             }
             finally
@@ -280,7 +288,8 @@ public class RestTest
                 int status = client.executeMethod( method );
                 if( status != 200 )
                 {
-                    throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method.getStatusText() + "'" );
+                    throw new RuntimeException( "EntityResource returned status code: '" + status + "' and message: '" + method
+                        .getStatusText() + "'" );
                 }
                 InputStream input = method.getResponseBodyAsStream();
                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -320,5 +329,4 @@ public class RestTest
         @Optional
         Association<Person> mother();
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
index 8510645..87e0963 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
@@ -48,9 +48,6 @@ import static org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation.Propa
  * any ordinary {@link org.apache.zest.api.entity.EntityComposite}. There is also a {@link Schedules}
  * entity composite that has Associations to all active, completed and cancelled schedules.
  * </p>
- * <p>
- *
- * </p>
  */
 @Concerns( UnitOfWorkConcern.class )
 public interface Scheduler

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java
index b4a2b4d..4708239 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java
@@ -24,19 +24,19 @@ import org.apache.zest.api.entity.Identity;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.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.UnitOfWorkPropagation;
 import org.apache.zest.library.scheduler.internal.Schedules;
 
-@Mixins(SchedulesHandler.SchedulesHandlerMixin.class)
+@Mixins( SchedulesHandler.SchedulesHandlerMixin.class )
 public interface SchedulesHandler
 {
-    @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY)
+    @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
     Schedules getActiveSchedules();
 
-    @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY)
+    @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
     Schedules getCancelledSchedules();
 
     class SchedulesHandlerMixin implements SchedulesHandler
@@ -45,18 +45,18 @@ public interface SchedulesHandler
         private Identity me;
 
         @Structure
-        private Module module;
+        private UnitOfWorkFactory module;
 
         @Override
         public Schedules getActiveSchedules()
         {
-            return getOrCreateSchedules(getActiveSchedulesIdentity());
+            return getOrCreateSchedules( getActiveSchedulesIdentity() );
         }
 
         @Override
         public Schedules getCancelledSchedules()
         {
-            return getOrCreateSchedules(getCancelledSchedulesIdentity());
+            return getOrCreateSchedules( getCancelledSchedulesIdentity() );
         }
 
         public String getActiveSchedulesIdentity()
@@ -69,7 +69,8 @@ public interface SchedulesHandler
             return "Schedules-Cancelled:" + me.identity().get();
         }
 
-        private Schedules getOrCreateSchedules( String identity ){
+        private Schedules getOrCreateSchedules( String identity )
+        {
             UnitOfWork uow = module.currentUnitOfWork();
             Schedules schedules;
             try
@@ -82,8 +83,6 @@ public interface SchedulesHandler
                 schedules = uow.newEntity( Schedules.class, identity );
             }
             return schedules;
-
         }
-
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
index 27c7125..3eb93b4 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
@@ -23,14 +23,14 @@ package org.apache.zest.library.scheduler.defaults;
 import org.apache.zest.api.entity.EntityBuilder;
 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.unitofwork.UnitOfWork;
-import org.apache.zest.library.scheduler.SchedulerService;
-import org.apache.zest.library.scheduler.Task;
-import org.apache.zest.library.scheduler.Schedule;
-import org.apache.zest.library.scheduler.ScheduleFactory;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.library.scheduler.CronSchedule;
 import org.apache.zest.library.scheduler.OnceSchedule;
+import org.apache.zest.library.scheduler.Schedule;
+import org.apache.zest.library.scheduler.ScheduleFactory;
+import org.apache.zest.library.scheduler.SchedulerService;
+import org.apache.zest.library.scheduler.Task;
 import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
 import org.joda.time.DateTime;
 import org.slf4j.Logger;
@@ -42,7 +42,7 @@ public class DefaultScheduleFactoryMixin
     private static final Logger logger = LoggerFactory.getLogger( ScheduleFactory.class );
 
     @Structure
-    private Module module;
+    private UnitOfWorkFactory uowf;
 
     @Service
     private SchedulerService scheduler;
@@ -64,7 +64,7 @@ public class DefaultScheduleFactoryMixin
 
     private CronSchedule newPersistentCronSchedule( Task task, String cronExpression, DateTime start )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         EntityBuilder<CronSchedule> builder = uow.newEntityBuilder( CronSchedule.class );
         CronSchedule instance = builder.instance();
         instance.task().set( task );
@@ -78,7 +78,7 @@ public class DefaultScheduleFactoryMixin
 
     private Schedule newPersistentOnceSchedule( Task task, DateTime runAt )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         EntityBuilder<OnceSchedule> builder = uow.newEntityBuilder( OnceSchedule.class );
         OnceSchedule builderInstance = builder.instance();
         builderInstance.task().set( task );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
index 1925ac6..e3b9312 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
@@ -27,15 +27,14 @@ import java.util.concurrent.RejectedExecutionHandler;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-import org.apache.zest.api.concern.Concerns;
+import org.apache.zest.api.composite.TransientBuilderFactory;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.unitofwork.NoSuchEntityException;
 import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.library.scheduler.Schedule;
 import org.apache.zest.library.scheduler.Scheduler;
 import org.apache.zest.library.scheduler.SchedulerConfiguration;
@@ -66,7 +65,10 @@ public interface Execution
         private final Object lock = new Object();
 
         @Structure
-        private Module module;
+        private UnitOfWorkFactory uowf;
+
+        @Structure
+        private TransientBuilderFactory tbf;
 
         @This
         private Scheduler scheduler;
@@ -164,7 +166,7 @@ public interface Execution
         {
             long now = System.currentTimeMillis();
 
-            try (UnitOfWork uow = module.newUnitOfWork()) // This will discard() the UoW when block is exited. We are only doing reads, so fine.
+            try (UnitOfWork uow = uowf.newUnitOfWork()) // This will discard() the UoW when block is exited. We are only doing reads, so fine.
             {
                 submitTaskForExecution( oldScheduleTime );
                 Schedule schedule = uow.get( Schedule.class, oldScheduleTime.scheduleIdentity() );
@@ -196,7 +198,7 @@ public interface Execution
 
         private void submitTaskForExecution( ScheduleTime scheduleTime )
         {
-            Runnable taskRunner = module.newTransient( Runnable.class, scheduleTime );
+            Runnable taskRunner = tbf.newTransient( Runnable.class, scheduleTime );
             this.taskExecutor.submit( taskRunner );
         }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
index 4f2272b..75212fe 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
@@ -24,10 +24,10 @@ import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.service.ServiceActivation;
-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.api.usecase.UsecaseBuilder;
 import org.apache.zest.library.scheduler.Scheduler;
 import org.apache.zest.library.scheduler.SchedulerConfiguration;
@@ -50,7 +50,7 @@ public class SchedulerMixin
     private ScheduleFactory scheduleFactory;
 
     @Structure
-    private Module module;
+    private UnitOfWorkFactory uowf;
 
     @This
     private SchedulerService me;
@@ -120,7 +120,7 @@ public class SchedulerMixin
     @Override
     public void cancelSchedule( String scheduleId )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         Schedule schedule;
         try
         {
@@ -153,7 +153,7 @@ public class SchedulerMixin
     private void loadSchedules()
         throws UnitOfWorkCompletionException
     {
-        try (UnitOfWork ignored = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Initialize Schedules" ) ))
+        try (UnitOfWork ignored = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Initialize Schedules" ) ))
         {
             Schedules schedules = schedulesHandler.getActiveSchedules();
             for( Schedule schedule : schedules.schedules() )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java
index fa52d73..fd88d9a 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java
@@ -24,11 +24,11 @@ import java.lang.reflect.UndeclaredThrowableException;
 import java.util.concurrent.locks.ReentrantLock;
 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.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.usecase.UsecaseBuilder;
-import org.apache.zest.library.scheduler.Task;
 import org.apache.zest.library.scheduler.Schedule;
+import org.apache.zest.library.scheduler.Task;
 
 public class TaskRunner
     implements Runnable
@@ -36,7 +36,7 @@ public class TaskRunner
     private static ReentrantLock lock = new ReentrantLock();
 
     @Structure
-    private Module module;
+    private UnitOfWorkFactory uowf;
 
     @Uses
     private ScheduleTime schedule;
@@ -45,7 +45,7 @@ public class TaskRunner
     public void run()
     {
         // TODO: (niclas) I am NOT happy with this implementation, requiring 3 UnitOfWorks to be created. 15-20 milliseconds on my MacBook. If there is a better way to detect overrun, two of those might not be needed.
-        UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner initialize" ) );
+        UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner initialize" ) );
         try
         {
             lock.lock();
@@ -58,14 +58,14 @@ public class TaskRunner
                     schedule.running().set( true );
                     uow.complete();                     // This completion is needed to detect overrun
 
-                    uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner" ) );
+                    uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner" ) );
                     schedule = uow.get( schedule );     // re-attach the entity to the new UnitOfWork
                     Task task = schedule.task().get();
                     lock.unlock();
                     task.run();
                     lock.lock();
                     uow.complete();
-                    uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner conclude" ) );
+                    uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner conclude" ) );
                     schedule = uow.get( schedule );     // re-attach the entity to the new UnitOfWork
                     schedule.running().set( false );
                     schedule.taskCompletedSuccessfully();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
index ed999fd..8b7dff9 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
@@ -48,7 +48,7 @@ public class CronScheduleTest extends AbstractZestTest
         throws Exception
     {
 
-        UnitOfWork work = module.newUnitOfWork();
+        UnitOfWork work = uowf.newUnitOfWork();
         EntityBuilder<Task> builder1 = work.newEntityBuilder( Task.class );
         builder1.instance().name().set( "abc" );
         Task task = builder1.newInstance();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
index 15a356c..f2c8fc6 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
@@ -73,14 +73,14 @@ public class SchedulerTest
     {
         Usecase usecase = UsecaseBuilder.newUsecase( "testTask" );
         String taskId;
-        try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
         {
             FooTask task = createFooTask( uow, "TestTask", BAZAR );
             taskId = task.identity().get();
             task.run();
             uow.complete();
         }
-        try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
         {
             FooTask task = uow.get( FooTask.class, taskId );
             assertThat( task.runCounter().get(), equalTo( 1 ) );
@@ -96,7 +96,7 @@ public class SchedulerTest
         DateTime start = new DateTime();
         String taskIdentity;
         long sleepMillis;
-        try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
         {
             Scheduler scheduler = module.findService( Scheduler.class ).get();
 
@@ -117,7 +117,7 @@ public class SchedulerTest
             .until( taskOutput( taskIdentity ), equalTo( 1 ) );
 
         //noinspection unused
-        try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
         {
             Timeline timeline = module.findService( Timeline.class ).get();
             DateTime now = new DateTime();
@@ -153,7 +153,7 @@ public class SchedulerTest
         Schedule schedule2;
         Schedule schedule3;
         Schedule schedule4;
-        try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
         {
             FooTask task = createFooTask( uow, usecase.name(), BAZAR );
             taskIdentity = task.identity().get();
@@ -169,7 +169,7 @@ public class SchedulerTest
             .atMost( 6, SECONDS )
             .until( taskOutput( taskIdentity ), equalTo( 4 ) );
 
-        try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
+        try( UnitOfWork uow = uowf.newUnitOfWork( usecase ) )
         {
             schedule1 = uow.get( schedule1 );
             schedule2 = uow.get( schedule2 );
@@ -193,7 +193,7 @@ public class SchedulerTest
     private Callable<Integer> taskOutput( final String taskIdentity )
     {
         return () -> {
-            try( UnitOfWork uow = module.newUnitOfWork() )
+            try( UnitOfWork uow = uowf.newUnitOfWork() )
             {
                 FooTask task = uow.get( FooTask.class, taskIdentity );
                 Integer count = task.runCounter().get();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/passwords/PasswordRealmMixin.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/passwords/PasswordRealmMixin.java b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/passwords/PasswordRealmMixin.java
index 2b26353..6e52b7d 100644
--- a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/passwords/PasswordRealmMixin.java
+++ b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/passwords/PasswordRealmMixin.java
@@ -33,9 +33,10 @@ import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.query.QueryBuilder;
+import org.apache.zest.api.query.QueryBuilderFactory;
 import org.apache.zest.api.service.ServiceActivation;
-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.library.shiro.Shiro;
 import org.apache.zest.library.shiro.domain.permissions.RoleAssignee;
 import org.slf4j.Logger;
@@ -45,14 +46,17 @@ import static org.apache.zest.api.query.QueryExpressions.eq;
 import static org.apache.zest.api.query.QueryExpressions.templateFor;
 
 public class PasswordRealmMixin
-        extends AuthorizingRealm
-        implements Realm, Authorizer, PasswordService, ServiceActivation
+    extends AuthorizingRealm
+    implements Realm, Authorizer, PasswordService, ServiceActivation
 {
 
     private static final Logger LOG = LoggerFactory.getLogger( Shiro.LOGGER_NAME );
 
     @Structure
-    private Module module;
+    private UnitOfWorkFactory uowf;
+
+    @Structure
+    private QueryBuilderFactory qbf;
 
     @This
     private Configuration<PasswordRealmConfiguration> configuration;
@@ -70,18 +74,21 @@ public class PasswordRealmMixin
 
     @Override
     public void activateService()
-            throws Exception
+        throws Exception
     {
         configuration.refresh();
         PasswordRealmConfiguration config = configuration.get();
         String algorithm = config.hashAlgorithmName().get();
         Integer iterations = config.hashIterationsCount().get();
-        if ( algorithm != null || iterations != null ) {
-            DefaultHashService hashService = ( DefaultHashService ) passwordService.getHashService();
-            if ( algorithm != null ) {
+        if( algorithm != null || iterations != null )
+        {
+            DefaultHashService hashService = (DefaultHashService) passwordService.getHashService();
+            if( algorithm != null )
+            {
                 hashService.setHashAlgorithmName( algorithm );
             }
-            if ( iterations != null ) {
+            if( iterations != null )
+            {
                 hashService.setHashIterations( iterations );
             }
         }
@@ -89,13 +96,13 @@ public class PasswordRealmMixin
 
     @Override
     public void passivateService()
-            throws Exception
+        throws Exception
     {
     }
 
     @Override
     public String encryptPassword( Object plaintextPassword )
-            throws IllegalArgumentException
+        throws IllegalArgumentException
     {
         return passwordService.encryptPassword( plaintextPassword );
     }
@@ -108,21 +115,25 @@ public class PasswordRealmMixin
 
     @Override
     protected AuthenticationInfo doGetAuthenticationInfo( AuthenticationToken token )
-            throws AuthenticationException
+        throws AuthenticationException
     {
-        UnitOfWork uow = module.newUnitOfWork();
-        try {
+        UnitOfWork uow = uowf.newUnitOfWork();
+        try
+        {
 
-            String username = ( ( UsernamePasswordToken ) token ).getUsername();
+            String username = ( (UsernamePasswordToken) token ).getUsername();
             PasswordSecurable account = findPasswordSecurable( uow, username );
-            if ( account == null ) {
+            if( account == null )
+            {
                 LOG.debug( "Unknown subject identifier: {}" + username );
                 return null;
             }
             LOG.debug( "Found account for {}: {}", username, account );
-            return new SimpleAuthenticationInfo( account.subjectIdentifier().get(), account.password().get(), getName() );
-
-        } finally {
+            return new SimpleAuthenticationInfo( account.subjectIdentifier().get(), account.password()
+                .get(), getName() );
+        }
+        finally
+        {
             uow.discard();
         }
     }
@@ -130,12 +141,14 @@ public class PasswordRealmMixin
     @Override
     protected AuthorizationInfo doGetAuthorizationInfo( PrincipalCollection principals )
     {
-        UnitOfWork uow = module.newUnitOfWork();
-        try {
+        UnitOfWork uow = uowf.newUnitOfWork();
+        try
+        {
 
             String username = getAvailablePrincipal( principals ).toString();
             RoleAssignee roleAssignee = findRoleAssignee( uow, username );
-            if ( roleAssignee == null ) {
+            if( roleAssignee == null )
+            {
                 LOG.debug( "No authorization info for {}", username );
                 return null;
             }
@@ -147,24 +160,24 @@ public class PasswordRealmMixin
             SimpleAuthorizationInfo atzInfo = new SimpleAuthorizationInfo( roleNames );
             atzInfo.setStringPermissions( permissionStrings );
             return atzInfo;
-
-        } finally {
+        }
+        finally
+        {
             uow.discard();
         }
     }
 
     private PasswordSecurable findPasswordSecurable( UnitOfWork uow, String username )
     {
-        QueryBuilder<PasswordSecurable> builder = module.newQueryBuilder( PasswordSecurable.class );
+        QueryBuilder<PasswordSecurable> builder = qbf.newQueryBuilder( PasswordSecurable.class );
         builder = builder.where( eq( templateFor( PasswordSecurable.class ).subjectIdentifier(), username ) );
         return uow.newQuery( builder ).find();
     }
 
     private RoleAssignee findRoleAssignee( UnitOfWork uow, String username )
     {
-        QueryBuilder<RoleAssignee> builder = module.newQueryBuilder( RoleAssignee.class );
+        QueryBuilder<RoleAssignee> builder = qbf.newQueryBuilder( RoleAssignee.class );
         builder = builder.where( eq( templateFor( RoleAssignee.class ).subjectIdentifier(), username ) );
         return uow.newQuery( builder ).find();
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/Role.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/Role.java b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/Role.java
index f8fc925..e4c0282 100644
--- a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/Role.java
+++ b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/Role.java
@@ -21,8 +21,8 @@ import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.property.Property;
-import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 
 @Mixins( Role.Mixin.class )
 public interface Role
@@ -41,7 +41,7 @@ public interface Role
     {
 
         @Structure
-        private Module module;
+        private UnitOfWorkFactory uowf;
 
         @This
         private Role role;
@@ -49,7 +49,7 @@ public interface Role
         @Override
         public RoleAssignment assignTo( RoleAssignee assignee )
         {
-            UnitOfWork uow = module.currentUnitOfWork();
+            UnitOfWork uow = uowf.currentUnitOfWork();
             EntityBuilder<RoleAssignment> builder = uow.newEntityBuilder( RoleAssignment.class );
             RoleAssignment assignment = builder.instance();
             assignment.assignee().set( assignee );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/RoleFactory.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/RoleFactory.java b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/RoleFactory.java
index 87f6b68..4b5b555 100644
--- a/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/RoleFactory.java
+++ b/libraries/shiro-core/src/main/java/org/apache/zest/library/shiro/domain/permissions/RoleFactory.java
@@ -23,8 +23,8 @@ 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.functional.Iterables;
 
 @Mixins( RoleFactory.Mixin.class )
@@ -41,7 +41,7 @@ public interface RoleFactory
     {
 
         @Structure
-        private Module module;
+        private UnitOfWorkFactory uowf;
 
         @Override
         public Role create( String name, String... permissions )
@@ -52,7 +52,7 @@ public interface RoleFactory
         @Override
         public Role create( String name, Iterable<String> permissions )
         {
-            UnitOfWork uow = module.currentUnitOfWork();
+            UnitOfWork uow = uowf.currentUnitOfWork();
             EntityBuilder<Role> roleBuilder = uow.newEntityBuilder( Role.class );
             Role role = roleBuilder.instance();
             role.name().set( name );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
index 90f9d87..35a9ceb 100644
--- a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
+++ b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PasswordDomainTest.java
@@ -17,6 +17,7 @@ import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authc.UsernamePasswordToken;
 import org.apache.shiro.authc.credential.PasswordService;
 import org.apache.shiro.subject.Subject;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.junit.Test;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.entity.EntityBuilder;
@@ -65,7 +66,7 @@ public class PasswordDomainTest
     {
 
         @Structure
-        private Module module;
+        private UnitOfWorkFactory uowf;
 
         @Service
         private PasswordService passwordService;
@@ -73,7 +74,7 @@ public class PasswordDomainTest
         @Override
         public User createNewUser( String username, String password )
         {
-            EntityBuilder<User> userBuilder = module.currentUnitOfWork().newEntityBuilder( User.class );
+            EntityBuilder<User> userBuilder = uowf.currentUnitOfWork().newEntityBuilder( User.class );
             User user = userBuilder.instance();
             user.subjectIdentifier().set( username );
             user.password().set( passwordService.encryptPassword( password ) );
@@ -116,7 +117,7 @@ public class PasswordDomainTest
             throws UnitOfWorkCompletionException
     {
 
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
 
         UserFactory userFactory = module.findService( UserFactory.class ).get();
         // START SNIPPET: usage
@@ -125,7 +126,7 @@ public class PasswordDomainTest
         // END SNIPPET: usage
         uow.complete();
 
-        uow = module.newUnitOfWork();
+        uow = uowf.newUnitOfWork();
 
         // START SNIPPET: usage
         Subject currentUser = SecurityUtils.getSubject();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
index 8fcb885..a436896 100644
--- a/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
+++ b/libraries/shiro-core/src/test/java/org/apache/zest/library/shiro/PermissionsDomainTest.java
@@ -17,6 +17,7 @@ import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authc.UsernamePasswordToken;
 import org.apache.shiro.authc.credential.PasswordService;
 import org.apache.shiro.subject.Subject;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.junit.Before;
 import org.junit.Test;
 import org.apache.zest.api.common.Visibility;
@@ -69,7 +70,7 @@ public class PermissionsDomainTest
     {
 
         @Structure
-        private Module module;
+        private UnitOfWorkFactory uowf;
 
         @Service
         private PasswordService passwordService;
@@ -77,7 +78,7 @@ public class PermissionsDomainTest
         @Override
         public User createNewUser( String username, String password )
         {
-            EntityBuilder<User> userBuilder = module.currentUnitOfWork().newEntityBuilder( User.class );
+            EntityBuilder<User> userBuilder = uowf.currentUnitOfWork().newEntityBuilder( User.class );
             User user = userBuilder.instance();
             user.subjectIdentifier().set( username );
             user.password().set( passwordService.encryptPassword( password ) );
@@ -129,7 +130,7 @@ public class PermissionsDomainTest
             throws UnitOfWorkCompletionException
     {
         // START SNIPPET: usage
-        UnitOfWork uow = module.newUnitOfWork();
+        UnitOfWork uow = uowf.newUnitOfWork();
 
         User user = userFactory.createNewUser( "foo", "bar" );
         Role role = roleFactory.create( "role-one", "permission-one", "permission-two" );
@@ -139,7 +140,7 @@ public class PermissionsDomainTest
 
         // END SNIPPET: usage
         // START SNIPPET: usage
-        uow = module.newUnitOfWork();
+        uow = uowf.newUnitOfWork();
 
         Subject currentUser = SecurityUtils.getSubject();
         currentUser.login( new UsernamePasswordToken( "foo", "bar" ) );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java b/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
index e3202de..8555f14 100644
--- a/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
+++ b/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.function.Function;
 import javax.sql.DataSource;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.junit.Test;
 import org.apache.zest.api.activation.ActivationEvent;
 import org.apache.zest.api.activation.ActivationEventListener;
@@ -86,6 +87,8 @@ public class LiquibaseServiceTest
                 // END SNIPPET: assembly
                 module.forMixin( LiquibaseConfiguration.class ).declareDefaults().enabled().set( true );
                 module.forMixin( LiquibaseConfiguration.class ).declareDefaults().changeLog().set( "changelog.xml" );
+
+                new DefaultUnitOfWorkAssembler().assemble( module );
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
index 5774fd4..93fa811 100644
--- a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
+++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
@@ -27,10 +27,10 @@ import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.service.ImportedServiceDescriptor;
 import org.apache.zest.api.service.ServiceImporter;
 import org.apache.zest.api.service.ServiceImporterException;
-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.api.usecase.UsecaseBuilder;
 import org.apache.zest.library.circuitbreaker.CircuitBreaker;
 import org.apache.zest.library.conversion.values.EntityToValue;
@@ -43,14 +43,14 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp
 
     protected static final Logger LOGGER = LoggerFactory.getLogger( AbstractDataSourceServiceImporterMixin.class );
 
-    private final Map<String, DataSourceConfigurationValue> configs = new HashMap<String, DataSourceConfigurationValue>();
+    private final Map<String, DataSourceConfigurationValue> configs = new HashMap<>();
 
-    private final Map<String, PooledDataSourceType> pools = new HashMap<String, PooledDataSourceType>();
+    private final Map<String, PooledDataSourceType> pools = new HashMap<>();
 
-    private final Map<DataSource, CircuitBreaker> circuitBreakers = new HashMap<DataSource, CircuitBreaker>();
+    private final Map<DataSource, CircuitBreaker> circuitBreakers = new HashMap<>();
 
     @Structure
-    protected Module module;
+    protected UnitOfWorkFactory uowf;
 
     @Service
     private EntityToValue entityToValue;
@@ -126,7 +126,7 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp
     {
         DataSourceConfigurationValue config = configs.get( identity );
         if ( config == null ) {
-            UnitOfWork uow = module.newUnitOfWork( UsecaseBuilder.newUsecase( "Create DataSource pool configuration" ) );
+            UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Create DataSource pool configuration" ) );
 
             try {
                 DataSourceConfiguration configEntity = uow.get( DataSourceConfiguration.class, identity );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
index 11e5ce5..03c04ce 100644
--- a/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
+++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerService.java
@@ -54,6 +54,7 @@ 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.UnitOfWorkCompletionException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.library.sql.datasource.DataSourceConfiguration;
 import org.apache.zest.spi.ZestSPI;
 
@@ -98,7 +99,7 @@ public interface DataSourceConfigurationManagerService
     {
 
         @Structure
-        Module module;
+        UnitOfWorkFactory uowf;
 
         @Service
         MBeanServer server;
@@ -177,7 +178,7 @@ public interface DataSourceConfigurationManagerService
             public Object getAttribute( String name )
                     throws AttributeNotFoundException, MBeanException, ReflectionException
             {
-                UnitOfWork uow = module.newUnitOfWork();
+                UnitOfWork uow = uowf.newUnitOfWork();
                 try {
                     EntityComposite configuration = uow.get( EntityComposite.class, identity );
                     AssociationStateHolder state = spi.stateOf( configuration );
@@ -195,7 +196,7 @@ public interface DataSourceConfigurationManagerService
             public void setAttribute( Attribute attribute )
                     throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
             {
-                UnitOfWork uow = module.newUnitOfWork();
+                UnitOfWork uow = uowf.newUnitOfWork();
                 try {
                     EntityComposite configuration = uow.get( EntityComposite.class, identity );
                     AssociationStateHolder state = spi.stateOf( configuration );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java b/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
index 7af957c..e7a6f36 100644
--- a/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
+++ b/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
@@ -18,6 +18,7 @@ import java.beans.PropertyVetoException;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import javax.sql.DataSource;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.junit.Assert;
 import org.junit.Test;
 import org.apache.zest.api.activation.ActivationException;
@@ -68,7 +69,7 @@ public class DataSourceConfigurationManagerServiceTest
     public void testDataSources()
         throws ActivationException, AssemblyException
     {
-        SingletonAssembler assembler = new SingletonAssembler()
+        new SingletonAssembler()
         {
             @Override
             public void assemble( ModuleAssembly module )
@@ -79,11 +80,13 @@ public class DataSourceConfigurationManagerServiceTest
                 // Create in-memory store for configurations
                 new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( module );
 
+                new DefaultUnitOfWorkAssembler().assemble( module );
+
                 // Set up DataSource service that will manage the connection pools
                 new DBCPDataSourceServiceAssembler().identifiedBy( "datasource-service" ).visibleIn( Visibility.layer ).assemble( module );
 
                 {
-                    ModuleAssembly testModule = module.layer().module( "TestDS" );
+                    ModuleAssembly testModule = module.layer().module( "TestDS" ).withDefaultUnitOfWorkFactory();
 
                     // Create a specific DataSource that uses the "datasource" service to do the main work
                     new DataSourceAssembler().
@@ -101,7 +104,7 @@ public class DataSourceConfigurationManagerServiceTest
                 }
 
                 {
-                    ModuleAssembly testModule2 = module.layer().module( "TestDS2" );
+                    ModuleAssembly testModule2 = module.layer().module( "TestDS2" ).withDefaultUnitOfWorkFactory();
 
                     // Create another specific DataSource that uses the "datasource" service to do the main work
                     // Use DataSourceAssembler to assemble the DataSource.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFileFactory.java
----------------------------------------------------------------------
diff --git a/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFileFactory.java b/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFileFactory.java
index 3dcb80a..8cdc5de 100644
--- a/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFileFactory.java
+++ b/libraries/uowfile/src/main/java/org/apache/zest/library/uowfile/internal/UoWFileFactory.java
@@ -30,10 +30,10 @@ import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.service.ServiceActivation;
 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.library.fileconfig.FileConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -60,7 +60,7 @@ public interface UoWFileFactory
         private Application app;
 
         @Structure
-        private Module module;
+        private UnitOfWorkFactory module;
 
         @This
         private ServiceComposite me;
@@ -181,5 +181,4 @@ public interface UoWFileFactory
             return uowMeta;
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
----------------------------------------------------------------------
diff --git a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
index 81a57f9..58e4703 100644
--- a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
+++ b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFileTest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.junit.Before;
 import org.junit.Test;
 import org.apache.zest.api.concern.Concerns;
@@ -31,7 +32,6 @@ import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.property.Property;
-import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
 import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
@@ -105,7 +105,7 @@ public class HasUoWFileTest
         implements TestService
     {
         @Structure
-        private Module module;
+        private UnitOfWorkFactory uowf;
 
         @Override
         public void modifyFile( String entityId )
@@ -148,7 +148,7 @@ public class HasUoWFileTest
         private void modifyFileImmediatly( String entityId )
             throws IOException
         {
-            TestedEntity entity = module.currentUnitOfWork().get( TestedEntity.class, entityId );
+            TestedEntity entity = uowf.currentUnitOfWork().get( TestedEntity.class, entityId );
             // START SNIPPET: api
             File attachedFile = entity.attachedFile();
             File managedFile = entity.managedFile();
@@ -190,7 +190,7 @@ public class HasUoWFileTest
         File attachedFile;
 
         // Test discarded creation
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedEntity( uow, "Testing Creation Rollback" );
             attachedFile = entity.attachedFile();
@@ -198,7 +198,7 @@ public class HasUoWFileTest
         assertFalse( "File still exists after discarded creation UoW", attachedFile.exists() );
 
         // Test completed creation
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedEntity( uow, "Testing Creation" );
             attachedFile = entity.attachedFile();
@@ -216,7 +216,7 @@ public class HasUoWFileTest
         File attachedFile;
 
         // Create new
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedEntity( uow, "Testing Modification" );
             entityId = entity.identity().get();
@@ -225,14 +225,14 @@ public class HasUoWFileTest
         }
 
         // Testing discarded modification
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             testService.modifyFile( entityId );
         }
         assertTrue( "File content after discarded modification was not the good one", isFileFirstLineEqualsTo( attachedFile, "Creation" ) );
 
         // Testing completed modification
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             testService.modifyFile( entityId );
             uow.complete();
@@ -249,7 +249,7 @@ public class HasUoWFileTest
         File attachedFile;
 
         // Create new
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedEntity( uow, "Testing Deletion" );
             entityId = entity.identity().get();
@@ -258,7 +258,7 @@ public class HasUoWFileTest
         }
 
         // Testing discarded deletion
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = uow.get( TestedEntity.class, entityId );
             uow.remove( entity );
@@ -266,7 +266,7 @@ public class HasUoWFileTest
         assertTrue( "File do not exists after discarded deletion", attachedFile.exists() );
 
         // Testing completed deletion
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = uow.get( TestedEntity.class, entityId );
             uow.remove( entity );
@@ -283,7 +283,7 @@ public class HasUoWFileTest
         final String entityId;
 
         // Create new
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedEntity( uow, "Testing Concurrent Modification" );
             entityId = entity.identity().get();
@@ -294,11 +294,11 @@ public class HasUoWFileTest
         UnitOfWork uow, uow2;
         TestedEntity entity;
 
-        uow = module.newUnitOfWork();
+        uow = uowf.newUnitOfWork();
         entity = uow.get( TestedEntity.class, entityId );
         Inputs.text( MODIFICATION_CONTENT_URL ).transferTo( Outputs.text( entity.managedFile() ) );
 
-        uow2 = module.newUnitOfWork();
+        uow2 = uowf.newUnitOfWork();
         entity = uow2.get( TestedEntity.class, entityId );
         Inputs.text( MODIFICATION_CONTENT_URL ).transferTo( Outputs.text( entity.managedFile() ) );
 
@@ -323,7 +323,7 @@ public class HasUoWFileTest
         File attachedFile;
 
         // Create new
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedEntity( uow, "Testing Concurrent Modification" );
             entityId = entity.identity().get();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
----------------------------------------------------------------------
diff --git a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
index 782db07..7c0418c 100644
--- a/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
+++ b/libraries/uowfile/src/test/java/org/apache/zest/library/uowfile/HasUoWFilesTest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.junit.Before;
 import org.junit.Test;
 import org.apache.zest.api.concern.Concerns;
@@ -121,7 +122,7 @@ public class HasUoWFilesTest
         implements TestService
     {
         @Structure
-        private Module module;
+        private UnitOfWorkFactory uowf;
 
         @Override
         public void modifyFile( String entityId )
@@ -164,7 +165,7 @@ public class HasUoWFilesTest
         private void modifyFileImmediatly( String entityId )
             throws IOException
         {
-            TestedEntity entity = module.currentUnitOfWork().get( TestedEntity.class, entityId );
+            TestedEntity entity = uowf.currentUnitOfWork().get( TestedEntity.class, entityId );
             // START SNIPPET: api
             File attachedFileTwo = entity.attachedFile( MyEnum.fileTwo );
             File managedFileOne = entity.managedFile( MyEnum.fileOne );
@@ -205,7 +206,7 @@ public class HasUoWFilesTest
         File attachedFile;
 
         // Test discarded creation
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Creation Rollback" );
             attachedFile = entity.attachedFile( MyEnum.fileOne );
@@ -213,7 +214,7 @@ public class HasUoWFilesTest
         assertFalse( "File still exists after discarded creation UoW", attachedFile.exists() );
 
         // Test completed creation
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Creation" );
             attachedFile = entity.attachedFile( MyEnum.fileOne );
@@ -231,7 +232,7 @@ public class HasUoWFilesTest
         File attachedFile;
 
         // Create new
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Modification" );
             entityId = entity.identity().get();
@@ -240,14 +241,14 @@ public class HasUoWFilesTest
         }
 
         // Testing discarded modification
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             testService.modifyFile( entityId );
         }
         assertTrue( "File content after discarded modification was not the good one", isFileFirstLineEqualsTo( attachedFile, "Creation" ) );
 
         // Testing completed modification
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             testService.modifyFile( entityId );
             uow.complete();
@@ -264,7 +265,7 @@ public class HasUoWFilesTest
         File attachedFile;
 
         // Create new
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Deletion" );
             entityId = entity.identity().get();
@@ -273,7 +274,7 @@ public class HasUoWFilesTest
         }
 
         // Testing discarded deletion
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = uow.get( TestedEntity.class, entityId );
             uow.remove( entity );
@@ -281,7 +282,7 @@ public class HasUoWFilesTest
         assertTrue( "File do not exists after discarded deletion", attachedFile.exists() );
 
         // Testing completed deletion
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = uow.get( TestedEntity.class, entityId );
             uow.remove( entity );
@@ -298,7 +299,7 @@ public class HasUoWFilesTest
         final String entityId;
 
         // Create new
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Concurrent Modification" );
             entityId = entity.identity().get();
@@ -309,11 +310,11 @@ public class HasUoWFilesTest
         UnitOfWork uow, uow2;
         TestedEntity entity;
 
-        uow = module.newUnitOfWork();
+        uow = uowf.newUnitOfWork();
         entity = uow.get( TestedEntity.class, entityId );
         Inputs.text( MODIFICATION_CONTENT_URL ).transferTo( Outputs.text( entity.managedFile( MyEnum.fileOne ) ) );
 
-        uow2 = module.newUnitOfWork();
+        uow2 = uowf.newUnitOfWork();
         entity = uow2.get( TestedEntity.class, entityId );
         Inputs.text( MODIFICATION_CONTENT_URL ).transferTo( Outputs.text( entity.managedFile( MyEnum.fileOne ) ) );
 
@@ -338,7 +339,7 @@ public class HasUoWFilesTest
         File attachedFile;
 
         // Create new
-        try( UnitOfWork uow = module.newUnitOfWork() )
+        try( UnitOfWork uow = uowf.newUnitOfWork() )
         {
             TestedEntity entity = createTestedOneEntityTwoFilesEntity( uow, "Testing Concurrent Modification" );
             entityId = entity.identity().get();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/manual/src/main/java/org/apache/zest/manual/recipes/assemble/Docs.java
----------------------------------------------------------------------
diff --git a/manual/src/main/java/org/apache/zest/manual/recipes/assemble/Docs.java b/manual/src/main/java/org/apache/zest/manual/recipes/assemble/Docs.java
index 74de20d..03d9d5c 100644
--- a/manual/src/main/java/org/apache/zest/manual/recipes/assemble/Docs.java
+++ b/manual/src/main/java/org/apache/zest/manual/recipes/assemble/Docs.java
@@ -21,12 +21,13 @@ package org.apache.zest.manual.recipes.assemble;
 import org.apache.zest.api.injection.scope.This;
 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.ValueComposite;
 
 public class Docs
 {
     @This
-    Module module;
+    UnitOfWorkFactory module;
 
     public void showUsage()
     {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/CarEntityFactoryMixin.java
----------------------------------------------------------------------
diff --git a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/CarEntityFactoryMixin.java b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/CarEntityFactoryMixin.java
index a6fff15..1abf6c7 100644
--- a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/CarEntityFactoryMixin.java
+++ b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/CarEntityFactoryMixin.java
@@ -20,29 +20,30 @@ package org.apache.zest.manual.recipes.createEntity;
 
 import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 
 // START SNIPPET: carFactoryMixin2
 // START SNIPPET: carFactoryMixin1
 public class CarEntityFactoryMixin
-        implements CarEntityFactory
+    implements CarEntityFactory
 {
 
-// END SNIPPET: carFactoryMixin1
+    // END SNIPPET: carFactoryMixin1
     @Structure
-    Module module;
-// END SNIPPET: carFactoryMixin2
+    UnitOfWorkFactory unitOfWorkFactory;
+
+    // END SNIPPET: carFactoryMixin2
 // START SNIPPET: carFactoryMixin3
-    public CarEntityFactoryMixin( @Structure Module module )
+    public CarEntityFactoryMixin( @Structure UnitOfWorkFactory unitOfWorkFactory )
     {
     }
 
-// END SNIPPET: carFactoryMixin3
+    // END SNIPPET: carFactoryMixin3
 // START SNIPPET: createCar
-    public Car create(Manufacturer manufacturer, String model)
+    public Car create( Manufacturer manufacturer, String model )
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        UnitOfWork uow = unitOfWorkFactory.currentUnitOfWork();
         EntityBuilder<Car> builder = uow.newEntityBuilder( Car.class );
 
         Car prototype = builder.instance();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
index 11f76d5..7bb8a31 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
@@ -79,7 +79,7 @@ public interface BaseDataService
         	throws Exception
         {
             logger.debug( "CREATING BASIC DATA..." );
-            UnitOfWork uow = module.newUnitOfWork( newUsecase( "Open uow for " ) );
+            UnitOfWork uow = module.unitOfWorkFactory().newUnitOfWork( newUsecase( "Open uow for " ) );
             try
             {
 	            // UnLocode value objects
@@ -154,7 +154,7 @@ public interface BaseDataService
 
         private Location location( UnLocode unlocode, String locationStr )
         {
-            UnitOfWork uow = module.currentUnitOfWork();
+            UnitOfWork uow = module.unitOfWorkFactory().currentUnitOfWork();
             EntityBuilder<Location> location = uow.newEntityBuilder( Location.class, unlocode.code().get() );
             location.instance().unLocode().set( unlocode );
             location.instance().name().set( locationStr );
@@ -163,7 +163,7 @@ public interface BaseDataService
 
         private Voyage voyage( String voyageNumberStr, Schedule schedule )
         {
-            UnitOfWork uow = module.currentUnitOfWork();
+            UnitOfWork uow = module.unitOfWorkFactory().currentUnitOfWork();
             EntityBuilder<Voyage> voyage = uow.newEntityBuilder( Voyage.class, voyageNumberStr );
 
             // VoyageNumber

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
index e10124f..3ac14f5 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
@@ -67,10 +67,10 @@ public class EntityModel<T extends DTO, U extends EntityComposite>
 
     private U loadEntity()
     {
-        U entity = module.currentUnitOfWork().get( entityClass, identity );
+        U entity = module.unitOfWorkFactory().currentUnitOfWork().get( entityClass, identity );
         if( entity == null )
         {
-            Usecase usecase = module.currentUnitOfWork().usecase();
+            Usecase usecase = module.unitOfWorkFactory().currentUnitOfWork().usecase();
             throw new NoSuchEntityException( EntityReference.parseEntityReference( identity ), entityClass, usecase );
         }
         return entity;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestApplication.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestApplication.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestApplication.java
index 675a164..b22fd46 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestApplication.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestApplication.java
@@ -17,6 +17,7 @@
  */
 package org.apache.zest.sample.dcicargo.sample_a.bootstrap.test;
 
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -58,7 +59,7 @@ public class TestApplication extends BaseData
     public TestApplication()
     {
         super(app.findModule( "BOOTSTRAP", "BOOTSTRAP-Bootstrap" ));
-        Context.prepareContextBaseClass( module );
+        Context.prepareContextBaseClass( module.unitOfWorkFactory() );
     }
 
     // Printing current test method name to console
@@ -71,20 +72,25 @@ public class TestApplication extends BaseData
     {
         logger.info( name.getMethodName() );
         Usecase usecase = UsecaseBuilder.newUsecase( "Usecase: " + name );
-        module.newUnitOfWork(usecase);
+        module.unitOfWorkFactory().newUnitOfWork(usecase);
     }
 
     @After
     public void concludeTest()
     {
-        UnitOfWork uow = module.currentUnitOfWork();
+        if( module == null )
+        {
+            return;
+        }
+        UnitOfWorkFactory uowf = module.unitOfWorkFactory();
+        UnitOfWork uow = uowf.currentUnitOfWork();
         if( uow != null && uow.isOpen() )
             uow.discard();
-        if( module != null && module.isUnitOfWorkActive() )
+        if( uowf.isUnitOfWorkActive() )
         {
-            while( module.isUnitOfWorkActive() )
+            while( uowf.isUnitOfWorkActive() )
             {
-                uow = module.currentUnitOfWork();
+                uow = uowf.currentUnitOfWork();
                 if( uow.isOpen() )
                 {
                     System.err.println( "UnitOfWork not cleaned up:" + uow.usecase().name() );


Mime
View raw message