Hello Joe, The "init" method has been introduced in order to satisfy recurrent requests made by Spring users of the Restlet framework. There is a need to create resources with the default constructor, instead of the "normal" one (the one with the 3 parameters). On the other hand resources need to be instantiated with their context plus the request and response objects. That's why the Finder tries to invoke the 3 parameters constructor, and if it doesn' exist, invokes the default constructor then the "init" method. Having said that, I'm conscious that I've uncompletely answered to your question... But I've a meeting right now.
best regards, Thierry Boileau On 10/22/07, Joe Nellis <[EMAIL PROTECTED]> wrote: > Greetings, > > This purposefully overridable method is called from the Resource(Context, > Request, Response) constructor and therefore subclasses that override > init(Context, Request, Response) are in for a big suprise if they try to do > operations on their own fields in the init method. At this point in > execution, the subclass of Resource has not been initialized and so default > field intializers have not been called, not even fields declared final. The > default initializers will be called after init finishes and any subclass > fields set during the init method call will be overwritten with defaults. > This is a gotcha in Joshua Blochs Effective Java pg 80. Constructors of > classes intended to be subclassed should not call overridable methods. > > So I think some clarification on when to override init when your class also > supports the three argument resource constructor (assuming you call > super(context,request,response) first in the constructor.) Why is there a > three argument constructor? The Finder.createResource calls the default > constructor then calls init afterwards which is ok because all subclasses > have been initialized by then. > > Perhaps there is a way with annotations to convey Variants a resource has > representations for as this is what the init method seems to be of value > for, adding variants to the list. > > -Joe >

