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 Dynamic/Specifying the EclipseLink Runtime"
< EclipseLink | UserGuide | MOXy | Runtime | Bootstrapping Dynamic
Line 34: | Line 34: | ||
* <tt>classLoader</tt> - The application's current class loader, which will be used to first lookup classes to see if they exist before new <tt>DynamicTypes</tt> are generated. | * <tt>classLoader</tt> - The application's current class loader, which will be used to first lookup classes to see if they exist before new <tt>DynamicTypes</tt> are generated. | ||
* <tt>properties</tt> - A map of properties to use when creating a new <tt>DynamicJAXBContext</tt>. This map must contain one of the following keys: | * <tt>properties</tt> - A map of properties to use when creating a new <tt>DynamicJAXBContext</tt>. This map must contain one of the following keys: | ||
− | **<tt>JAXBContext. | + | |
+ | **<tt>JAXBContext.XML_SCHEMA_KEY</tt>, which can have several possible values: | ||
***One of the following, pointing to your OXM file: <tt>java.io.File</tt>, <tt>java.io.InputStream</tt>, <tt>java.io.Reader</tt>, <tt>java.net.URL</tt>, <tt>javax.xml.stream.XMLEventReader</tt>, <tt>javax.xml.stream.XMLStreamReader</tt>, <tt>javax.xml.transform.Source</tt>, <tt>org.w3c.dom.Node</tt>, or <tt>org.xml.sax.InputSource</tt>. | ***One of the following, pointing to your OXM file: <tt>java.io.File</tt>, <tt>java.io.InputStream</tt>, <tt>java.io.Reader</tt>, <tt>java.net.URL</tt>, <tt>javax.xml.stream.XMLEventReader</tt>, <tt>javax.xml.stream.XMLStreamReader</tt>, <tt>javax.xml.transform.Source</tt>, <tt>org.w3c.dom.Node</tt>, or <tt>org.xml.sax.InputSource</tt>. | ||
***A <tt>List</tt> of objects from the set above. | ***A <tt>List</tt> of objects from the set above. | ||
− | ***A <tt>Map<String, Object></tt>, where <tt>String</tt> is a package name, and <tt>Object</tt> is the pointer to the OXM file, from the set of possibilities above. If using this option, a <tt>package-name</tt> element is not required in the <tt>xml-bindings</tt> | + | ***A <tt>Map<String, Object></tt>, where <tt>String</tt> is a package name, and <tt>Object</tt> is the pointer to the OXM file, from the set of possibilities above. If using this option, a <tt>package-name</tt> element is not required in the <tt>xml-bindings</tt> element of your OXM file. |
− | element of your OXM file. | + | |
+ | **<tt>JAXBContext.ECLIPSELINK_OXM_XML_KEY</tt>, which can have several possible values: | ||
+ | ***One of the following, pointing to your OXM file: <tt>java.io.File</tt>, <tt>java.io.InputStream</tt>, <tt>java.io.Reader</tt>, <tt>java.net.URL</tt>, <tt>javax.xml.stream.XMLEventReader</tt>, <tt>javax.xml.stream.XMLStreamReader</tt>, <tt>javax.xml.transform.Source</tt>, <tt>org.w3c.dom.Node</tt>, or <tt>org.xml.sax.InputSource</tt>. | ||
+ | ***A <tt>List</tt> of objects from the set above. | ||
+ | ***A <tt>Map<String, Object></tt>, where <tt>String</tt> is a package name, and <tt>Object</tt> is the pointer to the OXM file, from the set of possibilities above. If using this option, a <tt>package-name</tt> element is not required in the <tt>xml-bindings</tt> element of your OXM file. | ||
{{EclipseLink_MOXy | {{EclipseLink_MOXy | ||
|next= [[EclipseLink/UserGuide/MOXy/Runtime/Bootstrapping/From_Schema|From XML Schema]] | |next= [[EclipseLink/UserGuide/MOXy/Runtime/Bootstrapping/From_Schema|From XML Schema]] |
Revision as of 12:50, 6 January 2011
EclipseLink MOXy
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API
Specifying the EclipseLink Runtime
In order to use EclipseLink Dynamic MOXy as your JAXB implementation, you must identify the EclipseLink DynamicJAXBContextFactory in your jaxb.properties file.
- Create a text file named jaxb.properties, specifying DynamicJAXBContextFactory as the factory used to build new JAXBContexts.
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory
- Copy the file to your application package (or any of your packages on your classpath).
- Use the standard JAXBContext.newInstance(String contextPath) API to create a DynamicJAXBContext.
DynamicJAXBContext jaxbContext = (DynamicJAXBContext) JAXBContext.newInstance("org.example.mypackage");
Because you do not need to change any application code, you can easily switch between different JAXB implementations.
The following methods on DynamicJAXBContextFactory can be used to create DynamicJAXBContexts:
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
- contextPath - Location of jaxb.properties file.
- classLoader - The application's current class loader, which will be used to first lookup classes to see if they exist before new DynamicTypes are generated.
- properties - A map of properties to use when creating a new DynamicJAXBContext. This map must contain one of the following keys:
- JAXBContext.XML_SCHEMA_KEY, which can have several possible values:
- One of the following, pointing to your OXM file: java.io.File, java.io.InputStream, java.io.Reader, java.net.URL, javax.xml.stream.XMLEventReader, javax.xml.stream.XMLStreamReader, javax.xml.transform.Source, org.w3c.dom.Node, or org.xml.sax.InputSource.
- A List of objects from the set above.
- A Map<String, Object>, where String is a package name, and Object is the pointer to the OXM file, from the set of possibilities above. If using this option, a package-name element is not required in the xml-bindings element of your OXM file.
- JAXBContext.XML_SCHEMA_KEY, which can have several possible values:
- JAXBContext.ECLIPSELINK_OXM_XML_KEY, which can have several possible values:
- One of the following, pointing to your OXM file: java.io.File, java.io.InputStream, java.io.Reader, java.net.URL, javax.xml.stream.XMLEventReader, javax.xml.stream.XMLStreamReader, javax.xml.transform.Source, org.w3c.dom.Node, or org.xml.sax.InputSource.
- A List of objects from the set above.
- A Map<String, Object>, where String is a package name, and Object is the pointer to the OXM file, from the set of possibilities above. If using this option, a package-name element is not required in the xml-bindings element of your OXM file.
- JAXBContext.ECLIPSELINK_OXM_XML_KEY, which can have several possible values: