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?

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
추근 문
 

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

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
 

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

Ä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 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
 
Rest
RestRest
Rest
 
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

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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
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
Enterprise Knowledge
 

Kürzlich hochgeladen (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
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
 
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...
 
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)
 
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...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

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