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 E81F01803C for ; Wed, 11 Nov 2015 22:33:12 +0000 (UTC) Received: (qmail 28730 invoked by uid 500); 11 Nov 2015 22:33:12 -0000 Delivered-To: apmail-zest-dev-archive@zest.apache.org Received: (qmail 28694 invoked by uid 500); 11 Nov 2015 22:33:12 -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 28678 invoked by uid 99); 11 Nov 2015 22:33:12 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Nov 2015 22:33:12 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 241A5C428A for ; Wed, 11 Nov 2015 22:33:12 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.981 X-Spam-Level: *** X-Spam-Status: No, score=3.981 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=3, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id H0fuJICtSUIw for ; Wed, 11 Nov 2015 22:33:02 +0000 (UTC) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 6F3D021277 for ; Wed, 11 Nov 2015 22:33:02 +0000 (UTC) Received: from mfilter27-d.gandi.net (mfilter27-d.gandi.net [217.70.178.155]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 8BBE9172070 for ; Wed, 11 Nov 2015 23:33:00 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter27-d.gandi.net Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196]) by mfilter27-d.gandi.net (mfilter27-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id UuipuAaKKHb8 for ; Wed, 11 Nov 2015 23:32:58 +0100 (CET) X-Originating-IP: 212.195.187.94 Received: from [192.168.1.3] (bne75-h07-212-195-187-94.dsl.sta.abo.bbox.fr [212.195.187.94]) (Authenticated sender: paul@nosphere.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id B4372172081 for ; Wed, 11 Nov 2015 23:32:58 +0100 (CET) Message-ID: <5643C219.8020506@nosphere.org> Date: Wed, 11 Nov 2015 23:32:57 +0100 From: Paul Merlin User-Agent: Postbox 3.0.11 (Macintosh/20140602) MIME-Version: 1.0 To: dev@zest.apache.org Subject: Re: Bug in Assembly?? References: In-Reply-To: X-Enigmail-Version: 1.2.3 Content-Type: multipart/alternative; boundary="------------090102090003050801000701" --------------090102090003050801000701 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Niclas, Theses two interfaces are not the same thing. Maybe they are misnamed/misplaced. Activation Javadoc says: "Application and Layer expose this interface so you can activate and passivate them. Module and ServiceComposite activation/passivation is handled by the Zest runtime." Module activation is indeed handled by the runtime. For services, one can register Activators at assembly time, which are plain java objects. Then, ServiceActivation is a convenience interface that helps setting up "Service Activation" and comes up with a corresponding ServiceActivator. /Paul Niclas Hedhman a écrit : > So, I noticed that I did the wrong thing, that one needs to use > ServiceActivation instead of Activation. Then it works. > > But why is there two interfaces for the same thing? What am I missing? > > > Cheers > Niclas > > On Sat, Nov 7, 2015 at 1:41 PM, Niclas Hedhman wrote: > >> Some debugging done... >> >> 1. Activation reaches ServiceReferenceInstance.activate(), and since >> it is instantiateOnStartup(), it calls getInstance(); >> >> 2. The ServiceReferenceInstance has an activationModel of; >> >> ActivationDelegate{target=MyService(active=false,module='Module 1'), >> targetActivators=null, activeChildren=[]} >> Which seems fine to me. activate() is called on that >> activationModel. >> >> 3. In the ActivationDelegate's activate() method, the iteration of >> "children" will be done on the ServiceInstance, and the child.activate() >> actually happens on the ServiceInstance.activate() which has a NOOP >> implementation. >> >> IIRC, Paul's intention was that each Mixin can implement Activation and >> should be called accordingly. But where is this code? Was it forgotten? And >> should I simply add a loop in ServiceInstance.activate() where each of the >> Mixins that implements Activation gets called? >> >> I am somewhat uncertain what the intentions are here... >> >> Cheers >> Niclas >> >> On Sat, Nov 7, 2015 at 1:14 PM, Niclas Hedhman wrote: >> >>> Gang, >>> >>> I am chasing an Activation bug (I get activate() called twice), so I made >>> the testcase below. But here I get ZERO activate() called. Have I/we broken >>> the activation system completely when going to Java 8? Or am I missing >>> something bleeding obvious? >>> >>> Cheers >>> Niclas >>> >>> public class ServiceAssemblyTest extends AbstractZestTest >>> { >>> @Test >>> public void givenMyServiceWithTwoDeclarationsWhenActivatingServiceExpectServiceActivatedOnce() >>> throws PassivationException >>> { >>> ServiceReference ref = module.findService( MyService.class ); >>> MyService underTest = ref.get(); >>> assertThat(underTest.activated(), equalTo(1)); // Fails here!!! >>> underTest.passivate(); >>> assertThat(underTest.passivated(), equalTo(1)); >>> } >>> >>> @Override >>> public void assemble( ModuleAssembly module ) >>> throws AssemblyException >>> { >>> module.services( MyService.class ).instantiateOnStartup(); >>> module.services( MyService.class ).setMetaInfo( "Hello" ); >>> } >>> >>> @Mixins( MyServiceMixin.class ) >>> public static interface MyService extends Activation >>> { >>> int activated(); >>> int passivated(); >>> } >>> >>> public static class MyServiceMixin implements MyService, Activation >>> { >>> >>> private int activated; >>> private int passivated; >>> >>> @Override >>> public int activated() >>> { >>> return activated; >>> } >>> >>> @Override >>> public int passivated() >>> { >>> return passivated; >>> } >>> >>> @Override >>> public void activate() >>> throws ActivationException >>> { >>> activated++; >>> } >>> >>> @Override >>> public void passivate() >>> throws PassivationException >>> { >>> passivated++; >>> } >>> } >>> } >>> >>> >>> >>> -- >>> Niclas Hedhman, Software Developer >>> http://zest.apache.org - New Energy for Java >>> >> -- >> Niclas Hedhman, Software Developer >> http://zest.apache.org - New Energy for Java >> > > > --------------090102090003050801000701--