Difference between revisions of "EclipseLink/Examples/MOXy"

From Eclipsepedia

Jump to: navigation, search
(EclipseLink MOXy Examples)
m (EclipseLink MOXy Examples)
(54 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
[[Category:EclipseLink/Example|MOXy Examples]]
 
[[Category:EclipseLink/Example|MOXy Examples]]
 +
<div style="margin:5px;float:right;border:1px solid #000000;padding:5px">__TOC__</div>
  
__NOTOC__
 
 
The following examples are provided to assist developers with their adoption and usage of EclipseLink's JAXB and native OXM functionality.
 
The following examples are provided to assist developers with their adoption and usage of EclipseLink's JAXB and native OXM functionality.
  
== JAXB Examples ==
+
EclipseLink provides a standards-based JAXB implementation with many extensions.  For an introduction to the JAXB 2.0 reference implementation please see the following page:
  
EclipseLink provides standards based JAXB implementation with many extensions. These references are for the JAXB 2.0 reference implementation which is included within EclipseLink for its XSD compiler capabilities (XJC).
+
* [http://java.sun.com/developer/technicalArticles/WebServices/jaxb/index.html JAXB Tutorial (jaxb.dev.java.net)]
  
* [http://java.sun.com/developer/technicalArticles/WebServices/jaxb/index.html Short JAXB Tutorial (jaxb.dev.java.net)]
 
  
== EclipseLink MOXy Examples ==
+
See the ''[http://www.eclipse.org/eclipselink/documentation/ Developing JAXB Applications Using EclipseLink MOXy]'' guide and ''[http://www.eclipse.org/eclipselink/documentation/ EclipseLink Solutions Guide]'' for complete information.
* [[EclipseLink/Examples/MOXy/GettingStarted | Getting Started]]
+
*: No metadata is required to convert your existing object model to XML. Supply metadata (using annotations or XML) only when you need to fine tune the XML representation. Get started using MOXy.
+
* [[EclipseLink/Examples/MOXy/JAXB | Using EclipseLink MOXy's JAXB]]
+
*: Java Architecture for XML Binding (JSR 222) is the standard for XML Binding in Java. JAXB covers 100% of XML Schema concepts. Learn how to use MOXy as your JAXB provider.
+
* [[EclipseLink/Examples/MOXy/MeetInTheMiddle | Meet in the Middle Mapping]]
+
*: Normally in XML Binding solutions there is a one-to-one correspondence between the object model and the levels of nesting in the resulting XML document.  Learn how to leverage MOXy’s XPath based mapping to remove these limitations.
+
* [[EclipseLink/Examples/MOXy/EclipseLink-OXM.XML | Using EclipseLink MOXy's XML Mapping (eclipselink-oxm.xml)]]
+
*: Externalizing the JAXB and extended mappings in an eclipselink-oxm.xml mapping file can separate the XML bindings from the domain classes.
+
* [[EclipseLink/Examples/MOXy/Dynamic | Dynamic JAXB]]
+
*: Traditional JAXB maps static classes (POJOs) to XML.  Dynamic JAXB uses objects (instances of DynamicEntity) with generic get/set methods instead avoiding the need for the class generation step entirely.
+
* [[EclipseLink/Examples/MOXy/JPA | Mapping JPA Entities to XML]]
+
*: JPA provides an easy and powerful means to use Java objects to interact with a relational database. These Java objects are called entities, and have their own characteristics. Some of these characteristics (bidirectional relationships, compound keys, embedded key classes, and lazy loading) can cause challenges when mapping these objects to XML.  Learn how to easily map JPA entities to XML using MOXy.
+
* [[EclipseLink/Examples/SDO/JAXB | Converting POJOs to/from SDO DataObjects using the POJO/SDO Bridge (via JAXB)]]
+
*: Using SDO or SCA and want to leverage JPA to access your persistent data?  Learn how to expose your objects through SDO using MOXy.
+
* [[EclipseLink/Examples/MOXy/Spring | MOXy JAXB in Spring]]
+
*: Using static and dynamic MOXy JAXB in Spring.
+
* [[EclipseLink/Examples/MOXy/ElementMappingByAttributeValue | XPath Mapping with Predicates]]
+
* [[EclipseLink/Examples/MOXy/XMLNameTransformer | Customized XML Name Conversions]]
+
* [[EclipseLink/Examples/MOXy/Extensible | XML Extensions]]
+
*: Make MOXy JAXB beans extensible so that at runtime a set of additional extended mappings can be used
+
  
* *Externalized Mappings*
+
 
** [[EclipseLink/Examples/MOXy/MetadataRepository | MOXY Metadata Repository]]
+
== EclipseLink MOXy Examples  ==
**: Store mappings using a MetadataSource external to the running application so that mapping overrides and extended mappings can be more dynamically integrated into deployed applications
+
 
** [[EclipseLink/Examples/MOXy/MultipleBindingsFiles | Multiple Bindings Files]]
+
=== General ===
**: Process multiple bindings files from different locations, and create a merged set of metadata. This allows a JAXBContext to be created to represent any version of the XML document
+
*[[EclipseLink/Examples/MOXy/GettingStarted|Getting Started]]
 +
*:No metadata is required to convert your existing object model to XML. Supply metadata (using annotations or XML) only when you need to fine tune the XML representation. Get started using MOXy.
 +
*[[EclipseLink/Examples/MOXy/JAXB|Using EclipseLink MOXy's JAXB]]
 +
*:Java Architecture for XML Binding (JSR 222) is the standard for XML Binding in Java. JAXB covers 100% of XML Schema concepts. Learn how to use MOXy as your JAXB provider.
 +
*[[EclipseLink/Examples/MOXy/MeetInTheMiddle/Advantages|Meet in the Middle Mapping Advantages]]
 +
*:Compare meet-in-the-middle mapping to other approaches. Normally in XML Binding solutions there is a one-to-one correspondence between the object model and the levels of nesting in the resulting XML document. Learn how to leverage MOXy's XPath-based mapping to remove these limitations.
 +
*[[EclipseLink/Examples/MOXy/EclipseLink-OXM.XML|Using EclipseLink MOXy's XML Mapping (eclipselink-oxm.xml)]]
 +
*:Externalizing the JAXB and extended mappings in an eclipselink-oxm.xml mapping file can separate the XML bindings from the domain classes.
 +
*[[EclipseLink/Examples/MOXy/XMLNameTransformer|XMLNameTransformer]]'''
 +
*:Customized XML Name Conversions.
 +
 
 +
 
 +
=== MOXy's JSON-Binding ===
 +
*[[EclipseLink/Examples/MOXy/JSON_Twitter|Twitter Example]]
 +
*:Use MOXy to process JSON returned from a Twitter query.
 +
*[[EclipseLink/Examples/MOXy/JSON_Geocode|Google Maps Geocode Example]]
 +
*:Use MOXy to process JSON returned from a Google Maps query.
 +
*JAX-RS & MOXyJsonProvider
 +
*:[[EclipseLink/Examples/MOXy/MOXy_JSON_Provider|Use MOXyJsonProvider to make JAX-RS integration even easier]]
 +
*:[[EclipseLink/Examples/MOXy/MOXy_JSON_Provider/JSONwithPadding|MOXy and JSON with Padding (NEW in 2.5)]]
 +
*[[EclipseLink/Examples/MOXy/JSON_Metadata|JSON Metadata]]
 +
*:Write MOXy bindings files in JSON.
 +
*[[EclipseLink/Examples/MOXy/JSON_CollectionProperties|Collection Properties (NEW in 2.5)]]
 +
*:Mapping a collection property to both JSON and XML
 +
 
 +
 
 +
=== Object Graphs (NEW in 2.5) ===
 +
 
 +
*[[EclipseLink/Examples/MOXy/ObjectGraphs/Metadata|Specifying Object Graphs through Metadata]]
 +
*:Learn how to define object graphs through metadata
 +
*[[EclipseLink/Examples/MOXy/ObjectGraphs/Programmatic|Specifying Object Graphs Programmatically]]
 +
*:Learn how to define object graphs on the fly programmatically
 +
*[[EclipseLink/Examples/MOXy/ObjectGraphs/Inheritance|Handling Inheritance]]
 +
*:Learn how to leverage object graphs with models that have inheritance
 +
*[[EclipseLink/Examples/MOXy/Dynamic/ObjectGraphs|Object Graphs & Dynamic JAXB]]
 +
*:Learn how to use Object Graphs with Dynamic JAXB
 +
 
 +
 
 +
=== Working with JPA ===
 +
JPA provides an easy and powerful means to use Java objects to interact with a relational database. These Java objects are called entities, and have their own characteristics. Some of these characteristics (bidirectional relationships, compound keys, embedded key classes, and lazy loading) can cause challenges when mapping these objects to XML. Learn how to easily map JPA entities to XML using MOXy.
 +
 
 +
*[[EclipseLink/Examples/MOXy/JPA/Relationships|JPA Relationships]]
 +
*:Learn how to bind JPA Relationships to XML.
 +
*[[EclipseLink/Examples/MOXy/JPA/CompoundPrimaryKeys|Compound Primary Keys]]
 +
*:Learn how to bind Compound Primay Keys to XML.
 +
*[[EclipseLink/Examples/MOXy/JPA/EmbeddedIdClass|Embedded ID Classes]]
 +
*:Learn how to bind Embedded ID Classes to XML.
 +
 
 +
 
 +
=== Integration with Spring ===
 +
*[[EclipseLink/Examples/MOXy/Spring|MOXy JAXB in Spring]]
 +
*:Using static and dynamic MOXy JAXB in Spring.
 +
 
 +
 
 +
=== Mapping Extensions ===
 +
*[[EclipseLink/Examples/MOXy/XPath|XPath Based Mapping]]
 +
*:Map objects to XML using XPath.
 +
*[[EclipseLink/Examples/MOXy/ElementMappingByAttributeValue|XPath Mapping with Predicates]]
 +
*:Map elements based on the value of an attribute.
 +
*[[EclipseLink/Examples/MOXy/Mappings/Bidirectional|Bidirectional Mapping (NEW in 2.5)]]
 +
*:Mapping a bidirectional relationship
 +
 
 +
 
 +
=== Extensible Models ===
 +
*[[EclipseLink/Examples/MOXy/MetadataRepository|MOXY Metadata Repository]]  
 +
*:Store mappings using a MetadataSource external to the running application so that mapping overrides and extended mappings can be more dynamically integrated into deployed applications
 +
*[[EclipseLink/Examples/MOXy/MultipleBindingsFiles|Multiple Bindings Files]]  
 +
*:Process multiple bindings files from different locations, and create a merged set of metadata. This allows a JAXBContext to be created to represent any version of the XML document.
 +
*[[EclipseLink/Examples/MOXy/Extensible|XML Extensions]]
 +
*:Make MOXy JAXB beans extensible so that a set of additional extended mappings can be used at runtime.
 +
*[[EclipseLink/Examples/MOXy/RefreshMetadata|RefreshMetadata]]
 +
*:Update the metadata (in this example to include information about new extensions) without stopping the application.
 +
 
 +
 
 +
=== Dynamic JAXB ===
 +
Traditional JAXB maps static classes (POJOs) to XML. Dynamic JAXB uses objects (instances of DynamicEntity) with generic get/set methods instead avoiding the need for the class generation step entirely.
 +
 
 +
*[[EclipseLink/Examples/MOXy/Dynamic/StaticComparison|Static Comparison]]
 +
*:See how Dynamic JAXB compares with static JAXB.
 +
*[[EclipseLink/Examples/MOXy/Dynamic/JAXBContextFromXMLSchema|JAXBContext from XML Schema]]
 +
*:See how to bootstrap a Dynamic JAXBContext from an XML Schema.
 +
*[[EclipseLink/Examples/MOXy/Dynamic/XmlToDynamicEntity|XML to DynamicEntity]]
 +
*:Learn how to unmarshal an XML document to DynamicEntities.
 +
*[[EclipseLink/Examples/MOXy/Dynamic/DynamicEntityToXml|DynamicEntity to XML]]
 +
*:Learn how to marshal DyanamicEntities to XML.
 +
*[[EclipseLink/Examples/MOXy/Dynamic/ObjectGraphs|Object Graphs (NEW in 2.5)]]
 +
*:Learn how to use Object Graphs with Dynamic JAXB
 +
 
 +
 
 +
=== Working with SDO ===
 +
*[[EclipseLink/Examples/SDO/JAXB|Converting POJOs to/from SDO DataObjects using the POJO/SDO Bridge (via JAXB)]]
 +
*:Using SDO or SCA and want to leverage JPA to access your persistent data? Learn how to expose your objects through SDO using MOXy.
  
 
== Using Native OXM through JAXB Examples ==
 
== Using Native OXM through JAXB Examples ==
 
* [[EclipseLink/Examples/MOXy/NativeOxmJaxbContext | Creating a Native OXM aware JAXBContext]]
 
* [[EclipseLink/Examples/MOXy/NativeOxmJaxbContext | Creating a Native OXM aware JAXBContext]]
 +
*:Use the EclipseLink Workbench to map Java classes to an XML Schema, and Marshal and Unmarshal XML documents using JAXB APIs.

Revision as of 16:05, 5 April 2013

The following examples are provided to assist developers with their adoption and usage of EclipseLink's JAXB and native OXM functionality.

EclipseLink provides a standards-based JAXB implementation with many extensions. For an introduction to the JAXB 2.0 reference implementation please see the following page:


See the Developing JAXB Applications Using EclipseLink MOXy guide and EclipseLink Solutions Guide for complete information.


EclipseLink MOXy Examples

General

  • Getting Started
    No metadata is required to convert your existing object model to XML. Supply metadata (using annotations or XML) only when you need to fine tune the XML representation. Get started using MOXy.
  • Using EclipseLink MOXy's JAXB
    Java Architecture for XML Binding (JSR 222) is the standard for XML Binding in Java. JAXB covers 100% of XML Schema concepts. Learn how to use MOXy as your JAXB provider.
  • Meet in the Middle Mapping Advantages
    Compare meet-in-the-middle mapping to other approaches. Normally in XML Binding solutions there is a one-to-one correspondence between the object model and the levels of nesting in the resulting XML document. Learn how to leverage MOXy's XPath-based mapping to remove these limitations.
  • Using EclipseLink MOXy's XML Mapping (eclipselink-oxm.xml)
    Externalizing the JAXB and extended mappings in an eclipselink-oxm.xml mapping file can separate the XML bindings from the domain classes.
  • XMLNameTransformer
    Customized XML Name Conversions.


MOXy's JSON-Binding


Object Graphs (NEW in 2.5)


Working with JPA

JPA provides an easy and powerful means to use Java objects to interact with a relational database. These Java objects are called entities, and have their own characteristics. Some of these characteristics (bidirectional relationships, compound keys, embedded key classes, and lazy loading) can cause challenges when mapping these objects to XML. Learn how to easily map JPA entities to XML using MOXy.


Integration with Spring


Mapping Extensions


Extensible Models

  • MOXY Metadata Repository
    Store mappings using a MetadataSource external to the running application so that mapping overrides and extended mappings can be more dynamically integrated into deployed applications
  • Multiple Bindings Files
    Process multiple bindings files from different locations, and create a merged set of metadata. This allows a JAXBContext to be created to represent any version of the XML document.
  • XML Extensions
    Make MOXy JAXB beans extensible so that a set of additional extended mappings can be used at runtime.
  • RefreshMetadata
    Update the metadata (in this example to include information about new extensions) without stopping the application.


Dynamic JAXB

Traditional JAXB maps static classes (POJOs) to XML. Dynamic JAXB uses objects (instances of DynamicEntity) with generic get/set methods instead avoiding the need for the class generation step entirely.


Working with SDO

Using Native OXM through JAXB Examples