Difference between revisions of "EclipseLink/Release/2.4.0/JAXB RI Extensions"

From Eclipsepedia

Jump to: navigation, search
 
(41 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<div style="margin:5px;float:right;border:1px solid #000000;padding:5px">__TOC__</div>  
 
<div style="margin:5px;float:right;border:1px solid #000000;padding:5px">__TOC__</div>  
 +
 +
=JAXB RI Extensions Support=
 +
 +
In the current JAXB RI, developed by Sun, there is a series of "proprietary" JAXB extensions which provide advanced functionality outside of the JAXB specification (these extension classes and properties reside in the '''com.sun.xml.bind''' and '''com.sun.internal.xml.bind''' packages).  This document outlines the new EclipseLink MOXy support for these extensions.
 +
 +
=General Features=
 +
 +
==XML Accessor Factory==
 +
Allows the user to write their own logic to be used when setting and getting property values.
 +
 +
Usage:
 +
<div style="width:850px">
 +
<source lang="text">
 +
- Implement com.sun.xml.bind.AccessorFactory interface
 +
- Implement com.sun.xml.bind.v2.runtime.reflect.Accessors for field/property access
 +
- Add com.sun.xml.bind.XmlAccessorFactory annotation at Class or Package level
 +
</source>
 +
</div>
 +
 +
See: [[EclipseLink/Release/2.4.0/JAXB_RI_Extensions/XML_Accessor_Factory | @XmlAccessorFactory]]
  
 
=Marshaller Features=
 
=Marshaller Features=
  
==Cycle Recoverable==
+
==Namespace Prefix Mapper==
Usage: Implement the com.sun.xml.bind.CycleRecoverable interface
+
Allows the user to customize the way namespace prefixes are assigned to namespaces by extending the NamespacePrefixMapper class.
  
Allows the user to write their own logic to be used when object cycles are detected during marshal operations.
+
Usage:
 +
<div style="width:850px">
 +
<source lang="java">
 +
marshaller.setProperty(MarshallerProperties.NAMESPACE_PREFIX_MAPPER, new MyPrefixMapper());
 +
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new MyPrefixMapper());   
 +
</source>
 +
</div>
  
See: http://wiki.eclipse.org/EclipseLink/Development/372404
+
See: [[EclipseLink/Release/2.4.0/JAXB_RI_Extensions/Namespace_Prefix_Mapper | Namespace Prefix Mapper]]
  
  
==Object Identitity Cycle Detection==
+
==Cycle Recoverable==
 +
Allows the user to write their own logic to be used when object cycles are detected during marshal operations.
  
Usage: marshaller.setProperty("com.sun.xml.bind.objectIdentitityCycleDetection", false);
+
Usage:
 +
<div style="width:850px">
 +
<source lang="text">
 +
Implement the com.sun.xml.bind.CycleRecoverable interface on JAXB domain class
 +
</source>
 +
</div>
  
Used to configure the strategy EclipseLink will use to detect an Object cycle. By default, EclipseLink will use Object identity to determine if a cycle exists; setting this property to false will tell EclipseLink to use the equals() method instead.
+
See: [[EclipseLink/Release/2.4.0/JAXB_RI_Extensions/Cycle_Recoverable | Cycle Recoverable]]
  
  
==XML Declaration==
+
==Object Identitity Cycle Detection==
 +
Used to configure the strategy EclipseLink will use to detect an Object cycle. By default, EclipseLink will use Object identity to determine if a cycle exists; setting this property to false will tell EclipseLink to use the equals() method instead.
  
Usage: marshaller.setProperty("com.sun.xml.bind.xmlDeclaration", true);
+
Usage:
 +
<div style="width:850px">
 +
<source lang="java">
 +
marshaller.setProperty("com.sun.xml.bind.objectIdentitityCycleDetection", false);
 +
</source>
 +
</div>
  
Allows the user to omit the XML processing instruction from marshalled documens.  This property is the opposite of Marshaller.JAXB_FRAGMENT, and is included for backwards compatibility only.
 
  
 +
==XML Declaration==
 +
Allows the user to omit the XML processing instruction from marshalled documents.  This property is the opposite of Marshaller.JAXB_FRAGMENT, and is included for backwards compatibility only.
  
==XML Headers==
+
Usage:
 +
<div style="width:850px">
 +
<source lang="java">
 +
marshaller.setProperty("com.sun.xml.bind.xmlDeclaration", true);
 +
</source>
 +
</div>
  
Usage: marshaller.setProperty("com.sun.xml.bind.xmlHeaders", headerString);
 
  
 +
==XML Headers==
 
Allows the user to supply a header string, which  will appear after the XML processing instruction (&lt;?xml ...&gt;), but before the start of the document's data.
 
Allows the user to supply a header string, which  will appear after the XML processing instruction (&lt;?xml ...&gt;), but before the start of the document's data.
 +
 +
Usage:
 +
<div style="width:850px">
 +
<source lang="java">
 +
marshaller.setProperty("com.sun.xml.bind.xmlHeaders", headerString);
 +
</source>
 +
</div>
  
  
 
==Indent String==
 
==Indent String==
 
Usage: marshaller.setProperty("com.sun.xml.bind.indentString", indentString);
 
      marshaller.setProperty(org.eclipse.persistence.jaxb.MarshallerProperties.INDENT_STRING, indentString);
 
 
 
Allows the user to override the indent string that is used when marshalling objects.
 
Allows the user to override the indent string that is used when marshalling objects.
  
==Character Escape Handler==
+
Usage:
 +
<div style="width:850px">
 +
<source lang="java">
 +
marshaller.setProperty("com.sun.xml.bind.indentString", indentString);
 +
marshaller.setProperty(MarshallerProperties.INDENT_STRING, indentString);
 +
</source>
 +
</div>
  
Usage: marshaller.setProperty("com.sun.xml.bind.marshaller.CharacterEscapeHandler", new MyCharacterEscapeHandler());
 
      marshaller.setProperty(org.eclipse.persistence.jaxb.MarshallerProperties.CHARACTER_ESCAPE_HANDLER, new MyCharacterEscapeHandler());
 
  
 +
==Character Escape Handler==
 
Allows the user to provide their own character-escaping logic by supplying their own implementation of the CharacterEscapeHandler interface.
 
Allows the user to provide their own character-escaping logic by supplying their own implementation of the CharacterEscapeHandler interface.
  
See: http://wiki.eclipse.org/EclipseLink/Development/370589
+
Usage:
 +
<div style="width:850px">
 +
<source lang="java">
 +
marshaller.setProperty("com.sun.xml.bind.marshaller.CharacterEscapeHandler", new MyCharHandler());
 +
marshaller.setProperty(MarshallerProperties.CHARACTER_ESCAPE_HANDLER, new MyCharHandler());
 +
</source>
 +
</div>
 +
 
 +
See: [[EclipseLink/Release/2.4.0/JAXB_RI_Extensions/Character_Escape_Handler | Character Escape Handler]]
  
  
Line 53: Line 113:
  
 
==ID Resolver==
 
==ID Resolver==
 +
Allows the user to provide their own logic for resolving XML IDs/IDREFs by supplying their own implementation of the IDResolver interface.
  
Usage: unmarshaller.setProperty("com.sun.xml.bind.IDResolver", new MyIdResolver());
+
Usage:
      unmarshaller.setProperty(org.eclipse.persistence.jaxb.UnmarshallerProperties.ID_RESOLVER, new MyIdResolver());
+
<div style="width:850px">
 +
<source lang="java">
 +
unmarshaller.setProperty("com.sun.xml.bind.IDResolver", new MyIdResolver());
 +
unmarshaller.setProperty(UnmarshallerProperties.ID_RESOLVER, new MyIdResolver());
 +
</source>
 +
</div>
  
Allows the user to provide their own logic for resolving XML IDs/IDREFs.
+
See: [[EclipseLink/Release/2.4.0/JAXB_RI_Extensions/ID_Resolver | ID Resolver]]
  
See: http://wiki.eclipse.org/EclipseLink/Development/360249
 
  
 
==XML Location==
 
==XML Location==
 +
Allows the user to specify a property on the JAXB object that will be updated (upon unmarshalling) with that object's XML location information (i.e. the line number, column number, and system ID that points to this object's location in the XML input).
  
Usage: Annotate a property with @XmlLocation
+
Usage:
 
+
<div style="width:850px">
Allows the user to specify a property on the JAXB object that will be updated (upon unmarshalling) with that object's XML location information (i.e. the line number, column number, and system ID that points to this object's location in the XML input).
+
<source lang="java">
 +
Annotate a property with @XmlLocation
 +
</source>
 +
</div>
  
See: http://wiki.eclipse.org/EclipseLink/Development/355766
+
See: [[EclipseLink/Release/2.4.0/JAXB_RI_Extensions/XML_Location | XML Location]]

Latest revision as of 10:36, 19 June 2012

[edit] JAXB RI Extensions Support

In the current JAXB RI, developed by Sun, there is a series of "proprietary" JAXB extensions which provide advanced functionality outside of the JAXB specification (these extension classes and properties reside in the com.sun.xml.bind and com.sun.internal.xml.bind packages). This document outlines the new EclipseLink MOXy support for these extensions.

[edit] General Features

[edit] XML Accessor Factory

Allows the user to write their own logic to be used when setting and getting property values.

Usage:

- Implement com.sun.xml.bind.AccessorFactory interface
- Implement com.sun.xml.bind.v2.runtime.reflect.Accessors for field/property access
- Add com.sun.xml.bind.XmlAccessorFactory annotation at Class or Package level

See: @XmlAccessorFactory

[edit] Marshaller Features

[edit] Namespace Prefix Mapper

Allows the user to customize the way namespace prefixes are assigned to namespaces by extending the NamespacePrefixMapper class.

Usage:

marshaller.setProperty(MarshallerProperties.NAMESPACE_PREFIX_MAPPER, new MyPrefixMapper());
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new MyPrefixMapper());

See: Namespace Prefix Mapper


[edit] Cycle Recoverable

Allows the user to write their own logic to be used when object cycles are detected during marshal operations.

Usage:

Implement the com.sun.xml.bind.CycleRecoverable interface on JAXB domain class

See: Cycle Recoverable


[edit] Object Identitity Cycle Detection

Used to configure the strategy EclipseLink will use to detect an Object cycle. By default, EclipseLink will use Object identity to determine if a cycle exists; setting this property to false will tell EclipseLink to use the equals() method instead.

Usage:

marshaller.setProperty("com.sun.xml.bind.objectIdentitityCycleDetection", false);


[edit] XML Declaration

Allows the user to omit the XML processing instruction from marshalled documents. This property is the opposite of Marshaller.JAXB_FRAGMENT, and is included for backwards compatibility only.

Usage:

marshaller.setProperty("com.sun.xml.bind.xmlDeclaration", true);


[edit] XML Headers

Allows the user to supply a header string, which will appear after the XML processing instruction (<?xml ...>), but before the start of the document's data.

Usage:

marshaller.setProperty("com.sun.xml.bind.xmlHeaders", headerString);


[edit] Indent String

Allows the user to override the indent string that is used when marshalling objects.

Usage:

marshaller.setProperty("com.sun.xml.bind.indentString", indentString);
marshaller.setProperty(MarshallerProperties.INDENT_STRING, indentString);


[edit] Character Escape Handler

Allows the user to provide their own character-escaping logic by supplying their own implementation of the CharacterEscapeHandler interface.

Usage:

marshaller.setProperty("com.sun.xml.bind.marshaller.CharacterEscapeHandler", new MyCharHandler());
marshaller.setProperty(MarshallerProperties.CHARACTER_ESCAPE_HANDLER, new MyCharHandler());

See: Character Escape Handler


[edit] Unmarshaller Features

[edit] ID Resolver

Allows the user to provide their own logic for resolving XML IDs/IDREFs by supplying their own implementation of the IDResolver interface.

Usage:

unmarshaller.setProperty("com.sun.xml.bind.IDResolver", new MyIdResolver());
unmarshaller.setProperty(UnmarshallerProperties.ID_RESOLVER, new MyIdResolver());

See: ID Resolver


[edit] XML Location

Allows the user to specify a property on the JAXB object that will be updated (upon unmarshalling) with that object's XML location information (i.e. the line number, column number, and system ID that points to this object's location in the XML input).

Usage:

Annotate a property with @XmlLocation

See: XML Location