[ 
https://ops4j1.jira.com/browse/QI-310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15162#comment-15162
 ] 

Niclas Hedhman commented on QI-310:
-----------------------------------

This is actually not strange at all. 

Instead it raises a question;

 * Is there a distinction between implementing an interface that is inheriting 
Activatable or directly implementing Activatable?

For my reported case, the Activatable in the super-interface was needed to bind 
in the initializing Mixin at all, but then all other Mixins ended up having to 
implement it as well (empty methods was the work around).

Now, we *could* say that if the Activatable is inherited, it is like a normal 
Mixin Type without special meaning, whereas if it is directly implemented, then 
its methods should be called accordingly.


BUT, perhaps for 2.0 we should abandon Activatable and instead use Annotations 
and possibly Assembly information;

{code}
@Activation
public void myMethod() { ... }

@Passivation
public void myOtherMethod() { ... }
{code}

where we could then allow injection of regular Qi4j scopes into the method, for 
stuff you only need during that phase (quite common).

Likewise, we *could* support something like;

{code}
public void assemble( ModuleAssembly module )
{
    module.forMixin( MyServiceType.class ).setServiceActivation().myMethod();
    module.forMixin( MyServiceType.class 
).setServicePassivation().myOtherMethod();
}
{code}
but it then has the downside that if injection is supported a bunch of ugly 
'null' will be there.

I think composite lifecycle methods should be further discussed for 2.0. We 
didn't get it quite right in 1.x


> Bug in Activatable handling if inherited from super type.
> ---------------------------------------------------------
>
>                 Key: QI-310
>                 URL: https://ops4j1.jira.com/browse/QI-310
>             Project: Qi4j
>          Issue Type: Bug
>          Components: Core Runtime
>    Affects Versions: 1.2
>            Reporter: Niclas Hedhman
>            Assignee: Rickard Öberg
>             Fix For: Unknown
>
>
> If Activatable is inherited in super type and a mixin is not implementing it 
> (i.e. is abstract), then a strange exception is thrown.
> {code}
> public interface Abc extends Activatable
> {
>     void domainMethods();
> }
> public abstract class DefMixin
>     implements Abc
> {
>     public void domainMethods()
>     {
>       :
>     }
> }
> {code}
> will trigger this exception.
> org.qi4j.api.service.ServiceUnavailableException: Could not activate
> service SuperType
>        at 
> org.qi4j.runtime.service.ServiceReferenceInstance.getInstance(ServiceReferenceInstance.java:123)
>        at 
> org.qi4j.runtime.service.ServiceReferenceInstance.access$100(ServiceReferenceInstance.java:36)
>        at 
> org.qi4j.runtime.service.ServiceReferenceInstance$ServiceInvocationHandler.invoke(ServiceReferenceInstance.java:169)
>        at $Proxy12.doSomething(Unknown Source)
>        at 
> org.qi4j.runtime.service.ComplexActivatableTest.validateThatApplicationGotAssembled(ComplexActivatableTest.java:25)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
>        at 
> org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
>        at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
>        at 
> org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
>        at 
> org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
>        at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
>        at 
> org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
>        at 
> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
>        at 
> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
>        at 
> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
>        at 
> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
>        at 
> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
>        at org.junit.runner.JUnitCore.run(JUnitCore.java:130)
>        at 
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
> Caused by: org.qi4j.api.common.ConstructionException: Could not find
> the subclass method
>        at 
> org.qi4j.runtime.composite.CompositeMethodModel.newCompositeMethodInstance(CompositeMethodModel.java:204)
>        at 
> org.qi4j.runtime.composite.CompositeMethodModel.getInstance(CompositeMethodModel.java:172)
>        at 
> org.qi4j.runtime.composite.CompositeMethodModel.invoke(CompositeMethodModel.java:156)
>        at 
> org.qi4j.runtime.composite.CompositeMethodsModel.invoke(CompositeMethodsModel.java:117)
>        at 
> org.qi4j.runtime.composite.AbstractCompositeModel.invoke(AbstractCompositeModel.java:144)
>        at 
> org.qi4j.runtime.composite.TransientInstance.invokeComposite(TransientInstance.java:79)
>        at 
> org.qi4j.runtime.service.ComplexActivatableTest_DomainType_Stub.activate(Unknown
> Source)
>        at org.qi4j.runtime.composite.MixinModel.activate(MixinModel.java:317)
>        at 
> org.qi4j.runtime.composite.AbstractMixinsModel.activate(AbstractMixinsModel.java:301)
>        at 
> org.qi4j.runtime.service.ServiceModel.activate(ServiceModel.java:339)
>        at 
> org.qi4j.runtime.service.ServiceInstance.activate(ServiceInstance.java:58)
>        at org.qi4j.runtime.service.Activator.activate(Activator.java:61)
>        at 
> org.qi4j.runtime.service.ServiceReferenceInstance.getInstance(ServiceReferenceInstance.java:118)
>        ... 24 more
> Caused by: java.lang.NoSuchMethodException:
> org.qi4j.runtime.service.ComplexActivatableTest_ActivationMixin_Stub._activate()
>        at java.lang.Class.getMethod(Class.java:1605)
>        at 
> org.qi4j.runtime.composite.CompositeMethodModel.newCompositeMethodInstance(CompositeMethodModel.java:201)
>        ... 36 more

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to