First, the good news. My code is working. But I don't understand WHY it
works.
Using Restlet and the "Annotated Interface" approach, described at
http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/328-restlet/285-restlet.html.
I am also running Restlet GAE (if that matters).
I am using Post to add a new Comment to a collection of Comments, so my
CommentsResource interface has the following:
@Post("json")
public Representation postJson(String value);
@Post("java")
public Representation postJava(Comment comment);
@Post("form")
public Representation postForm(Form form);
And my CommentsServerResource class that implements this interface has three
corresponding implementations, each of which is annotated to match the
methods in the interface.
Now I write a test case in Java. The essence is:
ClientResource client4 = new ClientResource("xxx/comments/");
CommentsResource commentsResource =
client4.wrap(CommentsResource.class);
client4.setRequestEntityBuffering(true); //
stackoverflow.com/questions/6462142
Comment comment = new Comment("Hi there from Java", new Date());
Representation representation4 = commentsResource.postJava(comment);
And the big mystery is that the postJava() method is NOT called, but rather
the postJson() method IS called. And somehow my Comment object was
magically converted to a Json string. It's kinda cool that it works this
way, but I am sure I am missing something (in addition to my lack of IQ
points, which must be obvious by now :) :) ).
RB
--
View this message in context:
http://restlet-discuss.1400322.n2.nabble.com/Mystery-of-Post-tp7338202p7338202.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.
--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2928866