[jdom-interest] Making setMixedContent appear atomic

philip.nelson at omniresources.com philip.nelson at omniresources.com
Mon Apr 16 18:23:21 PDT 2001


> All this assumes that you will always have access to the offending
> source code,
> and that they are happy to fix it in a reasonable time scale.
> 
> Also what if this data is very important and has a very high value
> placed on
> it (like your pay cheque for example !) and the program 
> trashed the data
> and
> it was gone with no way of getting it back, you would not be 
> able to do
> the
> following.

Well, so long as we're talking about *your* paycheck...
> 
> 
> try {
>    tranferElement.setMixedContent(createPayCheque());
> } catch (IllegalAddException iae) {
>    // Oops, better save the original doc, we might need it.
>    // save the original document
> } 
So we would force people to code their own transaction
 try {
    List backup = tranferElement.getMixedContent();
   //duplicate the data
    tranferElement.setMixedContent(createPayCheque());
 } catch (IllegalAddException iae) {
    //restore the duplicate.
    // Oops, better save the original doc, we might need it.
    // save the original document
 } 

Somehow that doesn't seem to bad.  In your example, you wouldn't had much
until your check was created anyway.  If there weren't some possible heavy
consequences to always duplicating the data, it might not be a big deal, but
between large documents, subclasses and nulls, it just doesn't seem worth
it.

So, how about we reset the list to Collections.EMPTY_LIST, throw the NPE or
IllegalAddException and call it a day.  @throws and other comments in
JavaDoc says just what happens.  Simple, clear and easy enough to code
around.

Is FilterList serializable?



More information about the jdom-interest mailing list