期待了好久了,终于等到了规范的正式的发布。下面官方发布信息,记录了JSR 311规范从筹备到发布的历程。
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:
[email protected]
与其它规范发布一样,伴随此次发布,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
上面的代码,就会发布两个资源服务:
POST /bank/account/newAccount
GET /bank/account/newAccount
大家看到,用Rest发布资源服务非常方便。当然上面例子只是一个非常简单的示例,用于展示Rest的应用,也希望大家提出好的建议和意见。
Good Luck!
Yours Matthew!