SlideShare a Scribd company logo
By NeeravArora (Cerner Healthcare Solutions Pvt Ltd.)
&
Kumaraswamy M (IBM)
REST with Java (JAX-RS) and Jersey
Agenda
 Rest API concepts .
 Foundation .
 JAX-RS and Jersey .
 Setting up Jersey project in eclipse.
 JAX-RS annotations .
 CRUD app.
 Restful API’s with Swagger.
Rest API Concepts
 Services exposed to internet for programmatic access
 Users can be either producers or consumers or both
 Eg : api.twitter.com
 Data can be returned in the form of XML /JSON / etc
 Helps developers to parse data.
 Messages can be exchanged in any kind of HTTP method
Foundation
Nouns (Resources)
unconstrained
i.e., http://example.com/employees/12345
Representations
constrained
i.e., XML
Verbs
constrained
i.e., GET
Resources
 REST uses URI to identify resources .
 http://localhost/books/
 http://localhost/books/ISBN-0011
 http://localhost/books/ISBN-0011/authors
 http://localhost/classes
 http://localhost/classes/cs2650
 http://localhost/classes/cs2650/students
 As you traverse the path from more generic to more
specific, you are navigating the data .
Action/Verb
 /orders
 GET - list all orders
 POST - submit a new order
 /orders/{order-id}
 GET - get an order representation
 PUT - update an order
 DELETE - cancel an order
 /orders/average-sale
 GET - calculate average sale
 /customers
 GET - list all customers
 POST - create a new customer
 /customers/{cust-id}
 GET - get a customer representation
 DELETE- remove a customer
 /customers/{cust-id}/orders
 GET - get the orders of a customer
Representations (MediaType)
 XML
<COURSE>
<ID>CS2650</ID>
<NAME>Distributed Multimedia Software</NAME>
</COURSE>
 JSON
{“course”: {
“id”: “CS2650”
“name”: “Distributed Multimedia Software”
}
}
Why it is called “REST” ?
JAX-RS
 Java API for RESTfulWeb Services .
 Provides support in creating web services according to the
Representational StateTransfer (REST) architectural pattern .
 Uses annotations .
Jersey
 One of the libraries that implements JAX-RS , from Oracle.
 Other libraries in the market -
* Apache CXF , an open sourceWeb service framework .
* RESTeasy, JBoss 's implementation .
* Restlet .
* ApacheWink ,Apache Software Foundation Incubator .
*WebSphereApplication Server from IBM.
 Choice of library doesn’t matter .
Big Picture
Big Picture (contd…)
Your first Jersey project
Your first Jersey project (contd…)
http://repo1.maven.org/maven2/archetype-catalog.xml
Your first Jersey project (contd…)
Your first Jersey project (contd…)
Your first Jersey project (contd…)
Your first Jersey project (contd…)
Root resource class
@Path
Sets the path to base URL + /your_path.The base URL is based on your application name,
the servlet and the URL pattern from the web.xml configuration file.
@GET, @PUT, @POST, @DELETE, ...
@Produces
@Produces defines which MIME type is delivered by a method annotated with @GET. In
the example text ("text/plain") is produced. Other examples would be "application/xml"
or "application/json"
@PathParam
Used to inject values from the URL into a method parameter.This way you inject,
for example, the ID of a resource into the method to get the correct object.
@Consumes
@Consumes defines which MIME type is consumed by this method.
CRUD App example (Model)
CRUD App example (Model)
CRUD App example (Database)
CRUD App example (Service)
Crud App (Resource)
RESTFul APIs with Swagger
What is Swagger and Why Swagger?
• Simple representation of your RESTFul API
• Declarative resource specification
• JSON specification
• Swagger UI to interact with the API in a sandbox UI
• Why Jersey Client / JUNIT for your client or boss?
• Developers and documentation… hahaha
• Support your existing RESTFul API without change
Swagger Specification
• Resource Listing
• API Description
Create Swagger Specification
• Codgen - converts annotations in your code into swagger
specification
• Manually - writing the JSON by hand
Swagger Specification
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
References
• http://www.vogella.com/tutorials/REST/article.html
• https://jersey.java.net/documentation/latest/jaxrs-
resources.html
• https://github.com/koushikkothagal/messenger
• http://swagger.io/specification/
• https://github.com/swagger-api/swagger-spec
• https://github.com/swagger-api/swagger-core
• http://petstore.swagger.io/
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey

More Related Content

PDF
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
PPT
Developing RESTful WebServices using Jersey
PPTX
RESTEasy
PPTX
Introduction to RESTful Webservices in JAVA
PPTX
RESTful Web Services
PPTX
Rest presentation
PPTX
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
PDF
Making Java REST with JAX-RS 2.0
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
Developing RESTful WebServices using Jersey
RESTEasy
Introduction to RESTful Webservices in JAVA
RESTful Web Services
Rest presentation
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
Making Java REST with JAX-RS 2.0

What's hot (20)

PPTX
Design Beautiful REST + JSON APIs
PPTX
Rest and Rails
PPTX
REST & RESTful Web Services
PPT
Using Java to implement RESTful Web Services: JAX-RS
PPTX
Rest and Sling Resolution
PPTX
REST presentation
PDF
Rest web services
PPT
Rest in Rails
PDF
Creating Restful Web Services with restish
PPTX
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
PDF
REST - Representational state transfer
PDF
HATEOAS: The Confusing Bit from REST
PDF
Building RESTful applications using Spring MVC
PDF
Spring Web Services: SOAP vs. REST
PDF
Novelties in Java EE 7: JAX-RS 2.0 + IPT REST HATEOAS Polling Demo @ BGOUG Co...
ODP
REST API Laravel
PPT
The RESTful Soa Datagrid with Oracle
PPTX
WebLogic Developer Webcast 1: JPA 2.0
PDF
PPTX
Restful web services with java
Design Beautiful REST + JSON APIs
Rest and Rails
REST & RESTful Web Services
Using Java to implement RESTful Web Services: JAX-RS
Rest and Sling Resolution
REST presentation
Rest web services
Rest in Rails
Creating Restful Web Services with restish
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
REST - Representational state transfer
HATEOAS: The Confusing Bit from REST
Building RESTful applications using Spring MVC
Spring Web Services: SOAP vs. REST
Novelties in Java EE 7: JAX-RS 2.0 + IPT REST HATEOAS Polling Demo @ BGOUG Co...
REST API Laravel
The RESTful Soa Datagrid with Oracle
WebLogic Developer Webcast 1: JPA 2.0
Restful web services with java
Ad

Similar to Eclipse Day India 2015 - Rest with Java (jax rs) and jersey (20)

PPTX
JAX-RS 2.0 and OData
PPTX
Overview of RESTful web services
PDF
RESTful Web Services with Jersey
PPTX
Java Technology
PDF
CDI, Seam & RESTEasy: You haven't seen REST yet!
PDF
Network Device Database Management with REST using Jersey
PDF
JAX RS 2.0 - OTN Bangalore 2013
ODP
RESTing with JAX-RS
PDF
RESTful Web services using JAX-RS
PDF
Spark IT 2011 - Developing RESTful Web services with JAX-RS
PPTX
Ppt on web development and this has all details
DOCX
Spring review_for Semester II of Year 4
PDF
Restful web services_tutorial
PDF
Have You Seen Spring Lately?
PPTX
Java EE7
PDF
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
PDF
May 2010 - RestEasy
PDF
Java EE 7 in practise - OTN Hyderabad 2014
PPT
sMash at May NYPHP UG
PPTX
OREChem Services and Workflows
JAX-RS 2.0 and OData
Overview of RESTful web services
RESTful Web Services with Jersey
Java Technology
CDI, Seam & RESTEasy: You haven't seen REST yet!
Network Device Database Management with REST using Jersey
JAX RS 2.0 - OTN Bangalore 2013
RESTing with JAX-RS
RESTful Web services using JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Ppt on web development and this has all details
Spring review_for Semester II of Year 4
Restful web services_tutorial
Have You Seen Spring Lately?
Java EE7
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
May 2010 - RestEasy
Java EE 7 in practise - OTN Hyderabad 2014
sMash at May NYPHP UG
OREChem Services and Workflows
Ad

More from Eclipse Day India (20)

PPTX
Java Performance Testing for Everyone - Shelley Lambert
PDF
Eclipse IDE Tips and Tricks - Lakshmi Priya Shanmugam
PDF
Pattern Matching in Java - Srikanth Sankaran
PDF
Machine Learning for Java Developers - Nasser Ebrahim
PPTX
Scaling Eclipse on HiDPI Monitors - Niraj Modi
PPTX
Please Behave Yourself: BDD and automating Eclipse RCP applications using JBe...
PDF
Supporting Java™ 9 in Eclipse - A critical perspective - Stephan Herrmann
PDF
Eclipse Day India 2015 - Java bytecode analysis and JIT
PPTX
Eclipse Day India 2015 - Java 8 Overview
ODP
Eclipse Day India 2015 - Java 9
PDF
Eclipse Day India 2015 - Keynote - Stephan Herrmann
PDF
Eclipse Day India 2015 - Eclipse RCP testing using Jubula based automation
PDF
Eclipse Day India 2015 - Oomph
PDF
Eclipse Day India 2015 - Keynote (Mike Milinkovich)
PDF
Eclipse Day India 2015 - Unleashing the Java 8 Tooling in Eclipse
PDF
IDS and Bluemix
PPT
SWT - Technical Deep Dive
PPTX
PDE builds or Maven
PPT
Orion - IDE on the cloud
Java Performance Testing for Everyone - Shelley Lambert
Eclipse IDE Tips and Tricks - Lakshmi Priya Shanmugam
Pattern Matching in Java - Srikanth Sankaran
Machine Learning for Java Developers - Nasser Ebrahim
Scaling Eclipse on HiDPI Monitors - Niraj Modi
Please Behave Yourself: BDD and automating Eclipse RCP applications using JBe...
Supporting Java™ 9 in Eclipse - A critical perspective - Stephan Herrmann
Eclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 9
Eclipse Day India 2015 - Keynote - Stephan Herrmann
Eclipse Day India 2015 - Eclipse RCP testing using Jubula based automation
Eclipse Day India 2015 - Oomph
Eclipse Day India 2015 - Keynote (Mike Milinkovich)
Eclipse Day India 2015 - Unleashing the Java 8 Tooling in Eclipse
IDS and Bluemix
SWT - Technical Deep Dive
PDE builds or Maven
Orion - IDE on the cloud

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
Teaching material agriculture food technology
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Empathic Computing: Creating Shared Understanding
PPTX
A Presentation on Artificial Intelligence
PDF
Getting Started with Data Integration: FME Form 101
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Mushroom cultivation and it's methods.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Network Security Unit 5.pdf for BCA BBA.
Unlocking AI with Model Context Protocol (MCP)
Spectral efficient network and resource selection model in 5G networks
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Teaching material agriculture food technology
A comparative analysis of optical character recognition models for extracting...
Group 1 Presentation -Planning and Decision Making .pptx
cloud_computing_Infrastucture_as_cloud_p
Empathic Computing: Creating Shared Understanding
A Presentation on Artificial Intelligence
Getting Started with Data Integration: FME Form 101
Mobile App Security Testing_ A Comprehensive Guide.pdf
NewMind AI Weekly Chronicles - August'25-Week II
TLE Review Electricity (Electricity).pptx
Univ-Connecticut-ChatGPT-Presentaion.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Mushroom cultivation and it's methods.pdf
OMC Textile Division Presentation 2021.pptx
Per capita expenditure prediction using model stacking based on satellite ima...

Eclipse Day India 2015 - Rest with Java (jax rs) and jersey