users@jaxb.java.net

restricting access to constructors of generated classes

From: Lowell Kirsh <lowellk_at_gmail.com>
Date: Wed, 4 Oct 2006 22:37:11 -0700

It seems that there are 2 ways to instantiate objects that were
generated by jaxb:
 - call their constructor
 - call the create...() method on the ObjectFactory

Both of these seem to do the exact same thing. I'm curious, if there's
a factory, why are the constructors public? My problem is that I want
to only call the factory creation methods, and to not call the
constructors directly. That way I can sometimes return a subclass. But
sometimes I forget, and call the constructors directly, which in my
case is a bug. So I'd like to prevent myself from shooting myself in
the foot by making the constructors private. Is there a way to set all
generated classes to have private constructors?

Thanks
Lowell