Jersey Restlet and Apache CXF 都是现了RESTFUL 的支持.
Jersey 实现了jsr 311继续使用 jax-ws式样的使用annotation 完成对url 的控制。
下面的code很熟悉吧
Jersey 实现了jsr 311继续使用 jax-ws式样的使用annotation 完成对url 的控制。
下面的code很熟悉吧
@HttpMethod("GET")
@UriTemplate("{userId}.txt")
@ProduceMime("text/plain")
public String sayHello(@UriParam("userId") String userId) {
return "Hello " + userId;
}
Restlet使用的要自己使用code把消息dispach的相应的restlet上。
public class RestletMapper {
private Map restMap = new HashMap< String , Restlet>();
public void init( Router router){
for( Object key : restMap.keySet() ){
router.attach( (String)key , (Restlet) restMap.get(key));
}
}
public void setRestMap( HashMap< String , Restlet> map){
this.restMap = map;
}
}
Router
相比之下,感觉jersey的实现更加简洁, Restlet的控制能力更强。
Apache CXF 对 REST的sytle支持的比较全面,不过现在
- JAX-RS (JSR-311): CXF has an initial implementation of JAX-RS (JSR-311): Java API for RESTfulWeb Services. This provides a more standard way to build RESTful services in JAVA.
- HTTP Binding: The HTTP binding provides a flexible way of creating resources and mapping them to operations in your service. This can currently be done via annatotations or a convention based mapping.
- JAX-WS Provider and Dispatch: It is possible to create simple RESTful services with the JAX-WS Provider and Dispatch APIs. It is not as flexible as the HTTP binding, but does use standard APIs.
可惜,还没有真正去用一下。
RESTful服务框架对比
本文对比了Jersey、Restlet及Apache CXF三种RESTful服务框架的特点与实现方式。Jersey通过注解简化URL控制,Restlet提供强大的手动消息调度功能,而Apache CXF则支持全面的REST风格,并遵循JAX-RS标准。
3038

被折叠的 条评论
为什么被折叠?



