2014-01-05 146 views
0

Restlet看起來很酷,但是很抱歉,由於缺乏簡單客戶端上的文檔,我只是整天喋喋不休。Restlet客戶端界面類

我已經成功地從

http://restlet.org/learn/guide/2.1/core/resource/client

嬰兒牀一些有用的東西,但也僅僅是實際工作的完全下載(這將是很好的)什麼都沒有。例如,客戶在這裏只是一個pojo?或者它必須實現Serializable(我認爲它必須)。

我的具體問題如下:

我有一些代碼,這使得調用一個URL,並且取回此:

{"result":"success","data":{"last_local":{"value":"889.66000","value_int":"88966000","display":"$889.66","display_short":"$889.66","currency":"USD"},"last":{"value":"889.66000","value_int":"88966000","display":"$889.66","display_short":"$889.66","currency":"USD"},"last_orig":{"value":"889.66000","value_int":"88966000","display":"$889.66","display_short":"$889.66","currency":"USD"},"last_all":{"value":"889.66000","value_int":"88966000","display":"$889.66","display_short":"$889.66","currency":"USD"},"buy":{"value":"889.00000","value_int":"88900000","display":"$889.00","display_short":"$889.00","currency":"USD"},"sell":{"value":"889.66000","value_int":"88966000","display":"$889.66","display_short":"$889.66","currency":"USD"},"now":"1388846889233438"}} 

位,我掙扎,是魔法情況如下:

ClientResource cr = new ClientResource(….); // fine 
IDataStruct resource = cr.wrap(IDataStruct.class); // <---- Magic here, but fine at Runtime. 

     if(cr.getResponse().getStatus().isSuccess()) // fine 
     { 
     PriceObject price = resource.retrieve();//<--- get to this line but then everything blows up because no converter is found. I can't use Jackson because GAE does not like it 
    } 

的問題是,應該怎樣IDataStruct接口的樣子?

請問。

+0

Restlet在行動中是一本很好的書,它幾乎彌補了破損的RESTlet網站。另外,請查看他們的github存儲庫 - 文檔位於某處。 – tom

回答

0

該示例中的客戶確實是POJO。根據您使用的轉換器,您可以使其可序列化或不可以。順便說一句,傑克遜應該在GAE上工作,你遇到了哪個問題?

IDataStruct應的Restlet API註釋,比如@Get,@Post等

關於用戶指南中的Java接口註釋,你可以在GitHub上,在這裏我只是修正了一些的發現編輯後的版本(Restlet.org即將發佈): https://github.com/restlet/restlet-sites/blob/master/modules/org.restlet/learn/guide/2.1/introduction/first-steps/first-client.md

相關問題