RE: Is Multiple Get and Put annotations Possible?
I don't see a section called Annotations Parameter. Am I missing some thing here ? Also, is there any tutorial or documentation with details @ annotation in RestLet. Thanks, Deep -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Is-Multiple-Get-and-Put-annotations-Possible-tp5390580p6843657.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2847748
Re: Is Multiple Get and Put annotations Possible?
Hi Deep, if you mean @Get(...) @Get(...) public ... { } That is not allowed from Java, so you can't compile it. If you mean @Get(...) @Put(...) public ... { } Than it is nonsense from REST point of view. For the documentation I can't help you. bets regards Stephan -Ursprüngliche Nachricht- Von: D G dgisc...@gmail.com Gesendet: 29.09.2011 14:16:35 An: discuss@restlet.tigris.org Betreff: RE: Is Multiple Get and Put annotations Possible? I don't see a section called Annotations Parameter. Am I missing some thing here ? Also, is there any tutorial or documentation with details @ annotation in RestLet. Thanks, Deep ___ Schon gehört? WEB.DE hat einen genialen Phishing-Filter in die Toolbar eingebaut! https://produkte.web.de/mailcheck/ -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2847816
RE: Re: Is Multiple Get and Put annotations Possible?
Can we have multiple @Get and @Put for different URL's pointing to them?? For eg: For URI: /car/nissan, I have a @Get(json) method pointing to return nissan car attributes as json For URI: /car, I need just a list of car attributes to be returned as json But both these URI's are pointing to the CarResource which means I need some distinction on the @Get(json) method based on the URL. In short, do we or can we have the @Path annotation in JAX-RS for Restlet resources?? Thanks, Hetal Gaglani -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2705165
Re: Re: Is Multiple Get and Put annotations Possible?
Hello Hetal, you'd rather use two different resource classes here, because usually, in RESTful design, a collection of X is a different resource than X itself. So in your example, you can have the following resources/URI templates/server resource classes: A car: /cars/{car}, CarServerResource A list (collection) of car: /cars, CarsServerResource then, both CarsServerResource and CarServerResource can have as many @Get and @Put you want/need, for example: public class CarsServerResource extends ServerResource { private ListCar cars; @Get(json) public Representation toJSON() { } @Get(xml) public Representation toXML() { } } and so on. Hope this helps. On Thu, Feb 17, 2011 at 6:11 PM, Hetal Gaglani hgagl...@enterasys.com wrote: Can we have multiple @Get and @Put for different URL's pointing to them?? For eg: For URI: /car/nissan, I have a @Get(json) method pointing to return nissan car attributes as json For URI: /car, I need just a list of car attributes to be returned as json But both these URI's are pointing to the CarResource which means I need some distinction on the @Get(json) method based on the URL. In short, do we or can we have the @Path annotation in JAX-RS for Restlet resources?? Thanks, Hetal Gaglani -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2705165 -- Fabián Mandelbaum IS Engineer -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2705216
Re: Is Multiple Get and Put annotations Possible?
Hello, I'm afraid this is not possible. You can have only one parameter (there is only one entity in the request). In this case below , I wonder why the Address is not included inside the Contact object. Does it represent the contact's address? @Post public ArrayListContact update(Address addr, Contact contact); regarding the other post method (the one with a list of contacts as parameter) I will move this code into another resource. Does it add a list of contacts to the current contact? In this case, I create a sub-resource called Contacts, that help to cope with the contact's list of contact (as a side note, it sounds strange ...) Best regards Thierry Boileau Hi Thierry, Thanks for reply to my query. I am having a situation where I need to call various methods with GET/PUT annotations. For e.g. as follow. public interface ContactResource{ @Get public ObjectRepresentationContact retrive(); @Post public ArrayListContact update(Address addr, Contact contact); @Post public ArrayListContact store(ArrayListContact contactList); @Delete public void remove(); } In above example I need to handle 2 different methods with POST annotations. One is having Address and Contact object as the argument(update) while other is having ArrayListContact as the argument(store). So Is there any way to handle this kind of cases ? -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2649149
RE: Is Multiple Get and Put annotations Possible?
Hi Thierry, Thanks for reply to my query. I am having a situation where I need to call various methods with GET/PUT annotations. For e.g. as follow. public interface ContactResource{ @Get public ObjectRepresentationContact retrive(); @Post public ArrayListContact update(Address addr, Contact contact); @Post public ArrayListContact store(ArrayListContact contactList); @Delete public void remove(); } In above example I need to handle 2 different methods with POST annotations. One is having Address and Contact object as the argument(update) while other is having ArrayListContact as the argument(store). So Is there any way to handle this kind of cases ? -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2647420
RE: Is Multiple Get and Put annotations Possible?
Hello, you can have several annotated methods, but they should have distinct annotations. You have a look at this document [1], expecially the section Annotations parameter. Feel free to ask for more details. Best regards, Thierry boileau [1] http://wiki.restlet.org/developers/172-restlet/226-restlet.html -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2646556