public class DefaultResource extends ServerResource { @Get public String represent() { return "Default resource, try /hello/resource or /hello/handler"; } }
ServerResource has a no-arg constructor, so you don't need to pass Context, Request, and Response objects to super().
Nice as this is, I still want to inject my resources using Guice, so I've updated the Restlet-Guice classes from my previous post to support both the new ServerResources and the old Handlers. It incorporates the enhancement mentioned in the updates: You can override methods to use different providers for Application, Context, Request, and Response, although for most purposes the default providers should suffice.
Update 2009-Dec-11
I've been working on a Guice extension for Restlet as an incubator project that uses the ideas in this posting. My goal is to make this extension independent of Guice at the interface level, so that people can provide implementations for different DI frameworks, of which Guice is only the first.
2 comments:
Hi,
Thanks for the work that you've done here.
Any chance you can drop this into a public repo like GitHub or BitBucket so others can tool around with it and possibly contribute back?
I've volunteered to help create a Guice extension for Restlet, so this will have a real home.
Post a Comment