polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject Re: Bug in Assembly??
Date Wed, 11 Nov 2015 23:35:00 GMT
Ok, naming might be an issue, but there is a deeper one.

Is it correct that the ServiceActivation.activateService() is called on the
ServiceComposite and not each Mixin implementing it??

Just like Initializable was changed to be called on the Mixin, instead of
the Composite, I think a similar lifecycle method pair is needed for
Services. Otherwise it is really hard to make very generic Mixins that
works independently of the whole ServiceComposite.

Lifecycle is another interface with these semantics for entities.

Cheers
Niclas

On Thu, Nov 12, 2015 at 6:32 AM, Paul Merlin <paul@nosphere.org> wrote:

> 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 <niclas@hedhman.org>
> 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 <niclas@hedhman.org>
> 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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message