2009/11/19 Niclas Hedhman <[email protected]>
> On Wed, Nov 18, 2009 at 10:03 PM, Jacek Sokulski <[email protected]>
> wrote:
>
> > Still a bit confused, but I think I see now your points why this is a
> > feature and a way for DCI implementation. What bothered me was that
> mixins
> > interactions is mainly through row state, somehow I have missed other
> > possibilities.
>
> Uhhh? No, you don't have to (and perhaps shouldn't) share raw state
> between mixins, and instead use the regular Qi4j features.
>
> public class TheaterMixin
> {
> @This ScriptManagement sm;
> :
> }
>
> @Mixins( ScriptManagementMixin.class )
> public interface ScriptManagement
> {
> Script findMostAppropriateScript( Conditions cond );
> void addAvailableScript( Script script );
> void removeAvailableScript( Script script );
>
> interface State
> {
> ManyAssociation<Script> scriptsAvailable();
> }
> }
>
> @Mixins( TheaterMixin.class )
> public interface TheaterEntity extends Theater, EntityComposite
> {}
>
>
> In the above "sample", the ScriptManagement is a private mixin (role
> if you like) that doesn't intend to "publish" its internal state, but
> the ScriptManagement.State is part of the Entity's state and will be
> saved with the rest of the state of that entity.
>
In most available examples the state is either part of the composite
interface like:
public interface Book
{
Property<String> name();
Property<String> title();
}
public interface BookComposite extends Book, EntityComposite
{}
or a separate publicly available interface like:
public interface HelloWorldState
{
@NotEmpty Property<String> phrase();
@NotEmpty Property<String> name();
}
public class HelloWorldMixin ...
{
@This HelloWorldState state;
....
}
I got impression that this is a suggested pattern of usage. The usage as you
have given above makes me feel much better...
Thanks for your time explaining all this staff
Jacek
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev