[Biojava-l] Changable and rollbacks

Schreiber, Mark mark.schreiber@agresearch.co.nz
Tue, 15 May 2001 08:48:42 +1200


Yes -

I either need to modify all the objects or none of them. The only way i can
think of doing this at the moment is wrapping the objects in a clonable
wrapper and keeping a backup copy in case something goes wrong, or
serializing a backup copy, any other ideas?

- Mark


Mark Schreiber
Bioinformatics
AgResearch Invermay
PO Box 50034
Mosgiel
New Zealand

PH: +64 3 489 9175

 

> -----Original Message-----
> From: Matthew Pocock [mailto:mrp@sanger.ac.uk]
> Sent: Tuesday, May 15, 2001 1:16 AM
> To: Forsch, Dan
> Cc: Schreiber, Mark; 'Biojava-L (E-mail)
> Subject: Re: [Biojava-l] Changable and rollbacks
> 
> 
> Hi Dan,
> 
> I agree - preChange should do nothing except potentialy throw a 
> ChangeVetoException, and postChange should be the method used 
> to update 
> state. However, if I have 5 sequences, each of which I am 
> going to add 
> some features to, and want to either add all features to each 
> sequence 
> or do nothing, there is currently no way to do this. We can 
> process each 
> feature addition individualy, but we can't invoke preChange for every 
> listener for each change before *any* of the changes are 
> executed, then 
> perform *all* changes and then invoke all postChange methods.
> 
> Mark, is this what you wanted to be able to do?
> 
> M
> 
> Forsch, Dan wrote:
> 
> > I would think that this is easily supported by the current 
> model, at least
> > the way I understand Mark's question.  The preChange() 
> method's signature
> > throws ChangeVetoException and postChange() does not.  When 
> preChange() is
> > called you cannot be guaranteed that the change won't be 
> vetoed by another
> > listener, so a reasonable implementation of preChange() is 
> to veto if you
> > care to and do nothing otherwise.  The postChange() method is where
> > listeners can safely make any response to the change that 
> has ocurred.  If
> > any listener has vetoed, postChange() should never be 
> called.  Rather than
> > rolling back changes made too soon, you should wait until 
> postChange() has
> > been called to alter the state of any listeners.
> > 
> > Dan Forsch, Principal Software Engineer
> > NetGenics, Inc.
> > 
> > 
> > 
> >> -----Original Message-----
> >> From: Matthew Pocock [mailto:mrp@sanger.ac.uk]
> >> Sent: Friday, May 11, 2001 4:45 AM
> >> To: Schreiber, Mark
> >> Cc: 'Biojava-L (E-mail)
> >> Subject: Re: [Biojava-l] Changable and rollbacks
> >> 
> >> 
> >> 
> >> This sort of thing is not easily supported with the current 
> >> model, but I 
> >> agree that it is a usefull thing to have. One way to do it 
> >> would be to 
> >> make an entity that represented the list of sequences and has a 
> >> commitAll style method. This would do some package-private 
> diddling 
> >> inside each sequence it contains to check the prechange 
> >> vetoes, and if 
> >> successfull perform each real commit.
> >> 
> >> This does, however, require us to think again about the 
> >> encapsulation of 
> >> the pre/post change infrastructure (particularly as we may need to 
> >> synchronize on some resource to maintain atomicity).
> >> 
> >> All thoughts welcome.
> >> 
> >> M
> >> 
> 
>