Bug 412236 - Instead of @XmlSeeAlso, scan for subclasses dynamically (use Jandex)
Summary: Instead of @XmlSeeAlso, scan for subclasses dynamically (use Jandex)
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-03 13:26 EDT by Ondrej Zizka CLA
Modified: 2022-06-09 10:10 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Zizka CLA 2013-07-03 13:26:46 EDT
When unmarshalling to subclasses, they may be declared using @XmlSeeAlso.

When they are not known beforehand, one has to put them into the JAXBContext.
(This requirement may come e.g. for pluginable applications.)

My suggestion is to scan the classes on classpath with Jandex and use that to retrieve subclasses of particular class.

It brings few questions, like, how to get the jars on the classpath to give Jandex to scan etc. But I assume it's solvable, as CDI RI (Weld) can do that. It can also filter out some packages to speed up. Maybe Jandex can't do all the things necessary - maybe CDI could be reused for that? CDI developer just told me that it's the container what does the Jandex calls, and provides the index object for particular deployment to Weld.

Anyway, having MOXy doing this would be cool.

Regarding performance - Jandex can store index files at given location, usually next to .jar, and after that it reads the file pretty quickly. So user could specify a location to store the indexes to, for his app. Could go next to jar, or to /tmp/moxy/jandex, or app's root dir... Jandex index can also be created at build-time, eg. there's a Maven plugin.
Anyway, it should be optional, maybe through using another annotation like @XmlScanForSubclasses, or, not to clutter the annotation space, perhaps some MOXy's annotation's parameter.

Thanks for considering.
Comment 1 Eclipse Webmaster CLA 2022-06-09 10:10:08 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink