Hi Evan,

> I just started investigating Restlet a few days ago, and I'm quite 
> intrigued. It looks like it would be a perfect fit for a project I'm 
> working on, which uses Tomcat as the servlet container.
Cool!

> The only issue I'm running in to is that my application needs 
> access to 
> certain parameters (such as the location of a Lucene index, 
> or whether 
> to enable a certain feature) that are currently stored as context 
> parameters to our existing, non-REST servlet.
Ok.

> I've started using ServerServlet, but it doesn't seem to pass the 
> servlet context parameters through as initialization 
> parameters to the 
> target restlet.
The next beta version will improve the access to the Servlet context by
providing a unified concept of context for both Restlets and Maplets (base
on the WAR archive approach). Currently, there is a way to access to your
ServletContext via the ServletCall class:

ServletCall servletCall = (ServletCall)myCall.getConnectorCall();
ServletContext servletContext = servletCall.getContext();

> Normally, I would subclass ServerServlet to set the appropriate 
> initialization parameters on its target when getTarget() is 
> invoked, but 
> this causes problems, as the only way I can see to set up my 
> sub-restlets (which will require that the target restlet have 
> access to 
> these initialization parameters) is to do it in the 
> constructor, which, 
> of course, doesn't work, as the initialization parameters 
> will be set by 
> my ServerServlet subclass *after* the target restlet is constructed.
This is indeed an issue :-)

> Also, the start() method on restlets is intriguing, but I don't know 
> what it does :-) It doesn't seem to be invoked on my target restlet, 
> but, if it were, I could presumably do the setup there.
This is a good place to initialize your sub-restlets. However, as you
noticed, it's never called for ServerServlet targets. This is a bug that
will be fixed in the next version. Currently you can add this workaround in
your target: override the handle() method:

public void handle(Call call)
{
   if(!isStarted())
   {
      start();
   }

   super.handle(call);
}

> Any help would be much appreciated! I'd love to use the Restlet 
> framework, but this is the one issue that's currently holding me back.
Hope the workaround will help you wait to the next version (due soon, maybe
tomorrow).
Sorry for the inconvenience!

Thanks,
Jerome

Reply via email to