Skip to main content

@XMLSeeAlso

1 reply [Last post]
yelin66
Offline
Joined: 2010-08-06
Points: 0

JAXB 2.1 introduces the @XMLSeeAlso annotation that enables JAXB to bind additional Java classes. I am not exactly sure what problem it tries to address? Basically, the problem we are facing is that the @XMLSeeAlso annotation makes the base class tightly coupled to the sublclasses, and have unnecessary dependency on the subclasses. And in real world use cases, it's not realistic to make the base class have the knowledge of all potential subclasses, unless with the price of no extension at all. So is there a way to disable generating the @XMLSeeAlso annotation? And what would it break doing so? Bascially, in JAXB2.0 without @XMLSeeAlso annotation, how is the issue got handled? Response will be appreciated.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
blaise_doughan
Offline
Joined: 2003-09-30
Points: 0

Hello,
The purpose of the @XmlSeeAlso annotation is to reduce the initial number of classes that need to be passed in to bootstrap the JAXBContext. It is often used with inheritance hierachies. Since Java cannot determine all of a classes subclasses, without @XmlSeeAlso you would have had to explicitly pass these in when creating the JAXBContext.
-Blaise