On Thu, Dec 19, 2013 at 11:27 AM, Stephane Fellah <fella...@gmail.com>wrote:
> I am currently building a Restlet application where I need to build the > router from a configuration file. The router has different endpoints using > the SAME resource but configured with different settings defined in a > configuration file. Usually routers are defined using template route with > target resource class. This would not work in my case, as the resource > needs to be initialized with the different settings. I can see one way to > solve this problem : using a Filter that set the initialization parameters > in the context, the filter with then forward to the target resource. The > target resource will read the initialization parameters from context in the > doInit(). Is it the best practice to handle this use case ? Should I use > Restlet or Finder instead of Filter. > That's a reasonable way to go. Another way that avoids passing values via the Context is to use custom Finder that creates and initializes the resource in an overridden create(Class, Request, Response), either by calling super.create(targetClass, request, response) and setting the initialization parameters on the returned value, or by re-implementing create(Class, Request, Response) entirely. --tim ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3070538