Jerome,

Thxs for the zip. After further consideration I am looking at extended Spring's FrameworkServlet class using the example below.

cheers
</jima>
Jerome Louvel wrote:
Hi Jim,

As the integration mode 3) has been requested several times already, I have
just added a new ServletConverter class to the Servlet extension that
handles everything transparently. Here is a usage example:

public class TestServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    private ServletConverter converter;

    @Override
    public void init() throws ServletException {
        super.init();
        this.converter = new ServletConverter(getServletContext());
Restlet trace = new Restlet(this.converter.getContext()){ public void handle(Request req, Response res){
                getLogger().info("Hello World");
                res.setEntity("Hello World!", MediaType.TEXT_PLAIN);
            }
        };

        Router root = new Router();
        root.attach(trace);
this.converter.setTarget(root);
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse res)
            throws ServletException, IOException {
        this.converter.service(req, res);
    }
}

As you can see, your Servlet can extend any super class you want, you just
need to create one ServletConverter (and ideally to reuse it for all
requests).

I will add a FAQ entry tomorrow about this. For now, you can either get the
latest from SVN or get this current.zip:
http://www.restlet.org/downloads/1.0/current.zip

Best regards,
Jerome
-----Message d'origine-----
De : Jim Alateras [mailto:[EMAIL PROTECTED] Envoyé : lundi 26 mars 2007 13:24
À : [email protected]
Cc : [EMAIL PROTECTED]
Objet : Re: spring and restlet

Jerome,

Thxs, this is great. I have a few more comments\questions inline

Jerome Louvel wrote:
3) Embedded mode B: lighter version where Spring and the
Servlet container
are not masked by the concept of Restlet Application. This
requires the
creating of a special Servlet (maybe a Spring's
HttpBeanServlet subclass)
HttpServletBean is the class that needs to be subclassed.

and a bit of coding to convert Servlet's calls into
Restlet's calls. In this
mode, no Restlet's Application is created,
Restlets/Filters/Routers/Finders
are directly instantiated by Spring and configured like
other Spring beans.
Of course you loose the Application services and the
portability of your
Restlet code to other deployment environments.
i think this is the most appealing mode for my application but I think I need a bit more info to get going. For instance if all I want to do is use the Router class then all I need to do is

1. subclass HttpServletBean

2. subclass doXXX in HttpServletBean

3. for each method convert the HttpServletRequest to a org.restlet.data.Request and subsequently the org.restler.data.Response to a HttpServletResponse.

4. In each of the HttpServletBean.doXXX call Router.handle(request, response) method to route to the appropriate Resource.

Is this correct?

Should I also look at the ServerServlet class for help on converting a Servlet call to a Restlet call?


cheers
</jima>

Reply via email to