Utilized JAXB to generate POJOs automatically


Published on

Published in: Technology, Education
  • Can someone post a link for part 1?
    Are you sure you want to  Yes  No
    Your message goes here
  • very useful for parsing small amounts of data. but if you need to parse huge amounts of data you cannot afford reading it into memory all at once. check out the LDX toolkit+framework: generates Java parser, no need to learn a new API, memory sparse solution (in fact, you can process any data size)
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Utilized JAXB to generate POJOs automatically

  1. 1. Utilized JAXB to generate POJOs automatically -- Green Integration Part II Albert Guo [email_address]
  2. 2. Agenda <ul><li>Scenario </li></ul><ul><li>JAXB (Java Architecture for XML Binding) </li></ul><ul><li>Implementation steps in Green Integration </li></ul><ul><li>JAXB Usage </li></ul><ul><li>JAXB Limitations </li></ul><ul><li>Summary </li></ul><ul><li>Appendix </li></ul>
  3. 3. Scenario
  4. 4. System Architecture CIS Green Windchill Project Management Document Management Change Management Pro/E Wildfire Pro/E Work Space Pro/E PDMLink Supplier Management GSM Product Management (Part /BOM) Interface Table SAP ERP ProjectLink ODBC xml
  5. 5. Where to launch Export BOM to GSM xml
  6. 6. XML content example If the part has child, this part will be enclosed by <ProductStructure>. If the part does not have child, then this part will be enclosed by <Line>
  7. 7. JAXB (Java Architecture for XML Binding)
  8. 8. What is JAXB <ul><li>JAXB (Java Architecture for XML Binding) is part of the Java Web Services Developer pack . </li></ul><ul><li>This integrated toolkit contains all of J2EE's XML technologies, including SAX, DOM, web services, and others. </li></ul><ul><li>Official site: https://jaxb.dev.java.net/ </li></ul><ul><li>Download: http://java.sun.com/webservices/downloads/index.jsp </li></ul><ul><li>Installation instructions: http://java.sun.com/webservices/downloads/install-windows.html </li></ul>
  9. 9. Architecture JAXB We’ll focus on JAXB instead of Xstream in this material. If you’re interested in Xstream, please refer to Utilized XStrem in Green Integration . XML Spy can do the same thing, but it’s not free solution.
  10. 10. Implementation steps in Green Integration
  11. 11. Implementation steps in Green Integration Applied JAXB to generate POJOs automatically We can focus on retrieving data and setting them into POJOs. Applied XStream to generate XML file by easy way. Applied Commons IO to write xml content into file Logging service Utility classes Commons Lang
  12. 12. JAXB Usage
  13. 13. JAXB Usage -- commands xjc.bat -p [package name] [xsd location] -d [code gen destination]
  14. 14. JAXB Usage We can use JAXB to generate these POJOs based on xsd file automatically
  15. 15. JAXB Limitations
  16. 16. JAXB Limitations <ul><li>JAXB only support JDK 1.5 or later. </li></ul><ul><li>These POJOs which generated by JAXB will have many annotations in its content. Therefore, if your JDK is 1.4 or before, you need to remove these annotations part and remove its related import statement (javax.xml.bind.annotation.*). </li></ul>
  17. 17. Summary
  18. 18. Summary Logging service
  19. 19. Appendix
  20. 20. Appendix <ul><li>JAXB </li></ul><ul><ul><ul><li>JAXB is one of the APIs in the Java EE platform , and is part of the Java Web Services Development Pack (JWSDP). It is also one of the foundations for WSIT . JAXB is part of SE version 1.6. </li></ul></ul></ul><ul><ul><ul><li>JAXB 1.0 was developed under the Java Community Process as JSR 31. As of 2006 , JAXB 2.0 is being developed under JSR 222. Reference implementations for these specifications are available under the CDDL open source license at java.net. </li></ul></ul></ul><ul><li>Xstream </li></ul><ul><ul><ul><li>a simple Java library to serialize objects to XML and back again. </li></ul></ul></ul><ul><ul><ul><li>a Danish IT-company offering streaming media business solutions (spelled Xstream) </li></ul></ul></ul><ul><ul><ul><li>a simple functional transformation language for XML documents derived from Caml , for which a compiler is provided under CeCILL free software licence . </li></ul></ul></ul>
  21. 21. Appendix <ul><li>Commons IO </li></ul><ul><ul><ul><li>Commons IO is a library of utilities to assist with developing IO functionality. </li></ul></ul></ul><ul><ul><ul><li>There are three main areas included: </li></ul></ul></ul><ul><ul><ul><ul><li>Utility classes - with static methods to perform common tasks </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Filters - various implementations of file filters </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Streams - useful stream, reader and writer implementations </li></ul></ul></ul></ul><ul><li>Commons Lang </li></ul><ul><ul><ul><li>The Lang Component provides a host of helper utilities for the java.lang API, notably String manipulation methods, basic numerical methods, object reflection, creation and serialization, and System properties. Additionally it contains an inheritable enum type, an exception structure that supports multiple types of nested-Exceptions, basic enhancements to java.util.Date and a series of utlities dedicated to help with building methods, such as hashCode, toString and equals. </li></ul></ul></ul><ul><li>Log4j </li></ul><ul><ul><ul><li>log4j is a Java -based logging utility. It was originally written by Ceki Gülcü and is now a project of the Apache Software Foundation . It is used primarily as a debugging tool. </li></ul></ul></ul>