Installing Upgrading Designing Configuring Deploying Monitoring Administering Troubleshooting Reference JBI Components
Close Print View
Designing: Code-Seeder Palette (JAXB) Wizard Editor Palette Actions
 

Classic Java CAPS

Developing Java CAPS Projects

Using SOAP Message Handlers

Creating a Runtime Environment

Designing Business Processes in the Sun Business Process Manager

Working with TCP/IP HL7 Collaborations

Developing Sun Master Indexes (Repository)

Developing Sun Master Patient Indexes

Developing OTDs for Application Adapters

Developing OTDs for Communication Adapters

Developing OTDs for Database Adapters

Developing OTDs for Web Server Adapters

Designing with Application Adapters

Designing with Communication Adapters

Designing with Web Server Adapters

SWIFT Integration Projects

Java EE Based Components

Designing with Sun JCA Adapters

About the TCP/IP JCA Adapter

Defining Constants and Variables

Using Database Operations

Developing Sun Master Indexes

Using the JMS JCA Wizard

Using the JAXB Wizard and Code-Seeder Pallete

Understanding the JAXB Binding Process

To Perform a Typical JAXB Binding Process

The JAXB Wizard

Code-Seeder Palette (JAXB) Wizard Editor Palette Actions

Code-Seeder Palette (JAXB) Wizard Editor Palette Actions

The Code-Seeder Palette (JAXB) Wizard contains the following palette actions.

Figure 1 Palette Menu
JAXB Palette
Constructs JAXB Object

The Constructs action generates code to instantiate JAXB objects. This code generation is useful in automating the generation of a series of getter and setter methods, especially when the JAXB object contains a series of nested objects. The code that is generated will not only instantiate the JAXB Object, but will also populate all the nested objects with initial values. This instantiation and population of values and objects can be done by passing a sample XML file. The Sample XML file needs to conform to the XSD/Schema used to generate the JAXB class. When sample XML file is not provided, all the nested JAXB members objects are instantiated.

To Generate Code Using the Constructs JAXB Object
  1. Drag and drop the Constructs JAXB Object icon into the IDE editor of an existing project.

    The Generate JAXB Constructs code dialog box is displayed.

    Figure 2 JAXB Constructs Object
    JAXB Constuct
  2. Enter the JAXB class name with the package name to be instantiated/initialized. You can also use the Find... button to search for the class (as shown below).
    Figure 3 Find Class Type
    Find JAXB Type
  3. Enter a sample XML file (if available) for the initialization code to use. Update the auto generated method name if required.
    Figure 4 Providing Sample XML File
    Sample XML File
  4. Assuming the XML file conforms to the schema used in generating JAXB classes, a method will be created (as shown below)
    Figure 5 Successful Method Created
    Method creation

    If the sample XML file is not provided, the code generated will not populate the default values (as shown below).

    Figure 6 Unpopulated Method
    unsuccessful Method creation
Marshal JAXB Object

The Marshal palette icon action generates template code to marshal a JAXB object. This provides the ability to convert a Java object tree back into XML data. There is no difference between marshalling a content tree that is created manually using the factory methods and marshalling a content tree that is the result of an unmarshal operation. Clients can marshal a Java content tree back to XML data to a java.io.OutputStream or a java.io.Writer. You must know the Class name of the object you are trying to marshal. You can search for the class using the Find... button. The template code can be generated to marshal a JAXB object to a String, OutputStream, File, Writer, or byte array.

Note - The Code-Seeder currently generates code using a single package name in the context path. You may want to edit the code if more than one package name is needed in the context path.

To Generate Code Using the Marshal JAXB Object
  1. To marshal an existing JAXB class object, drag and drop the JAXB Marshal palette icon to IDE editor.

    The Generate JAXB Marshal codedialog box is displayed.

    Figure 7 JAXB Marshal Object
    JAXB Marshal Object
  2. Enter the JAXB object's class name or use the Find... button to search for the class. (as in the Construct's Figure 3section)
  3. Select the Marshal To option. You can generate the code from a marshal JAXB object to one of String, Writer, OutputStream, JMSTextMessage, or File.
    Figure 8 Select Marshal To
    Marshal To

    The desired method will be generated (as shown below).

    Figure 9 Marshal Generated Method
    Marshal generated method
Unmarshal JAXB Object

The Unmarshal palette icon action will generate template code to unmarshal a JAXB object. This allows for any global XML element declared in the schema to be unmarshalled as the root of an instance document. The JAXBContext object allows the merging of global elements across a set of schemas (listed in the contextPath). This means that a client application is able to unmarshal XML documents that are instances of any of the schemas listed in the contextPath. You must know the Class name of the object you are trying to unmarshal. Since each schema in the schema set can belong to distinct namespaces, the unification of schemas to an unmarshalling context should be namespace-independent. You can search for the class using the Find... button. The template code can be generated to unmarshal a JAXB object from a String, InputStream, File, Reader, or byte array.

Note - The Code-Seeder currently generates code using a single package name in the context path. You may want to edit the code if more than one package name is needed in the context path.

To Generate Code Using the Unmarshal JAXB Object
  1. To unmarshal an existing JAXB class object, drag and drop the JAXB Unmarshal palette icon into the IDE editor.

    The Generate JAXB Unmarshal code dialog box is displayed.

    Figure 10 Unmarshal Option
    Marshal To
  2. Enter the JAXB object's class name or use the Find... button to search for the class. (as in the Construct's Figure 3section)
  3. Select the Unmarshal From option. You can generate the code to unmarshal a JAXB object from one of String, Reader, InputStream, JMSTextMessage, or File.
    Figure 11 Select Unmarshal From
    Unmarshal From

    The Unmarshal Method will be generated as shown below.

    Figure 12 Unmarshal Method
    Unmarshal Method