Can a JAXB ObjectFactory instance be shared / reused?
Asked Answered
T

0

6

When using the ObjectFactory class generated by JAXB (from an XSD), I'd like to store it in a field or even constant, so I don't have to pass it around between private methods. As far as I can tell, the ObjectFactory does not have any state, at least for no schema I have used.

  1. Are there cases, e.g. when using specific XSD constructs or JAXB properties, where the ObjectFactory is not stateless?

  2. If there are, is it safe to use a static constant for storing the ObjectFactory or are there thread safety issues?

Tropophilous answered 19/4, 2017 at 11:28 Comment(1)
Looking at the source code: grepcode.com/file/repo1.maven.org/maven2/org.docx4j/docx4j/… I don't think there's any issues since all those methods call new and pass only seem to use local or static variables in their construction.Semicircle

© 2022 - 2024 — McMap. All rights reserved.