[jdom-interest] Re: XML document transfer performance
Dennis Sosnoski
dms at sosnoski.com
Mon Oct 1 13:32:37 PDT 2001
I certainly don't disagree with you on the slowness of Java default
serialization for XML documents, the charts at
http://www.sosnoski.com/opensrc/xmls/results.html demonstrate this pretty
clearly. It seems to me that there still may be cases where a user wants to use
default serialization, though, especially where they've subclassed the JDOM
classes and added information beyond what's contained in the document per se.
You can add another possibility to my earlier suggestions on how to allow both
types of serialization, though. Add a serial format flag to Document and
implement writeObject. This first writes the flag setting to the output stream,
and then either writes the document in XLMS (or other custom format chosen as
the JDOM standard) or calls out.defaultWriteObject for the Document to use
default serialization, as selected by the flag. Implement readObject to first
read the flag from the input stream and then use the corresponding technique for
rebuilding the document.
That way the custom format can be the default, but this can easily be changed by
the user while using the same classes either way.
- Dennis
Joseph Bowbeer wrote:
> I suspect that using Java's default serialization for XML document objects
> will be incredibly slow and apt to stack overflow. Also, because it exposes
> the internals of the implementation, it won't support transmission between
> independent JDOM implementations -- unless the entire implementation becomes
> part of the specification.
>
> So I think some efficient, implementation-independent serialized format is
> desirable. (Something similar to your format?)
>
> By the way, I remember we had a discussion a while back concerning whether
> JDOM objects should be Serializable or Externalizable:
>
> http://www.servlets.com/archive/servlet/ReadMsg?msgId=7697
>
> "Externalizable is less work for us and has less overhead. Serializable
> is more work for us (e.g., marking all the fields transient), but is also
> more extensible (via defaultWriteObject) and is friendlier to subclassers.
> ... I favor Serializable."
More information about the jdom-interest
mailing list