Skip to main content
Jump to: navigation, search

EclipseLink/UserGuide/MOXy/Runtime/Bootstrapping/JAXB properties

EclipseLink MOXy

Eclipselink-logo.gif
EclipseLink
Website
Download
Community
Mailing ListForumsIRCmattermost
Bugzilla
OpenHelp WantedBug Day
Contribute
Browse Source


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:

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory


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.

DynamicJAXBContext jaxbContext = (DynamicJAXBContext) JAXBContext.newInstance("example");

Back to the top