SlideShare una empresa de Scribd logo
1 de 13
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado

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
 

Destacado (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
 

Similar 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
 

Similar 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

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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 
🐬 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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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
 
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
 

Último (20)

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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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...
 
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
 

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