users@jaxb.java.net

Re: restricting access to constructors of generated classes

From: Dmitri Colebatch <dim_at_colebatch.com>
Date: Thu, 5 Oct 2006 15:44:56 +1000

I don't know the answer to your question, but many people use the
generated classes as javabeans, and javabeans must have a public
no-arg constructor.

cheers
dim

On 10/5/06, Lowell Kirsh <lowellk_at_gmail.com> wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>