是否有任何针对GAE的Restlet的开源项目?

时间:2010-12-25 08:56:30

标签: java google-app-engine orm restlet objectify

我正在寻找在GAE上托管的Restlet的开源项目,并试图通过restlet + objectify找出CRUD操作。在我目前的应用程序中,我使用了以下,

  • 使用Restlet for rest full webservice
  • Objectify as ORM framwork。
  • 主持GAE。

我不太清楚如何在restlet中请求JSON表示的响应。

因此,如果谷歌代码或github上有开源项目,那将有所帮助。

由于

2 个答案:

答案 0 :(得分:1)

我在项目中使用相同的技术。如果您正在寻找JSON表示示例,下面的代码可能会有所帮助。我正在使用Gson来处理JSON序列化/反序列化:

public Foo() {

    private String name;

    public Foo() {};

    public Foo(String name) {
        this.name = name;
    }

    public String toJson() {
        return new Gson().toJson(this);
    }
}

@Get("json")
public Representation represent() {

    Foo foo = new Foo("bar");
    return new JsonRepresentation(foo.toJson());

}

@Post("json")
public Representation post(Representation entity) {

    JsonRepresentation json = null;

    try {

        json = new JsonRepresentation(entity);
        Gson gson = new Gson();
        Foo foo = gson.fromJson(json.getText(), Foo.class);

    } catch (Exception e) {
        System.err.println(e.getMessage());
    }

    return json;
}

答案 1 :(得分:0)

我找到了一个

博客引擎:http://code.google.com/p/blogress/