36. . 用 URI Path Template 標示對應的函式
用 @Path 表示存取路徑
沒有常用屬性,內容就是一個相對網址
是不是 / 開頭或結尾沒有差別
@Path("users/{username: [a-zA-Z][a-zA-Z_0-9]*}")
URI Path Template 可以在 URI 嵌入變數
@Path("{bookId}/")
public Book getBook(@PathParam("bookId") int bookId) {...}
URI Path Template 也可以提供參數預設值
@Path("/books/")
public List<Book> getBooks(
@DefaultValue("5") @QueryParam("max") int max) {...}
63. 資料可以 RESTful
. NetBeans Support for RESTful Services
Server-Side:
Entity Classes from Database
Entity Classes from Patterns
RESTful Web Services from Entity Classes
RESTful Web Services from Patterns
RESTful Web Services from Database
JSF Pages from Entity Classes
Test RESTful Web Services
Client-Side:
RESTful Java Client
RESTful JavaScript Client
78. 不同系統之間當然可以透過 REST 整合
. Windows Azure AppFabric Service Bus REST API for Java, PHP
Since the AppFabric Service Bus REST API
can be used from almost all programming
languages and operating systems, it makes
it very easy for applications written on any
platform to interoperate with each another
through Windows Azure.
You can download the new PHP and Java
samples, as well as all others for all other
supported environments, from CodePlex.
88. . JAX-RS 2.0/JSR-339
三個主角先後離開,所以停頓了一段時間
Marc Hadley
Paul Sandoz
Roberto Chinnici
新的 Project Lead
Santiago Pericas-Geertsen
Marek Potociar
目前主要定調的議題
在 Java EE 7 提供更好的 REST 支援
Client API
HATEOAS 支援
Asynchronous Invocation
90. JAX-RS 2.0/JSR-339
. Server API
目前只支援 Synchronous 應用
預計提供 Asynchronous 應用
可能會以 Servlet 3.0 的 Asynchronous 功能
實作,也可能採用其他作法
91. JAX-RS 2.0/JSR-339
. Hypermedia as the Engine of Application State
希望提供 HATEOAS 支援
http://en.wikipedia.org/wiki/HATEOAS
不只要提供方便的 URI 產生機制
還要能夠提供 Link Header 或 Link within
Entity,方便處理 Representation 裡面的
Resource
也要讓 Client 端能夠輕鬆取得這些 Link,進
行後續的處理
光靠 Java SE 的 URI 是不夠的
JAX-RS 的 UriBuilder/UriTemplate/UriInfo 也不夠方便
98. . Summary
RESTful 是趨勢
GlassFish 是很好的平台
NetBeans 是很棒的開發工具
Jersey 是很完整的實作
希望可以平順地轉換到 Java EE 7 的 JSR 339
99. . References
Pavel Bucek's weblog
http://blogs.oracle.com/PavelBucek/
Japod's blog
http://blogs.oracle.com/japod/
Jean-Francois Arcand's blog
http://jfarcand.wordpress.com/
The Aquarium
http://blogs.oracle.com/theaquarium/
Jersey 1.8 User Guide
http://jersey.java.net/nonav/documentation/1.8/user-guide.html