is JAXP threadsafe

Hi,

I am writing a server application in Java which will read a XML file and maintain its DOM structure in memory. This DOM structure will be accessed by multiple threads simultaneously. Some of the threads may modify some nodes. I do not want any thread which is reading a part of the DOM to read partically modified nodes.

Is there any way to lock access to a particular node in a DOM tree. The JAXP documentation does not mention if the methods are synchronized.

Will I have to write a wrapper class around my DOM tree which has synchronized methods ?

Most of the threads will be performing read operation, I do not want the performance of the read operations to suffer because of synchronizing the methods in the wrapper.

Please let me know if you have a solution.

Regards,

Manvendra

[843 byte] By [manvendra] at [2007-9-26 1:56:56]
# 1

Hi Mavendra

As far as I understand it, JAXP is just a wrapper around any specific DOM implementation. That means you have to check the individual DOM implementations (Xerces, Crimson, etc.) for thread safety. I couldn't remeber reading anything about that in the DOM recomendation of the W3C, so I guess it is a bit unlikely that common implementations are thread-safe. I found some postings about this topic on IBMs alphaworks web-site. They basically say that Xerces (or xml4j) can not be considered thread-safe, although these postings were quite old.

Unless you want to implement your own, thread safe, DOM implementation, I guess you have to write some kind of wrapper that makes sure that methods are only called in a synchronised way.

Mathias

mneumi at 2007-6-29 3:12:53 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...