Hi,
On the server side, I have a simple SQLite database that provides and store
resources. Although it is discouraged, I went into extending the Restlet class
to keep a hook to the database, in order to write:
router.attach("/users/create", new CreateUserRestlet(database));
Indeed, I don't understand how I may pass the database to such a resource
mapping:
router.attach("/users/create", CreateUserResource.class);
Now, in the CreateUserRestlet, I don't understand how I can convert the
resource back to a java object:
public class CreateUserRestlet extends Restlet {
public void handle(Request request, Response response) {
System.out.println("request as text:" + request.getEntityAsText());
// fine: I can read the object as a json string
try {
JsonConverter c = new JsonConverter();
CreateUserQuery q = c.toObject(request.getEntity(), CreateUserQuery.class,
null);
// "null" should be replaced by "the calling resource", but I can't find a
method in Request that returns a resource object.
System.out.println("query:" + q);
// output is null
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Do you have a suggestion to make the manual conversion?
Do you think it is a wrong idea to write custom restlet directly?
Many thanks in advance,
Martin
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2910019