Login | Register
My pages Projects Community openCollabNet

Discussions > discuss > RE: CRUD Operation for Calling ServerResouce with ClientProxy

Discussion topic

2020-04-07: This site is going to be decommissioned and shut down on 2020-07-01. Please copy and archive any data you wish to keep before that date.

Back to topic list

RE: CRUD Operation for Calling ServerResouce with ClientProxy

Author thboileau
Full name Thierry Boileau
Date 2015-01-16 02:20:04 PST
Message Hello,

I guess I should explain the mapping between Java methods and HTTP request.
Using Restlet Framework, the annotated methods follow these conventions:
 - there is either one or no parameter to a Java method.
 - such parameter is either an instance of the Representation (that wraps the flow of bytes coming from the socket) or an instance of a Java bean which is the conversion of the entity sent by the client in the incoming request.

In your case, the annotated method is as follow:

public void readThing(Long id, Result<ThingItem> callback);

Which can't happen since a GET request has no entity. Same issue for the DELETE method.

Here is my first refactoring:
 - GaeThingServerResource is attached as follow

 - Here is content of the GaeThingServerResource class.
public class GaeThingServerResource extends SelfInjectingServerResource
         implements ThingResource {
     private static final Logger LOG
             = Logger.getLogger(Gae​​ThingServerResource​.​class.getName());

     /** The identifier of the resource. */
     private Long id;

     public ThingItem doInit() {
         id = Long.parseLong(getAt​tribute("thingitemid​"));
         // You may check that the resource really exist
        // setExisting(true or false);

     public ThingItem createThing(ThingItem Thing) {
         return Thing;

     public ThingItem readThing() {
         LOG.info("Read Thing id=" + id);
         ThingItem result = store().get(ThingItem.class, id);
         return result;

     public ThingItem updateThing(ThingItem Thing) {
         LOG.info("Updating Thing=" + Thing.toString());
         return Thing;

     public void deleteThing() {
         LOG.info("Delete Thing id=" + id);
         store().delete(ThingItem.class, id);

I guess you may have another question about how to create an entity.

Best regards,
Thierry Boileau

« Previous message in topic | 2 of 3 | Next message in topic »


Show all messages in topic

CRUD Operation for Calling ServerResouce with ClientProxy xybrek Xybrek 2015-01-13 16:45:20 PST
     RE: CRUD Operation for Calling ServerResouce with ClientProxy thboileau Thierry Boileau 2015-01-16 02:20:04 PST
         Re: CRUD Operation for Calling ServerResouce with ClientProxy tpeierls Tim Peierls 2015-01-16 03:46:25 PST
Messages per page: