SlideShare une entreprise Scribd logo
1  sur  35
Télécharger pour lire hors ligne
Topic 5

           REST and JAX-RS



Assoc.Prof. Dr. Thanachart Numnonda
       www.imcinstitute.com
            August 2010
Agenda
 What   is REST?
 REST/HTTP Methods

 JAX-RS




                             2
What is REST?




                3
REST : Definition [Wikipedia]
 Representational State Transfer
 a style of software architecture for distributed
  hypermedia systems such as the World Wide
  Web.
 was introduced and defined in 2000 by Roy
  Fielding in his doctoral dissertation.
 Conforming to the REST constraints is referred
  to as being ‘RESTful’.


                                                     4
REST is ...
 An architectural style, not technology
      – Client/server + Request/response approach.
 Everything is a RESOURCE.
 CRUD (Create / Read / Update / Delete)
 Stateless by nature (excellent for distributed
  systems)
 Cacheable (naturally supported !)
 A great way to web-service !


                                                     5
Architectural overview




                         6
Architectural overview




                         7
HTTP request overview




                        8
HTTP request overview




                        9
Everything is a resource …
 A resource   is …
    –   A network-accessible data object or service
        identified by an URI:
    –   Images,
    –   Documents (HTML, PDF, …),
    –   Geo-location,
    –   Weather



                                                      10
Resource

 Collections
    – http://portal/books/
 Members/Items:
    – http://portal/documents/mybook.doc




                                           11
Characteristics of REST
   RESTful services are stateless
      – Each request from client to server must contain all
           the information necessary to understand the
           request
   RESTful services have a uniform interface
       –   GET, POST, PUT, and DELETE.
   REST-based architectures are built from resources
    (pieces of information) that are uniquely identified by
    URIs
       –   In a RESTful purchasing system, each purchase
           order has a unique URI                        12
Characteristics of REST
   REST components manipulate resources by
    exchanging representations of the resources
       –   For example, a purchase order resource can be
           represented by an XML document.
       –   Within a RESTful purchasing system, a purchase
           order might be updated by posting an XML
           document containing the changed purchase order to
           its URI
   REST-based architectures communicate primarily
    through the transfer of representations of resources
       –   State is maintained within a resource representation
                                                                  13
REST/HTTP Methods




                    14
CRUD to HTTP method mapping




                              15
CRUD Operations are Performed
        through “HTTP
     method”+“Resource”

CRUD Operations   HTTP method      Resource
Create (Single)       POST         Collection URI
Read (Multiple)       GET          Collection URI
Read (Single)     GET       Entry URI
Update (Single)       PUT          Entry URI
Delete (Single)       DELETE       Entry URI


                                                    16
HTTP Methods
 /books/
      –   POST - submit a new book
      –   GET - list all books
    /books/{isbn}/
      – GET - get a book
      – PUT - update a book
      – DELETE - remove a book


                                     17
HTTP Methods: GET
 GET to retrieve information
 Retrieves a given URI
 Idempotent, should not initiate a state change
 Cacheable




                                                   18
HTTP Methods: POST
 POST to add new information
 add the entity as a subordinate/append to the
  POSTed resource
 Example
     – POST /music/beatles

             Adds the music specified in the
                 POSTDATA to the
                    list of music

                                                  19
HTTP Methods: DELETE
 Remove (logical) an entity
 Example
     – DELETE /songs/heyjude



            Delete the song 'heyjude”
              from the system



                                        20
HTTP Methods: POST
 POST to add new information
 add the entity as a subordinate/append to the
  POSTed resource
 Example
     – POST /music/beatles

             Adds the music specified in the
                 POSTDATA to the
                    list of music

                                                  21
Why REST ?
• Uniformity:
      –   URI is a uniform way to identify resources
      –   HTTP uniform interface to manipulate resources
• REST base services are easy to work with
      –   Do not need specialized API, just need to
          understand HTTP and browser for
          experimentation
• Scripting language friendly
      –   Easy to consume and develop
                                                           22
Advantages of REST
• Its architectural constraints when applied as a
  whole, generate:
     –   Scalable component interactions
     –   General interfaces
     –   Independently deployed connectors
     –   Reduced interaction latency
     –   Strengthened security
     –   Safe encapsulation of legacy systems

                                                    23
REST vs “Big” Web Services
• “Big” web service
     –   Few URIs (nouns), many custom methods
         (verbs)
           • musicPort.getRecordings(“beatles”)
     –   Uses HTTP as transport for SOAP messages
• RESTful web service
     –   Many resources (nouns), few fixed
         methods(verbs)
           • GET /music/artists/beatles/recordings
     –   HTTP is the protocol
                                                     24
JAX-RS




         25
JAX-RS (JSR-311) : Goals

• POJO-based,
• HTTP-centric,
• Format independent,
• Container independent,
• Availability as standalone and enterprise platforms.



                                                         26
JAX-RS: Address-ability through URI

• A Web service exposes data as resources
• A resource is exposed through a URI
• Resources are “plain old” Java classes and methods
• The annotation @Path exposes a resource
• Think resources and URIs using Java classes and
  @Path


                                                       27
POJO + Annotation = JAX-RS resource




                                      28
Reading the catalog




                      29
Reading the catalog item




                           30
Address-ability through HTTP Methods

• Methods: what are the HTTP methods?
• HTTP methods implemented as Java methods
  annotated with
    –   @POST
    –   @GET
    –   @PUT
    –   @DELETE


                                             31
Uniform interface: methods on root
             resources
@Path(“/books/”)
class books {
  @POST <type> create(<type>) { ... }
  @GET <type> get() { ... }
}
@Path(“/books/{isbn}/”)
class book {
  @GET <type> get(...) { ... }
  @PUT void update(...) { ... }
  @DELETE void delete(...) { ... }
}
        Java method name is not significant
         The HTTP method is the method        32
Leading JAX-RS implementations

• Glassfish Jersey project
• RESTEasy(JBoss)
• Apache CXF (Apache Software Foundation)
• Wink (ASF incubation project)
• Restlet(NoeliosTechnologies)


                                            33
Resources
 Some contents are borrowed from the presentation
  slides of Sang Shin, Java™ Technology Evangelist,
  Sun Microsystems, Inc.
 JAX-RS… and the REST will follow, Guy Nir, Java
  Edge 09




                                                      34
Thank you

   thananum@gmail.com
www.facebook.com/imcinstitute
   www.imcinstitute.com



                                35

Contenu connexe

En vedette

Java Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesJava Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesIMC Institute
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesArun Gupta
 
Java Web Service - Summer 2004
Java Web Service - Summer 2004Java Web Service - Summer 2004
Java Web Service - Summer 2004Danny Teng
 
Jaxp Xmltutorial 11 200108
Jaxp Xmltutorial 11 200108Jaxp Xmltutorial 11 200108
Jaxp Xmltutorial 11 200108nit Allahabad
 
Simple API for XML
Simple API for XMLSimple API for XML
Simple API for XMLguest2556de
 
REST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And JerseyREST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And JerseyStormpath
 
Xml Java
Xml JavaXml Java
Xml Javacbee48
 
java API for XML DOM
java API for XML DOMjava API for XML DOM
java API for XML DOMSurinder Kaur
 
Web Technologies in Java EE 7
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7Lukáš Fryč
 
Java Web Services [4/5]: Java API for XML Web Services
Java Web Services [4/5]: Java API for XML Web ServicesJava Web Services [4/5]: Java API for XML Web Services
Java Web Services [4/5]: Java API for XML Web ServicesIMC Institute
 
Community and Java EE @ DevConf.CZ
Community and Java EE @ DevConf.CZCommunity and Java EE @ DevConf.CZ
Community and Java EE @ DevConf.CZMarkus Eisele
 
Writing simple web services in java using eclipse editor
Writing simple web services in java using eclipse editorWriting simple web services in java using eclipse editor
Writing simple web services in java using eclipse editorSantosh Kumar Kar
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Peter R. Egli
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
Web Service Presentation
Web Service PresentationWeb Service Presentation
Web Service Presentationguest0df6b0
 

En vedette (20)

Java Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesJava Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web Services
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
 
Java Web Service - Summer 2004
Java Web Service - Summer 2004Java Web Service - Summer 2004
Java Web Service - Summer 2004
 
JAXP
JAXPJAXP
JAXP
 
Jaxp Xmltutorial 11 200108
Jaxp Xmltutorial 11 200108Jaxp Xmltutorial 11 200108
Jaxp Xmltutorial 11 200108
 
Simple API for XML
Simple API for XMLSimple API for XML
Simple API for XML
 
REST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And JerseyREST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And Jersey
 
Xml Java
Xml JavaXml Java
Xml Java
 
java API for XML DOM
java API for XML DOMjava API for XML DOM
java API for XML DOM
 
Web Technologies in Java EE 7
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7
 
Java Web Services
Java Web ServicesJava Web Services
Java Web Services
 
Java Web Services [4/5]: Java API for XML Web Services
Java Web Services [4/5]: Java API for XML Web ServicesJava Web Services [4/5]: Java API for XML Web Services
Java Web Services [4/5]: Java API for XML Web Services
 
6 xml parsing
6   xml parsing6   xml parsing
6 xml parsing
 
Java XML Parsing
Java XML ParsingJava XML Parsing
Java XML Parsing
 
Community and Java EE @ DevConf.CZ
Community and Java EE @ DevConf.CZCommunity and Java EE @ DevConf.CZ
Community and Java EE @ DevConf.CZ
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 
Writing simple web services in java using eclipse editor
Writing simple web services in java using eclipse editorWriting simple web services in java using eclipse editor
Writing simple web services in java using eclipse editor
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Web Service Presentation
Web Service PresentationWeb Service Presentation
Web Service Presentation
 

Similaire à Java Web Services [5/5]: REST and JAX-RS

OpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Alliance
 
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 for opentravel.org by HP
RESTful for opentravel.org by HPRESTful for opentravel.org by HP
RESTful for opentravel.org by HPRoni Schuetz
 
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
 
Restful web services rule financial
Restful web services   rule financialRestful web services   rule financial
Restful web services rule financialRule_Financial
 
RESTful Web services using JAX-RS
RESTful Web services using JAX-RSRESTful Web services using JAX-RS
RESTful Web services using JAX-RSArun Gupta
 
RDTF Metadata Guidelines: an update
RDTF Metadata Guidelines: an updateRDTF Metadata Guidelines: an update
RDTF Metadata Guidelines: an updateAndy Powell
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using SwaggerHong-Jhih Lin
 
Creating Restful Web Services with restish
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restishGrig Gheorghiu
 
Network Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyNetwork Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyPayal Jain
 
Introduction to REST and Jersey
Introduction to REST and JerseyIntroduction to REST and Jersey
Introduction to REST and JerseyChris Winters
 
FAIR Workflows and Research Objects get a Workout
FAIR Workflows and Research Objects get a Workout FAIR Workflows and Research Objects get a Workout
FAIR Workflows and Research Objects get a Workout Carole Goble
 
Scripting User Contributed Interlinking
Scripting User Contributed InterlinkingScripting User Contributed Interlinking
Scripting User Contributed Interlinkingwhalb
 
[2015/2016] The REST architectural style
[2015/2016] The REST architectural style[2015/2016] The REST architectural style
[2015/2016] The REST architectural styleIvano Malavolta
 
Restful webservice
Restful webserviceRestful webservice
Restful webserviceDong Ngoc
 
REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008Ryan Hoegg
 

Similaire à Java Web Services [5/5]: REST and JAX-RS (20)

OpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML Resources
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
 
RESTful for opentravel.org by HP
RESTful for opentravel.org by HPRESTful for opentravel.org by HP
RESTful for opentravel.org by HP
 
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 rule financial
Restful web services   rule financialRestful web services   rule financial
Restful web services rule financial
 
RESTful Web services using JAX-RS
RESTful Web services using JAX-RSRESTful Web services using JAX-RS
RESTful Web services using JAX-RS
 
RDTF Metadata Guidelines: an update
RDTF Metadata Guidelines: an updateRDTF Metadata Guidelines: an update
RDTF Metadata Guidelines: an update
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using Swagger
 
Creating Restful Web Services with restish
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restish
 
Network Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyNetwork Device Database Management with REST using Jersey
Network Device Database Management with REST using Jersey
 
Introduction to REST and Jersey
Introduction to REST and JerseyIntroduction to REST and Jersey
Introduction to REST and Jersey
 
L18 REST API Design
L18 REST API DesignL18 REST API Design
L18 REST API Design
 
FAIR Workflows and Research Objects get a Workout
FAIR Workflows and Research Objects get a Workout FAIR Workflows and Research Objects get a Workout
FAIR Workflows and Research Objects get a Workout
 
Scripting User Contributed Interlinking
Scripting User Contributed InterlinkingScripting User Contributed Interlinking
Scripting User Contributed Interlinking
 
[2015/2016] The REST architectural style
[2015/2016] The REST architectural style[2015/2016] The REST architectural style
[2015/2016] The REST architectural style
 
REST Basics
REST BasicsREST Basics
REST Basics
 
Restful webservice
Restful webserviceRestful webservice
Restful webservice
 
REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008
 
Linked (Open) Data
Linked (Open) DataLinked (Open) Data
Linked (Open) Data
 

Plus de IMC Institute

นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14IMC Institute
 
Digital trends Vol 4 No. 13 Sep-Dec 2019
Digital trends Vol 4 No. 13  Sep-Dec 2019Digital trends Vol 4 No. 13  Sep-Dec 2019
Digital trends Vol 4 No. 13 Sep-Dec 2019IMC Institute
 
บทความ The evolution of AI
บทความ The evolution of AIบทความ The evolution of AI
บทความ The evolution of AIIMC Institute
 
IT Trends eMagazine Vol 4. No.12
IT Trends eMagazine  Vol 4. No.12IT Trends eMagazine  Vol 4. No.12
IT Trends eMagazine Vol 4. No.12IMC Institute
 
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformationเพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital TransformationIMC Institute
 
IT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to WorkIT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to WorkIMC Institute
 
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรมมูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรมIMC Institute
 
IT Trends eMagazine Vol 4. No.11
IT Trends eMagazine  Vol 4. No.11IT Trends eMagazine  Vol 4. No.11
IT Trends eMagazine Vol 4. No.11IMC Institute
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationIMC Institute
 
บทความ The New Silicon Valley
บทความ The New Silicon Valleyบทความ The New Silicon Valley
บทความ The New Silicon ValleyIMC Institute
 
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10IMC Institute
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationIMC Institute
 
The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)IMC Institute
 
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง IMC Institute
 
IT Trends eMagazine Vol 3. No.9
IT Trends eMagazine  Vol 3. No.9 IT Trends eMagazine  Vol 3. No.9
IT Trends eMagazine Vol 3. No.9 IMC Institute
 
Thailand software & software market survey 2016
Thailand software & software market survey 2016Thailand software & software market survey 2016
Thailand software & software market survey 2016IMC Institute
 
Developing Business Blockchain Applications on Hyperledger
Developing Business  Blockchain Applications on Hyperledger Developing Business  Blockchain Applications on Hyperledger
Developing Business Blockchain Applications on Hyperledger IMC Institute
 
Digital transformation @thanachart.org
Digital transformation @thanachart.orgDigital transformation @thanachart.org
Digital transformation @thanachart.orgIMC Institute
 
บทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.orgบทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.orgIMC Institute
 
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital Transformationกลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital TransformationIMC Institute
 

Plus de IMC Institute (20)

นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14
 
Digital trends Vol 4 No. 13 Sep-Dec 2019
Digital trends Vol 4 No. 13  Sep-Dec 2019Digital trends Vol 4 No. 13  Sep-Dec 2019
Digital trends Vol 4 No. 13 Sep-Dec 2019
 
บทความ The evolution of AI
บทความ The evolution of AIบทความ The evolution of AI
บทความ The evolution of AI
 
IT Trends eMagazine Vol 4. No.12
IT Trends eMagazine  Vol 4. No.12IT Trends eMagazine  Vol 4. No.12
IT Trends eMagazine Vol 4. No.12
 
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformationเพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
 
IT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to WorkIT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to Work
 
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรมมูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
 
IT Trends eMagazine Vol 4. No.11
IT Trends eMagazine  Vol 4. No.11IT Trends eMagazine  Vol 4. No.11
IT Trends eMagazine Vol 4. No.11
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformation
 
บทความ The New Silicon Valley
บทความ The New Silicon Valleyบทความ The New Silicon Valley
บทความ The New Silicon Valley
 
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformation
 
The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)
 
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
 
IT Trends eMagazine Vol 3. No.9
IT Trends eMagazine  Vol 3. No.9 IT Trends eMagazine  Vol 3. No.9
IT Trends eMagazine Vol 3. No.9
 
Thailand software & software market survey 2016
Thailand software & software market survey 2016Thailand software & software market survey 2016
Thailand software & software market survey 2016
 
Developing Business Blockchain Applications on Hyperledger
Developing Business  Blockchain Applications on Hyperledger Developing Business  Blockchain Applications on Hyperledger
Developing Business Blockchain Applications on Hyperledger
 
Digital transformation @thanachart.org
Digital transformation @thanachart.orgDigital transformation @thanachart.org
Digital transformation @thanachart.org
 
บทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.orgบทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.org
 
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital Transformationกลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
 

Dernier

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 

Dernier (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 

Java Web Services [5/5]: REST and JAX-RS

  • 1. Topic 5 REST and JAX-RS Assoc.Prof. Dr. Thanachart Numnonda www.imcinstitute.com August 2010
  • 2. Agenda  What is REST?  REST/HTTP Methods  JAX-RS 2
  • 4. REST : Definition [Wikipedia]  Representational State Transfer  a style of software architecture for distributed hypermedia systems such as the World Wide Web.  was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation.  Conforming to the REST constraints is referred to as being ‘RESTful’. 4
  • 5. REST is ...  An architectural style, not technology – Client/server + Request/response approach.  Everything is a RESOURCE.  CRUD (Create / Read / Update / Delete)  Stateless by nature (excellent for distributed systems)  Cacheable (naturally supported !)  A great way to web-service ! 5
  • 10. Everything is a resource …  A resource is … – A network-accessible data object or service identified by an URI: – Images, – Documents (HTML, PDF, …), – Geo-location, – Weather 10
  • 11. Resource  Collections – http://portal/books/  Members/Items: – http://portal/documents/mybook.doc 11
  • 12. Characteristics of REST  RESTful services are stateless – Each request from client to server must contain all the information necessary to understand the request  RESTful services have a uniform interface – GET, POST, PUT, and DELETE.  REST-based architectures are built from resources (pieces of information) that are uniquely identified by URIs – In a RESTful purchasing system, each purchase order has a unique URI 12
  • 13. Characteristics of REST  REST components manipulate resources by exchanging representations of the resources – For example, a purchase order resource can be represented by an XML document. – Within a RESTful purchasing system, a purchase order might be updated by posting an XML document containing the changed purchase order to its URI  REST-based architectures communicate primarily through the transfer of representations of resources – State is maintained within a resource representation 13
  • 15. CRUD to HTTP method mapping 15
  • 16. CRUD Operations are Performed through “HTTP method”+“Resource” CRUD Operations HTTP method Resource Create (Single) POST Collection URI Read (Multiple) GET Collection URI Read (Single) GET Entry URI Update (Single) PUT Entry URI Delete (Single) DELETE Entry URI 16
  • 17. HTTP Methods  /books/ – POST - submit a new book – GET - list all books   /books/{isbn}/ – GET - get a book – PUT - update a book – DELETE - remove a book 17
  • 18. HTTP Methods: GET  GET to retrieve information  Retrieves a given URI  Idempotent, should not initiate a state change  Cacheable 18
  • 19. HTTP Methods: POST  POST to add new information  add the entity as a subordinate/append to the POSTed resource  Example – POST /music/beatles Adds the music specified in the POSTDATA to the list of music 19
  • 20. HTTP Methods: DELETE  Remove (logical) an entity  Example – DELETE /songs/heyjude Delete the song 'heyjude” from the system 20
  • 21. HTTP Methods: POST  POST to add new information  add the entity as a subordinate/append to the POSTed resource  Example – POST /music/beatles Adds the music specified in the POSTDATA to the list of music 21
  • 22. Why REST ? • Uniformity: – URI is a uniform way to identify resources – HTTP uniform interface to manipulate resources • REST base services are easy to work with – Do not need specialized API, just need to understand HTTP and browser for experimentation • Scripting language friendly – Easy to consume and develop 22
  • 23. Advantages of REST • Its architectural constraints when applied as a whole, generate: – Scalable component interactions – General interfaces – Independently deployed connectors – Reduced interaction latency – Strengthened security – Safe encapsulation of legacy systems 23
  • 24. REST vs “Big” Web Services • “Big” web service – Few URIs (nouns), many custom methods (verbs) • musicPort.getRecordings(“beatles”) – Uses HTTP as transport for SOAP messages • RESTful web service – Many resources (nouns), few fixed methods(verbs) • GET /music/artists/beatles/recordings – HTTP is the protocol 24
  • 25. JAX-RS 25
  • 26. JAX-RS (JSR-311) : Goals • POJO-based, • HTTP-centric, • Format independent, • Container independent, • Availability as standalone and enterprise platforms. 26
  • 27. JAX-RS: Address-ability through URI • A Web service exposes data as resources • A resource is exposed through a URI • Resources are “plain old” Java classes and methods • The annotation @Path exposes a resource • Think resources and URIs using Java classes and @Path 27
  • 28. POJO + Annotation = JAX-RS resource 28
  • 31. Address-ability through HTTP Methods • Methods: what are the HTTP methods? • HTTP methods implemented as Java methods annotated with – @POST – @GET – @PUT – @DELETE 31
  • 32. Uniform interface: methods on root resources @Path(“/books/”) class books { @POST <type> create(<type>) { ... } @GET <type> get() { ... } } @Path(“/books/{isbn}/”) class book { @GET <type> get(...) { ... } @PUT void update(...) { ... } @DELETE void delete(...) { ... } } Java method name is not significant The HTTP method is the method 32
  • 33. Leading JAX-RS implementations • Glassfish Jersey project • RESTEasy(JBoss) • Apache CXF (Apache Software Foundation) • Wink (ASF incubation project) • Restlet(NoeliosTechnologies) 33
  • 34. Resources  Some contents are borrowed from the presentation slides of Sang Shin, Java™ Technology Evangelist, Sun Microsystems, Inc.  JAX-RS… and the REST will follow, Guy Nir, Java Edge 09 34
  • 35. Thank you thananum@gmail.com www.facebook.com/imcinstitute www.imcinstitute.com 35