Hey,
Now that I'm starting to use the REST EntityStore *for real* in
StreamFlow I'm getting into some interesting problems. Funny how that
always happens when you do things for real :-)
Currently the webserver does not have to know the domain model at all,
as the client access state as just that, state. But, this also means
that the webserver does not have the EntityType for the stored entities,
which is a problem. I have fixed this by ensuring that EntityTypes for
any new entities in a UoW gets their EntityTypes registered on the server.
But a more important question is how to deal with evolution of types.
Currently you access the state of one Entity by doing this:
http://host/qi4j/entity/<type>/<id>
This is fine if the server and client have the same versions of types,
but after some time this will not be the case. Example: in v1 an Entity
is accessed like this:
http://host/qi4j/entity/org.host.myapp.MyEntity/1234
Then the EntityType is refactored and so the client now expects it to be at:
http://host/qi4j/entity/org.host.myapp.SomeEntity/1234
to which the server will just answer 404! There are a couple of ways to
solve this, and I'm not sure what is best. One is to remove the type
from the URL:
http://host/qi4j/entity/1234
Then the type can change as much as it wants, and it will still work.
The problem here is that the server-side of this will have to call
EntityStore.getEntityState() which takes a QualifiedIdentity as input,
which includes the type. So that's no good.
Another way to do this is to use schema versions instead of type names.
If the Entity is accessed like this:
http://host/qi4j/entity/2aejfb43/1234
where "2aejfb43" is the computed version of the EntityType, then we are
not only requesting a specific Entity id, but also a specific version of
the type. The REST-server-resource can translate this into a
QualifiedIdentity by asking the EntityStore for its registered
EntityTypes and checking which one corresponds to the hash in the URL.
But... hm... this is all wrong. We cannot specify type to an EntityStore
based on type names, since one EntityStore can easily have 10 different
versions of the same type name simultaneouosly!! In other words, the
type name (org.host.myapp.MyEntity) is NOT unique within an EntityStore
as a key to register the type, just as "HTML" is not enough to declare
the type of a webpage. It needs to be "HTML 3" or "HTML 4.01" or
similar, and we probably have to do the same thing here! The ONLY thing
that is unique enough is the computed version of the type. Maybe this is
what should be used for QualifiedIdentities instead?
This requires thinking. Any ideas?
/Rickard
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev