Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/MOXy/Runtime/Bootstrapping/JAXB properties"

m
 
Line 1: Line 1:
{{EclipseLink_UserGuide
+
'''[[Image:Elug_draft_icon.png|Warning]] This page is obsolete. Please see ''[http://www.eclipse.org/eclipselink/documentation/ Developing JAXB Applications Using EclipseLink MOXy]'' for current information.'''
|info=y
+
|eclipselink=y
+
|eclipselinktype=MOXy
+
|api=y
+
|apis= * [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/jaxb/dynamic/DynamicJAXBContextFactory.html DynamicJAXBContextFactory]
+
}}
+
 
+
= Bootstrapping using jaxb.properties =
+
 
+
The JAXB Specification supports another way of creating '''JAXBContexts'''; by specifying a factory class in a '''jaxb.properties''' file and then using the '''JAXBContext.newInstance()''' API.  '''DynamicJAXBContexts''' can be created in this way as well.
+
 
+
First, we create a '''jaxb.properties''' file with the following contents, specifying our '''DynamicJAXBContextFactory''' as the factory used to build new '''JAXBContexts'''.  Place the '''jaxb.properties''' file on your classpath in the package that your '''DynamicEntites''' will be generated in (in our example, the '''example''' package).
+
 
+
 
+
'''jaxb.properties''':
+
<source lang="text">
+
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory
+
</source>
+
 
+
 
+
Now, you can use the '''newInstance(String contextPath)''' method to create a '''DynamicJAXBContext'''.  When this method is called, MOXy attempts to locate a '''jaxb.properties''' file on the classpath in the package specified by '''contextPath''', and use the specified factory.
+
 
+
<source lang="java">
+
DynamicJAXBContext jaxbContext = (DynamicJAXBContext) JAXBContext.newInstance("example");
+
</source>
+

Latest revision as of 12:17, 30 January 2013

Warning This page is obsolete. Please see Developing JAXB Applications Using EclipseLink MOXy for current information.