SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
JAX-RS & JERSEY
   Yung-Lin Ho <yho@bluetangstudio.com>
                founder of blue tang studio
ABOUT ME
• Yung-Lin     Ho. AKA HYL.

• founder      of blue tang studio

• Working      on Location Based Platform

 • Cassandra       / Zookeeper

 • Lucene

 • Tapestry      / Jersey

 • Scala   !
WEBSERVICE IN YEAR 2000
• Servlet API

  •   public void doGet(HttpServletRequest request, HttpServletResponse response) {
        String name = request.getParameter(“name”);
        NameParameterValidator.validate(name);
        Object resObj = requestProcessor.process(name);
        Serializer ser = ObjectSerializerFactory.getSerializer(request.getParameter(“format”))
        ser.write(resObj, response);
      }


• Struts

  • Action, Validator, Processor...
YEAR 2005
• SOAP, Apache Axis, Apache   CXF

• XML   configuration HELL.

 • no   compile time check.

 • keep   code and configuration in-sync.
OPEN SOURCE WORLD
• Restful   Requests
urlpatterns = patterns('',
    (r'^articles/2003/$', 'news.views.special_case_2003'),
    (r'^articles/(?P<year>d{4})/$', 'news.views.year_archive'),
    (r'^articles/(?P<year>d{4})/(?P<month>d{2})/$', 'news.views.month_archive'),
    (r'^articles/(?P<year>d{4})/(?P<month>d{2})/(?P<day>d+)/$',
'news.views.article_detail'),
)




• Rest   won the battle. SOAP started to fad.

  • why?
ANNOTATION COME TO RESCUE
    @Path("/rest/1.0/model/{modelId}")
    @Produces({"application/json"})
    public interface DataService {

    @GET
    @Path("/doc/{docId}")
    public Document get(@PathParam(“modelId”) UserModelId modelId,
                        @PathParam("docId") DocumentId documentId);
    @PUT
    @Path("/doc/{docId}")
    @Consumes({"application/json"})
    public void saveOrUpdate(@PathParam(“modelId”) UserModelId modelId
                             @PathParam("docId") DocumentId documentId,
                             Document document);

    @DELETE
    @Path("/doc/{docId}")
    public void delete(@PathParam(“modelId”) UserModelId modelId
                       @PathParam("docId") DocumentId documentId);

}
URL AND PATTERN MATCHING
• @Path("/rest/1.0/model/{modelId}")

• @GET, @POST, @PUT, @DELETE, @HEAD

• @PathParam, @QueryParam, @FormParam, @HeaderParam,
 @CookieParam and @MartixParam

• @DefaultValue
OBJECT SERIALIZATION
• @Produce       & @Consume

• POJO, JAXB, Jackson-Json.

@XmlRootElement
                                              {"name":"Agamemnon", "age":"32"}
public class MyJaxbBean {
	 public String name;
	 public int age;
	 public MyJaxbBean() {} // JAXB needs this

	 public MyJaxbBean(String name, int age) {
	 this.name = name;
	 this.age = age;
  }
}
FINALLY. JERSEY.
• what     is jersey - a servlet javax.ws.rs.core.Application

• ways     to contributes RootResource(s) to Application.
 <servlet>
     <servlet-name>Jersey Web Application</servlet-name>
     <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
     <init-param>
         <param-name>com.sun.jersey.config.property.packages</param-name>
         <param-value>org.foo.rest;org.bar.rest</param-value>
     </init-param>
 </servlet>

 public class MyApplicaton extends Application {
     public Set<Class<?>> getClasses() {
     Set<Class<?>> s = new HashSet<Class<?>>();
     s.add(HelloWorldResource.class);
     return s;
   }
 }
ROOTRESOURCE LIFECYCLE
• New class instance for each request if you put class into
 Application

• Same instance for all requests if you put class instance into
 Application.
WADL
•   @Path("/form")@ProduceMime("text/html")
    public class Form {
        @Path("colours")
        public Colours getColours() {
            return coloursResource;
        }

    }


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<application xmlns="http://research.sun.com/wadl/2006/10">
	    <resources base="http://localhost:9998/resources/">
	    	    <resource path="/form">
	    	    	    <method name="GET">
	    	    	    	    <response>
	    	    	    	    	    <representation mediaType="text/html" />
	    	    	    	    </response>
	    	    	    </method>
	    	    	    <method name="POST">
	    	    	    	    <request>
	    	    	    	    	    <representation mediaType="application/x-www-form-urlencoded" />
	    	    	    	    </request>
	    	    	    	    <response>
	    	    	    	    	    <representation mediaType="text/html" />
	    	    	    	    </response>
	    	    	    </method>
	    	    	    <resource path="colours" />
	    	    </resource>
	    </resources>
</application>
CLIENT API
• https://github.com/yunglin/common-jaxrs-client

    SearchServiceClient client =
      ClientFactory.getClient(
            SearchServiceClient.class, endPoint, myModel);


•
QA

Mais conteúdo relacionado

Mais procurados

Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETTomas Jansson
 
Omnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsOmnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsJustin Edelson
 
Using the new WordPress REST API
Using the new WordPress REST APIUsing the new WordPress REST API
Using the new WordPress REST APICaldera Labs
 
ERRest - Designing a good REST service
ERRest - Designing a good REST serviceERRest - Designing a good REST service
ERRest - Designing a good REST serviceWO Community
 
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...SPTechCon
 
Types - ScalaSyd
Types - ScalaSydTypes - ScalaSyd
Types - ScalaSydRen Pillay
 
Stack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersStack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersJonathan Sharp
 
Backbone.js Simple Tutorial
Backbone.js Simple TutorialBackbone.js Simple Tutorial
Backbone.js Simple Tutorial추근 문
 
Slick: Bringing Scala’s Powerful Features to Your Database Access
Slick: Bringing Scala’s Powerful Features to Your Database Access Slick: Bringing Scala’s Powerful Features to Your Database Access
Slick: Bringing Scala’s Powerful Features to Your Database Access Rebecca Grenier
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingJace Ju
 
Clojure Workshop: Web development
Clojure Workshop: Web developmentClojure Workshop: Web development
Clojure Workshop: Web developmentSytac
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Sven Efftinge
 
Solr's Search Relevancy (Understand Solr's query debug)
Solr's Search Relevancy (Understand Solr's query debug)Solr's Search Relevancy (Understand Solr's query debug)
Solr's Search Relevancy (Understand Solr's query debug)Wongnai
 
Restful App Engine
Restful App EngineRestful App Engine
Restful App EngineRyan Morlok
 

Mais procurados (20)

Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NET
 
Omnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsOmnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the Things
 
Using the new WordPress REST API
Using the new WordPress REST APIUsing the new WordPress REST API
Using the new WordPress REST API
 
ERRest - Designing a good REST service
ERRest - Designing a good REST serviceERRest - Designing a good REST service
ERRest - Designing a good REST service
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
 
Types - ScalaSyd
Types - ScalaSydTypes - ScalaSyd
Types - ScalaSyd
 
Stack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersStack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for Developers
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
Backbone.js Simple Tutorial
Backbone.js Simple TutorialBackbone.js Simple Tutorial
Backbone.js Simple Tutorial
 
Slick: Bringing Scala’s Powerful Features to Your Database Access
Slick: Bringing Scala’s Powerful Features to Your Database Access Slick: Bringing Scala’s Powerful Features to Your Database Access
Slick: Bringing Scala’s Powerful Features to Your Database Access
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstraping
 
Php summary
Php summaryPhp summary
Php summary
 
Clojure Workshop: Web development
Clojure Workshop: Web developmentClojure Workshop: Web development
Clojure Workshop: Web development
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]
 
Solr's Search Relevancy (Understand Solr's query debug)
Solr's Search Relevancy (Understand Solr's query debug)Solr's Search Relevancy (Understand Solr's query debug)
Solr's Search Relevancy (Understand Solr's query debug)
 
Oak Lucene Indexes
Oak Lucene IndexesOak Lucene Indexes
Oak Lucene Indexes
 
Restful App Engine
Restful App EngineRestful App Engine
Restful App Engine
 
URLProtocol
URLProtocolURLProtocol
URLProtocol
 
Mongo db
Mongo dbMongo db
Mongo db
 

Destaque

Iniesta & Malú - Carlos
Iniesta & Malú  - CarlosIniesta & Malú  - Carlos
Iniesta & Malú - Carlosisarevi
 
Xela & Ana
Xela & AnaXela & Ana
Xela & Anaisarevi
 
Italia in preghiera 13.03
Italia in preghiera 13.03Italia in preghiera 13.03
Italia in preghiera 13.03Paolo Montecchi
 
Dickens and his works by 1st ESO
Dickens and his works by 1st ESODickens and his works by 1st ESO
Dickens and his works by 1st ESOisarevi
 
Avenue Restaurant - Sara
Avenue Restaurant - SaraAvenue Restaurant - Sara
Avenue Restaurant - Saraisarevi
 
Cristina
CristinaCristina
Cristinaisarevi
 
Manuela's Restaurant - Andrea
Manuela's Restaurant  - AndreaManuela's Restaurant  - Andrea
Manuela's Restaurant - Andreaisarevi
 
Cheesecake
Cheesecake   Cheesecake
Cheesecake isarevi
 
Lucía, Ana, Paula, Adrián & Mateo
Lucía, Ana, Paula, Adrián & MateoLucía, Ana, Paula, Adrián & Mateo
Lucía, Ana, Paula, Adrián & Mateoisarevi
 
A Christmas Carol
A Christmas CarolA Christmas Carol
A Christmas Carolisarevi
 
Jaime P.
Jaime P.Jaime P.
Jaime P.isarevi
 
TheNewLead SouthEast Asian contacts
TheNewLead SouthEast Asian contactsTheNewLead SouthEast Asian contacts
TheNewLead SouthEast Asian contactsJulie Ann Ensomo
 
London - Alvaro
London -  AlvaroLondon -  Alvaro
London - Alvaroisarevi
 
Sap가멈추면 세계경제도 멈춘다
Sap가멈추면 세계경제도 멈춘다Sap가멈추면 세계경제도 멈춘다
Sap가멈추면 세계경제도 멈춘다Todd Ki
 
Cannabis social clubs. normalisation, neoliberalism, political opportunities ...
Cannabis social clubs. normalisation, neoliberalism, political opportunities ...Cannabis social clubs. normalisation, neoliberalism, political opportunities ...
Cannabis social clubs. normalisation, neoliberalism, political opportunities ...Universitat Autònoma de Barcelona.
 
Italia in preghiera Novembre 2013
Italia in preghiera Novembre 2013Italia in preghiera Novembre 2013
Italia in preghiera Novembre 2013Paolo Montecchi
 
Christmas in Great Britain
Christmas in Great BritainChristmas in Great Britain
Christmas in Great Britainisarevi
 

Destaque (20)

Iniesta & Malú - Carlos
Iniesta & Malú  - CarlosIniesta & Malú  - Carlos
Iniesta & Malú - Carlos
 
Adrián
AdriánAdrián
Adrián
 
Xela & Ana
Xela & AnaXela & Ana
Xela & Ana
 
Cpre
CpreCpre
Cpre
 
Italia in preghiera 13.03
Italia in preghiera 13.03Italia in preghiera 13.03
Italia in preghiera 13.03
 
Dickens and his works by 1st ESO
Dickens and his works by 1st ESODickens and his works by 1st ESO
Dickens and his works by 1st ESO
 
Avenue Restaurant - Sara
Avenue Restaurant - SaraAvenue Restaurant - Sara
Avenue Restaurant - Sara
 
Cristina
CristinaCristina
Cristina
 
Manuela's Restaurant - Andrea
Manuela's Restaurant  - AndreaManuela's Restaurant  - Andrea
Manuela's Restaurant - Andrea
 
Brown powerpoint
Brown powerpointBrown powerpoint
Brown powerpoint
 
Cheesecake
Cheesecake   Cheesecake
Cheesecake
 
Lucía, Ana, Paula, Adrián & Mateo
Lucía, Ana, Paula, Adrián & MateoLucía, Ana, Paula, Adrián & Mateo
Lucía, Ana, Paula, Adrián & Mateo
 
A Christmas Carol
A Christmas CarolA Christmas Carol
A Christmas Carol
 
Jaime P.
Jaime P.Jaime P.
Jaime P.
 
TheNewLead SouthEast Asian contacts
TheNewLead SouthEast Asian contactsTheNewLead SouthEast Asian contacts
TheNewLead SouthEast Asian contacts
 
London - Alvaro
London -  AlvaroLondon -  Alvaro
London - Alvaro
 
Sap가멈추면 세계경제도 멈춘다
Sap가멈추면 세계경제도 멈춘다Sap가멈추면 세계경제도 멈춘다
Sap가멈추면 세계경제도 멈춘다
 
Cannabis social clubs. normalisation, neoliberalism, political opportunities ...
Cannabis social clubs. normalisation, neoliberalism, political opportunities ...Cannabis social clubs. normalisation, neoliberalism, political opportunities ...
Cannabis social clubs. normalisation, neoliberalism, political opportunities ...
 
Italia in preghiera Novembre 2013
Italia in preghiera Novembre 2013Italia in preghiera Novembre 2013
Italia in preghiera Novembre 2013
 
Christmas in Great Britain
Christmas in Great BritainChristmas in Great Britain
Christmas in Great Britain
 

Semelhante a Jersey

Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
03 form-data
03 form-data03 form-data
03 form-datasnopteck
 
RESTful Web services using JAX-RS
RESTful Web services using JAX-RSRESTful Web services using JAX-RS
RESTful Web services using JAX-RSArun Gupta
 
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
 
Javaone 2010
Javaone 2010Javaone 2010
Javaone 2010Hien Luu
 
RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with JerseyScott Leberknight
 
CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!Dan Allen
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC AnnotationsJordan Silva
 
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
 
Resource Routing in ExpressionEngine
Resource Routing in ExpressionEngineResource Routing in ExpressionEngine
Resource Routing in ExpressionEngineMichaelRog
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Matthew Groves
 
Full Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLFull Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLAll Things Open
 
Summer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and ScalaSummer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and Scalarostislav
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)Doris Chen
 
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010Arun Gupta
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web servicesnbuddharaju
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 

Semelhante a Jersey (20)

Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
03 form-data
03 form-data03 form-data
03 form-data
 
RESTful Web services using JAX-RS
RESTful Web services using JAX-RSRESTful Web services using JAX-RS
RESTful Web services using JAX-RS
 
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
 
Javaone 2010
Javaone 2010Javaone 2010
Javaone 2010
 
RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with Jersey
 
CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
 
Rest
RestRest
Rest
 
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
 
Resource Routing in ExpressionEngine
Resource Routing in ExpressionEngineResource Routing in ExpressionEngine
Resource Routing in ExpressionEngine
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
Full Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLFull Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQL
 
Summer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and ScalaSummer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and Scala
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
Requery overview
Requery overviewRequery overview
Requery overview
 
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
Android and REST
Android and RESTAndroid and REST
Android and REST
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 

Último

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Último (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Jersey

  • 1. JAX-RS & JERSEY Yung-Lin Ho <yho@bluetangstudio.com> founder of blue tang studio
  • 2. ABOUT ME • Yung-Lin Ho. AKA HYL. • founder of blue tang studio • Working on Location Based Platform • Cassandra / Zookeeper • Lucene • Tapestry / Jersey • Scala !
  • 3. WEBSERVICE IN YEAR 2000 • Servlet API • public void doGet(HttpServletRequest request, HttpServletResponse response) { String name = request.getParameter(“name”); NameParameterValidator.validate(name); Object resObj = requestProcessor.process(name); Serializer ser = ObjectSerializerFactory.getSerializer(request.getParameter(“format”)) ser.write(resObj, response); } • Struts • Action, Validator, Processor...
  • 4. YEAR 2005 • SOAP, Apache Axis, Apache CXF • XML configuration HELL. • no compile time check. • keep code and configuration in-sync.
  • 5. OPEN SOURCE WORLD • Restful Requests urlpatterns = patterns('', (r'^articles/2003/$', 'news.views.special_case_2003'), (r'^articles/(?P<year>d{4})/$', 'news.views.year_archive'), (r'^articles/(?P<year>d{4})/(?P<month>d{2})/$', 'news.views.month_archive'), (r'^articles/(?P<year>d{4})/(?P<month>d{2})/(?P<day>d+)/$', 'news.views.article_detail'), ) • Rest won the battle. SOAP started to fad. • why?
  • 6. ANNOTATION COME TO RESCUE @Path("/rest/1.0/model/{modelId}") @Produces({"application/json"}) public interface DataService { @GET @Path("/doc/{docId}") public Document get(@PathParam(“modelId”) UserModelId modelId, @PathParam("docId") DocumentId documentId); @PUT @Path("/doc/{docId}") @Consumes({"application/json"}) public void saveOrUpdate(@PathParam(“modelId”) UserModelId modelId @PathParam("docId") DocumentId documentId, Document document); @DELETE @Path("/doc/{docId}") public void delete(@PathParam(“modelId”) UserModelId modelId @PathParam("docId") DocumentId documentId); }
  • 7. URL AND PATTERN MATCHING • @Path("/rest/1.0/model/{modelId}") • @GET, @POST, @PUT, @DELETE, @HEAD • @PathParam, @QueryParam, @FormParam, @HeaderParam, @CookieParam and @MartixParam • @DefaultValue
  • 8. OBJECT SERIALIZATION • @Produce & @Consume • POJO, JAXB, Jackson-Json. @XmlRootElement {"name":"Agamemnon", "age":"32"} public class MyJaxbBean { public String name; public int age; public MyJaxbBean() {} // JAXB needs this public MyJaxbBean(String name, int age) { this.name = name; this.age = age; } }
  • 9. FINALLY. JERSEY. • what is jersey - a servlet javax.ws.rs.core.Application • ways to contributes RootResource(s) to Application. <servlet> <servlet-name>Jersey Web Application</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>org.foo.rest;org.bar.rest</param-value> </init-param> </servlet> public class MyApplicaton extends Application { public Set<Class<?>> getClasses() { Set<Class<?>> s = new HashSet<Class<?>>(); s.add(HelloWorldResource.class); return s; } }
  • 10. ROOTRESOURCE LIFECYCLE • New class instance for each request if you put class into Application • Same instance for all requests if you put class instance into Application.
  • 11. WADL • @Path("/form")@ProduceMime("text/html") public class Form { @Path("colours") public Colours getColours() { return coloursResource; } } <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <application xmlns="http://research.sun.com/wadl/2006/10"> <resources base="http://localhost:9998/resources/"> <resource path="/form"> <method name="GET"> <response> <representation mediaType="text/html" /> </response> </method> <method name="POST"> <request> <representation mediaType="application/x-www-form-urlencoded" /> </request> <response> <representation mediaType="text/html" /> </response> </method> <resource path="colours" /> </resource> </resources> </application>
  • 12. CLIENT API • https://github.com/yunglin/common-jaxrs-client SearchServiceClient client = ClientFactory.getClient( SearchServiceClient.class, endPoint, myModel); •
  • 13. QA