jersey and jax-rs
DESCRIPTION
A mini-overview of JAX-RS, the JCP standard for RESTful applications, and Jersery, its production-quality reference implementationTRANSCRIPT
JAX-RS and Jersey
Marc Hadley and Paul SandozSun Microsystems
HEAD /JAX-RS
● Java API for RESTful Web Services● Annotation-based server-side API● Servlet or SE deployment
● 1.0 finalized end of September 2008● Online Spec and API
● 1.1 planned to integrate with new Java EE 6 features
● Five open source implementations already● Jersey, JBoss RESTEasy, Restlet, Apache CXF,
Triaxrs
GET /JAX-RS/Example
@Path("widgets/{id}")@Produce("application/widgets+xml")@Consumes("application/widgets+xml")public class WidgetResource {
private Widget w;
public WidgetResource(@PathParam("id") String id) { this.w = locateRecord(id); }
@GET Widget getWidget() { return w; }
@PUT Widget updateWidget(Widget update) { w = processUpdate(update); return w; }}
HEAD /Jersey
● Open source production quality Reference Implementation● https://jersey.dev.java.net/● http://wikis.sun.com/display/Jersey/Main
● 1.0 released in October● Getting started● Dependencies● Overview of JAX-RS features● Jersey API
GET /Glassfish/v3/Prelude
GET /NetBeans/6.5
GET /Samples
● Many samples are provided with the release● Atom, JAXB, JSON, Scala, Spring, WADL, …● Using GlassFish (+embedded) and Grizzly
● Download the 1.0 samples zip● Samples are maven-based● Works with NetBeans 6.x + maven plugin● Individual sample zip file are also available
– e.g. Sparklines, Mandel
GET /Involved
● Ask/answer questions, propose fixes/features● mailto:[email protected]
http://markmail.org/search/?q=list%3Anet.java.dev.jersey.users
GET /Jersey/API
● Jersey client (API)● Easier than HttpURLConnection!● Reuses JAX-RS API● Many samples contain tests using this API
● Spring 2.0.x or 2.5.x (Sample)● XML configuration or Auto-wiring
● JSON with JAXB (API, Sample)
● MIME Multipart (in 1.0.1, API)