Return-Path: X-Original-To: apmail-zest-dev-archive@minotaur.apache.org Delivered-To: apmail-zest-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B0640182EB for ; Tue, 25 Aug 2015 13:31:31 +0000 (UTC) Received: (qmail 7593 invoked by uid 500); 25 Aug 2015 13:31:31 -0000 Delivered-To: apmail-zest-dev-archive@zest.apache.org Received: (qmail 7555 invoked by uid 500); 25 Aug 2015 13:31:31 -0000 Mailing-List: contact dev-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 dev@zest.apache.org Received: (qmail 7543 invoked by uid 99); 25 Aug 2015 13:31:31 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Aug 2015 13:31:31 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id E2F07C009B for ; Tue, 25 Aug 2015 13:31:30 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.98 X-Spam-Level: ** X-Spam-Status: No, score=2.98 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id mGxhRlD3_tpv for ; Tue, 25 Aug 2015 13:31:28 +0000 (UTC) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 42BD520865 for ; Tue, 25 Aug 2015 13:31:27 +0000 (UTC) Received: by lbbpu9 with SMTP id pu9so99818331lbb.3 for ; Tue, 25 Aug 2015 06:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=7YT+pPzX/bT/TTxuwfLWrgefvEl2EWU+tRvVUp7IziY=; b=PI6Zvwhm/tIgbJtkjYIZbvif5vmZbZGiV3xk+j4YjHd8k84hJvDIxNanuJ+wL1uUHO 09yzprg1FBXi/EwGaiFnYCMN6174zfUBeBiKSdTPwEXz89VTTd6bI3KeRF0mrbzKEH/f DyR59K0v4mQvzRbpWe57NsDFUisWMsG1CjPHjTYVc1UTyrxIrygBcE7xLQ46XLJAg7y9 okbztS3q07FUIcSZICNsVQmCOENZyM0q9tNYLGtHF8MggpHC7pw/kCuQtQLx0OXRT1cC KDtvPUdSYE4heFA7GCrLu7AJ+0JviHIJ3hGmxYjr7AU8nIfcmg2dZUkJnmEtck0weFlM gUbA== X-Received: by 10.152.6.73 with SMTP id y9mr19962691lay.45.1440509485704; Tue, 25 Aug 2015 06:31:25 -0700 (PDT) MIME-Version: 1.0 Sender: hedhman@gmail.com Received: by 10.25.133.135 with HTTP; Tue, 25 Aug 2015 06:31:06 -0700 (PDT) In-Reply-To: <55DBA8F3.9090004@gmail.com> References: <55DBA8F3.9090004@gmail.com> From: Niclas Hedhman Date: Tue, 25 Aug 2015 21:31:06 +0800 X-Google-Sender-Auth: 4BaRXo41GFmo5new5A6jTG80rUE Message-ID: Subject: Re: A few zest 3.0 thought? To: dev Content-Type: multipart/alternative; boundary=089e0149422030eae5051e22c007 --089e0149422030eae5051e22c007 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Yes, you are making sense, and aligns with my thoughts. The challenge lies in the details, and why QI4j pre-1.0 got seriously burned, by something we don't even have a name for (call it Visibility migration). The UnitOfWork adjusts the visibility as the calls traverses the modules and layers. So, although the UoW is created high up, it needs to "adapt" to visibility for each composite/object asking for something. The mechanism for this is both very delicate, not obvious, and hard to reason around. It is also likely to be filled with bugs. Most of the Persistence does the right thing, but in Indexing it works for rdf-indexer, but IIRC it doesn't work in the sql-indexer. A lot of that is probably related to broken separation of concerns, in that UoW should "somehow" ensure that the SPI level stuff doesn't need to worry about it. And it could be that there is missing a "ViewPoint" concept, i.e. the location from where the Visibility is derived, and that the ViewPoint might be even more central to the invocation stack than belonging inside the UoW, since I assume UoW isn't necessarily required (OR IS IT??). Hard to discuss this on mailing list, and a whiteboard and couple of days of time would sure be more efficient. I more than welcome you to drive this with some stylized examples, that tries to take into consideration what happens during persistence, querying and other future "services" in such a world. Cheers Niclas On Tue, Aug 25, 2015 at 7:29 AM, Kent S=C3=B8lvsten wrote: > Gang, > > A lot of stuff has been discussed during the summer - suggestions for an > upcoming 3.0 release. > A lot of it consists of new composite types and new ways of persistence > - thus challenging the existing way of persisting stuff. > > A Zest application consists of a single application with a CONFIGURABLE > number of layers > Each layer has a CONFIGURABLE number of modules. > Each module has a FIXED set of structural parts: The UOW and > implementations of some factories, each factory handling the lifecycle > of a single composite type. > The UOW stuff implements a FIXED set of lifecycle interfaces, adding > ways to query, fetch and manipulate entities (a single composite type). > > Below the fixed API a few service provider interfaces allow for several > implementations, especially for storing and querying stuff. > > We have already stuff challenging that model, since the native queries > (SOLR/SERQL if i recall correctly) are not a great fit. > We have the spatial query stuff, which is great, but the existing model > is not really prepared to add that. > > In the pipeline we have more stuff .... > > Message composites with a message store? > Aggregates with an event store? > And maybe some ORM stuff too? > > The "natural" way to add that would be by adding more factories to the > UOW - and maybe some more query interfaces to the modules. > Probably not a good idea to overload those already large interfaces - > and a suggestion that has already (implicitly?) been rejected for the > native query stuff. > > I think we simply *need* a way to extend the core with new stuff in a > natural way. > > Could we use services for that? > > What would happen if we removed > ObjectFactory/ValueBuilderFactory/TransientBuilderFactory from the > module itself, and added those as services instead? > Application code could no longer use the functionality from the module > directly, but would have to use the ServiceFinder or @Structure injection= s. > A bonus would be adding visibility - allowing assemblers to enforce that > some of the factories can only be used from inside the module. > > Not trivial to implement, but not that bad either, I think. > > Somewhere down the road, that might even suggest a way to add new > composite types. Bootstrapping TransientComposites could in some way be > regarded as syntactical sugar around configuring the > TransientBuilderFactory structural service - and maybe the model > definitions could even live inside that service instead of inside the > module? > > But ..... > > The hairy stuff is the persistent stuff living inside the UnitOfWork! > > Going down the road suggested above, the obvious way would be to > implement services such as > EntityBuilderFactory/QueryBuilderFactory/EntityFinder - and then more > services to support new persistence/composites. > The UOW can NOT depend directly on those, since it cannot know which > sort of composites are persisted. So the services will have to manage > that themselves, and need to implement a common interface for receiving > notifications before/during/after completion of a UOW. The services > could have a concern ensuring the existence of an active UOW. > > I believe it CAN be done - but would require a lot of collaboration > between the UOW and those services - and a lot of the services would > have to hold maps Map for stores and pending changes. > > Can it be improved? > > Currently all services are singletons (at least within a module) - that > is, they have module scope. The services may implement interfaces > allowing them to get notified when the module is activated/passivated. > > What if we had "UnitOfWork-scoped" services? > > A service with UOW scope is having a single instance per UOW (if used) - > which is ensured by the runtime itself. No need for having a concern > ensuring an active UOW - if there is no UOW there is simply no instance! > References to a UOW-scoped service is simply a proxy delegating to the > correct implementation at runtime - (the same pattern has been used in > other frameworks, normally to delegate to a ThreadLocal instance). The > service may implement interfaces allowing to get notified when the UOW > is activated/passivated - maybe the usual Activation/Activator > interfaces can be used? > > The point is that these services can be stateful - and could be used to > hold eg. pending changes (entities/messages/events/aggregates) inside a > UOW. No Maps necessary. No need for the UOW to do that book keeping. So > EntityBuilderFactory/EntityFinder/QueryBuilderFactory could be > UOW-scoped services. The services would not need to register themselves > with the UOW (that is done automatically). And the UOW would not need to > tell a lot of details on completion, since those details are remembered > by the service itself. > > This can be used for persistance stuff but other ideas come to mind > - a service could implement a logging API, but only flush all debug > messages regarding a UOW to disk in case of that UOW failing. > - another service could track usage patterns of the application sorted > by use cases. > > We could have a SpatialQueryBuilderFactory as a UOW-scoped service, > using an underlying indexer > We could have a SOLRQueryBuilderFactory as a UOW-scoped service using an > underlying indexer. > We could have a MessageDispatcher as a UOW-scoped service using a JMS > implementation below > ....... > > Maybe we could even have services with other kind of scopes - the > obvious case is HttpSession - but i guess we are now far beyond 3.0 scope= . > > Am I making sense? Would it be worthwhile to attempt a prototype based > on some of these ideas? > > /Kent > > --=20 Niclas Hedhman, Software Developer http://zest.apache.org - New Energy for Java --089e0149422030eae5051e22c007--