![]() |
![]() |
|||||||
Status: Final | ||||||||
Stage | Start | Finish | ||||||
Final Release | Download page | 10 Oct, 2008 | ||||||
Final Approval Ballot | View results | 09 Sep, 2008 | 22 Sep, 2008 | |||||
Proposed Final Draft | Download page | 15 Aug, 2008 | ||||||
Public Review Ballot | View results | 27 May, 2008 | 02 Jun, 2008 | |||||
Public Review | Download page | 02 May, 2008 | 02 Jun, 2008 | |||||
Early Draft Review | Download page | 24 Oct, 2007 | 23 Nov, 2007 | |||||
Expert Group Formation | 27 Feb, 2007 | 15 Aug, 2007 | ||||||
JSR Review Ballot | View results | 13 Feb, 2007 | 26 Feb, 2007 | |||||
JCP version in use: 2.6 Java Specification Participation Agreement version in use: 2.0 Please direct comments on this JSR to: jsr-311-comments@jcp.org |
與其它規范發布一樣,伴隨此次發布,Sun同步發布該規范的參考實現項目jersey。最新版本為1.0。 為了讓大家能快速體驗Rest帶給我們全新的架構風格,可以直接從本地下載程序。bookstore-1.0.war 源代碼 bookmark-1.0-project.zip.
下面展示了一個代碼片斷,讓大家直觀感受一下。
1 @Path("/bank")
2 public class Bank {
3
4 @POST
5 @Path("/account/{name}")
6 public Account createAccount(@PathParam("name") String name,
7 @QueryParam("balance")BigDecimal balance) {
8 //
9 return new Account(name, balance);
10 }
11
12 @GET
13 @Path("/account/{name}")
14 public Account getAccount(@PathParam("name") String name) {
15 //
16 return Account.getByName(name);
17 }
18
19 }
20
2 public class Bank {
3
4 @POST
5 @Path("/account/{name}")
6 public Account createAccount(@PathParam("name") String name,
7 @QueryParam("balance")BigDecimal balance) {
8 //

9 return new Account(name, balance);
10 }
11
12 @GET
13 @Path("/account/{name}")
14 public Account getAccount(@PathParam("name") String name) {
15 //

16 return Account.getByName(name);
17 }
18
19 }
20
上面的代碼,就會發布兩個資源服務:
POST /bank/account/newAccount
GET /bank/account/newAccount
大家看到,用Rest發布資源服務非常方便。當然上面例子只是一個非常簡單的示例,用于展示Rest的應用,也希望大家提出好的建議和意見。
Good Luck!
Yours Matthew!