More Related Content
Similar to Jbug beijing 2011 rest easy introduction [兼容模式]
Similar to Jbug beijing 2011 rest easy introduction [兼容模式] (20)
Jbug beijing 2011 rest easy introduction [兼容模式]
- 1. RESTEa 简介
asy
By 李
李伟男
l.weinan@
@gmail.com
2011-10-27
- 3. 自我介绍
• JBoss Software En
ngineer since 2010
• RESTEasy Produc ctization Lead
• JBoss EWS Produ uctization Lead
• JBoss EAP 6 Prodductization Team
Member
• cocoa / lisp / reverrse engineering / ror ...
• http://weibo.com/b bluedash
- 4. 团队介绍
• 产品化团队北京Te
eam:杨泳,王卉,高
林,李伟男
• Team Leader: Fernando Nasser
(Toronto Office)
•M
Manager: B
Bruno Georges
- 5. 什么是
是REST
• REpresentationa State Transfer
al
• PhD by Roy Fiielding
- 6. 的目标
REST的
• 让开发者像用户使用
用浏览器看网页一样
方便,简单地使用W
便 简单 使 WebService接口。
接
- 7. REST达成目标使用的
方法
• 一套架构标准,特别是对接 地址设计
套架构标准 特别是对接口地址设计
的指导意见。
的指导意见
• REST 并未规定所使
使用的网络协议,但
使用的网络协议 但
一般用于HTTP协议
协议之下。
• REST针对HTTP协
协议的URL地址设计及
数据交换提供了具体的说明。
- 8. JAX RS
X
X-RS
• JCP标准
标准
• JSR-311
• Java EE6 的组成部 部分
• 基于Annotation的框框架
• HTTP request 映射
射至Java methods
- 9. JAX RS GET
S:
•
/orders/3323
/ d s/3323
@Path(“/orders”)
• public class OrderResource {
• @Path(“/{order-id}”)
• @GET
• @Produces( application/xml )
@Produces(“application/xml”)
• Order getOrder(@PathParam(“or
rder-id”) int id) {
• …
• }
• }
- 10. JAX RS
JAX-RS Annotations
• @Path
• 定义对应的URI路
路径
• @Produces, @Con
nsumes
• 定义接受与返回的
的数据MIME类型
• @GET, @POST, @
@DELETE, @PUT,
@HEAD
• 定义对应的HTTP方法
定义对应的
- 11. JAX RS GET
S:
•
/orders/3323
/ d s/3323
@Path(“/orders”)
• public class OrderResource {
对应的基础URI
• @Path(“/{order-id}”)
• @GET
• @Produces( application/xml )
@Produces(“application/xml”)
• Order getOrder(@PathParam(“or
rder-id”) int id) {
• …
• }
• }
- 12. JAX RS GET
S:
•
/orders/3323
/ d s/3323
@Path(“/orders”)
• public class OrderResource {
getOrder()方法对应
• @Path(“/{order-id}”) 的进一步路径。
• @GET
• @Produces( application/xml )
@Produces(“application/xml”)
• Order getOrder(@PathParam(“or
rder-id”) int id) {
• …
• }
• }
- 13. JAX RS GET
S:
•
/orders/3323
/ d s/3323
@Path(“/orders”)
• public class OrderResource {
• @Path(“/{order-id}”) 参数映射
• @GET
• @Produces( application/xml )
@Produces(“application/xml”)
数据类型自动
转换
• Order getOrder(@PathParam(“or
rder-id”) int id) {
• …
• }
• }
- 14. JAX RS GET
S:
•
/orders/3323
/ d s/3323
@Path(“/orders”)
• public class OrderResource {
• @Path(“/{order-id}”)
对应的
对应的HTTP方
方
• @GET 法
• @Produces( application/xml )
@Produces(“application/xml”)
• Order getOrder(@PathParam(“or
rder-id”) int id) {
• …
• }
• }
- 15. JAX RS GET
S:
•
/orders/3323
/ d s/3323
@Path(“/orders”)
• public class OrderResource {
• @Path(“/{order-id}”)
定义返回的数
• @GET 据类型
• @Produces( application/xml )
@Produces(“application/xml”)
• Order getOrder(@PathParam(“or
rder-id”) int id) {
• …
• }
• }
- 16. JAX RS GET
S:
•
/orders/3323
/ d s/3323
@Path(“/orders”)
• public class OrderResource {
• @Path(“/{order-id}”)
• @GET
• @Produces( application/xml )
@Produces(“application/xml”)
• Order getOrder(@PathParam(“or
rder-id”) int id) {
• …
由Coontent
• } Hand
dler负责数据
类型的转换。
• }
- 17. RESTEa
asy功能
• 可嵌入
• CDI Spring EJB, Guice, 及Seam
CDI, Spring, EJB Guice m集成
• 客户端框架
• 支持异步HTTP (COMET)
• Asynchronous Jobs
• 客户端及服务器的缓存方案
• Interceptor
• 自动GZIP压缩及解压
• 可扩展的数据交换格式
• 可扩展的HTTP Method支持
• ...
- 18. 参考资料
• http://www.jboss.org/res
steasy
• http://bluedash.net/sear
rch/resteasy
• http://bluedash.net/sear h/jb
htt //bl d h t/ rch/jboss
• http://bluedash.net/spac
http://bluedash net/spac
ces/JBoss%20AS7中的新概
念-域
• http://bluedash.net/spac
ces/JBoss%20AS%207%20
快速上手
• http://bluedash.net/spac
p p ces/Arquillian%20-
q
%20JBoss的测试利器