Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Pattern to restrict from using default constructor

843830Jul 3 2009 — edited Jul 4 2009
I have a Class with a protected constructor that gets created by a factory method. For using an Object of this Class as a bean i need a default constructor.
My bean is used in a JSP page and gets created in a servlet previously by a factory object.

I didn't find a solution to omit the default constructor.

What is the prefered way to forbid use of the default constructor? I thought about throwing a runtime exception. But I don't really know java and it's patterns so I'll love every better solution
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 1 2009
Added on Jul 3 2009
3 comments
244 views