polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Merlin <p...@nosphere.org>
Subject Re: Bug in Assembly??
Date Wed, 11 Nov 2015 22:32:57 GMT
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
>>
>
>
>

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