Welcome to Aspire Knowledge Central (AKC)
Home Public Library Author Content
Jaxb 2.0 tutorial
- Realize the reflection based architecture of Jaxb
- Plan a sample project for exercising Jaxb
- Resources and how best to use them
Reflection based architecture
jaxb 2.x architecture supports metadata based marshalling and unmarshalling of xml. This makes xsd optional unlike the jaxb 1.x architecture
The project is a simple project where an xml file is marshalled and unmarshalled using jaxb 2.x. All of the files needed to accomplish this are provided on the right hand side of the menu.
Because jaxb 2.x relies on reflection, you will need to get jdk 1.5. And also a development environment that works with jdk 1.5. See the pre-requisites menus on the right hand side to get some help on these pre-requisites. I have used the 3.1 release candidate of eclipse to work with jdk 1.5. Seem to work ok
You will also probably need to understand XSDs if you are planning on exploring options with XSDs.
Some tool like XML SPy might be helpful although not required. In the XSD links I have put a link for online xsd verifiers
How best to use the tutorial page
Using the the notes on eclipse, you may want to download and install 1.5 development environment. You will also want to read up briefly on what metadata is and how to use it to annotate your code.
The key to using jaxb 2.x effectively is to understand the metadata attributes. You can look these up in the jaxb java api. Sometimes the java api description is a bit terse. The best place to look up is the jaxb mailing list. For convenience I have placed a search link for the news groups.
While working with the tutorial you will also need java api links for jaxb and jdk. I have placed these links as well on the control pages.
In short everything you need to work with this tutorial is included in the links here. Just keep this browser page open in the background when you are developing your tutorial and you will have everything you need in one place.
Check my working notes
I have a running notes that I have kept track of while I have developed and tested the solution. Use this link to read through to see if you run into similar things. You can use the feedback links, if you want to add your own things to it.
I have included a section called "Rolling your own reflection". You are probably thinking why is this needed when I have so many tools that I can between xml and java. These classes goes to the core idea of how most of these tools work. Knowing that you can use the concept in a number of scenarios, including rolling your own jaxb 2.x like package to run on java 1.4.x. Why is that important, well a number of IT companies may take a while to go to jdk 1.5, rendering that option quite impractical. Under such cases you have the option of using Castor or something like this. The advantage of using this option, is your entire code is packaged as a jar file and no additional configuration files. You can also use this technology for mapping partial xml to java or binding non xml data to java.
1. Eclipse Notes for jdk 1.5 link error
The link to 'Eclipse Notes for jdk 1.5' is wrong, could you fix it and let me know please.
I desparatly need it to get your tutorial work on my machine.
Dr. Bing Yang, Give me a few minutes ...
Dr. Bing Yang, Give me a few minutes. I will check it. Also if you are looking for something specific don't hesitate to leave a note here or email me at satya at activeintellect.com.
Feedback here is usually better though.
Just remember to put a
before each sentence in your feedback. You don't have to end it with a paragraph tag.
I have fixed the jdk 1.5 links
Dr Bing Yang,
I have fixed the links for jdk 1.5. If you use the jdk 1.5 link, it will directly take you to the jdk 1.5 notes from the eclipse site.
You can also look at my faq page for eclipse. Especially go to the end of that page and you will see the download pages for 1.5 and a few more instructions and caveats on the 3.1 build of eclipse.
If you need further assistance on setting up eclipse for jdk 1.5 don't hesitate to post your questions here.