brief intro to jax rs
TRANSCRIPT
A Brief Introduction to JAX-RS
Marc HadleySun Microsystems
HEAD /JAX-RS
● Java API for RESTful Web Services● Annotation-based server-side API● HTTP centric● Server-side only● Servlet or SE deployment
GET /JAX-RS/Examples/Resource
@Path("widgets/{id}")@Produces("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; }}
GET /JAX-RS/Examples/Writer
@Provider@Produces("application/widgets+xml")public class WidgetWriter implements MessageBodyWriter<Widget> {
public boolean isWriteable(...) {...}
public long getSize(...) {...}
public void writeTo(...) {...}}
GET /JAX-RS/Status
● 1.0 finalized end of September 2008● Online spec and API:
– https://jsr311.dev.java.net/nonav/releases/1.0/spec/index.html– https://jsr311.dev.java.net/nonav/releases/1.0/index.html
● 1.1 maintenance release in progress focussing on integration with new Java EE 6 features
● Five open-source implementations already● Jersey, JBoss RESTEasy, Restlet, Apache CXF,
Triaxrs
*(question (answer | stumped))