users@jersey.java.net

Hello all

From: Kevin Duffey <andjarnic_at_yahoo.com>
Date: Sun, 25 May 2008 18:31:13 -0700 (PDT)

Hello all,

Just started using Jersey with Glassfish v2, Netbeans IDE. I'm kind of a noob to the RESTful stuff. I like that GlassFish has the JSR-311 (I think its jersey) implementation built in... er, at least I think it does, maybe its the Netbeans IDE plugin wizard that adds it to my WAR/EAR files? I see a REST build.xml that gets added when I use the wizards.

Got a couple questions, was hoping some of you more experienced guys/gals could answer.

1) At least with Netbeans, the wizard is nice... not used to using GUI wizards for things. I was able to build/deploy and actually access the GeneircResource I created. What I am not too clear on is, the IDE wizard creates a getXml() and putXml() methods. The getXml() has annotattions for @GET and @ProduceMime("application/xml"), the other one has @PUT and @ConsumeMime("application/xml"). So, first part of this question is, with the @GET, which I was able to test with a simple browser URL to it, it does not accept any input. Generally speaking, I would expect the ability to call a GET handler and pass in either request parameters (?key=value&key2=value), OR pass in a body of XML that provides some parameters. As I am new to REST, I am not entirely sure if this is out of the norm or not. Perhaps I am supposed to use a PUT in the case I need to pass something in that can be used to dictate the response I get back? My understanding tho is put/post
 "change/create" things, where as GET just returns a response, and has no side affects based on any input. So is it possible to pass in something into a GET handler that can be used to help formulate the response? Or are GET calls purely to return some sort of static-like (maybe from a DB table, no logic applied, just a query) response? If you CAN specify parameters, do you put both a @ProduceMime & a @ConsumeMine for one method? Or are u limited to one or the other annotation per method?

2) I notice, at least in code completion. only @GET and @PUT are available. Maybe it's just the IDE, are @POST and @DELETE not available? I am using the latest (from about a week ago) IDE plugin for JSR-311. Haven't tried compiling with them, but I was guessing they would also be present.

3) So, in my API, I have to handle something like so:
  /a - resource
 /b - diff resource
  /c - yet another resource

so this would be 3 classes. However, we have two many to many relationships, such that A can "belong" to one or more Bs, and a B can belong to one or more As. So we might have a
GET /a/{a_name}/b to get me all the Bs that belong to the A, and vice versa, GET /b/{b_name}/a to get a list of all the As.

How would this be handled in either A or B class (resource)? I am not quite clear how when the GET /a is called, how do I set up the method to handle the /a alone, and the /a/{a-name}... two separate methods that are auto-called for me? Or do I have to parse something myself to figure out the a_name in the 2nd call? In the event of a GET /a/{a_name}/b ... I assume the /a resource is being called, is there some automagic thing that is done by the JSR-311 to get me the a_name as well as the b... or do I have to do some parsing to get down into it? Just wondering the scope of what I need to learn to get this API I have to do working. I have about a week left to make some magic happen. lol

I will probably have some more questions down the road. Just looking to get started and understanding how to use JSR 311.

Thank you all.