Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/MOXy/Runtime/Specifying the EclipseLink Runtime"

m
m
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{EclipseLink_UserGuide
+
'''[[Image:Elug_draft_icon.png|Warning]] For the current release, see [http://www.eclipse.org/eclipselink/documentation/2.4/moxy Developing JAXB Applications Using EclipseLink MOXy, EclipseLink 2.4]
|eclipselink=y
+
'''
|eclipselinktype=MOXy
+
|info=y
+
|api=y
+
|apis= * [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/jaxb/JAXBContext.html JAXBContext]
+
* [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/jaxb/JAXBContextFactory.html JAXBContextFactory]
+
* [http://www.eclipse.org/eclipselink/api/latest/javax/xml/bind/attachment/AttachmentMarshaller.html AttachmentMarshaller]
+
|toc=y
+
}}
+
  
 
+
http://www.eclipse.org/eclipselink/documentation/2.4/moxy/runtime001.htm
=Specifying the EclipseLink Runtime=
+
 
+
In order to use EclipseLink MOXy as your JAXB implementation, you must identify the EclipseLink <tt>JAXBContextFactory</tt> in your <tt>jaxb.properties</tt> file.
+
 
+
# Create a text file named <tt>jaxb.properties</tt>, specifying <tt>JAXBContextFactory</tt> as the factory used to build new <tt>JAXBContexts</tt>.<div><source lang="java">
+
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
+
</source></div>
+
# Copy the file to the same package (directory) in which your model classes reside.
+
# Use the standard <tt>JAXBContext.newInstance(Class... classesToBeBound)</tt> API to create a <tt>JAXBContext</tt>.<div><source lang="java">
+
JAXBContext jaxbContext = JAXBContext.newInstance(Customer.class);
+
</source></div>
+
 
+
Because you do not need to change any application code, you can easily switch between different JAXB implementations.
+
 
+
=Instantiating a JAXBContext=
+
 
+
The following methods on <tt>JAXBContext</tt> can be used to create new instances of <tt>JAXBContexts</tt>:
+
 
+
<source lang="java">
+
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
+
</source>
+
 
+
* <tt>classesToBeBound</tt> - List of Java classes to be recognized by the new <tt>JAXBContext</tt>.
+
* <tt>contextPath</tt> - List of Java package names that contain mapped classes.
+
* <tt>classLoader</tt> - The class loader used to locate the mapped classes.
+
* <tt>properties</tt> - A map of additional properties.
+
 
+
 
+
{{EclipseLink_MOXy
+
|next=[[EclipseLink/UserGuide/MOXy/Runtime/Bootstrapping|Bootstrapping]]
+
|previous=[[EclipseLink/UserGuide/MOXy/Runtime|Runtime]]
+
|up=[[EclipseLink/UserGuide/MOXy/Runtime|Runtime]]
+
|version=2.2.0}}
+

Latest revision as of 16:26, 6 November 2012

Warning For the current release, see Developing JAXB Applications Using EclipseLink MOXy, EclipseLink 2.4

http://www.eclipse.org/eclipselink/documentation/2.4/moxy/runtime001.htm

Copyright © Eclipse Foundation, Inc. All Rights Reserved.