开发者

JAXB together with Builder Pattern. Is that possible?

开发者 https://www.devze.com 2022-12-21 18:52 出处:网络
I was wondering if anybody knows how I can use JAXB together with the Builder Pattern? The builder pattern wants you 开发者_C百科to set the constructor as private, and JAXB says \"1 counts of IllegalA

I was wondering if anybody knows how I can use JAXB together with the Builder Pattern? The builder pattern wants you 开发者_C百科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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消