utilized jaxb to generate pojos automatically

Post on 29-Jun-2015

7.835 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Utilized JAXB to generate POJOs automatically -- Green Integration Part II Albert Guo

jguo@ptc.com

Agenda

Scenario

JAXB (Java Architecture for XML Binding)

Implementation steps in Green Integration

JAXB Usage

JAXB Limitations

Summary

Appendix

2

Scenario

4

System Architecture

CIS

Green

Windchill

Project Management

Document Management

Change Management

Pro/EWildfire

Pro/E

Wo

rk Sp

ace

Pro/E

PDMLink

Supplier Management

GSM

Product Management

(Part /BOM)

Interface

Ta

ble

SAPERP

ProjectLinkO

DB

C

xml

5

Where to launch

Export BOM to GSMxml

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>

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>

JAXB (Java Architecture for XML Binding)

What is JAXB

JAXB (Java Architecture for XML Binding) is part of the Java Web Services Developer pack.

This integrated toolkit contains all of J2EE's XML technologies, including SAX, DOM, web services, and others.

Official site: https://jaxb.dev.java.net/

Download: http://java.sun.com/webservices/downloads/index.jsp

Installation instructions: http://java.sun.com/webservices/downloads/install-windows.html

8

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 .

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.XML Spy can do the same thing, but it’s not free solution.

Implementation steps in Green Integration

Implementation steps in Green Integration

11

Applied JAXB to generate POJOs automaticallyApplied JAXB to generate POJOs automatically

We can focus on retrieving data and setting them into POJOs.

We can focus on retrieving data and setting them into POJOs.

Applied XStream to generate XML file by easy way.Applied XStream to generate XML file by easy way.

Applied Commons IO to write xml content into fileApplied Commons IO to write xml content into file

Logging serviceLogging service

Utility classes

Utility classes

Commons LangCommons Lang

JAXB Usage

JAXB Usage -- commands

xjc.bat -p [package name] [xsd location] -d [code gen destination]xjc.bat -p [package name] [xsd location] -d [code gen destination]

13

JAXB Usage

We can use JAXB to generate these POJOs based on xsd file automaticallyWe can use JAXB to generate these POJOs based on xsd file automatically

14

JAXB Limitations

JAXB Limitations

① JAXB only support JDK 1.5 or later.

② 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.*).

16

Summary

17

Summary

18

Logging serviceLogging service

Appendix

19

Appendix

• JAXB

– 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.

– 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.

• Xstream

– a simple Java library to serialize objects to XML and back again.

– a Danish IT-company offering streaming media business solutions (spelled Xstream)

– a simple functional transformation language for XML documents derived from Caml, for which a compiler is provided under CeCILL free software licence.

20

Appendix

• Commons IO

– Commons IO is a library of utilities to assist with developing IO functionality.

– There are three main areas included:

• Utility classes - with static methods to perform common tasks

• Filters - various implementations of file filters

• Streams - useful stream, reader and writer implementations

• Commons Lang

– 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.

• Log4j

– 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.

21

top related