Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/UserGuide/MOXy/Runtime/Bootstrapping"
< EclipseLink | UserGuide | MOXy | Runtime
Line 41: | Line 41: | ||
== Bootstrapping from Classes == | == Bootstrapping from Classes == | ||
+ | |||
+ | If you already have a collection of Java '''Classes''' annotated with JAXB annotations, you can provide an array of these '''Classes''' directly: | ||
+ | |||
+ | <source lang="java"> | ||
+ | JAXBContext context = JAXBContext.newInstance(Company.class, Employee.class); | ||
+ | </source> | ||
Revision as of 11:41, 10 June 2011
EclipseLink MOXy
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API
Contents
Bootstrapping
EclipseLink MOXy offers several options when creating your JAXBContext. You have the option of bootstrapping from:
- A list of one or more JAXB-annotated Classes
- A list of one or more EclipseLink OXM Bindings Files defining the mappings for your Java classes
- A combination of Classes and OXM files
- A Session name, referring to an EclipseLink Session defined in sessions.xml
JAXBContext API
The following methods on JAXBContext are used to create new instances of JAXBContexts:
public static JAXBContext newInstance(Class... classesToBeBound) throws JAXBException public static JAXBContext newInstance(Class[] classesToBeBound, Map<String,?> properties) throws JAXBException public static JAXBContext newInstance(String contextPath) throws JAXBException public static JAXBContext newInstance(String contextPath, ClassLoader classLoader) throws JAXBException public static JAXBContext newInstance(String contextPath, ClassLoader classLoader, Map<String,?> properties) throws JAXBException
- classesToBeBound - List of Java classes to be recognized by the new JAXBContext.
- contextPath - List of Java package names that contain mapped classes.
- classLoader - The class loader used to locate the mapped classes.
- properties - A map of additional properties.
Bootstrapping from Classes
If you already have a collection of Java Classes annotated with JAXB annotations, you can provide an array of these Classes directly:
JAXBContext context = JAXBContext.newInstance(Company.class, Employee.class);