On Fri, Aug 12, 2011 at 11:51 AM, Rickard Öberg <[email protected]> wrote:
> What would access code look like? What would the Associations reference?
> Association<Entity<Person>>?
>
> Values are immutable. What would modification code look like?
I think something like this;
* An Identity can have one Value per Mixin Type associated with it.
* UnitOfWork is used to set/get the values of an identity.
* The Entity meta type can also be accessed from UoW for the meta
data around the Identity.
So normally,
Person p1 = ...;
uow.set( "123", Person.class, p1 );
Person p2 = uow.get( "123", Person.class );
assertEquals( p1, p2 );
p1 == p2 is undefined and subject to impl details in Qi4j internals.
Entity p = uow.get( "123", Entity.class )
will return all information known about the Identity "123".
Which Mixins has been assigned to it? lastModified as an aggregate.
lastModified for each mixin, version data and so on.
The trickier bit, which I have not spent to much thinking about is
whether it should have automatic mixin aggregation, so that;
Motorized m = ....;
uow.set( "123", Motorized.class, m );
TwoWheler t = ...;
uow.set( "123", TwoWheeler.class, t );
and if
Motorbike extends TwoWheeler, Motorized
would
Motorbike b = uow.get( "123", Motorbike.class );
return a Motorbike value instance with state from the two individual
set operations?
GutFeeling is "yes".
Entity is possibly wrong name
public interface EntityTypeDescriptor
{
String identity();
DateTime created();
DateTime lastModified();
MixinTypeDescriptor[] mixins();
<T> T metaInfo( Class<T> metaInfoType );
<T> T getMixin( Class<T> mixin ); // reflexive access
}
public interface MixinTypeDescriptor
{
Class mixinType();
Annotation[] annotations();
<T> T metaInfo( Class<T> metaInfoType );
PropertyDescriptor[] properties();
AssociationDescriptor[] associations();
ManyAssociationDescriptor[] manyAssociations();
NamedAssociationDescriptor[] namedAssociations();
}
the associations might be collapsed into a single one.
This is just a 15 min dump of what has been brewing in the back of my
mind for quite a long time, and by no means backed by any detailed
analysis. The main difference now from last week is that last week I
was on the track that an identity could only have a single value,
whereas now I leaning towards the model above with many.
WDYT? (I am sick today, so perhaps can put in a few more hours on this later...)
Cheers
--
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java
I live here; http://tinyurl.com/3xugrbk
I work here; http://tinyurl.com/24svnvk
I relax here; http://tinyurl.com/2cgsug
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev