Results 1 to 2 of 2
Thread: Jaxb
- 08-03-2009, 08:14 PM #1
Member
- Join Date
- Oct 2008
- Location
- UK
- Posts
- 65
- Rep Power
- 0
Jaxb
My project is in NetBeans 6.7. I have previously used SAX to parse my XML. However, a colleague has done some work for me on my program using JAXB. He has written the schema and uses the bindings to automatically generate the code. This is a radically different approach.
How do you use JAXB? The "data" classes are auto-generated, but my "data" classes have algorithms in them as well. They are not just fields/getters/setters. How do you integrate it into the architecture of your application?
Do you separate out the data and the algorithms and use the getters/setters in the auto-generated code? Or, do you have your own classes for the data and just use the auto-generated ones for the purposes of reading/writing from XML?
If you alter the schema, it will generate different codes and you will get compiler errors. There is no "refactoring" like if you were coding it yourself. Is there any way around this?
Is there any way to include your own code within the auto-generated stuff?
JAXB puts the fields as Protected. Is there any setting to make them Private?
- 08-03-2009, 09:56 PM #2
Member
- Join Date
- Aug 2009
- Location
- Heidelberg
- Posts
- 47
- Rep Power
- 0
I never mix my domain model with application logic. AFAIK this is considered as good design. Mixing model and processing concerns should be avoided.
JAXB can also work with private fields. The following tutorial demonstrates this: Java and XML - Tutorial
Best regards, Lars
Similar Threads
-
JAXB Marshalling
By akbar4ums in forum XMLReplies: 1Last Post: 12-20-2008, 04:39 AM -
Custom XML to Java Type Binding using JAXB
By surajkumar in forum XMLReplies: 0Last Post: 09-02-2008, 12:32 PM -
JAXB Unmarshalling
By prateek in forum XMLReplies: 0Last Post: 07-10-2008, 06:53 PM -
JAXB unmarshall not responding (help needed)
By Buglish in forum XMLReplies: 0Last Post: 06-03-2008, 11:26 PM -
How to clone a JAXB object ?
By simon in forum Advanced JavaReplies: 1Last Post: 07-14-2007, 11:56 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks