blob: d9e52256a58d5d7e998db5df0be87c91968d78ff [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<title>Using Dynamic JAXB/MOXy | EclipseLink 2.7 Understanding EclipseLink</title>
<meta name="generator" content="Oracle DARB XHTML Converter (Mode = document) - Version 1.0.22 Build 1" />
<meta name="date" content="2014-06-10T10:35:15Z" />
<meta name="robots" content="noarchive" />
<meta name="doctitle" content="Using Dynamic JAXB/MOXy" />
<meta name="relnum" content="Release 2.7" />
<link rel="stylesheet" type="text/css" href="../../dcommon/style.css" media="screen" />
<link rel="copyright" href="../../dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
<link rel="start" href="../../index.htm" title="Home" type="text/html" />
<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
<link rel="prev" href="jpatoxml005.htm" title="Previous" type="text/html" />
<link rel="next" href="jpatoxml007.htm" title="Next" type="text/html" />
<!-- START: Disqus --><script type="text/javascript"> var disqus_developer = 0; </script><!-- END: Disqus --><!-- START: Sharethis --><script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript" src="http://s.sharethis.com/loader.js"></script> <!-- END: Sharethis --></head>
<body bgcolor="#FFFFFF"><iframe id="docheader" frameborder="0" framemargin="0" scrolling="no" src="../../dcommon/header.html"></iframe><script src="http://www.google.com/jsapi" type="text/javascript"></script><script type="text/javascript"> google.load('search', '1', {language : 'en'}); google.setOnLoadCallback(function() { var customSearchOptions = {}; var googleAnalyticsOptions = {}; googleAnalyticsOptions['queryParameter'] = 'q'; googleAnalyticsOptions['categoryParameter'] = ''; customSearchOptions['googleAnalyticsOptions'] = googleAnalyticsOptions; var customSearchControl = new google.search.CustomSearchControl( '016171230611334810008:enkkfjmsqju', customSearchOptions); customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); var options = new google.search.DrawOptions(); options.setSearchFormRoot('cse-search-form'); customSearchControl.draw('cse', options); }, true);</script><link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" /><div id="cse" style="width:100%;"></div>
<div class="header"><a id="top" name="top"></a>
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left" valign="top"><font face="helvetica, arial, sans-serif"><b>EclipseLink Solutions Guide for EclipseLink</b><br />
Release 2.7</div></td>
<td valign="bottom" align="right" width="144">
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>&nbsp;</td>
<td align="center" valign="top"><a href="toc.htm"><img src="../../dcommon/images/contents.png" alt="Go To Table Of Contents" border="0" height="16" width="16" /><br />
</td><td>&nbsp;</td><td align="center"><a href="../../" target="_top" class="external text" title="Search" rel="nofollow"><img src="../../dcommon/images/search.png" alt="Search" style="border:0;" /><br /><span class="mini"></span></a></td><td>&nbsp;</td><td align="center"><a href="../eclipselink_otlcg.pdf" title="PDF" target="_blank"><img src="../../dcommon/images/pdf_icon.png" style="padding-right:5px;border:0" alt="PDF"></a></td>
</tr>
</table>
</td>
</tr>
</table>
<hr />
<table class="navigation simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100" align="center">
<tr>
<td align="center"><a href="jpatoxml005.htm"><img src="../../dcommon/images/larrow.png" alt="Previous" border="0" height="16" width="16" /></a></td>
<td align="center"><a href="jpatoxml007.htm"><img src="../../dcommon/images/rarrow.png" alt="Next" border="0" height="16" width="16" /></a></td>
<td>&nbsp;</td>
</tr>
</table>
</div>
<!-- class="header" -->
<div class="ind"><!-- End Header --><a id="BEIHCDIB" name="BEIHCDIB"></a><a id="TLADG368" name="TLADG368"></a>
<div class="sect1"><!-- infolevel="all" infotype="General" -->
<h1 class="sect1"><font face="arial, helvetica, sans-serif" color="#330099">Using Dynamic JAXB/MOXy</font></h1>
<p>Dynamic JAXB/MOXy allows you to bootstrap a <code>JAXBContext</code> from a variety of metadata sources and use familiar JAXB APIs to marshal and unmarshal data, without requiring compiled domain classes. This is an enhancement over static JAXB, because now you can update the metadata without having to update and recompile the previously-generated Java source code.</p>
<p>The benefits of using dynamic JAXB/MOXy entities are:</p>
<ul>
<li>
<p>Instead of using actual Java classes (for example, <code>Customer.class</code>, <code>Address.class</code>, and so on), the domain objects are subclasses of the <code>DynamicEntity</code>.</p>
</li>
<li>
<p>Dynamic entities offer a simple <code>get(propertyName)</code>/<code>set(propertyName propertyValue)</code> API to manipulate their data.</p>
</li>
<li>
<p>Dynamic entities have an associated <code>DynamicType</code>, which is generated in-memory, when the metadata is parsed.</p>
</li>
</ul>
<p>The following Tasks demonstrate how to use dynamic JAXB:</p>
<ul>
<li>
<p><a href="#BEIFDBCA">Task 1: Bootstrap a Dynamic JAXBContext from an XML Schema</a></p>
</li>
<li>
<p><a href="#BEIDHGHI">Task 2: Create Dynamic Entities and Marshal Them to XML</a></p>
</li>
<li>
<p><a href="#BEIGCBBH">Task 3: Unmarshal the Dynamic Entities from XML</a></p>
</li>
</ul>
<a id="BEIFDBCA" name="BEIFDBCA"></a><a id="TLADG369" name="TLADG369"></a>
<div class="sect2">
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Task 1: Bootstrap a Dynamic JAXBContext from an XML Schema</font></h2>
<p>This example demonstrates how to bootstrap a dynamic <code>JAXBContext</code> from an XML Schema.</p>
<a id="TLADG370" name="TLADG370"></a>
<div class="sect3"><a id="sthref122" name="sthref122"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Bootstrapping from an XML Schema</font></h3>
<p>Use the <code>DynamicJAXBContextFactory</code> to create a dynamic <code>JAXBContext</code>. <a href="#BEIJDEFA">Example 15-26</a> to bootstrap a <code>DynamicJAXBContext</code> from the <code>customer.xsd</code> schema (<a href="#BEIBCJFF">Example 15-27</a>) by using <code>createContextFromXSD()</code>.</p>
<div class="example"><a id="BEIJDEFA" name="BEIJDEFA"></a><a id="TLADG371" name="TLADG371"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 15-26 Specifying the Input Stream and Creating the DynamicJAXBContext</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
import java.io.FileInputStream;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory;
public class Demo {
public static void main(String[] args) throws Exception {
FileInputStream xsdInputStream = new FileInputStream(<strong>"src/example/customer.xsd"</strong>);
DynamicJAXBContext jaxbContext =
<strong>DynamicJAXBContextFactory.</strong><strong>createContextFromXSD(xsdInputStream, null, null, null)</strong>;
</pre></div>
<!-- class="example" -->
<p>The first parameter represents the XML schema itself and must be in one of the following forms: <code>java.io.InputStream</code>, <code>org.w3c.dom.Node</code>, or <code>javax.xml.transform.Source</code>.</p>
</div>
<!-- class="sect3" -->
<a id="TLADG372" name="TLADG372"></a>
<div class="sect3"><a id="sthref123" name="sthref123"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">The XML Schema</font></h3>
<p><a href="#BEIBCJFF">Example 15-27</a> shows the <code>customer.xsd</code> schema that represents the metadata for the dynamic JAXBContext you are bootstrapping.</p>
<div class="example"><a id="BEIBCJFF" name="BEIBCJFF"></a><a id="TLADG373" name="TLADG373"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 15-27 Sample XML Schema Document</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
&lt;xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.org"
targetNamespace="http://www.example.org"
elementFormDefault="qualified"&gt;
<strong>&lt;xsd:complexType name="address"&gt;</strong>
&lt;xsd:sequence&gt;
&lt;xsd:element name="street" type="xsd:string" minOccurs="0"/&gt;
&lt;xsd:element name="city" type="xsd:string" minOccurs="0"/&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:complexType&gt;
<strong>&lt;xsd:element name="customer"&gt;</strong>
&lt;xsd:complexType&gt;
&lt;xsd:sequence&gt;
&lt;xsd:element name="name" type="xsd:string" minOccurs="0"/&gt;
&lt;xsd:element name="address" type="address" minOccurs="0"/&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:complexType&gt;
&lt;/xsd:element&gt;
&lt;/xsd:schema&gt;
</pre></div>
<!-- class="example" --></div>
<!-- class="sect3" -->
<a id="TLADG374" name="TLADG374"></a>
<div class="sect3"><a id="sthref124" name="sthref124"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Handling Schema Import/Includes</font></h3>
<p>To bootstrap <code>DynamicJAXBContext</code> from an XML schema that contains imports of other schemas, you need to configure an <code>org.xml.sax.EntityResolver</code> to resolve the locations of the imported schemas and pass the <code>EntityResolver</code> to <code>DynamicJAXBContextFactory</code>.</p>
<p>The following example shows two schema documents, <code>customer.xsd</code> (<a href="#BEIJBFAG">Example 15-28</a>) and <code>address.xsd</code> <a href="#BEIDIAJB">Example 15-29</a>). You can see that <code>customer.xsd</code> imports <code>address.xsd</code> by using the statement:</p>
<pre xml:space="preserve" class="oac_no_warn">
&lt;xsd:import namespace="http://www.example.org/address" schemaLocation="address.xsd"/&gt;
</pre>
<div class="example"><a id="BEIJBFAG" name="BEIJBFAG"></a><a id="TLADG375" name="TLADG375"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 15-28 customer.xsd</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:add="http://www.example.org/address"
xmlns="http://www.example.org/customer"
targetNamespace="http://www.example.org/customer"
elementFormDefault="qualified"&gt;
<strong>&lt;xsd:import namespace="http://www.example.org/address" schemaLocation="address.xsd"/&gt;</strong>
&lt;xsd:element name="customer"&gt;
&lt;xsd:complexType&gt;
&lt;xsd:sequence&gt;
&lt;xsd:element name="name" type="xsd:string" minOccurs="0"/&gt;
&lt;xsd:element name="address" type="add:address" minOccurs="0"/&gt;
&lt;/xsd:sequence&gt;
&lt;/xsd:complexType&gt;
&lt;/xsd:element&gt;
&lt;/xsd:schema&gt;
</pre></div>
<!-- class="example" -->
<div class="example"><a id="BEIDIAJB" name="BEIDIAJB"></a><a id="TLADG376" name="TLADG376"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 15-29 address.xsd</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.org/address"
targetNamespace="http://www.example.org/address"
elementFormDefault="qualified"&gt;
&lt;xsd:complexType name="address"&gt;
&lt;xs:sequence&gt;
&lt;xs:element name="street" type="xs:string"/&gt;
&lt;xs:element name="city" type="xs:string"/&gt;
&lt;/xs:sequence&gt;
&lt;/xsd:complexType&gt;
&lt;/xsd:schema&gt;
</pre></div>
<!-- class="example" --></div>
<!-- class="sect3" -->
<a id="TLADG377" name="TLADG377"></a>
<div class="sect3"><a id="sthref125" name="sthref125"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Implementing and Passing an EntityResolver</font></h3>
<p>If you want to bootstrap <code>DynamicJAXBContext</code> from the <code>customer.xsd</code> schema, you need to pass an entity resolver. Do the following:</p>
<ol>
<li>
<p>To resolve the locations of the imported schemas, you need to implement an <code>entityResolver</code> by supplying the code shown in <a href="#BEIBCJAB">Example 15-30</a>.</p>
<div class="example"><a id="BEIBCJAB" name="BEIBCJAB"></a><a id="TLADG378" name="TLADG378"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 15-30 Implementing an EntityResolver</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
class MyEntityResolver implements EntityResolver {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
// Imported schemas are located in ext\appdata\xsd\
// Grab only the filename part from the full path
String filename = new File(systemId).getName();
// Now prepend the correct path
String correctedId = "ext/appdata/xsd/" + filename;
InputSource is = new InputSource(ClassLoader.getSystemResourceAsStream(correctedId));
is.setSystemId(correctedId);
return is;
}
}
</pre></div>
<!-- class="example" --></li>
<li>
<p>After you implement your <code>DynamicJAXBContext</code>, pass the <code>EntityResolver</code>, as shown in <a href="#BEIHGJAA">Example 15-31</a>.</p>
<div class="example"><a id="BEIHGJAA" name="BEIHGJAA"></a><a id="TLADG379" name="TLADG379"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 15-31 Passing in the Entityresolver</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
FileInputStream xsdInputStream = new FileInputStream(<strong>"src/example/customer.xsd"</strong>);
DynamicJAXBContext jaxbContext =
DynamicJAXBContextFactory.createContextFromXSD(xsdInputStream, new MyEntityResolver(), null, null);
</pre></div>
<!-- class="example" --></li>
</ol>
</div>
<!-- class="sect3" -->
<a id="TLADG380" name="TLADG380"></a>
<div class="sect3"><a id="sthref126" name="sthref126"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Error Handling</font></h3>
<p>You might see the following exception when importing another schema:</p>
<pre xml:space="preserve" class="oac_no_warn">
Internal Exception: org.xml.sax.SAXParseException: schema_reference.4: Failed to read schemadocument '<em>&lt;imported-schema-name&gt;</em>', because 1) could not find the document; 2) the document couldnot be read; 3) the root element of the document is not &lt;xsd:schema&gt;.
</pre>
<p>To work around this exception, disable XJC's schema correctness check by setting the <code>noCorrectnessCheck</code> Java property. You can set this property one of two ways:</p>
<ul>
<li>
<p>From within the code, by adding this line:</p>
<pre xml:space="preserve" class="oac_no_warn">
System.setProperty("<strong>com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.noCorrectnessCheck", "true"</strong>)
</pre></li>
<li>
<p>From the command line, by using this command:</p>
<pre xml:space="preserve" class="oac_no_warn">
-Dcom.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.<strong>noCorrectnessCheck=true</strong>
</pre></li>
</ul>
</div>
<!-- class="sect3" -->
<a id="TLADG381" name="TLADG381"></a>
<div class="sect3"><a id="sthref127" name="sthref127"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Specifying a ClassLoader</font></h3>
<p>Use your application's current class loader as the <code>classLoader</code> parameter. This parameter verifies that specified classes exist before new <code>DynamicTypes</code> are generated. In most cases you can pass <code>null</code> for this parameter and use <code>Thread.currentThread().getContextClassLoader()</code> instead.</p>
</div>
<!-- class="sect3" --></div>
<!-- class="sect2" -->
<a id="BEIDHGHI" name="BEIDHGHI"></a><a id="TLADG382" name="TLADG382"></a>
<div class="sect2">
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Task 2: Create Dynamic Entities and Marshal Them to XML</font></h2>
<p>This example shows how to create dynamic entities and marshal then to XML.</p>
<a id="TLADG383" name="TLADG383"></a>
<div class="sect3"><a id="sthref128" name="sthref128"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Creating the Dynamic Entities</font></h3>
<p>Use the <code>DynamicJAXBContext</code> to create instances of <code>DynamicEntity</code>. The entity and property names correspond to the class and property names&mdash;in this case, the <code>customer</code> and <code>address</code>&mdash;that would have been generated if you had used static JAXB.</p>
<div class="example"><a id="TLADG384" name="TLADG384"></a><a id="sthref129" name="sthref129"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 15-32 Creating the Dynamic Entity</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
<strong>DynamicEntity customer = jaxbContext.newDynamicEntity("org.example.Customer");</strong>
customer.set("name", "Jane Doe");
<strong>DynamicEntity address = jaxbContext.newDynamicEntity("org.example.Address");</strong>
address.set("street", "1 Any Street").set("city", "Any Town");
customer.set("address", address);
</pre></div>
<!-- class="example" --></div>
<!-- class="sect3" -->
<a id="TLADG385" name="TLADG385"></a>
<div class="sect3"><a id="sthref130" name="sthref130"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Marshalling the Dynamic Entities to XML</font></h3>
<p>The marshaller obtained from the <code>DynamicJAXBContext</code> is a standard marshaller and can be used normally to marshal instances of DynamicEntity.</p>
<div class="example"><a id="TLADG386" name="TLADG386"></a><a id="sthref131" name="sthref131"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 15-33 Standard Dynamic JAXB Marshaller</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
<strong>Marshaller marshaller = jaxbContext.createMarshaller()</strong>;
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);marshaller.marshal(customer, System.out);
</pre></div>
<!-- class="example" -->
<p><a href="#BEIDBCBF">Example 15-34</a> shows the resultant XML document:</p>
<div class="example"><a id="BEIDBCBF" name="BEIDBCBF"></a><a id="TLADG387" name="TLADG387"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 15-34 Updated XML Document Showing &lt;address&gt; Element and Its Attributes</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;customer xmlns="www.example.org"&gt;
&lt;name&gt;Jane Doe&lt;/name&gt;
&lt;address&gt;
&lt;street&gt;1 Any Street&lt;/street&gt;
&lt;city&gt;Any Town&lt;/city&gt;
&lt;/address&gt;
&lt;/customer&gt;
</pre></div>
<!-- class="example" --></div>
<!-- class="sect3" --></div>
<!-- class="sect2" -->
<a id="BEIGCBBH" name="BEIGCBBH"></a><a id="TLADG388" name="TLADG388"></a>
<div class="sect2">
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Task 3: Unmarshal the Dynamic Entities from XML</font></h2>
<p>In this example shows how to unmarshal from XML the dynamic entities you created in <a href="#BEIDHGHI">Task 2: Create Dynamic Entities and Marshal Them to XML</a>. The XML in reference is shown in <a href="#BEIDBCBF">Example 15-34</a>.</p>
<a id="TLADG389" name="TLADG389"></a>
<div class="sect3"><a id="sthref132" name="sthref132"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Unmarshal DynamicEntities from XML</font></h3>
<p>The Unmarshaller obtained from the <code>DynamicJAXBContext</code> is a standard unmarshaller, and can be used normally to unmarshal instances of <code>DynamicEntity</code>.</p>
<div class="example"><a id="TLADG390" name="TLADG390"></a><a id="sthref133" name="sthref133"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 15-35 Standard Dynamic JAXB Unmarshaller</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
FileInputStream xmlInputStream = new FileInputStream("src/example/dynamic/customer.xml");
<strong>Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();</strong>
DynamicEntity customer = (DynamicEntity) unmarshaller.unmarshal(xmlInputStream);
</pre></div>
<!-- class="example" --></div>
<!-- class="sect3" -->
<a id="TLADG391" name="TLADG391"></a>
<div class="sect3"><a id="sthref134" name="sthref134"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Get Data from the Dynamic Entity</font></h3>
<p>Next, specify which data in the dynamic entity to obtain. Specify this value by using <code>System.out.println()</code> and passing in the entity name. <code>DynamicEntity</code> offers property-based data access; for example, <code>get("name")</code> instead of <code>getName()</code>:</p>
<pre xml:space="preserve" class="oac_no_warn">
System.out.println(<strong>customer.&lt;String&gt;get("name")</strong>);
</pre></div>
<!-- class="sect3" -->
<a id="TLADG392" name="TLADG392"></a>
<div class="sect3"><a id="sthref135" name="sthref135"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Use DynamicType to Introspect Dynamic Entity</font></h3>
<p>Instances of <code>DynamicEntity</code> have a corresponding <code>DynamicType</code>, which you can use to introspect the <code>DynamicEntity</code>, as shown in <a href="#BEIDDBCC">Example 15-36</a>.</p>
<div class="example"><a id="BEIDDBCC" name="BEIDDBCC"></a><a id="TLADG393" name="TLADG393"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 15-36</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
DynamicType addressType = jaxbContext.getDynamicType(<strong>"org.example.Address"</strong>);
DynamicEntity address = customer.&lt;DynamicEntity&gt;get("address");
for(String propertyName: addressType.getPropertiesNames()) {
System.out.println(address.get(propertyName));
}
</pre></div>
<!-- class="example" --></div>
<!-- class="sect3" --></div>
<!-- class="sect2" --></div>
<!-- class="sect1" --></div>
<!-- class="ind" -->
<!-- Start Footer -->
<div class="footer">
<hr />
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
<col width="33%" />
<col width="*" />
<col width="33%" />
<tr>
<td valign="bottom">
<table class="navigation simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100" align="center">
<col width="*" />
<col width="48%" />
<col width="48%" />
<tr>
<td>&nbsp;</td>
<td align="center"><a href="jpatoxml005.htm"><img src="../../dcommon/images/larrow.png" alt="Previous" border="0" height="16" width="16" /></a></td>
<td align="center"><a href="jpatoxml007.htm"><img src="../../dcommon/images/rarrow.png" alt="Next" border="0" height="16" width="16" /></a></td>
</tr>
</table>
</td>
<td align="center" width="34%"><a href="http://www.eclipse.org/eclipselink/" title="EclipseLink home"><img src="../../dcommon/images/ellogo.png" alt="EclipseLink" width="150" border="0" /></a><br />
<font size="-2">Copyright&nbsp;&copy;&nbsp;2014,&nbsp;Oracle&nbsp;and/or&nbsp;its&nbsp;affiliates.&nbsp;All&nbsp;rights&nbsp;reserved.</font> <a href="../../dcommon/html/cpyr.htm"><br />
<td valign="bottom" align="right">
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="225">
<tr>
<td>&nbsp;</td>
<td align="center" valign="top"><a href="toc.htm"><img src="../../dcommon/images/contents.png" alt="Go To Table Of Contents" border="0" height="16" width="16" /><br />
</td><td>&nbsp;</td><td align="center"><a href="../../" target="_top" class="external text" title="Search" rel="nofollow"><img src="../../dcommon/images/search.png" alt="Search" style="border:0;" /><br /><span class="mini"></span></a></td><td>&nbsp;</td><td align="center"><a href="../eclipselink_otlcg.pdf" title="PDF" target="_blank"><img src="../../dcommon/images/pdf_icon.png" style="padding-right:5px;border:0" alt="PDF"></a></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- class="footer" -->
<div id="copyright">Copyright &copy; 2014 by The Eclipse Foundation under the <a href="http://www.eclipse.org/org/documents/epl-v10.php">Eclipse Public License (EPL)</a><br /> <script type="text/javascript">var LastUpdated = document.lastModified;document.writeln ("Updated: " + LastUpdated);</script> </div><!-- START: Analytics --><script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-1608008-2']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script><!-- END: Analytics --><!-- START: Sharethis --><script>var options={ "publisher": "e2fe9e07-fab6-4f84-83ea-0991b429842c", "position": "right", "ad": { "visible": false, "openDelay": 5, "closeDelay": 0}};var st_hover_widget = new sharethis.widgets.hoverbuttons(options);</script><!-- END: Sharethis --></body>
</html>