Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/MOXy/Overview/DynamicEntities"

m
Line 1: Line 1:
 +
{{EclipseLink_UserGuide
 +
|info=y
 +
}}
 +
=Static and Dynamic Entities=
 +
 +
 +
==Dynamic MOXy==
 +
With EclipseLink Dynamic MOXy, you can bootstrap a '''JAXBContext''' from a variety of metadata sources and use exitging JAXB APIs to marshal and unmarshal data… ''without having compiled Java class files on the classpath''. This allows you to alter the metadata source as needed, without having to update and recompile the previously-generated Java source code.
 +
 +
 +
===Dynamic Entities===
 +
Instead of using actual Java classes (such as <tt>Customer.class</tt> or <tt>Address.class</tt>), dynamic MOXy uses a simple <tt>get(propertyName)</tt>/<tt>set(propertyName, propertyValue)</tt> API to manipulate data. EclipseLInk generates (in memory) a <tt>DynamicType</tt> associated with each <tt>DynamicEntity</tt>
 +
{{tip||<tt>DynamicTypes</tt> are similar to Java classes; whereas <tt>DynamicEntities</tt> can be thought of as instances of a <tt>DynamicType</tt>.}}
 +
 +
'''Example'''
 +
<source lang="java">
 +
DynamicEntity customer = (DynamicEntity) dynamicJAXBContext.createUnmarshaller().unmarshal(instanceDoc);
 +
 +
String lastName = customer.get("lastName");
 +
List orders = customer.get("orders");
 +
...
 +
DynamicEntity address = dContext.newDynamicEntity("mynamespace.Address");
 +
address.set("street", "1001 Fleet St.");
 +
 +
customer.set("lastName", lastName + "Jr.");
 +
customer.set("address", address);
 +
</source>
 +
 +
 +
{{EclipseLink_MOXy
 +
|next=[[EclipseLink/UserGuide/MOXy/Runtime|Runtime]]
 +
|previous=[[EclipseLink/UserGuide/MOXy/Overview/Annotations|Annotations]]
 +
|up=[[EclipseLink/UserGuide/MOXy/Overview|Overview]]
 +
|version=2.2.0}}
 +
 +
 +
 +
 
Can use Dynamic MOXy when:
 
Can use Dynamic MOXy when:
  

Revision as of 09:17, 10 December 2010


link="http://wiki.eclipse.org/EclipseLink"
EclipseLink
Website
Download
Community
Mailing ListForumsIRC
Bugzilla
Open
Help Wanted
Bug Day
Contribute
Browse Source

Static and Dynamic Entities

Dynamic MOXy

With EclipseLink Dynamic MOXy, you can bootstrap a JAXBContext from a variety of metadata sources and use exitging JAXB APIs to marshal and unmarshal data… without having compiled Java class files on the classpath. This allows you to alter the metadata source as needed, without having to update and recompile the previously-generated Java source code.


Dynamic Entities

Instead of using actual Java classes (such as Customer.class or Address.class), dynamic MOXy uses a simple get(propertyName)/set(propertyName, propertyValue) API to manipulate data. EclipseLInk generates (in memory) a DynamicType associated with each DynamicEntity

Idea.png
DynamicTypes are similar to Java classes; whereas DynamicEntities can be thought of as instances of a DynamicType.


Example

DynamicEntity customer = (DynamicEntity) dynamicJAXBContext.createUnmarshaller().unmarshal(instanceDoc);
 
String lastName = customer.get("lastName");
List orders = customer.get("orders");
...
DynamicEntity address = dContext.newDynamicEntity("mynamespace.Address");
address.set("street", "1001 Fleet St.");
 
customer.set("lastName", lastName + "Jr.");
customer.set("address", address);


Eclipselink-logo.gif
Version: 2.2.0
Other versions...

Elug previous icon.pngAnnotations

link=‎
Overview

Runtimelink=‎

link=‎ EclipseLink Home MOXy User Guide: Elug guide icon.pngTable of Contents, Search elug.pngSearch
How to contribute to this guide...



Can use Dynamic MOXy when:

  • You want to start from an XML Schema (XSD) and have EclipseLink generate classes for you
  • You do not want to deal with concrete Java domain classes

Introduction to Dynamic MOXy: