|
|
(22 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] |
− | |info=y | + | ''' |
− | |api=y
| + | |
− | |apis= * [http://www.eclipse.org/eclipselink/api/2.1/index.html?org/eclipse/persistence/jaxb/JAXBContextFactory.html *.jaxb.JAXBContextFactory]
| + | |
− | |eclipselink=y
| + | |
− | |eclipselinktype=MOXy
| + | |
− | }}
| + | |
| | | |
− | =Specifying the EclipseLink Runtime=
| + | http://www.eclipse.org/eclipselink/documentation/2.4/moxy/runtime001.htm |
− | | + | |
− | 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.
| + | |
− | # Create a <tt>JAXBContent</tt> using the standard APIs. When this method is called, MOXy attempts to locate a <tt>jaxb.properties</tt> file on the classpath in the package specified by <tt>contextPath</tt>, and use the specified factory.<br><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.
| + | |
− | | + | |
− | The <tt>JAXBContextFactory</tt> can
| + | |
− | * Create a <tt>JAXBContext</tt> from an array of Classes and a Properties object
| + | |
− | * Create a <tt>JAXBContext</tt> from a context path and a ClassLoader
| + | |
− | | + | |
− | | + | |
− | {{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 DRAFT}}
| + | |