Jersey Restlet and Apache CXF

1575 ワード

Jersey  Restlet  and  Apache CXFはいずれもRESTFULのサポートが現れた.
Jerseyはjsr 311がjax-ws仕様の使用annotationを引き続き使用してurlの制御を完了することを実現した.
次のコードはおなじみでしょう
@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.

  • 残念ながら、まだ本当に使っていません.