SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
Sagara	
  Gunathunga	
  
Architect	
  -­‐	
  WSO2	
  
Deep	
  dive	
  into	
  JAX-­‐RS	
  
2	
  
	
  	
  REST	
  	
  
REpresentational State Transfer
“An architecture style of networked systems & uses
HTTP Protocol for data communication ”
3	
  
	
  	
  REST	
  	
  Fundamentals	
  	
  	
  
Resources with unique IDs
Standard methods
Multiple representations
Link Resources together
HTTP Content
(JSON/POX/TXT)
HTTP URL
Hyperlinks
HTTP Methods
4	
  
	
  	
  REST	
  	
  Fundamentals	
  	
  	
  
5	
  
	
  	
  REST	
  	
  Fundamentals	
  	
  	
  
• Client-Server
• Separation principle
• Components Independent
• Stateless
• Session state on the client
• Visibility, reliability and scalability
• Trade off (network performance, etc.)
• Cacheable
• A response can be cacheable
• Efficiency but reduce reliability
• Layered system
• System scalability
6	
  
JAX-­‐RS	
  –	
  Java	
  API	
  for	
  RESTfull	
  	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  WebServices	
  	
  
•  Annotation driven JavaEE API
•  Expose annotated Java bean as HTTP based services
•  Implementation may support service descriptions.
•  Swagger
•  RAML
•  WADL
•  Define JAVA ó HTTP mapping
•  Number of implementations
•  Apache CXF
•  Apache Wink
•  Jersey
•  Also used by Microservices frameworks to define services
•  Dropwizard
•  Spring Boot
7	
  
Richardson	
  Maturity	
  Model	
  
8	
  
RMM	
  –	
  Level	
  0	
  	
  
•  HTTP as a transport system for remote interactions.
•  Same as SOAP or XML-RPC it's basically the same mechanism.
•  Most of the cases only one endpoint is exposed for whole service/
application.
9	
  
RMM	
  –	
  Level	
  1	
  	
  
•  For each web resource there is a unique identifiable Id.
•  http://school.com/api/students => All student collection
•  Http://scholl.com/api/student/2345 => A unique student
10	
  
RMM	
  –	
  Level	
  2	
  	
  
•  Map HTTP Methods to operations (state transition) on resources.
•  GET Http://scholl.com/api/student/2345
•  PUT Http://scholl.com/api/student/2345
•  DELETE Http://scholl.com/api/student/2345
•  Do not overload HTTP POST/GET and define WS like operations.
•  Do not use “verbs/actions” as a part of resource URL.
•  E.g – createStudent, editStudent
• 
11	
  
HTTP Method CRUD Desc.
POST CREATE Create -
GET RETRIEVE Retrieve Safe,Idempotent,Cacheable
PUT UPDATE Update Idempotent
DELETE DELETE Delete Idempotent
	
  	
  REST	
  HTTP Methods 	
  
12	
  
RMM	
  –	
  Level	
  3	
  	
  
•  Use Hyperlinks to relate (link) resources.
•  Also known as HATEOAS (Hypertext As The Engine Of Application
State).
13	
  
JAX-­‐WS	
  AnnotaGons	
  	
  
•  @Path
•  @GET
•  @PUT
•  @POST
•  @DELETE
•  @Produces
•  @Consumes
•  @PathParam
•  @QueryParam
•  @MatrixParam
•  @HeaderParam
•  @CookieParam
•  @FormParam
•  @DefaultValue
•  @Context
JAX-­‐RS	
  
JAX-RS Annotated Service
@Path("/hello”)
public class HelloWorldService {
@GET
@Path("/{user}")
public String hello(@PathParam("user") String user) {
}
}
JAX-­‐RS	
  
JAX-RS Annotated Service
@Path("/hello”)
public class HelloWorldService {
@GET
@Consumes("text/plain")
@Produces("text/xml")
@Path("/{user}")
public String hello(@PathParam("user") String user) {
}
}
JAX-­‐RS	
  parameter	
  types	
  
•  @PathParam
•  @QueryParam
•  @HeaderParam
•  @CookieParam
•  @FormParam
•  @MatrixParam
JAX-­‐RS	
  Path	
  parameters	
  
@GET
@Path("/hello/{user}")
public String hello(@PathParam("user") String user) {
return "Hello " + user;
}
http://localhost:8080/helloworldapp/hello/sagara
PathParam
“user” value
•  URL template style
•  Generally used to represent compulsory
user inputs
JAX-­‐RS	
  OpGonal	
  Path	
  parameters	
  
@GET
@Path("/hello{user: (/user)?}")
public String hello(@PathParam("user") String user) {
return "Hello " + user;
}
http://localhost:8080/helloworldapp/hello/sagara
PathParam
“user” value
•  Important in backward compatible API
designs.
•  Generally incorporate with @DefaultValue
annotation
http://localhost:8080/helloworldapp/hello/
No PathParam
“user” value
http://localhost:8080/helloworldapp/hello
JAX-­‐RS	
  Query	
  parameters	
  
@GET
@Path("/hello")
public String hello(@QueryParam (”name") String user) {
return "Hello " + user;
}
http://localhost:8080/helloworldapp/hello?name=sagara
PathParam
“user” value•  Query string parameter style
•  Generally used to represent optional user
inputs or controller operations.
•  Generally incorporate with @DefaultValue
annotation
JAX-­‐RS	
  Header	
  parameters	
  
@GET
@Path("/hello")
public String hello(@HeaderParam("Referer") String referer) {
return "Hello World ” ;
}
GET /helloworldapp/hello http/1.1
Host localhost
Referer http://facebook/…….. Header value
•  Map HTTP header values to Java method
parameters.
•  Can be used to handle resource
versioning , pagination, cache etc.
21	
  
	
  Error	
  handling	
  	
  -­‐	
  Status	
  Codes	
  	
  	
  
Do not define your own error codes instead use HTTP status codes
as much as possible.
HTTP 200 - OK
HTTP 201 - Resource created
HTTP 204 - No content found
HTTP 30 4 - Not modified
HTTP 404 - Resource not found
HTTP 410 - Resource gone
HTTP 409 - Conflicts
HTTP 403 - Forbidden
HTTP 500 - Internal Server Error
HTTP 503 - Service Unavailable
22	
  
	
  Error	
  handling	
  	
  -­‐	
  Status	
  Codes	
  	
  	
  
Do not define your own error codes instead use HTTP status codes
as much as possible.
public Response findAll() {
try {
return Response.status(Response.Status.ACCEPTED)
.entity(users.findAll()).build();
} catch (UserDAOException e) {
return Response.
status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
23	
  
	
  Error	
  handling	
  -­‐	
  ExcepGonMapper	
  
Instead of scatter error handling code in resource code possible
to define .
class UserExceptionMapper implements
ExceptionMapper<UserDAOException> {
public Response toResponse(UserDAOException exception) {
if (exception instanceof UserNotFoundException) {
return Response.status(Response.Status.NOT_FOUND).build();
} else {
return Response
.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
24	
  
Resource	
  Linking	
  
Use hyper links properly to link related resources.
Account can
be in many
groups
Link to related
group
Links to group
members
25	
  
JAX-­‐RS	
  PaginaHon	
  
Widely used approaches.
•  LimitOffset based pagination
•  Limit – Define the size of the page
•  Offset – Define the starting point of each page.
•  Curser based pagination
•  Limit – Define the size of the page
•  Before –
Cursor that points to the start of the page of data that has been
returned
•  After - cursor that points to the end of the page of data that
has been returned
•  Time based pagination
•  Limit – Define the size of the page
•  Until – points to the end of the range of time-based data
•  Since – points to the startof the range of time-based data
26	
  
JAX-­‐RS	
  LimitOffset	
  based	
  PaginaHon	
  
@GET
@Path("/users")
@Produces(MediaType.APPLICATION_JSON)
public Response findAll(
@QueryParam("offset") @DefaultValue("0") int offset,
@QueryParam("limit") @DefaultValue("10") int limit,
@Context UriInfo uriInfo) {
}
URI currentLink = UriBuilder.fromUri(uriInfo.getBaseUri())
.path("/page/users")
.queryParam("offset", offset)
.queryParam("limit", limit)
.build();
Creating Links
27	
  
AuthenHcaHon	
  and	
  AuthorizaHon	
  	
  
Widely used approaches.
•  HTTP BasicAuth
•  OAuth2
28	
  
References	
  	
  	
  
•  https://github.com/sagara-gunathunga/jaxrs-java-colombo/
•  http://martinfowler.com/articles/richardsonMaturityModel.html
Contact	
  us	
  !	
  

Weitere ähnliche Inhalte

Was ist angesagt?

WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleJames Bayer
 
SQLSaturday Bulgaria : HA & DR with SQL Server AlwaysOn Availability Groups
SQLSaturday Bulgaria : HA & DR with SQL Server AlwaysOn Availability GroupsSQLSaturday Bulgaria : HA & DR with SQL Server AlwaysOn Availability Groups
SQLSaturday Bulgaria : HA & DR with SQL Server AlwaysOn Availability Groupsturgaysahtiyan
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Weblogic performance tuning2
Weblogic performance tuning2Weblogic performance tuning2
Weblogic performance tuning2Aditya Bhuyan
 
Restful风格ž„web服务架构
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构Benjamin Tan
 
Always on in SQL Server 2012
Always on in SQL Server 2012Always on in SQL Server 2012
Always on in SQL Server 2012Fadi Abdulwahab
 
Rails Request & Middlewares
Rails Request & MiddlewaresRails Request & Middlewares
Rails Request & MiddlewaresSantosh Wadghule
 
Native REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gNative REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gMarcelo Ochoa
 
Rails request & middlewares
Rails request & middlewaresRails request & middlewares
Rails request & middlewaresSantosh Wadghule
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
RESTful application with JAX-RS and how to expose and test them
RESTful application with JAX-RS and how to expose and test themRESTful application with JAX-RS and how to expose and test them
RESTful application with JAX-RS and how to expose and test themKumaraswamy M
 
Weblogic introduction
Weblogic introductionWeblogic introduction
Weblogic introductionAditya Bhuyan
 
Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: ServletsFahad Golra
 
Sql server 2012 AlwaysOn
Sql server 2012 AlwaysOnSql server 2012 AlwaysOn
Sql server 2012 AlwaysOnWarwick Rudd
 

Was ist angesagt? (20)

WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan Example
 
SQLSaturday Bulgaria : HA & DR with SQL Server AlwaysOn Availability Groups
SQLSaturday Bulgaria : HA & DR with SQL Server AlwaysOn Availability GroupsSQLSaturday Bulgaria : HA & DR with SQL Server AlwaysOn Availability Groups
SQLSaturday Bulgaria : HA & DR with SQL Server AlwaysOn Availability Groups
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Weblogic performance tuning2
Weblogic performance tuning2Weblogic performance tuning2
Weblogic performance tuning2
 
Restful风格ž„web服务架构
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构
 
Always on in SQL Server 2012
Always on in SQL Server 2012Always on in SQL Server 2012
Always on in SQL Server 2012
 
Rails Request & Middlewares
Rails Request & MiddlewaresRails Request & Middlewares
Rails Request & Middlewares
 
AlwaysON Basics
AlwaysON BasicsAlwaysON Basics
AlwaysON Basics
 
Andrei shakirin rest_cxf
Andrei shakirin rest_cxfAndrei shakirin rest_cxf
Andrei shakirin rest_cxf
 
Native REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gNative REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11g
 
Rails request & middlewares
Rails request & middlewaresRails request & middlewares
Rails request & middlewares
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Weblogic
WeblogicWeblogic
Weblogic
 
RESTful application with JAX-RS and how to expose and test them
RESTful application with JAX-RS and how to expose and test themRESTful application with JAX-RS and how to expose and test them
RESTful application with JAX-RS and how to expose and test them
 
Weblogic introduction
Weblogic introductionWeblogic introduction
Weblogic introduction
 
Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: Servlets
 
Weblogic security
Weblogic securityWeblogic security
Weblogic security
 
Weblogic plug in
Weblogic plug inWeblogic plug in
Weblogic plug in
 
Oracle Web Logic server
Oracle Web Logic serverOracle Web Logic server
Oracle Web Logic server
 
Sql server 2012 AlwaysOn
Sql server 2012 AlwaysOnSql server 2012 AlwaysOn
Sql server 2012 AlwaysOn
 

Andere mochten auch

Scalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyondScalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyondAndy Moncsek
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyMohamed Taman
 
Server-Side Programming Primer
Server-Side Programming PrimerServer-Side Programming Primer
Server-Side Programming PrimerIvano Malavolta
 
Regla del Boy Scout y la Oxidación del Software
Regla del Boy Scout y la Oxidación del SoftwareRegla del Boy Scout y la Oxidación del Software
Regla del Boy Scout y la Oxidación del SoftwareAlejandro Pérez García
 
JAX-RS 2.0: RESTful Java on Steroids, by Aron Gupta
JAX-RS 2.0: RESTful Java on Steroids, by Aron GuptaJAX-RS 2.0: RESTful Java on Steroids, by Aron Gupta
JAX-RS 2.0: RESTful Java on Steroids, by Aron GuptaCodemotion
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and ODataAnil Allewar
 
Using Java to implement RESTful Web Services: JAX-RS
Using Java to implement RESTful Web Services: JAX-RSUsing Java to implement RESTful Web Services: JAX-RS
Using Java to implement RESTful Web Services: JAX-RSKatrien Verbert
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSCarol McDonald
 
JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?Arun Gupta
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to MavenJoao Pereira
 
Adopt-a-jsr Mar 1 2017 JAX-RS update
Adopt-a-jsr Mar 1 2017 JAX-RS updateAdopt-a-jsr Mar 1 2017 JAX-RS update
Adopt-a-jsr Mar 1 2017 JAX-RS updatePavel Bucek
 
JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013Jagadish Prasath
 

Andere mochten auch (20)

Scalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyondScalableenterpriseapplicationswith jee7andbeyond
Scalableenterpriseapplicationswith jee7andbeyond
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new Strategy
 
Server-Side Programming Primer
Server-Side Programming PrimerServer-Side Programming Primer
Server-Side Programming Primer
 
Regla del Boy Scout y la Oxidación del Software
Regla del Boy Scout y la Oxidación del SoftwareRegla del Boy Scout y la Oxidación del Software
Regla del Boy Scout y la Oxidación del Software
 
JAX-RS 2.0: RESTful Java on Steroids, by Aron Gupta
JAX-RS 2.0: RESTful Java on Steroids, by Aron GuptaJAX-RS 2.0: RESTful Java on Steroids, by Aron Gupta
JAX-RS 2.0: RESTful Java on Steroids, by Aron Gupta
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
 
Gradle vs Maven
Gradle vs MavenGradle vs Maven
Gradle vs Maven
 
Gradle como alternativa a maven
Gradle como alternativa a mavenGradle como alternativa a maven
Gradle como alternativa a maven
 
Using Java to implement RESTful Web Services: JAX-RS
Using Java to implement RESTful Web Services: JAX-RSUsing Java to implement RESTful Web Services: JAX-RS
Using Java to implement RESTful Web Services: JAX-RS
 
Maven
MavenMaven
Maven
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RS
 
Maven
Maven Maven
Maven
 
Maven (EN ESPANOL)
Maven (EN ESPANOL)Maven (EN ESPANOL)
Maven (EN ESPANOL)
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
 
Java desde cero maven
Java desde cero mavenJava desde cero maven
Java desde cero maven
 
JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
Adopt-a-jsr Mar 1 2017 JAX-RS update
Adopt-a-jsr Mar 1 2017 JAX-RS updateAdopt-a-jsr Mar 1 2017 JAX-RS update
Adopt-a-jsr Mar 1 2017 JAX-RS update
 
JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013
 

Ähnlich wie Java colombo-deep-dive-into-jax-rs

Restful webservice
Restful webserviceRestful webservice
Restful webserviceDong Ngoc
 
Restful webservices
Restful webservicesRestful webservices
Restful webservicesKong King
 
JAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesJAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesLudovic 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-RSArun Gupta
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011Shreedhar Ganapathy
 
XSEDE14 SciGaP-Apache Airavata Tutorial
XSEDE14 SciGaP-Apache Airavata TutorialXSEDE14 SciGaP-Apache Airavata Tutorial
XSEDE14 SciGaP-Apache Airavata Tutorialmarpierc
 
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Arun Gupta
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackChiradeep Vittal
 
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
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.pptWalaSidhom1
 
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 detailsgogijoshiajmer
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API07.pallav
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New FeaturesNaveen Hegde
 
Apache Ambari BOF - APIs - Hadoop Summit 2013
Apache Ambari BOF - APIs - Hadoop Summit 2013Apache Ambari BOF - APIs - Hadoop Summit 2013
Apache Ambari BOF - APIs - Hadoop Summit 2013Hortonworks
 
GraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: ScaleGraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: ScaleNeo4j
 

Ähnlich wie Java colombo-deep-dive-into-jax-rs (20)

Restful webservice
Restful webserviceRestful webservice
Restful webservice
 
Restful webservices
Restful webservicesRestful webservices
Restful webservices
 
JAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesJAX-RS Creating RESTFul services
JAX-RS Creating RESTFul services
 
Rest And Rails
Rest And RailsRest And Rails
Rest And Rails
 
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
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
Rest
RestRest
Rest
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
 
XSEDE14 SciGaP-Apache Airavata Tutorial
XSEDE14 SciGaP-Apache Airavata TutorialXSEDE14 SciGaP-Apache Airavata Tutorial
XSEDE14 SciGaP-Apache Airavata Tutorial
 
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
 
REST API with CakePHP
REST API with CakePHPREST API with CakePHP
REST API with CakePHP
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStack
 
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?
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
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
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
 
Apache Ambari BOF - APIs - Hadoop Summit 2013
Apache Ambari BOF - APIs - Hadoop Summit 2013Apache Ambari BOF - APIs - Hadoop Summit 2013
Apache Ambari BOF - APIs - Hadoop Summit 2013
 
GraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: ScaleGraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: Scale
 

Mehr von Sagara Gunathunga

Microservices Security landscape
Microservices Security landscapeMicroservices Security landscape
Microservices Security landscapeSagara Gunathunga
 
Privacy by Design as a system design strategy - EIC 2019
Privacy by Design as a system design strategy - EIC 2019 Privacy by Design as a system design strategy - EIC 2019
Privacy by Design as a system design strategy - EIC 2019 Sagara Gunathunga
 
Consumer Identity World EU - Five pillars of consumer IAM
Consumer Identity World EU - Five pillars of consumer IAM Consumer Identity World EU - Five pillars of consumer IAM
Consumer Identity World EU - Five pillars of consumer IAM Sagara Gunathunga
 
kicking your enterprise security up a notch with adaptive authentication sa...
kicking your enterprise security up a notch with adaptive authentication   sa...kicking your enterprise security up a notch with adaptive authentication   sa...
kicking your enterprise security up a notch with adaptive authentication sa...Sagara Gunathunga
 
Synergies across APIs and IAM
Synergies across APIs and IAMSynergies across APIs and IAM
Synergies across APIs and IAMSagara Gunathunga
 
GDPR impact on Consumer Identity and Access Management (CIAM)
GDPR impact on Consumer Identity and Access Management (CIAM)GDPR impact on Consumer Identity and Access Management (CIAM)
GDPR impact on Consumer Identity and Access Management (CIAM)Sagara Gunathunga
 
Introduction to the All New WSO2 Governance Centre
Introduction to the All New WSO2 Governance CentreIntroduction to the All New WSO2 Governance Centre
Introduction to the All New WSO2 Governance CentreSagara Gunathunga
 
Building Services with WSO2 Application Server and WSO2 Microservices Framewo...
Building Services with WSO2 Application Server and WSO2 Microservices Framewo...Building Services with WSO2 Application Server and WSO2 Microservices Framewo...
Building Services with WSO2 Application Server and WSO2 Microservices Framewo...Sagara Gunathunga
 
An Introduction to WSO2 Microservices Framework for Java
An Introduction to WSO2 Microservices Framework for JavaAn Introduction to WSO2 Microservices Framework for Java
An Introduction to WSO2 Microservices Framework for JavaSagara Gunathunga
 
Understanding Microservice Architecture WSO2Con Asia 2016
Understanding Microservice Architecture WSO2Con Asia 2016 Understanding Microservice Architecture WSO2Con Asia 2016
Understanding Microservice Architecture WSO2Con Asia 2016 Sagara Gunathunga
 
Introduction to the all new wso2 governance centre asia 16
Introduction to the all new wso2 governance centre asia 16Introduction to the all new wso2 governance centre asia 16
Introduction to the all new wso2 governance centre asia 16Sagara Gunathunga
 
Building Your Own Store with WSO2 Enterprise Store: The WSO2 Store Case Study
Building Your Own Store with WSO2 Enterprise Store: The WSO2 Store Case StudyBuilding Your Own Store with WSO2 Enterprise Store: The WSO2 Store Case Study
Building Your Own Store with WSO2 Enterprise Store: The WSO2 Store Case StudySagara Gunathunga
 
Introduction to the All New WSO2 Governance Centre
Introduction to the All New WSO2 Governance CentreIntroduction to the All New WSO2 Governance Centre
Introduction to the All New WSO2 Governance CentreSagara Gunathunga
 
Application Monitoring with WSO2 App Server
Application Monitoring with WSO2 App ServerApplication Monitoring with WSO2 App Server
Application Monitoring with WSO2 App ServerSagara Gunathunga
 
Creating APIs with the WSO2 Platform
Creating APIs with the WSO2 PlatformCreating APIs with the WSO2 Platform
Creating APIs with the WSO2 PlatformSagara Gunathunga
 
Apache contribution-bar camp-colombo
Apache contribution-bar camp-colomboApache contribution-bar camp-colombo
Apache contribution-bar camp-colomboSagara Gunathunga
 

Mehr von Sagara Gunathunga (20)

Microservices Security landscape
Microservices Security landscapeMicroservices Security landscape
Microservices Security landscape
 
Privacy by Design as a system design strategy - EIC 2019
Privacy by Design as a system design strategy - EIC 2019 Privacy by Design as a system design strategy - EIC 2019
Privacy by Design as a system design strategy - EIC 2019
 
Consumer Identity World EU - Five pillars of consumer IAM
Consumer Identity World EU - Five pillars of consumer IAM Consumer Identity World EU - Five pillars of consumer IAM
Consumer Identity World EU - Five pillars of consumer IAM
 
kicking your enterprise security up a notch with adaptive authentication sa...
kicking your enterprise security up a notch with adaptive authentication   sa...kicking your enterprise security up a notch with adaptive authentication   sa...
kicking your enterprise security up a notch with adaptive authentication sa...
 
Synergies across APIs and IAM
Synergies across APIs and IAMSynergies across APIs and IAM
Synergies across APIs and IAM
 
GDPR impact on Consumer Identity and Access Management (CIAM)
GDPR impact on Consumer Identity and Access Management (CIAM)GDPR impact on Consumer Identity and Access Management (CIAM)
GDPR impact on Consumer Identity and Access Management (CIAM)
 
Introduction to the All New WSO2 Governance Centre
Introduction to the All New WSO2 Governance CentreIntroduction to the All New WSO2 Governance Centre
Introduction to the All New WSO2 Governance Centre
 
Building Services with WSO2 Application Server and WSO2 Microservices Framewo...
Building Services with WSO2 Application Server and WSO2 Microservices Framewo...Building Services with WSO2 Application Server and WSO2 Microservices Framewo...
Building Services with WSO2 Application Server and WSO2 Microservices Framewo...
 
An Introduction to WSO2 Microservices Framework for Java
An Introduction to WSO2 Microservices Framework for JavaAn Introduction to WSO2 Microservices Framework for Java
An Introduction to WSO2 Microservices Framework for Java
 
Understanding Microservice Architecture WSO2Con Asia 2016
Understanding Microservice Architecture WSO2Con Asia 2016 Understanding Microservice Architecture WSO2Con Asia 2016
Understanding Microservice Architecture WSO2Con Asia 2016
 
Introduction to the all new wso2 governance centre asia 16
Introduction to the all new wso2 governance centre asia 16Introduction to the all new wso2 governance centre asia 16
Introduction to the all new wso2 governance centre asia 16
 
Building Your Own Store with WSO2 Enterprise Store: The WSO2 Store Case Study
Building Your Own Store with WSO2 Enterprise Store: The WSO2 Store Case StudyBuilding Your Own Store with WSO2 Enterprise Store: The WSO2 Store Case Study
Building Your Own Store with WSO2 Enterprise Store: The WSO2 Store Case Study
 
Introduction to the All New WSO2 Governance Centre
Introduction to the All New WSO2 Governance CentreIntroduction to the All New WSO2 Governance Centre
Introduction to the All New WSO2 Governance Centre
 
Application Monitoring with WSO2 App Server
Application Monitoring with WSO2 App ServerApplication Monitoring with WSO2 App Server
Application Monitoring with WSO2 App Server
 
WSO2 Application Server
WSO2 Application ServerWSO2 Application Server
WSO2 Application Server
 
Creating APIs with the WSO2 Platform
Creating APIs with the WSO2 PlatformCreating APIs with the WSO2 Platform
Creating APIs with the WSO2 Platform
 
WSO2 AppDev platform
WSO2 AppDev platformWSO2 AppDev platform
WSO2 AppDev platform
 
Apache contribution-bar camp-colombo
Apache contribution-bar camp-colomboApache contribution-bar camp-colombo
Apache contribution-bar camp-colombo
 
What is new in Axis2 1.7.0
What is new in Axis2 1.7.0 What is new in Axis2 1.7.0
What is new in Axis2 1.7.0
 
Web service introduction 2
Web service introduction 2Web service introduction 2
Web service introduction 2
 

Kürzlich hochgeladen

TRose UXPA Experience Design Concord .pptx
TRose UXPA Experience Design Concord .pptxTRose UXPA Experience Design Concord .pptx
TRose UXPA Experience Design Concord .pptxtrose8
 
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...Nitya salvi
 
Sweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptxSweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptxbingyichin04
 
High Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
High Profile Escorts Nerul WhatsApp +91-9930687706, Best ServiceHigh Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
High Profile Escorts Nerul WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
BLOCK CHAIN PROJECT block chain project
BLOCK CHAIN  PROJECT block chain projectBLOCK CHAIN  PROJECT block chain project
BLOCK CHAIN PROJECT block chain projectujraj8767
 
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEKLANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEKMarekMitek1
 
Minimalist Orange Portfolio by Slidesgo.pptx
Minimalist Orange Portfolio by Slidesgo.pptxMinimalist Orange Portfolio by Slidesgo.pptx
Minimalist Orange Portfolio by Slidesgo.pptxbalqisyamutia
 
How to Create a Productive Workspace Trends and Tips.pdf
How to Create a Productive Workspace Trends and Tips.pdfHow to Create a Productive Workspace Trends and Tips.pdf
How to Create a Productive Workspace Trends and Tips.pdfOffice Furniture Plus - Irving
 
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...Nitya salvi
 
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...Nitya salvi
 
Q4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentationQ4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentationZenSeloveres
 
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service AvailableCall Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service AvailableNitya salvi
 
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...samsungultra782445
 
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...sriharipichandi
 
Essential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive GuideEssential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive GuideDesign Studio UI UX
 
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证eeanqy
 
Jordan_Amanda_DMBS202404_PB1_2024-04.pdf
Jordan_Amanda_DMBS202404_PB1_2024-04.pdfJordan_Amanda_DMBS202404_PB1_2024-04.pdf
Jordan_Amanda_DMBS202404_PB1_2024-04.pdfamanda2495
 
poliovirus-190801072449. pptx
poliovirus-190801072449.            pptxpoliovirus-190801072449.            pptx
poliovirus-190801072449. pptxssuser0ad194
 
Furniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptxFurniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptxNikhil Raut
 
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证wpkuukw
 

Kürzlich hochgeladen (20)

TRose UXPA Experience Design Concord .pptx
TRose UXPA Experience Design Concord .pptxTRose UXPA Experience Design Concord .pptx
TRose UXPA Experience Design Concord .pptx
 
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...
 
Sweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptxSweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptx
 
High Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
High Profile Escorts Nerul WhatsApp +91-9930687706, Best ServiceHigh Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
High Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
 
BLOCK CHAIN PROJECT block chain project
BLOCK CHAIN  PROJECT block chain projectBLOCK CHAIN  PROJECT block chain project
BLOCK CHAIN PROJECT block chain project
 
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEKLANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
 
Minimalist Orange Portfolio by Slidesgo.pptx
Minimalist Orange Portfolio by Slidesgo.pptxMinimalist Orange Portfolio by Slidesgo.pptx
Minimalist Orange Portfolio by Slidesgo.pptx
 
How to Create a Productive Workspace Trends and Tips.pdf
How to Create a Productive Workspace Trends and Tips.pdfHow to Create a Productive Workspace Trends and Tips.pdf
How to Create a Productive Workspace Trends and Tips.pdf
 
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
 
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
 
Q4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentationQ4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentation
 
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service AvailableCall Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
 
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
 
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
 
Essential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive GuideEssential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive Guide
 
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证
 
Jordan_Amanda_DMBS202404_PB1_2024-04.pdf
Jordan_Amanda_DMBS202404_PB1_2024-04.pdfJordan_Amanda_DMBS202404_PB1_2024-04.pdf
Jordan_Amanda_DMBS202404_PB1_2024-04.pdf
 
poliovirus-190801072449. pptx
poliovirus-190801072449.            pptxpoliovirus-190801072449.            pptx
poliovirus-190801072449. pptx
 
Furniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptxFurniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptx
 
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
 

Java colombo-deep-dive-into-jax-rs

  • 1. Sagara  Gunathunga   Architect  -­‐  WSO2   Deep  dive  into  JAX-­‐RS  
  • 2. 2      REST     REpresentational State Transfer “An architecture style of networked systems & uses HTTP Protocol for data communication ”
  • 3. 3      REST    Fundamentals       Resources with unique IDs Standard methods Multiple representations Link Resources together HTTP Content (JSON/POX/TXT) HTTP URL Hyperlinks HTTP Methods
  • 4. 4      REST    Fundamentals      
  • 5. 5      REST    Fundamentals       • Client-Server • Separation principle • Components Independent • Stateless • Session state on the client • Visibility, reliability and scalability • Trade off (network performance, etc.) • Cacheable • A response can be cacheable • Efficiency but reduce reliability • Layered system • System scalability
  • 6. 6   JAX-­‐RS  –  Java  API  for  RESTfull                                                            WebServices     •  Annotation driven JavaEE API •  Expose annotated Java bean as HTTP based services •  Implementation may support service descriptions. •  Swagger •  RAML •  WADL •  Define JAVA ó HTTP mapping •  Number of implementations •  Apache CXF •  Apache Wink •  Jersey •  Also used by Microservices frameworks to define services •  Dropwizard •  Spring Boot
  • 8. 8   RMM  –  Level  0     •  HTTP as a transport system for remote interactions. •  Same as SOAP or XML-RPC it's basically the same mechanism. •  Most of the cases only one endpoint is exposed for whole service/ application.
  • 9. 9   RMM  –  Level  1     •  For each web resource there is a unique identifiable Id. •  http://school.com/api/students => All student collection •  Http://scholl.com/api/student/2345 => A unique student
  • 10. 10   RMM  –  Level  2     •  Map HTTP Methods to operations (state transition) on resources. •  GET Http://scholl.com/api/student/2345 •  PUT Http://scholl.com/api/student/2345 •  DELETE Http://scholl.com/api/student/2345 •  Do not overload HTTP POST/GET and define WS like operations. •  Do not use “verbs/actions” as a part of resource URL. •  E.g – createStudent, editStudent • 
  • 11. 11   HTTP Method CRUD Desc. POST CREATE Create - GET RETRIEVE Retrieve Safe,Idempotent,Cacheable PUT UPDATE Update Idempotent DELETE DELETE Delete Idempotent    REST  HTTP Methods  
  • 12. 12   RMM  –  Level  3     •  Use Hyperlinks to relate (link) resources. •  Also known as HATEOAS (Hypertext As The Engine Of Application State).
  • 13. 13   JAX-­‐WS  AnnotaGons     •  @Path •  @GET •  @PUT •  @POST •  @DELETE •  @Produces •  @Consumes •  @PathParam •  @QueryParam •  @MatrixParam •  @HeaderParam •  @CookieParam •  @FormParam •  @DefaultValue •  @Context
  • 14. JAX-­‐RS   JAX-RS Annotated Service @Path("/hello”) public class HelloWorldService { @GET @Path("/{user}") public String hello(@PathParam("user") String user) { } }
  • 15. JAX-­‐RS   JAX-RS Annotated Service @Path("/hello”) public class HelloWorldService { @GET @Consumes("text/plain") @Produces("text/xml") @Path("/{user}") public String hello(@PathParam("user") String user) { } }
  • 16. JAX-­‐RS  parameter  types   •  @PathParam •  @QueryParam •  @HeaderParam •  @CookieParam •  @FormParam •  @MatrixParam
  • 17. JAX-­‐RS  Path  parameters   @GET @Path("/hello/{user}") public String hello(@PathParam("user") String user) { return "Hello " + user; } http://localhost:8080/helloworldapp/hello/sagara PathParam “user” value •  URL template style •  Generally used to represent compulsory user inputs
  • 18. JAX-­‐RS  OpGonal  Path  parameters   @GET @Path("/hello{user: (/user)?}") public String hello(@PathParam("user") String user) { return "Hello " + user; } http://localhost:8080/helloworldapp/hello/sagara PathParam “user” value •  Important in backward compatible API designs. •  Generally incorporate with @DefaultValue annotation http://localhost:8080/helloworldapp/hello/ No PathParam “user” value
  • 19. http://localhost:8080/helloworldapp/hello JAX-­‐RS  Query  parameters   @GET @Path("/hello") public String hello(@QueryParam (”name") String user) { return "Hello " + user; } http://localhost:8080/helloworldapp/hello?name=sagara PathParam “user” value•  Query string parameter style •  Generally used to represent optional user inputs or controller operations. •  Generally incorporate with @DefaultValue annotation
  • 20. JAX-­‐RS  Header  parameters   @GET @Path("/hello") public String hello(@HeaderParam("Referer") String referer) { return "Hello World ” ; } GET /helloworldapp/hello http/1.1 Host localhost Referer http://facebook/…….. Header value •  Map HTTP header values to Java method parameters. •  Can be used to handle resource versioning , pagination, cache etc.
  • 21. 21    Error  handling    -­‐  Status  Codes       Do not define your own error codes instead use HTTP status codes as much as possible. HTTP 200 - OK HTTP 201 - Resource created HTTP 204 - No content found HTTP 30 4 - Not modified HTTP 404 - Resource not found HTTP 410 - Resource gone HTTP 409 - Conflicts HTTP 403 - Forbidden HTTP 500 - Internal Server Error HTTP 503 - Service Unavailable
  • 22. 22    Error  handling    -­‐  Status  Codes       Do not define your own error codes instead use HTTP status codes as much as possible. public Response findAll() { try { return Response.status(Response.Status.ACCEPTED) .entity(users.findAll()).build(); } catch (UserDAOException e) { return Response. status(Response.Status.INTERNAL_SERVER_ERROR).build(); } }
  • 23. 23    Error  handling  -­‐  ExcepGonMapper   Instead of scatter error handling code in resource code possible to define . class UserExceptionMapper implements ExceptionMapper<UserDAOException> { public Response toResponse(UserDAOException exception) { if (exception instanceof UserNotFoundException) { return Response.status(Response.Status.NOT_FOUND).build(); } else { return Response .status(Response.Status.INTERNAL_SERVER_ERROR).build(); } }
  • 24. 24   Resource  Linking   Use hyper links properly to link related resources. Account can be in many groups Link to related group Links to group members
  • 25. 25   JAX-­‐RS  PaginaHon   Widely used approaches. •  LimitOffset based pagination •  Limit – Define the size of the page •  Offset – Define the starting point of each page. •  Curser based pagination •  Limit – Define the size of the page •  Before – Cursor that points to the start of the page of data that has been returned •  After - cursor that points to the end of the page of data that has been returned •  Time based pagination •  Limit – Define the size of the page •  Until – points to the end of the range of time-based data •  Since – points to the startof the range of time-based data
  • 26. 26   JAX-­‐RS  LimitOffset  based  PaginaHon   @GET @Path("/users") @Produces(MediaType.APPLICATION_JSON) public Response findAll( @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("10") int limit, @Context UriInfo uriInfo) { } URI currentLink = UriBuilder.fromUri(uriInfo.getBaseUri()) .path("/page/users") .queryParam("offset", offset) .queryParam("limit", limit) .build(); Creating Links
  • 27. 27   AuthenHcaHon  and  AuthorizaHon     Widely used approaches. •  HTTP BasicAuth •  OAuth2
  • 28. 28   References       •  https://github.com/sagara-gunathunga/jaxrs-java-colombo/ •  http://martinfowler.com/articles/richardsonMaturityModel.html