views:

113

answers:

2

Hi.

I was wondering if anybody knows how I can use JAXB together with the Builder Pattern? The builder pattern wants you to set the constructor as private, and JAXB says

"1 counts of IllegalAnnotationExceptions myClass does not have a no-arg default constructor"

Is there somehow I can tell JAXB that I don't want no-arg default constructor, and that it can create a new instance using the Builder pattern somehow?

Update I should note (even though it shouldn't be relevant) that I am using Axis 2 to generate my stub files.

+1  A: 

I don't know the specifics of how to do it, as I've never had to do it, but you can tell JAXB to use a factory class to generate objects. I did a quick google search on it and there appears to be some of the data you're looking for right off the bat.

Mike Thomsen
Alright, I will google factory with jaxb and see what I get.
Shervin
A: 

jaxb provides an ObjectFactory when you generate the classes from the schema with xjc.bat

bobf
I am using Linux and I am generating the stubs with Axis 2
Shervin