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 <[email protected]> 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 <[email protected]> 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<MyService> 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 > -- Niclas Hedhman, Software Developer http://zest.apache.org - New Energy for Java
