I use JAXRS a lot, tied into Guice. It's great - my resources are
instantiated, get their injections, executed, then thrown away. But
sometimes I need to use something lower level, so I mount a servlet with
ServletModule.
The problem is that servlets suck. They have to be singletons and they have
an awkward API, passing HttpServletRequest and HttpServletResponse around.
Not at all like the simple throwaway instances that I get in JAXRS-land.
This is what I really want:
public class MyServletModule extends BetterServletModule {
public void configureRunnables() {
serve("/somepath").with(MyClassThatImplementsRunnable.class);
}
}
Now anyone could make a class like this:
public class MyAction implements Runnable {
private final HttpServletResponse response;
@Inject
public MyAction(HttpServletResponse response) {
this.response = response;
}
public void run() {
response.getWriter().println("Hello, world");
}
}
It's pretty easy to imagine that by injecting more sophisticated objects
(that themselves abstract request/response), you could have a pretty
elegant mini-web-framework without a lot of effort. Less need for
Provider<?>s everywhere.
I looked at the implementation of ServletModule and didn't really
understand what's going on. How hard would it be to implement something
like what I describe? Can someone suggest a general approach that would get
me started in the right direction? Even better, has anyone already done
this?
Thanks,
Jeff
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/73e28f6e-bca7-413a-916e-fb6830002b7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.