毕鹏的专栏

Jeffrey

Jersey Restlet and Apache CXF

Jersey  Restlet  and  Apache CXF 都是现了RESTFUL 的支持.

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支持的比较全面,不过现在
  1. 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.
  2. 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.
  3. 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.

可惜,还没有真正去用一下。

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭