I'm trying out Restlets in a Tomcat servlet container.

As part of the integration testing, I'm using an existing servlet to
establish authentication and resource access tokens, then using the
servlet API
servletContext.getRequestDispatcher(location).forward(request, response)
to forward to a RESTLet connected using
com.noelios.restlet.ext.servlet.ServerServlet.  My plan was to put the
objects necessary for the servlet to access my existing application's
resources on the HttpServletRequest inside my servlet with
httpServletRequest.setAttribute(key, value) and then retrieve them in
the org.restlet.resource.Resource implementation.

I'm not finding a path way that provides the Resource with access to the
javax.servlet.http.HttpServletRequest object, or its Attributes.

I'm not using an IOC framework

I've read
http://restlet.tigris.org/servlets/ReadMsg?list=discuss&&msgNo=397 but
it seems not to have happened (at least, there is no Maplet and some of
the other classes mentioned aren't there either.)

I need a way to pass this information through on a per-request basis
(i.e., they aren't servlet init parameters).

I've got the following hack but it's clearly wrong.

  private Object getHttpRequestAttribute(String name) {
    Request request = getRequest();
    com.noelios.restlet.http.HttpRequest hr =
(com.noelios.restlet.http.HttpRequest)request;
    com.noelios.restlet.http.HttpCall hc = hr.getHttpCall();
    com.noelios.restlet.ext.servlet.ServletCall sc =
(com.noelios.restlet.ext.servlet.ServletCall)hc;
    HttpServletRequest hsr = sc.getRequest();
    return (hsr.getAttribute(name));
  }
  
Do you have any suggestions for how to re-cast the problem or how to
pass the objects?

Thank you,
Leigh.

Reply via email to