SlideShare a Scribd company logo
AGENDA
• Discuss REST Architecture Principles
• Discuss REST API Design Approach
• Discuss JAX – RS Standards
• Discuss Mule REST Component for REST API
REST ARCHITECTURE – PRINCIPLES
Rest Architecture
Principle
Description
Addressability Every resource in the system is reachable by a unique
identifier.
Uniform Constrained
Interface
Constraints on the methods of application protocol to
access operations on the published service for e.g. GET,
POST, PUT, DELETE, HEAD, OPTIONS
Representation
Oriented
Resource representations between the client and server
can be XML, JSON or YAML
Communicate
Statelessly
No client information is stored in the sessions on the
server
HATEOAS Support to embed inside the resource representation, the
links other services.
REST API DESIGN
 Design the URIs for all the resources in the system
 Define the resource representation – XML, JSON etc.
 Assign HTTP Methods to the resources
 Version the REST API
 Choose the REST API URL root
 Filtering / limiting results returned from the API on the basis of request
parameters
 Define authentication strategy e.g. Oauth 1.0
 Develop documentation for the REST APIs
 Track Analytics on REST API usage
JAX-RS ANNOTATIONS
JAX-RS Annotation Description
@Path URI to the Rest API
@Consumes / @Produces Defines the media type of the message payload
accepted / produced by the API
@GET,@POST,@PUT,@DEL
ETE…
HTTP methods assigned to API
@QueryParam Binds query parameters from http request to API
method parameters
@DefaultValue Default value of the query parameter
@PathParam Maps the URI template parameter to resource
method parameter or resource class field
@FormParam Maps the form parameter to resource method
parameter or resource class field
JAX-RS ANNOTATIONS CONTD…
JAX-RS
Annotation
Description
@CookieParam Extracts information from the cookies declared in the http
headers
@HeaderPara
m
Maps the value from an http header to a resource method
parameter or a resource class field.
@BeanParam JAX-RS parameter aggregator value object . Injects the bean into
a resource class field or property
@EncodedPara
m
Disables automatic decoding of parameters bound to
QueryParam, PathParam, FormParam or Matrix Param
@MatrixParam Maps the URI matric parameter / path segment to a method
parameter or resource class field or resource bean property
JAX-RS CONTENT HANDLERS
JAX-RS has built in handlers for marshalling and unmarshalling of certain Java
types
• Content Marshalling – Following are objects used for API I/O
• javax.ws.rs.core.StreamingOutput
• java.io.InputStream, java.io.Reader
• java.io.File
• byte[]
• char[]
• JAXB
• Custom Marshalling – Implement the following interfaces
• javax.ws.rs.ext.MessageBodyWriter
• javax.ws.rs.ext.MessageBodyReader
CONTENT NEGOTIATION
• Content Negotiation
Clients can request for a specific media type when querying the server
for
information
• Preference Ordering
The server assumes that the client always wants a more specific media type over
a wild card specified media type
• Language Negotiation
Clients use the ACCEPT-Language header to specify the language in
which the information is expected
• Encoding Negotiation
Clients specify the Accept Encoding header to specify the message
body
encoding for e.g. GZIP, to save on network bandwidth
JAX-RS & MULE
Jersey JAX-RS Transport:
Mule uses Jersey for REST API development. Mule 3.6 uses Jersey v2.11
Following is the piece of code that hosts the REST API using Jersey:
<jersey:resources>
<component class="org.mule.module.jersey.HelloWorldResource"/>
</jersey:resources>
The HelloWorldResource is the resource that use JAX-RS annotations to map
HTTP
verbs to resource methods.
JAX-RS EXAMPLE
@Path("/customer")
public class CustomerResource {
@GET
@Produces("text/plain")
@Path("/{customerId}")
public String getCustomer(@PathParam("customerId") String customerId){
Map<String, String> customerDetailsMap = new HashMap<String,String>();
customerDetailsMap.put("C0001", "TOM");
customerDetailsMap.put("C0002", "JERRY");
return customerDetailsMap.get(customerId);
}
}
Path to URI
Http Verb
Media Type
Path Variable
Thank You !!

More Related Content

Viewers also liked

Mike Gigl Resume 04-2015 A
Mike Gigl Resume 04-2015 AMike Gigl Resume 04-2015 A
Mike Gigl Resume 04-2015 AMike Gigl
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled PresentationDarren Henson
 
Introduction
IntroductionIntroduction
Introduction
mahendratiwari
 
Jonatan y angie 10 b
Jonatan y angie 10 bJonatan y angie 10 b
Jonatan y angie 10 b
97fernando
 
MultipleYaxis
MultipleYaxisMultipleYaxis
MultipleYaxis
Betskaren
 
Rwa density what lies behind this underrated financial ratio
Rwa density what lies behind this underrated financial ratioRwa density what lies behind this underrated financial ratio
Rwa density what lies behind this underrated financial ratio
Léonard Brie
 
у серці кожної дитини живе любов до україни
у серці кожної дитини живе любов до україниу серці кожної дитини живе любов до україни
у серці кожної дитини живе любов до україни
Vasilij Goncharenko
 
Hojas de trabajo de 5 a 8
Hojas de trabajo de 5 a 8Hojas de trabajo de 5 a 8
Hojas de trabajo de 5 a 8
profedespanyol
 
Jackie Robinson Power Point
Jackie Robinson Power PointJackie Robinson Power Point
Jackie Robinson Power Pointjohnson19
 
UAF Official Transcripts
UAF Official TranscriptsUAF Official Transcripts
UAF Official TranscriptsKarin Baldwin
 
με πινέλα και φαντασία
με πινέλα και φαντασίαμε πινέλα και φαντασία
με πινέλα και φαντασία
Despina Zeka
 
Resume (1) (1) (1) AR
Resume (1) (1) (1) ARResume (1) (1) (1) AR
Resume (1) (1) (1) ARSyed Ahmed
 

Viewers also liked (16)

Mike Gigl Resume 04-2015 A
Mike Gigl Resume 04-2015 AMike Gigl Resume 04-2015 A
Mike Gigl Resume 04-2015 A
 
Top 10 Guianza En Recorridos Por Naturaleza
Top 10 Guianza En Recorridos Por NaturalezaTop 10 Guianza En Recorridos Por Naturaleza
Top 10 Guianza En Recorridos Por Naturaleza
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentation
 
e-Cert
e-Certe-Cert
e-Cert
 
Materials
MaterialsMaterials
Materials
 
Introduction
IntroductionIntroduction
Introduction
 
Jonatan y angie 10 b
Jonatan y angie 10 bJonatan y angie 10 b
Jonatan y angie 10 b
 
MultipleYaxis
MultipleYaxisMultipleYaxis
MultipleYaxis
 
Rwa density what lies behind this underrated financial ratio
Rwa density what lies behind this underrated financial ratioRwa density what lies behind this underrated financial ratio
Rwa density what lies behind this underrated financial ratio
 
у серці кожної дитини живе любов до україни
у серці кожної дитини живе любов до україниу серці кожної дитини живе любов до україни
у серці кожної дитини живе любов до україни
 
Hojas de trabajo de 5 a 8
Hojas de trabajo de 5 a 8Hojas de trabajo de 5 a 8
Hojas de trabajo de 5 a 8
 
Jackie Robinson Power Point
Jackie Robinson Power PointJackie Robinson Power Point
Jackie Robinson Power Point
 
UAF Official Transcripts
UAF Official TranscriptsUAF Official Transcripts
UAF Official Transcripts
 
Mechanical Engineer Resume
Mechanical Engineer ResumeMechanical Engineer Resume
Mechanical Engineer Resume
 
με πινέλα και φαντασία
με πινέλα και φαντασίαμε πινέλα και φαντασία
με πινέλα και φαντασία
 
Resume (1) (1) (1) AR
Resume (1) (1) (1) ARResume (1) (1) (1) AR
Resume (1) (1) (1) AR
 

Similar to JAX - RS MuleSoft ESB

JAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesJAX-RS Creating RESTFul services
JAX-RS Creating RESTFul services
Ludovic Champenois
 
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RSSpark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Arun Gupta
 
RESTful Web services using JAX-RS
RESTful Web services using JAX-RSRESTful Web services using JAX-RS
RESTful Web services using JAX-RS
Arun Gupta
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011Shreedhar Ganapathy
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using Swagger
Hong-Jhih Lin
 
6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework
Arcadian Learning
 
Ppt on web development and this has all details
Ppt on web development and this has all detailsPpt on web development and this has all details
Ppt on web development and this has all details
gogijoshiajmer
 
#6 (RESTtful Web Wervices)
#6 (RESTtful Web Wervices)#6 (RESTtful Web Wervices)
#6 (RESTtful Web Wervices)
Ghadeer AlHasan
 
aip-workshop1-dev-tutorial
aip-workshop1-dev-tutorialaip-workshop1-dev-tutorial
aip-workshop1-dev-tutorial
Matthew Vaughn
 
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
Sagara Gunathunga
 
Lab swe-2013intro jax-rs
Lab swe-2013intro jax-rsLab swe-2013intro jax-rs
Lab swe-2013intro jax-rs
Aravindharamanan S
 
Resting on your laurels will get you powned
Resting on your laurels will get you pownedResting on your laurels will get you powned
Resting on your laurels will get you powned
Dinis Cruz
 
An architecture for federated data discovery and lineage over on-prem datasou...
An architecture for federated data discovery and lineage over on-prem datasou...An architecture for federated data discovery and lineage over on-prem datasou...
An architecture for federated data discovery and lineage over on-prem datasou...
DataWorks Summit
 
API Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNG
Siddharth Sharma
 
W3C Web Annotation WG Update (I Annotate 2016)
W3C Web Annotation WG Update (I Annotate 2016)W3C Web Annotation WG Update (I Annotate 2016)
W3C Web Annotation WG Update (I Annotate 2016)
Robert Sanderson
 
Restful webservice
Restful webserviceRestful webservice
Restful webservice
Dong Ngoc
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
Anil Allewar
 
The Glory of Rest
The Glory of RestThe Glory of Rest
The Glory of Rest
Sławomir Chrobak
 
Webinar: What's new in CDAP 3.5?
Webinar: What's new in CDAP 3.5?Webinar: What's new in CDAP 3.5?
Webinar: What's new in CDAP 3.5?
Cask Data
 
HDP Next: Governance
HDP Next: GovernanceHDP Next: Governance
HDP Next: Governance
DataWorks Summit
 

Similar to JAX - RS MuleSoft ESB (20)

JAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesJAX-RS Creating RESTFul services
JAX-RS Creating RESTFul services
 
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RSSpark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RS
 
RESTful Web services using JAX-RS
RESTful Web services using JAX-RSRESTful Web services using JAX-RS
RESTful Web services using JAX-RS
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using Swagger
 
6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework
 
Ppt on web development and this has all details
Ppt on web development and this has all detailsPpt on web development and this has all details
Ppt on web development and this has all details
 
#6 (RESTtful Web Wervices)
#6 (RESTtful Web Wervices)#6 (RESTtful Web Wervices)
#6 (RESTtful Web Wervices)
 
aip-workshop1-dev-tutorial
aip-workshop1-dev-tutorialaip-workshop1-dev-tutorial
aip-workshop1-dev-tutorial
 
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
 
Lab swe-2013intro jax-rs
Lab swe-2013intro jax-rsLab swe-2013intro jax-rs
Lab swe-2013intro jax-rs
 
Resting on your laurels will get you powned
Resting on your laurels will get you pownedResting on your laurels will get you powned
Resting on your laurels will get you powned
 
An architecture for federated data discovery and lineage over on-prem datasou...
An architecture for federated data discovery and lineage over on-prem datasou...An architecture for federated data discovery and lineage over on-prem datasou...
An architecture for federated data discovery and lineage over on-prem datasou...
 
API Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNG
 
W3C Web Annotation WG Update (I Annotate 2016)
W3C Web Annotation WG Update (I Annotate 2016)W3C Web Annotation WG Update (I Annotate 2016)
W3C Web Annotation WG Update (I Annotate 2016)
 
Restful webservice
Restful webserviceRestful webservice
Restful webservice
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
 
The Glory of Rest
The Glory of RestThe Glory of Rest
The Glory of Rest
 
Webinar: What's new in CDAP 3.5?
Webinar: What's new in CDAP 3.5?Webinar: What's new in CDAP 3.5?
Webinar: What's new in CDAP 3.5?
 
HDP Next: Governance
HDP Next: GovernanceHDP Next: Governance
HDP Next: Governance
 

Recently uploaded

Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 

Recently uploaded (20)

Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 

JAX - RS MuleSoft ESB

  • 1.
  • 2. AGENDA • Discuss REST Architecture Principles • Discuss REST API Design Approach • Discuss JAX – RS Standards • Discuss Mule REST Component for REST API
  • 3. REST ARCHITECTURE – PRINCIPLES Rest Architecture Principle Description Addressability Every resource in the system is reachable by a unique identifier. Uniform Constrained Interface Constraints on the methods of application protocol to access operations on the published service for e.g. GET, POST, PUT, DELETE, HEAD, OPTIONS Representation Oriented Resource representations between the client and server can be XML, JSON or YAML Communicate Statelessly No client information is stored in the sessions on the server HATEOAS Support to embed inside the resource representation, the links other services.
  • 4. REST API DESIGN  Design the URIs for all the resources in the system  Define the resource representation – XML, JSON etc.  Assign HTTP Methods to the resources  Version the REST API  Choose the REST API URL root  Filtering / limiting results returned from the API on the basis of request parameters  Define authentication strategy e.g. Oauth 1.0  Develop documentation for the REST APIs  Track Analytics on REST API usage
  • 5. JAX-RS ANNOTATIONS JAX-RS Annotation Description @Path URI to the Rest API @Consumes / @Produces Defines the media type of the message payload accepted / produced by the API @GET,@POST,@PUT,@DEL ETE… HTTP methods assigned to API @QueryParam Binds query parameters from http request to API method parameters @DefaultValue Default value of the query parameter @PathParam Maps the URI template parameter to resource method parameter or resource class field @FormParam Maps the form parameter to resource method parameter or resource class field
  • 6. JAX-RS ANNOTATIONS CONTD… JAX-RS Annotation Description @CookieParam Extracts information from the cookies declared in the http headers @HeaderPara m Maps the value from an http header to a resource method parameter or a resource class field. @BeanParam JAX-RS parameter aggregator value object . Injects the bean into a resource class field or property @EncodedPara m Disables automatic decoding of parameters bound to QueryParam, PathParam, FormParam or Matrix Param @MatrixParam Maps the URI matric parameter / path segment to a method parameter or resource class field or resource bean property
  • 7. JAX-RS CONTENT HANDLERS JAX-RS has built in handlers for marshalling and unmarshalling of certain Java types • Content Marshalling – Following are objects used for API I/O • javax.ws.rs.core.StreamingOutput • java.io.InputStream, java.io.Reader • java.io.File • byte[] • char[] • JAXB • Custom Marshalling – Implement the following interfaces • javax.ws.rs.ext.MessageBodyWriter • javax.ws.rs.ext.MessageBodyReader
  • 8. CONTENT NEGOTIATION • Content Negotiation Clients can request for a specific media type when querying the server for information • Preference Ordering The server assumes that the client always wants a more specific media type over a wild card specified media type • Language Negotiation Clients use the ACCEPT-Language header to specify the language in which the information is expected • Encoding Negotiation Clients specify the Accept Encoding header to specify the message body encoding for e.g. GZIP, to save on network bandwidth
  • 9. JAX-RS & MULE Jersey JAX-RS Transport: Mule uses Jersey for REST API development. Mule 3.6 uses Jersey v2.11 Following is the piece of code that hosts the REST API using Jersey: <jersey:resources> <component class="org.mule.module.jersey.HelloWorldResource"/> </jersey:resources> The HelloWorldResource is the resource that use JAX-RS annotations to map HTTP verbs to resource methods.
  • 10. JAX-RS EXAMPLE @Path("/customer") public class CustomerResource { @GET @Produces("text/plain") @Path("/{customerId}") public String getCustomer(@PathParam("customerId") String customerId){ Map<String, String> customerDetailsMap = new HashMap<String,String>(); customerDetailsMap.put("C0001", "TOM"); customerDetailsMap.put("C0002", "JERRY"); return customerDetailsMap.get(customerId); } } Path to URI Http Verb Media Type Path Variable