SlideShare a Scribd company logo
1 of 14
Download to read offline
JAX-RS - REST web
services in the JEE
ecosystem
Catalin Mihalache
Java Architect / Project Manager at Pentalog
Oracle Certified Master, Java EE 5 Enterprise Architect
the examples: https://www.dropbox.com/s/z1cj30b9y7pznao/samples.zip
Agenda
• What is JAX-RS ?
• The use case
• JAX-RS resources
• Providers
• Handling exceptions
• Customizing the response
• More JAX-RS annotations!
• Q&A
What is JAX-RS ?
RESTful web services in JEE
• JSR 311 – a JEE6 specification
Available in JEE6 Application Servers: like JBoss6.x, JBoss7.x, Glassfish 3.x, IBM
WebSphere 8.x, Apache TomEE Plus

• JSR 339 – a JEE7 specification
Available in JEE7 Application Servers: Glassfish 4.x (waiting for JBoss8 & WebSphere9 ..)

• Open source implementations
JBoss RestEasy
Glassfish Jersey – the Reference Implementation
Apache CXF
Apache Wink

• Spring MVC
(the dark side of the Force ..)
Used samples
https://www.dropbox.com/s/z1cj30b9y7pznao/samples.zip
The use case - caveatEmptor

• TODO: an HTTP-based API able to manage the domain model and to be easily consumed
by JavaScript-based applications (yeah, hire a professional JS developer and let me do my job:
JAVA!!)
JAX-RS resources (1)
• The URLs:
–

http://www.caveatemptor.com/rest/retrieveAllCategories.do
http://www.caveatemptor.com/rest/retrieveCategory.do?id=13
http://www.caveatemptor.com/rest/retrieveItems.do?categId=13

–

unique & pretty URLs for each object / collection from the domain model:
http://www.caveatemptor.com/rest/categories
http://www.caveatemptor.com/rest/categories/13
http://www.caveatemptor.com/rest/categories/13/items

• The HTTP methods: • HTTP error codes -

GET, POST, PUT, DELETE

http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

–

2xx Success

–

3xx Redirection

–

4xx Client Error (401 Unauthorized, 404 Not found, 400 Bad request)

–

5xx Server Error (well ..)

• XML &&|| JSON
JAX-RS resources (2)
Case study – the simpleJaxRs project
• @Path, @PathParam, @ApplicationPath and
javax.ws.rs.core.Application
http://localhost:8080/simpleJaxRs/rs/categories
http://localhost:8080/simpleJaxRs/rs/categories/1
/simpleJaxRs
/rs
/categories
/categories/1

–
–
–
–

servlet context name
JAX-RS front-controller
instance of CategoriesResource
instance of CategoryResource with id = 1

(no XML configuration, just tons of Java annotations ..)

• XML & JSON; JAXB
–
–

●

(Java annotations everywhere ..)
Accept → @Produces
Content-Type → @Consumes

CRUD operations on same URL
@POST, @GET, @PUT, @DETELE
Providers
Case study – simpleJaxRs2 project
producing / consuming JSON without JAXB
• JEE6: No standard JSON – JAX-RS integration!
available in JEE7

• Converting Java objects into “something” (like JSON) &
vice-versa:
javax.ws.rs.ext.MessageBodyWriter
javax.ws.rs.ext.MessageBodyReader

• Jackson - JAX-RS integration – producing / consuming JSON
@Provider
@Consumes({MediaType.APPLICATION_JSON, "text/json"})
@Produces({MediaType.APPLICATION_JSON, "text/json"})
public class JacksonJsonProvider implements MessageBodyReader<Object>,
MessageBodyWriter<Object> { ... }

• @Provider - “provides” automatic registration & usage
Handling exceptions
Case study – caveatEmptor-rs project
• Managing Checked Exceptions (business exception)
javax.ws.rs.WebApplicationException
HTTP error code: 4xx

• Managing Unchecked Exceptions
javax.ws.rs.ext.ExceptionMapper
HTTP error code: 5xx (internal server error)
@Provider
public class RuntimeExceptionMapper
implements ExceptionMapper<RuntimeException>
{ ... }
Customizing the response
Case study – caveatEmptor-rs project
javax.ws.rs.core.Response

• Redirects
• Controlling the cache headers
•
More JAX-RS annotations!
• @javax.ws.rs.core.Context
–

javax.ws.rs.core.UriInfo
●

–

javax.ws.rs.core.HttpHeaders
●

–

An injectable interface that provides access to application and request URI
information.

An injectable interface that provides access to HTTP header information.

javax.ws.rs.core.SecurityContext
●

An injectable interface that provides access to security related information.

• @QueryParam
–

injects a query string parameters, just as @PathParam does

• @FormParam
–

injects a HTML form input's value, just as @PathParam does
A

Q&A
Please fill in your evaluation form
[JAX-RS - REST web services in the JEE ecosystem]
Catalin Mihalache

[12th of October 2013

More Related Content

What's hot

Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeansRyan Cuprak
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5Smita B Kumar
 
Hibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance TechniquesHibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance TechniquesBrett Meyer
 
File System On Steroids
File System On SteroidsFile System On Steroids
File System On SteroidsJukka Zitting
 
Advance java session 15
Advance java session 15Advance java session 15
Advance java session 15Smita B Kumar
 
JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup Sagara Gunathunga
 
Java colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rsJava colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rsSagara Gunathunga
 
Flyway: The agile database migration framework for Java
Flyway: The agile database migration framework for JavaFlyway: The agile database migration framework for Java
Flyway: The agile database migration framework for JavaAxel Fontaine
 
Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsAndrei Solntsev
 
Liquibase få kontroll på dina databasförändringar
Liquibase   få kontroll på dina databasförändringarLiquibase   få kontroll på dina databasförändringar
Liquibase få kontroll på dina databasförändringarSqueed
 
Advance java session 20
Advance java session 20Advance java session 20
Advance java session 20Smita B Kumar
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSpeedment, Inc.
 
Utilized JAXB to generate POJOs automatically
Utilized JAXB to generate POJOs automaticallyUtilized JAXB to generate POJOs automatically
Utilized JAXB to generate POJOs automaticallyGuo Albert
 
Database Change Management as a Service
Database Change Management as a ServiceDatabase Change Management as a Service
Database Change Management as a ServiceAndrew Solomon
 
Scala adoption by enterprises
Scala adoption by enterprisesScala adoption by enterprises
Scala adoption by enterprisesMike Slinn
 
JSR-222 Java Architecture for XML Binding
JSR-222 Java Architecture for XML BindingJSR-222 Java Architecture for XML Binding
JSR-222 Java Architecture for XML BindingHeiko Scherrer
 
No Container: a Modern Java Stack with Bootique
No Container: a Modern Java Stack with BootiqueNo Container: a Modern Java Stack with Bootique
No Container: a Modern Java Stack with BootiqueAndrus Adamchik
 

What's hot (20)

Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
 
Flywaydb
FlywaydbFlywaydb
Flywaydb
 
Hibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance TechniquesHibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance Techniques
 
File System On Steroids
File System On SteroidsFile System On Steroids
File System On Steroids
 
Liquibase
LiquibaseLiquibase
Liquibase
 
Advance java session 15
Advance java session 15Advance java session 15
Advance java session 15
 
JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup
 
Java colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rsJava colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rs
 
Flyway: The agile database migration framework for Java
Flyway: The agile database migration framework for JavaFlyway: The agile database migration framework for Java
Flyway: The agile database migration framework for Java
 
Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOps
 
Liquibase få kontroll på dina databasförändringar
Liquibase   få kontroll på dina databasförändringarLiquibase   få kontroll på dina databasförändringar
Liquibase få kontroll på dina databasförändringar
 
Advance java session 20
Advance java session 20Advance java session 20
Advance java session 20
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
XML parsing using jaxb
XML parsing using jaxbXML parsing using jaxb
XML parsing using jaxb
 
Utilized JAXB to generate POJOs automatically
Utilized JAXB to generate POJOs automaticallyUtilized JAXB to generate POJOs automatically
Utilized JAXB to generate POJOs automatically
 
Database Change Management as a Service
Database Change Management as a ServiceDatabase Change Management as a Service
Database Change Management as a Service
 
Scala adoption by enterprises
Scala adoption by enterprisesScala adoption by enterprises
Scala adoption by enterprises
 
JSR-222 Java Architecture for XML Binding
JSR-222 Java Architecture for XML BindingJSR-222 Java Architecture for XML Binding
JSR-222 Java Architecture for XML Binding
 
No Container: a Modern Java Stack with Bootique
No Container: a Modern Java Stack with BootiqueNo Container: a Modern Java Stack with Bootique
No Container: a Modern Java Stack with Bootique
 

Viewers also liked

Eugen Constantinescu - Genivi - Codecamp 10 may 2014
Eugen Constantinescu - Genivi - Codecamp 10 may 2014Eugen Constantinescu - Genivi - Codecamp 10 may 2014
Eugen Constantinescu - Genivi - Codecamp 10 may 2014Codecamp Romania
 
Intro CodeCamp/IASI 16 oct 2010
Intro CodeCamp/IASI 16 oct 2010Intro CodeCamp/IASI 16 oct 2010
Intro CodeCamp/IASI 16 oct 2010Codecamp Romania
 
Iulian dogariu the sad story of the server etc
Iulian dogariu   the sad story of the server etcIulian dogariu   the sad story of the server etc
Iulian dogariu the sad story of the server etcCodecamp Romania
 
Iasi code camp 12 october 2013 play oriented development - leon daniel
Iasi code camp 12 october 2013   play oriented development - leon danielIasi code camp 12 october 2013   play oriented development - leon daniel
Iasi code camp 12 october 2013 play oriented development - leon danielCodecamp Romania
 
Ana milutinovic quality awareness when practicing agile testing
Ana milutinovic   quality awareness when practicing agile testingAna milutinovic   quality awareness when practicing agile testing
Ana milutinovic quality awareness when practicing agile testingCodecamp Romania
 
Code camp iasi silviu niculita - machine learning for mere mortals with azu...
Code camp iasi   silviu niculita - machine learning for mere mortals with azu...Code camp iasi   silviu niculita - machine learning for mere mortals with azu...
Code camp iasi silviu niculita - machine learning for mere mortals with azu...Codecamp Romania
 
Cristi Ursachi - Xamarin - CodeCamp 10 may 2014
Cristi Ursachi  - Xamarin - CodeCamp 10 may 2014Cristi Ursachi  - Xamarin - CodeCamp 10 may 2014
Cristi Ursachi - Xamarin - CodeCamp 10 may 2014Codecamp Romania
 
Iasi code camp 12 october 2013 an invitation to agile product management - ...
Iasi code camp 12 october 2013   an invitation to agile product management - ...Iasi code camp 12 october 2013   an invitation to agile product management - ...
Iasi code camp 12 october 2013 an invitation to agile product management - ...Codecamp Romania
 
Material design screen transitions in android
Material design screen transitions in androidMaterial design screen transitions in android
Material design screen transitions in androidCodecamp Romania
 
Managing technical debt - Dan Nicola - Florin Cardasim
Managing technical debt - Dan Nicola - Florin CardasimManaging technical debt - Dan Nicola - Florin Cardasim
Managing technical debt - Dan Nicola - Florin CardasimCodecamp Romania
 
Codecamp Iasi 7 mai 2011 Exception tail.com
Codecamp Iasi 7 mai 2011 Exception tail.comCodecamp Iasi 7 mai 2011 Exception tail.com
Codecamp Iasi 7 mai 2011 Exception tail.comCodecamp Romania
 
Angajatori de Top Iasi - Nov 2013
Angajatori de Top Iasi - Nov 2013Angajatori de Top Iasi - Nov 2013
Angajatori de Top Iasi - Nov 2013Codecamp Romania
 
Mihai mahulea the zen of test driven development
Mihai mahulea   the zen of test driven developmentMihai mahulea   the zen of test driven development
Mihai mahulea the zen of test driven developmentCodecamp Romania
 
Vlad Zelinschi - Embrace Native JavaScript (the anti-plugins talk) - Codecamp...
Vlad Zelinschi - Embrace Native JavaScript (the anti-plugins talk) - Codecamp...Vlad Zelinschi - Embrace Native JavaScript (the anti-plugins talk) - Codecamp...
Vlad Zelinschi - Embrace Native JavaScript (the anti-plugins talk) - Codecamp...Codecamp Romania
 
Iasi code camp 12 october 2013 typescript vs coffeescript - vlad iliescu
Iasi code camp 12 october 2013   typescript vs coffeescript - vlad iliescuIasi code camp 12 october 2013   typescript vs coffeescript - vlad iliescu
Iasi code camp 12 october 2013 typescript vs coffeescript - vlad iliescuCodecamp Romania
 

Viewers also liked (18)

The bigrewrite
The bigrewriteThe bigrewrite
The bigrewrite
 
Eugen Constantinescu - Genivi - Codecamp 10 may 2014
Eugen Constantinescu - Genivi - Codecamp 10 may 2014Eugen Constantinescu - Genivi - Codecamp 10 may 2014
Eugen Constantinescu - Genivi - Codecamp 10 may 2014
 
The bigrewrite
The bigrewriteThe bigrewrite
The bigrewrite
 
Intro CodeCamp/IASI 16 oct 2010
Intro CodeCamp/IASI 16 oct 2010Intro CodeCamp/IASI 16 oct 2010
Intro CodeCamp/IASI 16 oct 2010
 
Iulian dogariu the sad story of the server etc
Iulian dogariu   the sad story of the server etcIulian dogariu   the sad story of the server etc
Iulian dogariu the sad story of the server etc
 
Iasi code camp 12 october 2013 play oriented development - leon daniel
Iasi code camp 12 october 2013   play oriented development - leon danielIasi code camp 12 october 2013   play oriented development - leon daniel
Iasi code camp 12 october 2013 play oriented development - leon daniel
 
Ana milutinovic quality awareness when practicing agile testing
Ana milutinovic   quality awareness when practicing agile testingAna milutinovic   quality awareness when practicing agile testing
Ana milutinovic quality awareness when practicing agile testing
 
Code camp iasi silviu niculita - machine learning for mere mortals with azu...
Code camp iasi   silviu niculita - machine learning for mere mortals with azu...Code camp iasi   silviu niculita - machine learning for mere mortals with azu...
Code camp iasi silviu niculita - machine learning for mere mortals with azu...
 
Cristi Ursachi - Xamarin - CodeCamp 10 may 2014
Cristi Ursachi  - Xamarin - CodeCamp 10 may 2014Cristi Ursachi  - Xamarin - CodeCamp 10 may 2014
Cristi Ursachi - Xamarin - CodeCamp 10 may 2014
 
Iasi code camp 12 october 2013 an invitation to agile product management - ...
Iasi code camp 12 october 2013   an invitation to agile product management - ...Iasi code camp 12 october 2013   an invitation to agile product management - ...
Iasi code camp 12 october 2013 an invitation to agile product management - ...
 
Ccp
CcpCcp
Ccp
 
Material design screen transitions in android
Material design screen transitions in androidMaterial design screen transitions in android
Material design screen transitions in android
 
Managing technical debt - Dan Nicola - Florin Cardasim
Managing technical debt - Dan Nicola - Florin CardasimManaging technical debt - Dan Nicola - Florin Cardasim
Managing technical debt - Dan Nicola - Florin Cardasim
 
Codecamp Iasi 7 mai 2011 Exception tail.com
Codecamp Iasi 7 mai 2011 Exception tail.comCodecamp Iasi 7 mai 2011 Exception tail.com
Codecamp Iasi 7 mai 2011 Exception tail.com
 
Angajatori de Top Iasi - Nov 2013
Angajatori de Top Iasi - Nov 2013Angajatori de Top Iasi - Nov 2013
Angajatori de Top Iasi - Nov 2013
 
Mihai mahulea the zen of test driven development
Mihai mahulea   the zen of test driven developmentMihai mahulea   the zen of test driven development
Mihai mahulea the zen of test driven development
 
Vlad Zelinschi - Embrace Native JavaScript (the anti-plugins talk) - Codecamp...
Vlad Zelinschi - Embrace Native JavaScript (the anti-plugins talk) - Codecamp...Vlad Zelinschi - Embrace Native JavaScript (the anti-plugins talk) - Codecamp...
Vlad Zelinschi - Embrace Native JavaScript (the anti-plugins talk) - Codecamp...
 
Iasi code camp 12 october 2013 typescript vs coffeescript - vlad iliescu
Iasi code camp 12 october 2013   typescript vs coffeescript - vlad iliescuIasi code camp 12 october 2013   typescript vs coffeescript - vlad iliescu
Iasi code camp 12 october 2013 typescript vs coffeescript - vlad iliescu
 

Similar to Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache

Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Skills Matter
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Arun Gupta
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Arun Gupta
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGArun Gupta
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionArun Gupta
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerArun Gupta
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Arun Gupta
 
Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Arun Gupta
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Arun Gupta
 
JAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesJAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesLudovic Champenois
 
Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Agora Group
 
OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6glassfish
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 UpdateRyan Cuprak
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack ImplementationMert Çalışkan
 
Java EE 6 & GlassFish v3 @ DevNexus
Java EE 6 & GlassFish v3 @ DevNexusJava EE 6 & GlassFish v3 @ DevNexus
Java EE 6 & GlassFish v3 @ DevNexusArun Gupta
 
Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Kile Niklawski
 
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Arun Gupta
 

Similar to Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache (20)

Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
 
Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011
 
JAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesJAX-RS Creating RESTFul services
JAX-RS Creating RESTFul services
 
Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011
 
Prototype-1
Prototype-1Prototype-1
Prototype-1
 
Prototype-1
Prototype-1Prototype-1
Prototype-1
 
OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
 
Java EE 6 & GlassFish v3 @ DevNexus
Java EE 6 & GlassFish v3 @ DevNexusJava EE 6 & GlassFish v3 @ DevNexus
Java EE 6 & GlassFish v3 @ DevNexus
 
Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Java EE8 - by Kito Mann
Java EE8 - by Kito Mann
 
GlassFish and JavaEE, Today and Future
GlassFish and JavaEE, Today and FutureGlassFish and JavaEE, Today and Future
GlassFish and JavaEE, Today and Future
 
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
 

More from Codecamp Romania

Cezar chitac the edge of experience
Cezar chitac   the edge of experienceCezar chitac   the edge of experience
Cezar chitac the edge of experienceCodecamp Romania
 
Business analysis techniques exercise your 6-pack
Business analysis techniques   exercise your 6-packBusiness analysis techniques   exercise your 6-pack
Business analysis techniques exercise your 6-packCodecamp Romania
 
Bpm company code camp - configuration or coding with pega
Bpm company   code camp - configuration or coding with pegaBpm company   code camp - configuration or coding with pega
Bpm company code camp - configuration or coding with pegaCodecamp Romania
 
Andrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabaseAndrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabaseCodecamp Romania
 
2015 dan ardelean develop for windows 10
2015 dan ardelean   develop for windows 10 2015 dan ardelean   develop for windows 10
2015 dan ardelean develop for windows 10 Codecamp Romania
 
The case for continuous delivery
The case for continuous deliveryThe case for continuous delivery
The case for continuous deliveryCodecamp Romania
 
Stefan stolniceanu spritekit, 2 d or not 2d
Stefan stolniceanu   spritekit, 2 d or not 2dStefan stolniceanu   spritekit, 2 d or not 2d
Stefan stolniceanu spritekit, 2 d or not 2dCodecamp Romania
 
Sizing epics tales from an agile kingdom
Sizing epics   tales from an agile kingdomSizing epics   tales from an agile kingdom
Sizing epics tales from an agile kingdomCodecamp Romania
 
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
Raluca butnaru corina cilibiu   the unknown universe of a product and the cer...Raluca butnaru corina cilibiu   the unknown universe of a product and the cer...
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...Codecamp Romania
 
Parallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflowParallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflowCodecamp Romania
 
Material design screen transitions in android
Material design screen transitions in androidMaterial design screen transitions in android
Material design screen transitions in androidCodecamp Romania
 
Kickstart your own freelancing career
Kickstart your own freelancing careerKickstart your own freelancing career
Kickstart your own freelancing careerCodecamp Romania
 
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
Ionut grecu   the soft stuff is the hard stuff. the agile soft skills toolkitIonut grecu   the soft stuff is the hard stuff. the agile soft skills toolkit
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkitCodecamp Romania
 
Diana antohi me against myself or how to fail and move forward
Diana antohi   me against myself  or how to fail  and move forwardDiana antohi   me against myself  or how to fail  and move forward
Diana antohi me against myself or how to fail and move forwardCodecamp Romania
 
Codecamp2015 pimp yourpipeline-saade-jens-1.1
Codecamp2015 pimp yourpipeline-saade-jens-1.1Codecamp2015 pimp yourpipeline-saade-jens-1.1
Codecamp2015 pimp yourpipeline-saade-jens-1.1Codecamp Romania
 
Code camp iasi silviu niculita - machine learning for mere mortals with azu...
Code camp iasi   silviu niculita - machine learning for mere mortals with azu...Code camp iasi   silviu niculita - machine learning for mere mortals with azu...
Code camp iasi silviu niculita - machine learning for mere mortals with azu...Codecamp Romania
 

More from Codecamp Romania (20)

Cezar chitac the edge of experience
Cezar chitac   the edge of experienceCezar chitac   the edge of experience
Cezar chitac the edge of experience
 
Cloud powered search
Cloud powered searchCloud powered search
Cloud powered search
 
Business analysis techniques exercise your 6-pack
Business analysis techniques   exercise your 6-packBusiness analysis techniques   exercise your 6-pack
Business analysis techniques exercise your 6-pack
 
Bpm company code camp - configuration or coding with pega
Bpm company   code camp - configuration or coding with pegaBpm company   code camp - configuration or coding with pega
Bpm company code camp - configuration or coding with pega
 
Andrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabaseAndrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabase
 
Agility and life
Agility and lifeAgility and life
Agility and life
 
2015 dan ardelean develop for windows 10
2015 dan ardelean   develop for windows 10 2015 dan ardelean   develop for windows 10
2015 dan ardelean develop for windows 10
 
The case for continuous delivery
The case for continuous deliveryThe case for continuous delivery
The case for continuous delivery
 
Stefan stolniceanu spritekit, 2 d or not 2d
Stefan stolniceanu   spritekit, 2 d or not 2dStefan stolniceanu   spritekit, 2 d or not 2d
Stefan stolniceanu spritekit, 2 d or not 2d
 
Sizing epics tales from an agile kingdom
Sizing epics   tales from an agile kingdomSizing epics   tales from an agile kingdom
Sizing epics tales from an agile kingdom
 
Scale net apps in aws
Scale net apps in awsScale net apps in aws
Scale net apps in aws
 
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
Raluca butnaru corina cilibiu   the unknown universe of a product and the cer...Raluca butnaru corina cilibiu   the unknown universe of a product and the cer...
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
 
Parallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflowParallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflow
 
Material design screen transitions in android
Material design screen transitions in androidMaterial design screen transitions in android
Material design screen transitions in android
 
Kickstart your own freelancing career
Kickstart your own freelancing careerKickstart your own freelancing career
Kickstart your own freelancing career
 
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
Ionut grecu   the soft stuff is the hard stuff. the agile soft skills toolkitIonut grecu   the soft stuff is the hard stuff. the agile soft skills toolkit
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
 
Ecma6 in the wild
Ecma6 in the wildEcma6 in the wild
Ecma6 in the wild
 
Diana antohi me against myself or how to fail and move forward
Diana antohi   me against myself  or how to fail  and move forwardDiana antohi   me against myself  or how to fail  and move forward
Diana antohi me against myself or how to fail and move forward
 
Codecamp2015 pimp yourpipeline-saade-jens-1.1
Codecamp2015 pimp yourpipeline-saade-jens-1.1Codecamp2015 pimp yourpipeline-saade-jens-1.1
Codecamp2015 pimp yourpipeline-saade-jens-1.1
 
Code camp iasi silviu niculita - machine learning for mere mortals with azu...
Code camp iasi   silviu niculita - machine learning for mere mortals with azu...Code camp iasi   silviu niculita - machine learning for mere mortals with azu...
Code camp iasi silviu niculita - machine learning for mere mortals with azu...
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 

Recently uploaded (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache

  • 1.
  • 2. JAX-RS - REST web services in the JEE ecosystem Catalin Mihalache Java Architect / Project Manager at Pentalog Oracle Certified Master, Java EE 5 Enterprise Architect the examples: https://www.dropbox.com/s/z1cj30b9y7pznao/samples.zip
  • 3. Agenda • What is JAX-RS ? • The use case • JAX-RS resources • Providers • Handling exceptions • Customizing the response • More JAX-RS annotations! • Q&A
  • 4. What is JAX-RS ? RESTful web services in JEE • JSR 311 – a JEE6 specification Available in JEE6 Application Servers: like JBoss6.x, JBoss7.x, Glassfish 3.x, IBM WebSphere 8.x, Apache TomEE Plus • JSR 339 – a JEE7 specification Available in JEE7 Application Servers: Glassfish 4.x (waiting for JBoss8 & WebSphere9 ..) • Open source implementations JBoss RestEasy Glassfish Jersey – the Reference Implementation Apache CXF Apache Wink • Spring MVC (the dark side of the Force ..)
  • 6. The use case - caveatEmptor • TODO: an HTTP-based API able to manage the domain model and to be easily consumed by JavaScript-based applications (yeah, hire a professional JS developer and let me do my job: JAVA!!)
  • 7. JAX-RS resources (1) • The URLs: – http://www.caveatemptor.com/rest/retrieveAllCategories.do http://www.caveatemptor.com/rest/retrieveCategory.do?id=13 http://www.caveatemptor.com/rest/retrieveItems.do?categId=13 – unique & pretty URLs for each object / collection from the domain model: http://www.caveatemptor.com/rest/categories http://www.caveatemptor.com/rest/categories/13 http://www.caveatemptor.com/rest/categories/13/items • The HTTP methods: • HTTP error codes - GET, POST, PUT, DELETE http://en.wikipedia.org/wiki/List_of_HTTP_status_codes – 2xx Success – 3xx Redirection – 4xx Client Error (401 Unauthorized, 404 Not found, 400 Bad request) – 5xx Server Error (well ..) • XML &&|| JSON
  • 8. JAX-RS resources (2) Case study – the simpleJaxRs project • @Path, @PathParam, @ApplicationPath and javax.ws.rs.core.Application http://localhost:8080/simpleJaxRs/rs/categories http://localhost:8080/simpleJaxRs/rs/categories/1 /simpleJaxRs /rs /categories /categories/1 – – – – servlet context name JAX-RS front-controller instance of CategoriesResource instance of CategoryResource with id = 1 (no XML configuration, just tons of Java annotations ..) • XML & JSON; JAXB – – ● (Java annotations everywhere ..) Accept → @Produces Content-Type → @Consumes CRUD operations on same URL @POST, @GET, @PUT, @DETELE
  • 9. Providers Case study – simpleJaxRs2 project producing / consuming JSON without JAXB • JEE6: No standard JSON – JAX-RS integration! available in JEE7 • Converting Java objects into “something” (like JSON) & vice-versa: javax.ws.rs.ext.MessageBodyWriter javax.ws.rs.ext.MessageBodyReader • Jackson - JAX-RS integration – producing / consuming JSON @Provider @Consumes({MediaType.APPLICATION_JSON, "text/json"}) @Produces({MediaType.APPLICATION_JSON, "text/json"}) public class JacksonJsonProvider implements MessageBodyReader<Object>, MessageBodyWriter<Object> { ... } • @Provider - “provides” automatic registration & usage
  • 10. Handling exceptions Case study – caveatEmptor-rs project • Managing Checked Exceptions (business exception) javax.ws.rs.WebApplicationException HTTP error code: 4xx • Managing Unchecked Exceptions javax.ws.rs.ext.ExceptionMapper HTTP error code: 5xx (internal server error) @Provider public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException> { ... }
  • 11. Customizing the response Case study – caveatEmptor-rs project javax.ws.rs.core.Response • Redirects • Controlling the cache headers •
  • 12. More JAX-RS annotations! • @javax.ws.rs.core.Context – javax.ws.rs.core.UriInfo ● – javax.ws.rs.core.HttpHeaders ● – An injectable interface that provides access to application and request URI information. An injectable interface that provides access to HTTP header information. javax.ws.rs.core.SecurityContext ● An injectable interface that provides access to security related information. • @QueryParam – injects a query string parameters, just as @PathParam does • @FormParam – injects a HTML form input's value, just as @PathParam does
  • 13. A Q&A
  • 14. Please fill in your evaluation form [JAX-RS - REST web services in the JEE ecosystem] Catalin Mihalache [12th of October 2013