Quoting Niclas Hedhman <[email protected]>:

On Wed, Jan 20, 2010 at 9:39 PM, Stanislav Muhametsin
<[email protected]> wrote:

@Mixins({MyEmptyInterface.MyLifecycleMixin.class})

Is this a bug or a feature?

It is a feature (which unfortunately bites you in the butt often). The
@Mixins annotation is NOT "put in these Mixins" but a list of "Here
are the Mixins that you can pick method implementations from". So, the
Composite interface is scanned for methods, and for each found method
it will look in the list of mixins and pick a method that is
compatible, and for each of the classes found the instantiation will
occur.

I assume this also happens when I want to implement Initializable interface
instead of Lifecycle, however I did not test this.

Yes, Initializable is checked upon instantiation of the Mixin.


Note that "methods" in my explanation also includes the methods of the
Private Mixin references, i.e.

@This
private Niclas mixin;

and can often help in the situations I think you are exploring.



I dug this email out from naphtaline, as I kinda run into a problem with Lifecycle. I implemented the code example shown in Lifecycle's javadoc (and fixed numerous typos and errors). I ran the test, and it didn't call the create() method. As a consequence, it threw ConstaintViolationException, as the admin() property was never set.

Then I search my mail folder and found this mail. Niclas mentioned searching methods of private mixins, and I thought he meant to add something like this into SystemAdminMixin:

    @This private Dummy _dummy;

    public static interface Dummy
    {
        public void dummy();
    }
    public static class DummyMixin
        implements Dummy
    {
        public void dummy() {}
    }

But, alas, it still didn't work. Even adding Lifecycle to implementation list of DummyMixin didn't work. In fact, I could leave out the whole DummyMixin from @Mixins-list of SystemEntity and Qi4j runtime would still start up. It seems that it doesn't scan these private mixins anymore?

Since I've misunderstood this issue before, I rather ask here first than create JIRA issue. So, the question: how do I implement Lifecycle functionality for role-interfaces, which are empty or have only Property/Association/ManyAssociation methods?



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

Reply via email to