Return-Path: X-Original-To: apmail-zest-commits-archive@minotaur.apache.org Delivered-To: apmail-zest-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D2C34180FC for ; Thu, 17 Dec 2015 22:20:07 +0000 (UTC) Received: (qmail 18099 invoked by uid 500); 17 Dec 2015 22:20:07 -0000 Delivered-To: apmail-zest-commits-archive@zest.apache.org Received: (qmail 18079 invoked by uid 500); 17 Dec 2015 22:20:07 -0000 Mailing-List: contact commits-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list commits@zest.apache.org Received: (qmail 18070 invoked by uid 99); 17 Dec 2015 22:20:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Dec 2015 22:20:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8AC67E1856; Thu, 17 Dec 2015 22:20:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: soelvsten@apache.org To: commits@zest.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: zest-java git commit: ZEST-132 DefaultUnitOfWorkAssembler now redundant, since work is done by EventBus Date: Thu, 17 Dec 2015 22:20:07 +0000 (UTC) Repository: zest-java Updated Branches: refs/heads/ZEST-132 4190b401d -> 86cbd80f8 ZEST-132 DefaultUnitOfWorkAssembler now redundant, since work is done by EventBus Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/86cbd80f Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/86cbd80f Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/86cbd80f Branch: refs/heads/ZEST-132 Commit: 86cbd80f8f2f9bd8877279c56dbb12db981bb111 Parents: 4190b40 Author: Kent Sølvsten Authored: Thu Dec 17 23:20:10 2015 +0100 Committer: Kent Sølvsten Committed: Thu Dec 17 23:20:10 2015 +0100 ---------------------------------------------------------------------- .../unitofwork/DefaultUnitOfWorkAssembler.java | 11 +++++------ .../org/apache/zest/runtime/event/EventBus.java | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/86cbd80f/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java ---------------------------------------------------------------------- diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java old mode 100644 new mode 100755 index 14171cd..3ef541d --- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java +++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java @@ -20,8 +20,6 @@ package org.apache.zest.bootstrap.unitofwork; -import org.apache.zest.api.unitofwork.UnitOfWork; -import org.apache.zest.api.unitofwork.UnitOfWorkFactory; import org.apache.zest.bootstrap.Assembler; import org.apache.zest.bootstrap.AssemblyException; import org.apache.zest.bootstrap.ModuleAssembly; @@ -33,11 +31,12 @@ public class DefaultUnitOfWorkAssembler public void assemble( ModuleAssembly module ) throws AssemblyException { - Class factoryMixin = loadMixinClass( "org.apache.zest.runtime.unitofwork.UnitOfWorkFactoryMixin" ); - module.services( UnitOfWorkFactory.class ).withMixins( factoryMixin ); + // Do nothing - added automatically by EventBus + //Class factoryMixin = loadMixinClass( "org.apache.zest.runtime.unitofwork.UnitOfWorkFactoryMixin" ); + //module.services( UnitOfWorkFactory.class ).withMixins( factoryMixin ); - Class uowMixin = loadMixinClass( "org.apache.zest.runtime.unitofwork.ModuleUnitOfWork" ); - module.transients( UnitOfWork.class ).withMixins( uowMixin ); + //Class uowMixin = loadMixinClass( "org.apache.zest.runtime.unitofwork.ModuleUnitOfWork" ); + //module.transients( UnitOfWork.class ).withMixins( uowMixin ); } private Class loadMixinClass( String name ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/86cbd80f/core/runtime/src/main/java/org/apache/zest/runtime/event/EventBus.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/event/EventBus.java b/core/runtime/src/main/java/org/apache/zest/runtime/event/EventBus.java index 59b8c73..74dd346 100755 --- a/core/runtime/src/main/java/org/apache/zest/runtime/event/EventBus.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/event/EventBus.java @@ -26,13 +26,31 @@ import java.util.ListIterator; import java.util.Map; import org.apache.zest.api.event.ZestEvent; import org.apache.zest.api.event.ZestEventHandler; +import org.apache.zest.api.unitofwork.UnitOfWork; +import org.apache.zest.api.unitofwork.UnitOfWorkFactory; +import org.apache.zest.bootstrap.ModuleAssembly; import org.apache.zest.bootstrap.handler.ModuleAssembledEvent; +import org.apache.zest.runtime.unitofwork.ModuleUnitOfWork; +import org.apache.zest.runtime.unitofwork.UnitOfWorkFactoryMixin; public class EventBus { public EventBus() { + // emit ModuleAssembledEvent to interested users ModuleAssembledRuntimeEvent.Handler handler = event -> EventBus.this.emit( new ModuleAssembledEvent( event.getModuleAssembly() ) ); addHandler( ModuleAssembledRuntimeEvent.TYPE, handler ); + // add default UnitOfWork to all modules (of not already added by user) + addHandler( ModuleAssembledRuntimeEvent.TYPE, new ModuleAssembledRuntimeEvent.Handler( ) { + @Override + public void onModuleAssembled( ModuleAssembledRuntimeEvent event ) + { + ModuleAssembly moduleAssembly = event.getModuleAssembly(); + // mixin will not be used, if user have already added a matching mixin + // @TODO make it possible to ask if service is already there (more robust) + moduleAssembly.services( UnitOfWorkFactory.class ).withMixins( UnitOfWorkFactoryMixin.class ); + moduleAssembly.transients( UnitOfWork.class ).withMixins( ModuleUnitOfWork.class ); + } + }); } /**