I like how Harald extends Router to be injector-aware in order to avoid
requiring the explicit use of FinderFactory. In fact, I have been
experimenting with a Router extension that adds two more methods:

    public TemplateRoute attach(String pathTemplate, Class<? extends
ServerResource> targetClass, Class<? extends Annotation> targetAnnotation) {
        return attach(pathTemplate,
finderFactory.finderOf(Key.get(targetClass, targetAnnotation)));
    }

    public TemplateRoute attachDefault(Class<? extends ServerResource>
targetClass, Class<? extends Annotation> targetAnnotation) {
        return attachDefault(finderFactory.finderOf(Key.get(targetClass,
targetAnnotation)));
    }

This allows users to attach to resource classes qualified by an annotation,
which was the only thing that I felt was missing from Harald's GuiceRouter.

In order to smooth the way to JSR-330 integration, however, I think it would
be better to call this class QualifiedRouter and make it abstract, with
DI-framework-specific concrete subclasses. Ideally, construction could be
left to a factory class that would produce the correct concrete subclass
without having to mention it explicitly in the user code.

I'd like to see if it's possible to avoid having any extra machinery to deal
with servlets -- good support for servlets already comes with Guice and
Spring (and others I'm sure), so I'm working on a way to get the
injector-awareness passed in at the Application level so it doesn't leak
into Restlet "wiring" code. I wouldn't want to require a particular
structure for the linkage between Servlet and Restlet worlds.

Another topic: What about scopes? Servlets need scopes like request,
session, conversation, etc. Only the first of those makes any sense in
Restlet, but I'm having trouble imagining a strong need for it in practice,
given that Resources are fundamentally request-scoped. Does anyone have an
example of a need for binding in request scope that isn't trivially
satisfied by Restlet already?

--tim


On Mon, Nov 23, 2009 at 1:19 PM, Jerome Louvel <jerome.lou...@noelios.com>wrote:

>  Hi Tim and Harald,
>
>
>
> The goal and main value is see is to ensure the maximum portability of a
> Restlet Application from one deployment environment to another
> (JSE/standalone, JEE, GAE, etc.).
>
>
>
> GAE/J only provides HTTP listening through the Servlet API, so we have to
> use our Servlet/Restlet adaptation layer. The default way is to leverage our
> ServerServlet class from org.restlet.ext.servlet, but we also provide a
> ServletAdapter class to manual adaptation.
>
>
>
> It feels like both approaches should merge as soon as we configure the
> inner of the Restlet Application with Guice. Same GuiceRouter and
> GuiceFinder should be usable. I’ve added a comment on the related RFE:
>
>
>
> “Add support for Guice”
>
> http://restlet.tigris.org/issues/show_bug.cgi?id=546
>
>
>
> Harald, would you be willing to contribute your code to the Guice extension
> developed by Tim (with the help of Bruno Harbulot recently) and to
> collaborate on creating the best Guice extension possible? The current
> extension code is in Restlet Incubator but should find its official place in
> the next Restlet 2.1 version.
>
>
>
> Best regards,
> Jerome Louvel
> --
> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
>
>
>
>
>
>
>
>
>
> *De :* tpeie...@gmail.com [mailto:tpeie...@gmail.com] *De la part de* Tim
> Peierls
> *Envoyé :* dimanche 22 novembre 2009 22:36
>
> *À :* discuss@restlet.tigris.org
> *Objet :* Re: Dependency injection in Restlet 2.0 with Guice
>
>
>
> I thought that the GAE Edition of Restlet hid the "servlet-ness" and made
> it possible to write standalone Restlet components that run in GAE. Is that
> not the case?
>
>
>
> --tim
>
>
>
> On Sun, Nov 22, 2009 at 4:09 PM, <webp...@tigris.org> wrote:
>
> Hi there,
>
> I was looking for dependency injection with guice, as I found the post from
> Tim. The approach described there, seems to best for a standalone setup. As
> I'm currently developing an application using the Google AppEngine, I was
> looking for an integration with a servlet based setup. I described my
> approach in my blog under <a href="
> http://haraldpehl.blogspot.com/2009/11/google-appengine-restlet.html";>
> http://haraldpehl.blogspot.com/2009/11/google-appengine-restlet.html</a>
>
> Greetings
> Harald
>
>
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2423617

Reply via email to