i'm newbie.
I have two questions.
When i use the restlet, i have to use @Post, @Get.
example:
@Post
public String registerUserInfo(StringRepresentation rep){
String str = rep.getText();
....
return "success";
}
But, I saw many @Post example in Google. ( e.g. @Post("text/plain") @Post("xml") @Post("........") )
I want to know What type is possible? Actually, i spend many time finding any guide and RestLet User Guide and example. However, i can not find any official document. if you know, please let me know.
Another question is to use Restlet. i saw many tutorials, that said "you should separate method.."
For example, I make two methods "registerUserInfo" and "modifyUserInfo". i try to implement one resource class "UserResource" to above two methos. However, many people said you separate two resource class. One is registerUserResource, One is modifyUserResource.
Then, at the end of the my project, maybe, my project could be flooded with too many classes. is this right? i don't know.... please let me know.
I think you can find a user guide at this URL: http://restlet.com/learn/guide/2.2/ I think you can find some sample code: http://restlet.com/learn/guide/2.2/introduction/first-steps/
And here is an explanation about annotations: http://restlet.com/learn/guide/2.2/core/resource/
Regarding the design of your application and resources, first determine what resources you need (quickly answer to the following question: what state do I want to expose?)
In your case, as you want to expose users, I see two resources:
Which more or less corresponds in term of implementation: - a UsersServerResource
@Get
public List<User> list(){
[...]
}
@Post
public User add(User user) {
[...]
}
a UserServerResource
@Get public User represent(){ [...] }
@Put public User update(User user) { [...] }
@Delete public User update(User user) { [...] }
You can implement your resources using POJO (such as "User" as in the sample code above) in conjunction with extensions that support serialization/deserialization such as Jackson (cf http://restlet.com/learn/guide/2.2/core/services/converter). We encourage you to use such feature as it ease the developement of resources.
If you want a precise control on the representations exchanged between the client and the server, you can use the Representation class, or StringRepresentation class.
Feel free to ask for more details.