Concurrency and reuse of org.w3c.dom.Node

From here I learned that org.w3c.dom.Node(and other classes in one package) are not thread safe.

I ask myself how and how should I cache these classes?

  • Is there a better approach?
  • Are there immutable wrapper classes?
  • Should I use ThreadLocalfor DocumentBuilder/ DocumentBuilderFactoryinstead and recreate Nodeevery time?
  • What are you doing?
+3
source share
3 answers

You do not want to cache the XML document. It would be better to read / parse it into a "configuration" object. Depending on how complicated or complex your configuration is, it could be a simple map or something more complex.

( concurrency ) , XML- . , , XML, XML. , . Hibernate - .

, XML.

+1

- /. ( DOM , DOM ), . , . , "", .

+1

Sorry, this is not really the answer, but if usecase is the model of the configuration file that will be used for multiple threads. where the recording with the configuration takes place. If it is read and used several times, do you need synchronization? Did I miss something?

0
source

All Articles