Your SlideShare is downloading. ×
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
soft-shake.ch - JAX-RS and Java EE 6
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

soft-shake.ch - JAX-RS and Java EE 6

1,225

Published on

Paul Sandoz …

Paul Sandoz

The presentation focuses on three parts REST, JAX-RS and how JAX-RS integrates with Java EE 6.
The REST style will be briefly introduced explaining what it is and what are the advantages.
Then JAX-RS, the Java API for RESTful Web services, will be discussed. Where appropriate live coding demonstrations will be used to aid the explanations of JAX-RS features.
Finally how JAX-RS integrates with Java EE 6 technologies such as Enterprise Java Beans (EJB) 3.1. Live coding demonstrations will be used.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,225
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
35
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Paul Sandoz 2010 J4 JAX-RS and Java EE 6
  • 2. Agilité iPhone Java Incubateur 8:15 Accueil des participantsAccueil des participantsAccueil des participantsAccueil des participants 8:40 Mot des organisateurs & Criée des orateursMot des organisateurs & Criée des orateursMot des organisateurs & Criée des orateursMot des organisateurs & Criée des orateurs 9:00 Keynote de Nicolas Martignole (30 minutes)Keynote de Nicolas Martignole (30 minutes)Keynote de Nicolas Martignole (30 minutes)Keynote de Nicolas Martignole (30 minutes) 9:40 10:40 - A1 - Le terrain Agile Jean-Philippe Vigniel - I1- Hello iPhone Stephane Tavera - J1 - NOSQL also means RDF stores: an Android case study Fabrizio Giudci - X1 - Le développement durable Dominic Williams 11:00 12:00 - A2 - Integration of User Centered Design in Agile Development of RIA J. Borkenhagen, J. Desmazières - I2 - Développement d'une application iPhone pilotée par les tests Emmanuel Etasse, Van-Charles Tran - J2 - La Tequila du développement Web Nicolas Martignole - X2 - Cloud Computing: anatomie et pratique Marc-Elian Bégin 12:20 13:20 - A3 - Adoption de l'Agilité par les usages Xavier Warzee - I3 - Distribution d'applications iPhone en Entreprise: Réalisation d'un AppStore interne Géraud de Laval - J3 - Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaScript Joonas Lehtinen - X3 - Les DVCS sont vos amis Sébastien Douche Pause repas (50 minutes)Pause repas (50 minutes)Pause repas (50 minutes)Pause repas (50 minutes) 14h10 Keynote de Regis Medina (30 minutes)Keynote de Regis Medina (30 minutes)Keynote de Regis Medina (30 minutes)Keynote de Regis Medina (30 minutes) 14h50 15h50 - A4 - Scrum, introduction et mise en oeuvre avec iceScrum Claude Aubry - I4 - Agile iOS Development Jérôme Layat, Alexander Osterwalder - J4 - JAX-RS and Java EE 6 Paul Sandoz - X4 - IT Design & Ergonomy Pascal Petit, Aude Lussigny 16h10 17h10 - A5 - Agilité : 10 ans déjà Thierry Cros - I5 - Optimizing iOS applications Marc-Antoine Scheurer - J5 - Ecrivez et automatisez vos tests fonctionnels avec jBehave Xavier Bourguignon - X5 - NoSQL : Enfin de la biodiversité dans l'écosystème des BD Olivier Mallassi 17h30 18h30 - A6 - Lean engineering Jean-Christophe Dubail - I6 - iPhone et Agile, l'amour vache Guillaume Duquesnay - J6 - Let's make this test suite run faster David Gageot - X6 - The feel of Scala Mario Fusco Mot de la fin & tombolaMot de la fin & tombolaMot de la fin & tombolaMot de la fin & tombola Programme de la Conférence www.soft-shake.ch
  • 3. JAX-RS, The Java API for RESTful Web services, and Java EE 6 paul.sandoz@oracle.com http://blogs.sun.com/sandoz/ https://twitter.com/PaulSandoz/
  • 4. Agenda ● REST and JAX-RS primer ● Deployment options ● Demonstration ● Status ● Q & A
  • 5. Very short REST primer: buy this book
  • 6. ...and these!
  • 7. REST is an Architectural Style Set of constraints you apply to the architecture of a distributed system to induce desirable properties
  • 8. RESTful Web services Application of REST architectural style to services that utilize Web standards (URIs, HTTP, HTML, XML, Atom, RDF etc.)
  • 9. Java API for RESTful Web Services (JAX-RS) Standard annotation-driven API helping developers build RESTful Web services in Java
  • 10. RESTful application cycle Resources are identified by URIs ↓ Clients communicate with resources via requests using a standard set of methods ↓ Requests and responses contain resource representations in formats identified by media types ↓ Responses contain URIs that link to further resources
  • 11. Resources are identified by URIs http://example.com/widgets/foo http://example.com/customers/bar http://example.com/customers/bar/orders/2 http://example.com/orders/101230/customer
  • 12. Resources are identified by URIs ● Resource == Java class ● POJO ● No required interface ● ID provided by @Path annotation ● Value is relative URI path, base URI is provided by deployment context or “super” resource ● Embedded parameters for non-fixed parts of the URI path ● Annotate class or “sub-resource-locator” method
  • 13. Resources are identified by URIs @Path("properties") public class SystemProperties { @GET List<SystemProperty> getProperties(...) {...} @Path("{name}") SystemProperty getProperty(...) {...} }
  • 14. Standard set of methods Method Purpose GET Read, possibly cached POST Update or create without a known ID PUT Update or create with a known ID DELETE Remove
  • 15. Standard set of methods ● Annotate resource class methods with standard method ● @GET, @PUT, @POST, @DELETE, @HEAD, @OPTIONS ● @HttpMethod meta-annotation allows extensions, e.g. WebDAV or @PATCH ● JAX-RS routes request to appropriate resource class and method ● Flexible method signatures, annotations on parameters specify mapping from request ● Return value mapped to response
  • 16. Standard set of methods @Path("properties/{name}") public class SystemProperty { @GET Property get(@PathParam("name") String name) {...} @PUT Property set(@PathParam("name") String name, String value) {...} }
  • 17. Resource representations ● Representation format identified by media type. E.g.: ● XML – application/properties+xml ● JSON – application/properties+json ● (X)HTML+microformats – application/xhtml+xml ● JAX-RS automates content negotiation ● GET /foo Accept:application/properties+json
  • 18. Resource representations Static and dynamic content negotiation ● Annotate methods or classes with static capabilities ● @Produces, @Consumes ● Use Variant, VariantListBuilder and Request.selectVariant for dynamic capabilities ● Also supports language and encoding
  • 19. Resource representations @GET @Produces("application/properties+xml") Property getXml(@PathParam("name") String name) { ... } @GET @Produces("text/plain") String getText(@PathParam("name") String name) { ... }
  • 20. Response contains links HTTP/1.1 201 Created Date: Wed, 03 Jun 2009 16:41:58 GMT Server: Apache/1.3.6 Location: http://example.com/properties/foo Content-Type: application/order+xml Content-Length: 184 <property self="http://example.com/properties/foo"> <parent ref="http://example.com/properties/bar"/> <name>Foo</name> <value>1</value> </order>
  • 21. Response contains links ● UriInfo provides information about deployment context, the request URI and the route to the resource ● UriBuilder provides facilities to easily construct URIs for resources
  • 22. Response contains links @Context UriInfo i; SystemProperty p = ... UriBuilder b = i.getBaseUriBuilder(); URI u = b.path(SystemProperties.class) .path(p.getName()).build(); List<URI> ancestors = i.getMatchedURIs(); URI parent = ancestors.get(1);
  • 23. Agenda ● REST and JAX-RS primer ● Deployment options ● Demonstration ● Status ● Q & A
  • 24. Java SE deployment ● RuntimeDelegate is used to create instances of a desired endpoint class ● Application supplies configuration information ● List of resource classes and providers as subclass of Application ● Implementations can support any Java type ● Jersey supports Grizzly and the LW HTTP server in Sun's JDK
  • 25. Java SE deployment Application app = ... RuntimeDelegate rd = RuntimeDelegate.getInstance(); Adapter a = rd.createEndpoint(app, Adapter.class); SelectorThread st = GrizzlyServerFactory.create( "http://127.0.0.1:8084/", a);
  • 26. Servlet deployment ● JAX-RS application packaged in WAR like a servlet ● For JAX-RS aware containers (e.g. supporting Servlet 3.0) ● Application subclass referenced to in web.xml as servlet name ● Application subclass annotated with @ApplicationPath, no web.xml required
  • 27. Servlet deployment ● For non-JAX-RS aware containers ● web.xml points to implementation-specific Servlet; and ● an init-param identifies the Application subclass ● Resource classes and providers can access Servlet request, context, config and response via injection ● @Context HttpServletRequest hsr;
  • 28. Java EE 6 deployment ● Annotate with @Path, or @Provider ● EJB 3.1 session or singleton bean ● A (managed) bean annotated with @ManagedBean ● A CDI (managed) bean annotated with scope, such as @RequestScoped or @ApplicationScoped – CDI is enabled with an empty WEB-INF/beans.xml file ● Full access to facilities of native component model ● Resource injection: @EJB, @Resource ● Support for @Inject
  • 29. Implementations ● Apache CXF ● Apache Wink ● JBoss RESTEasy ● Jersey ● Restlet ● Triaxrs
  • 30. Agenda ● REST and JAX-RS primer ● Deployment options ● Demonstration ● Status ● Q & A
  • 31. Agenda ● REST and JAX-RS primer ● Deployment options ● Demonstration ● Status ● Q & A
  • 32. Status ● JAX-RS 1.1 maintenance released on 23rd November 2009 ● Jersey integrated into GlassFish 3.0, 3.0.1 and 3.1 ● Possibly in-scope for any JAX-RS 2.0 effort ● Client API ● Hyperlinking ● Module view controller ● Parameter validation ● Better integration with @Inject
  • 33. More information ● JSR ● http://jcp.org/en/jsr/detail?id=311 ● http://jsr311.dev.java.net/ ● mailto:users@jsr311.dev.java.net ● Jersey, the Reference Implementation ● http://jersey.dev.java.net/ ● mailto:users@jersey.dev.java.net ● Blogs ● http://blogs.sun.com/sandoz/ ● http://blogs.sun.com/japod/ ● http://weblogs.java.net/blog/mhadley/
  • 34. Q&Apaul.sandoz@oracle.com http://blogs.sun.com/sandoz/ https://twitter.com/PaulSandoz/

×