9 messages in net.java.dev.jersey.usersRe: [Jersey] [PATCH] to allow the API...
FromSent OnAttachments
James StrachanFeb 19, 2009 7:03 am 
Paul SandozFeb 19, 2009 7:13 am 
James StrachanFeb 19, 2009 7:41 am 
Paul SandozFeb 20, 2009 6:01 am 
James StrachanFeb 20, 2009 6:38 am 
Paul SandozFeb 20, 2009 8:40 am 
Paul SandozFeb 24, 2009 2:53 am 
James StrachanFeb 24, 2009 10:18 am 
Paul SandozFeb 25, 2009 12:03 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [Jersey] [PATCH] to allow the API of RESTful services to be rendered using hierarchial Implicit ViewsActions...
From:Paul Sandoz (Paul@Sun.COM)
Date:Feb 25, 2009 12:03:47 am
List:net.java.dev.jersey.users

On Feb 24, 2009, at 7:18 PM, James Strachan wrote:

Next steps:

1) investigate the move of WadlResource and creation of further classes into the API so that they can be extended. My initial thoughts on this is i want to be conservative in terms of implicit views, implicit produces and produces media types. i.e. the developer should override or replace as appropriate. Currently the patch for WadlResourceResource and WadlPartialResource are really specific to implicit views because there are not actual resource methods present. James, do you have any opinions on this?

I wonder if Jersey should ship with a default implementation of WadlResource and WadlResourceResource (or whatever the 2 classes are called - one for the application and one for sub resources) but by default they are not mapped to anything (or maybe they are just mapped to /application.wadl but then derived classes can map them to new URIs with new @Produces/@ImplicitProduces?.

Then users can just derive from them and map them to a URI if they wish?

e.g.

@Path("api") @ImplicitProduces("text/html;qs=5") @Produces({"application/vnd.sun.wadl+xml", "application/xml", "application/json"}) public class MyWadlResource extends WadlResource { ... // not much code or inner knowledge of Jersey's impl required here apart from the factory method to create nested resources...

protected WadlResourceResource createChildResource(String uri) { return new MyWadlResourceResource(...); } }

Then the derived class is mostly about adding your own @Path / @Produces and optional @ImplicitProduces and helper methods if you need any? I'm keen for there to be as little ninja-Jersey hacking required for folks to add the API stuff to their apps

OK. I see what you are getting at now.

For efficiency purposes it be recommended that @Singleton be used (or the same for whatever IoC framework is being used). This is because one obtains a new instance of Application (since instances are mutable) and we also need to place the base URI into the Application instance (unfortunately it is not always possible to derive the base URI at initialization, especially so for Servlet). So we can also provide this functionality for the developer as well.

Note that the way things are defined now the WadlResource and other classes do not depend on any Jersey implementation classes so it will all be nicely isolated.

Paul.