SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
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
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 

Kürzlich hochgeladen (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
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
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 

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