Document Information Preface Part I Introduction 1. Overview 2. Using the Tutorial Examples Part II The Web Tier 3. Getting Started with Web Applications 4. Java Servlet Technology 5. JavaServer Pages Technology 6. JavaServer Pages Documents 7. JavaServer Pages Standard Tag Library 8. Custom Tags in JSP Pages 9. Scripting in JSP Pages 10. JavaServer Faces Technology 11. Using JavaServer Faces Technology in JSP Pages 12. Developing with JavaServer Faces Technology 13. Creating Custom UI Components 14. Configuring JavaServer Faces Applications 15. Internationalizing and Localizing Web Applications Part III Web Services 16. Building Web Services with JAX-WS 17. Binding between XML Schema and Java Classes JAXB Architecture Architectural Overview The JAXB Binding Process More about Unmarshalling More about Marshalling More about Validation Representing XML Content Java Representation of XML Schema Binding XML Schemas Simple Type Definitions Default Data Type Bindings Schema-to-Java Mapping JAXBElement Object Java-to-Schema Mapping JAXB Examples JAXB Compiler Options JAXB Schema Generator Option About the Schema-to-Java Bindings Schema-Derived JAXB Classes Comment Class Items Class ObjectFactory Class PurchaseOrder Class PurchaseOrderType Class USAddress Class Basic JAXB Examples Modify Marshal Example Building and Running the Modify Marshal Example Using NetBeans IDE Building and Running the Modify Marshal Example Using Ant Unmarshal Validate Example Building and Running the Unmarshal Validate Example Using NetBeans IDE Building and Running the Unmarshal Validate Example Using Ant Customizing JAXB Bindings Why Customize? Customization Overview Inline and External Customizations Scope, Inheritance, and Precedence Customization Syntax Customization Namespace Prefix Customize Inline Example Building and Running the Customize Inline Example Using NetBeans IDE Building and Running the Customize Inline Example Using Ant Customized Schema Global Binding Declarations Schema Binding Declarations Class Binding Declarations Property Binding Declarations MyDatatypeConverter Class Datatype Converter Example Building and Running the Datatype Converter Example Using NetBeans IDE Building and Running the Datatype Converter Example Using Ant Binding Declaration Files JAXB Version, Namespace, and Schema Attributes Global and Schema Binding Declarations Class Declarations External Customize Example Building and Running the External Customize Example Using NetBeans IDE Building and Running the External Customize Example Using Ant Java-to-Schema Examples Create Marshal Example Building and Running the Create Marshal Example Using NetBeans IDE Building and Running the Create Marshal Example Using Ant XmlAccessorOrder Example Using the@XmlAccessorOrder Annotation to Define Schema Element Ordering Using the@XmlType Annotation to Define Schema Element Ordering Schema Content Ordering in the Example Building and Running the XmlAccessorOrder Example Using NetBeans IDE Building and Running the XmlAccessorOrder Example Using Ant XmlAdapter Field Example Building and Running the XmlAdapter Field Example Using NetBeans IDE Building and Running the XmlAdapter Field Example Using Ant XmlAttribute Field Example Building and Running the XmlAttribute Field Example Using NetBeans IDE Building and Running the XmlAttribute Field Example Using Ant XmlRootElement Example Building and Running the XmlRootElement Example Using NetBeans IDE Building and Running the XmlRootElement Example Using Ant XmlSchemaType Class Example Building and Running the XmlSchemaType Class Example Using NetBeans IDE Building and Running the XmlSchemaType Class Example Using Ant XmlType Example Building and Running the XmlType Example Using NetBeans IDE Building and Running the XmlType Example Using Ant Further Information about JAXB 18. Streaming API for XML 19. SOAP with Attachments API for Java Part IV Enterprise Beans 20. Enterprise Beans 21. Getting Started with Enterprise Beans 22. Session Bean Examples 23. A Message-Driven Bean Example Part V Persistence 24. Introduction to the Java Persistence API 25. Persistence in the Web Tier 26. Persistence in the EJB Tier 27. The Java Persistence Query Language Part VI Services 28. Introduction to Security in the Java EE Platform 29. Securing Java EE Applications 30. Securing Web Applications 31. The Java Message Service API 32. Java EE Examples Using the JMS API 33. Transactions 34. Resource Connections 35. Connector Architecture Part VII Case Studies 36. The Coffee Break Application 37. The Duke's Bank Application Part VIII Appendixes A. Java Encoding Schemes B. About the Authors Index | | The Java EE 5 Tutorial |  |
Customizing Generated Classes and Java Program ElementsThe following sections explain how to customize generated JAXB classes and Java programelements. Schema-to-JavaCustom JAXB binding declarations allow you to customize your generated JAXB classes beyondthe XML-specific constraints in an XML schema to include Java-specific refinements, such asclass and package name mappings. JAXB provides two ways to customize an XML schema: Code examples that show how to customize JAXB bindings are provided later inthis chapter. Java-to-SchemaThe JAXB annotations defined in thejavax.xml.bind.annotations package can be used tocustomize Java program elements to XML schema mapping.Table 17-3 summarizes the JAXB annotations thatcan be used with a Java package. Table 17-3 JAXB Annotations Associated with a Java Package Annotation | Description and Default Setting |
|---|
@XmlSchema | Maps a packageto an XML target namespace. Default Settings: @XmlSchema ( xmlns = {}, namespace = "", elementFormDefault = XmlNsForm.UNSET, attributeFormDefault = XmlNsForm.UNSET) | @XmlAccessorType | Controls default serialization of fields andproperties. Default Settings: @XmlAccessorType ( value = AccessType.PUBLIC_MEMBER ) | @XmlAccessorOrder | Controls the default ordering of properties and fields mapped toXML elements. Default Settings: @XmlAccessorOrder ( value = AccessorOrder.UNDEFINED) | @XmlSchemaType | Allows a customized mapping to an XML Schema built-in type.Default Settings: @XmlSchemaType ( namespace = "http://www.w3.org/2001/XMLSchema", type = DEFAULT.class) | @XmlSchemaTypes | A container annotation for defining multiple@XmlSchemaType annotations. Default Settings: None |
Table 17-4 summarizes JAXB annotations that can be used with a Java class. Table 17-4 JAXB Annotations Associated with a Java Class Annotation | Description andDefault Setting |
|---|
@XmlType | Maps a Java class to a schema type. Default Settings: @XmlType ( name = "##default", propOrder = {""}, namespace = "##default", factoryClass = DEFAULT.class, factoryMethod = "") | @XmlRootElement | Associates aglobal element with the schema type to which the class is mapped. DefaultSettings: @XmlRootElement ( name = "##default", namespace = "##default" ) |
Table 17-5 summarizes JAXB annotations that can be used with a Javaenum type. Table 17-5 JAXB Annotations Associated with a Javaenum Type Annotation | Descriptionand Default Setting |
|---|
@XmlEnum | Maps a Java type to an XML simple type. DefaultSettings: @XmlEnum ( value = String.class ) | @XmlEnumValue | Maps a Java type to an XML simple type. Default Settings: None | @XmlType | Maps aJava class to a schema type. Default Settings: @XmlType ( name = "##default", propOrder = {""}, namespace = "##default", factoryClass = DEFAULT.class, factoryMethod = "") | @XmlRootElement | Associates a global element withthe schema type to which the class is mapped. Default Settings: @XmlRootElement ( name = "##default", namespace = "##default" ) |
Table 17-6 summarizes JAXB annotations that can be used with Java properties and fields. Table 17-6 JAXB Annotations Associated with Java Properties and Fields Annotation | Descriptionand Default Setting |
|---|
@XmlElement | Maps a JavaBeans property/field to an XML element derived froma property/field name. Default Settings: @XmlElement ( name = "##default", nillable = false, namespace = "##default", type = DEFAULT.class, defaultValue = "\u0000") | @XmlElements | A container annotation for defining multiple@XmlElement annotations. Default Settings: None | @XmlElementRef | Mapsa JavaBeans property/field to an XML element derived from a property/field’s type. DefaultSettings: @XmlElementRef ( name = "##default", namespace = "##default", type = DEFAULT.class) | @XmlElementRefs | A container annotation for defining multiple@XmlElementRef annotations. Default Settings: None | @XmlElementWrapper | Generates a wrapper elementaround an XML representation. Typically a wrapper XML element around collections. Default Settings: @XmlElementWrapper ( name = "##default", namespace = "##default", nillable = false) | @XmlAnyElement | Mapsa JavaBeans property to an XML infoset representation and/or JAXB element. Default Settings: @XmlAnyElement ( lax = false, value = W3CDomHandler.class) | @XmlAttribute | Mapsa JavaBeans property to an XML attribute. Default Settings: @XmlAttribute ( name = ##default, required = false, namespace = "##default" ) | @XmlAnyAttribute | Maps a JavaBeans propertyto a map of wildcard attributes. Default Settings: None | @XmlTransient | Prevents the mapping of aJavaBeans property to an XML representation. Default Settings: None | @XmlValue | Defines mapping of a class toan XML Schema complex type with asimpleContent or an XML Schemasimple type. Default Settings: None | @XmlID | Maps a JavaBeans property to an XML ID. DefaultSettings: None | @XmlIDREF | Maps a JavaBeans property to an XML IDREF. Default Settings: None | @XmlList | Maps a propertyto a list simple type. Default Settings: None | @XmlMixed | Marks a JavaBeans multi-valued property tosupport mixed content. Default Settings: None | @XmlMimeType | Associates the MIME type that controls the XML representationof the property. Default Settings: None | @XmlAttachmentRef | Marks a field/property that its XML form is aURI reference to mime content. Default Settings: None | @XmlInlineBinaryData | Disables consideration of XOP encoding for datatypes that are bound to base64-encoded binary data in XML. Default Settings: None |
Table 17-7 summarizes the JAXB annotation that can be used with object factories. Table 17-7 JAXB Annotations Associated with Object Factories Annotation | Description andDefault Setting |
|---|
@XmlElementDecl | Maps a factory method to an XML element. Default Settings: @XmlElementDecl ( scope = GLOBAL.class, namespace = "##default", substitutionHeadNamespace = "##default", substitutionHeadName = "") |
Table 17-8 summarizes JAXB annotations that can be used with adapters. Table 17-8 JAXB Annotations Associated with Adapters Annotation | Description and Default Setting |
|---|
@XmlJavaTypeAdapter | Usethe adapter that implements the@XmlAdapter annotation for custom marshalling. Default Settings: @XmlJavaTypeAdapter ( type = DEFAULT.class ) | @XmlJavaTypeAdapters | A containerannotation for defining multiple@XmlJavaTypeAdapter annotations at the package level. Default Settings: None |
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.Legal Notices |