RE: id objects & prevayler

Jon Tirsén <[email protected]> Tue, 11 Feb 2003 08:10:06 +0100
Newsgroups gmane.comp.java.nanning.devel
Message-ID <000a01c2d19c$9c056da0$6c4a59d5@jon>
Almost correct. The main problem is how Prevayler works. Since a
complete snapshot of the system is stored in a single file there will be
no problems of actually modifying the objects. The problem is with how
commands are stored. They are stored in a separate file and references
from commands to objects are thus not correct.

This example explains it better:
Say you have an object A and a _command_ C. The C command executes
A.setProperty(property) with a new value and thus takes an A and a new
value as parameters. All parameters are stored in the command log.
If I stored a direct reference to A in the command C this A (and
everything it references) would be stored together with the command,
when the command was unserialized I would have two copies of A, one
would belong to the actual system and one would belong to the command.
Thus the actual command execution on A wouldn't do anything because it's
not the correct A.
Instead I store a reference to A (an object id) that I resolve against
the actual system I want to modify (by doing getObjectWithID) this way I
get the correct object to modify. This is being done here:
http://nanning.sourceforge.net/xref/com/tirsen/nanning/samples/prevayler
/Identity.html#44
The object id is retrieved and stored here:
http://nanning.sourceforge.net/xref/com/tirsen/nanning/samples/prevayler
/IdentifyingCall.html#70

As an experiement try to see what happens if you replace this:
http://nanning.sourceforge.net/xref/com/tirsen/nanning/samples/prevayler
/IdentifyingCall.html#43
from 
args = marshalArguments(invocation.getArgs());
Into
args = invocation.getArgs();
That is remove the id-resolution. Run the test and you'll see what
happens.

> -----Original Message-----
> From: Steve Conover [mailto:[email protected]] 
> Sent: Tuesday, February 11, 2003 1:22 AM
> To: [email protected]
> Subject: id objects & prevayler
> 
> 
> Jon - I think I have stumbled on why to use Id objects, and I 
> wanted to run this by you first.
> 
> Let's say you have classes A and B, with A.get/setB, and one 
> object of each type is stored sequqntially in a List that's 
> Prevayler-ized.  The question is, how do you update B?  You 
> couldn't remove B and add the updated B (let's call these two 
> things B1 and B2) - A would still reference B1.  However if A 
> actually referenced an Id that pointed to B, you could 
> actually overwrite B1 with B2 and maintain data integrity.
> 
> Anyway, does that sound right?  Are there any other reasons 
> you can think of you use these id objects?
> 
> Regards,
> Steve
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now. 
http://mailplus.yahoo.com



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com