Results 1 to 2 of 2

Thread: Jaxb

  1. #1
    Paul Richards is offline Member
    Join Date
    Oct 2008
    Rep Power

    Question 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?

  2. #2
    vogella is offline Member
    Join Date
    Aug 2009
    Rep Power


    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

  1. JAXB Marshalling
    By akbar4ums in forum XML
    Replies: 1
    Last Post: 12-20-2008, 04:39 AM
  2. Custom XML to Java Type Binding using JAXB
    By surajkumar in forum XML
    Replies: 0
    Last Post: 09-02-2008, 12:32 PM
  3. JAXB Unmarshalling
    By prateek in forum XML
    Replies: 0
    Last Post: 07-10-2008, 06:53 PM
  4. Replies: 0
    Last Post: 06-03-2008, 11:26 PM
  5. How to clone a JAXB object ?
    By simon in forum Advanced Java
    Replies: 1
    Last Post: 07-14-2007, 11:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts