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

From Eclipsepedia

Jump to: navigation, search
m
m
Line 4: Line 4:
 
=Static and Dynamic Entities=
 
=Static and Dynamic Entities=
  
 +
 +
==Static MOXy==
  
 
==Dynamic MOXy==
 
==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.
 
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.
 +
 +
You should consider using [#Dynamic Entities|Dynamic MOXy] when:
 +
*You want EclipseLink to generate classes from an XML schema (XSD).
 +
*You do not want to deal with concrete Java domain classes.
 +
  
  
Line 26: Line 33:
 
customer.set("address", address);
 
customer.set("address", address);
 
</source>
 
</source>
 +
 +
 +
{{Template:EclipseLink_Spec
 +
|section=Appendix D: Binding XML Names to Java Identifiers
 +
}}
 +
  
  

Revision as of 10:22, 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

Static MOXy

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.

You should consider using [#Dynamic Entities|Dynamic MOXy] when:

  • You want EclipseLink to generate classes from an XML schema (XSD).
  • You do not want to deal with concrete Java domain classes.


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);


Elug javaspec icon.gif

For more information, see Appendix D: Binding XML Names to Java Identifiers in the JPA Specification.


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: