Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

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

m
m (Replacing page with 'See http://www.eclipse.org/eclipselink/documentation/2.4/moxy/dynamic_jaxb001.htm')
 
(39 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{EclipseLink_UserGuide
+
See http://www.eclipse.org/eclipselink/documentation/2.4/moxy/dynamic_jaxb001.htm
|info=y
+
}}
+
=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 <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>
+
 
+
 
+
{{Template:EclipseLink_Spec
+
|section=Appendix D: Binding XML Names to Java Identifiers
+
}}
+
 
+
 
+
 
+
{{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:
+
 
+
*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:'''
+
*http://wiki.eclipse.org/EclipseLink/Development/2.1/DynamicMOXy/296967/Documentation#Dynamic_MOXy_-_JAXB_with_Dynamically_Generated_Java_Classes
+

Latest revision as of 10:35, 8 November 2012

See http://www.eclipse.org/eclipselink/documentation/2.4/moxy/dynamic_jaxb001.htm

Back to the top