[jdom-interest] XMLOutputter & currentFormat

Rolf Lear rlear at algorithmics.com
Fri Dec 20 11:42:18 PST 2002


XMLFormat is very close to being "thread-friendly" ... I know that JDom does
not attempt thread-safeness, but hear me out.

Once XMLOutputter is instantiated, and the defaultFormatter is set, then the
"output" methods can be called any number of times concurrently without
breaking things ... except for the "currentFormat". This may be changed if
an Element has a "space" attribute.

The currentFormat is stored as an instance variable, and thus, if the data
in one thread changes the current format, then all threads will take on the
new format.

This is relatively easily corrected by having the format cascade down the
element tree as the XML Is output.

This will/may break objects which extend the XMLOutputter....

Pro's:
   XMLOutputter needs only one instance per Format permutation, instead of
one instance per thread.

Con's:
   Break classes which extend XMLOutputter (none in JDom, but may be
outside).
   XMLOutputter is relatively "light" anyway, and the memory saved would be
relatively small.

I have a patch available which makes the above change, and I have been using
it myself.

Are attachments permitted on this list?

Rolf


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20021220/0ade7067/attachment.htm


More information about the jdom-interest mailing list