brief intro to jax rs

6

Click here to load reader

Upload: eduardo-pelegri-llopart

Post on 10-May-2015

1.420 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Brief Intro To Jax Rs

A Brief Introduction to JAX-RS

Marc HadleySun Microsystems

Page 2: Brief Intro To Jax Rs

HEAD /JAX-RS

● Java API for RESTful Web Services● Annotation-based server-side API● HTTP centric● Server-side only● Servlet or SE deployment

Page 3: Brief Intro To Jax Rs

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; }}

Page 4: Brief Intro To Jax Rs

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(...) {...}}

Page 5: Brief Intro To Jax Rs

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

Page 6: Brief Intro To Jax Rs

*(question (answer | stumped))