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

Stack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersStack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for Developers
Jonathan Sharp
 
Backbone.js Simple Tutorial
Backbone.js Simple TutorialBackbone.js Simple Tutorial
Backbone.js Simple Tutorial
추근 문
 

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

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
isarevi
 
Avenue Restaurant - Sara
Avenue Restaurant - SaraAvenue Restaurant - Sara
Avenue Restaurant - Sara
isarevi
 
Cristina
CristinaCristina
Cristina
isarevi
 
Manuela's Restaurant - Andrea
Manuela's Restaurant  - AndreaManuela's Restaurant  - Andrea
Manuela's Restaurant - Andrea
isarevi
 
A Christmas Carol
A Christmas CarolA Christmas Carol
A Christmas Carol
isarevi
 
Jaime P.
Jaime P.Jaime P.
Jaime P.
isarevi
 
London - Alvaro
London -  AlvaroLondon -  Alvaro
London - Alvaro
isarevi
 
Italia in preghiera Novembre 2013
Italia in preghiera Novembre 2013Italia in preghiera Novembre 2013
Italia in preghiera Novembre 2013
Paolo Montecchi
 

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 Jersey
b_kathir
 
03 form-data
03 form-data03 form-data
03 form-data
snopteck
 
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
Carol McDonald
 

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

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
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...
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
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...
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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...
 
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...
 

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