SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
RESTEasy




 Dessì Massimiliano

 Jug Meeting Cagliari
   29 maggio 2010
Author
    Software Architect and Engineer
        ProNetics / Sourcesense

              Presidente
          JugSardegna Onlus

        Fondatore e coordinatore
  SpringFramework Italian User Group

      Committer - Contributor
  OpenNMS - MongoDB - MagicBox

                 Autore
Spring 2.5 Aspect Oriented Programming
REST
               * Addressable resources *
       Each resource must be addressable via a URI

            * Uniform, constrained interface *
           Http methods to manipulate resources

                 * Representation-oriented *
Interact with representations of the service (JSON,XML,HTML)

                * Stateless communication *

    * Hypermedia As The Engine Of Application State *
    data formats drive state transitions in the application
Addressability




 http://www.fruits.com/products/134
http://www.fruits.com/customers/146
  http://www.fruits.com/orders/135
http://www.fruits.com/shipments/2468
Uniform, Constrained Interface


GET read-only idempotent and safe (not change the server state)

               PUT insert or update idempotent

                     DELETE idempotent

              POST nonidempotent and unsafe

    HEAD like GET but return response code and headers

   OPTIONS information about the communication options
Representation Oriented



     JSON XML YAML
          ...


     Content-Type:
      text/plain
       text/html
    application/xml
      text/html;
   charset=iso-8859-1
          ....
Stateless communication




no client session data stored on the server
     it should be held and maintained
       by the client and transferred
to the server with each request as needed
   The server only manages the state
        of the resources it exposes
HATEOAS

           Hypermedia is a document-centric approach
                 hypermedia and hyperlinks as sets
               of information from disparate sources



<order id="576">
    <customer>http://www.fruits.com/customers/146</customer>
       <order-entries>
           <order-entry>
               <quantity>7</quantity>
                   <product>http://www.fruits.com/products/113</product>
                      ...
URI != RPC



http://www.fruits.com/orders
http://www.fruits.com/orders/{id}
http://www.fruits.com/products
http://www.fruits.com/products/{id}
http://www.fruits.com/customers
http://www.fruits.com/customers/{id}
Read - HTTP GET
GET /orders?index=0&size=15 HTTP/1.1
GET /products?index=0&size=15 HTTP/1.1
GET /customers?index=0&size=15 HTTP/1.1

GET /orders/189 HTTP/1.1

HTTP/1.1 200 OK
Content-Type: application/xml
<order id="189">
  ...
</order>
Read - HTTP GET - RESTEasy way

@Path("/orders")
public class OrderController {

  @GET
  @Path("/{id}")
  @Produces("application/xml")
  public StreamingOutput getCustomer(@PathParam("id") int id) {
       final Order order = DBOrders.get(id);
       if (order == null) {
           throw new WebApplicationException(Response.Status.NOT_FOUND);
       }
       return new StreamingOutput() {
           public void write(OutputStream outputStream)
                throws IOException, WebApplicationException {
                   outputOrder(outputStream, order);
           }
       };
  }
Create - HTTP POST



POST /orders HTTP/1.1
Content-Type: application/xml
<order>
   <total>€150.20</total>
   <date>June 22, 2010 10:30</date>
   ...
</order>
Create - HTTP POST – RESTEasy Way

@Path("/customers")
public class CustomerController {


@POST
@Consumes("application/xml")
public Response createCustomer(InputStream is) {
    Customer customer = readCustomerFromStream(is);
    customer.setId(idCounter.getNext());
    DB.put(customer);
    StringBuilder sb = new StringBuilder("/customers/").
    append(customer.getId());
    return Response.created(URI.create(sb.toString()).build();
}
Update - HTTP PUT



PUT /orders/232 HTTP/1.1
Content-Type: application/xml
<product id="444">
    <name>HTC Desire</name>
    <cost>€450.00</cost>
</product>
Update - HTTP PUT - RESTEasy Way


@Path("/customers")
public class CustomerController {

 @PUT
 @Path("{id}")
 @Consumes("application/xml")
 public void updateCustomer(@PathParam("id") int id,InputStream is){
    Customer update = readCustomerFromStream(is);
    Customer current = DB.get(id);
    if (current == null)
    throw new WebApplicationException(Response.Status.NOT_FOUND);

     current.setFirstName(update.getFirstName());
     …
     DB.update(current);
 }
Delete - HTTP DELETE




DELETE /orders/232 HTTP/1.1
Delete - HTTP DELETE -RESTEasy way




    @Path("/customers")
    public class CustomerController {

         @Path("{id}")
         @DELETE
         public void delete(@PathParam("id") int id) {
            db.delete(id);
     }
Content Negotiation




   @Consumes("text/xml")
@Produces("application/json")
    @Produces("text/*")
          ...
Annotations available

     @PathParam
    @QueryParam
    @HeaderParam
    @MatrixParam
    @CookieParam
     @FormParam
       @Form
      @Encoded
      @Context
The best is yet to come :)




Interceptors like Servlet Filter and AOP

          Asynchronous calls

          Asynchronous Job

          GZIP compression
Interceptors


public interface MessageBodyReaderInterceptor {
     Object read(MessageBodyReaderContext    context)
             throws IOException, WebApplicationException;
}




public interface MessageBodyWriterInterceptor {
     void write(MessageBodyWriterContext context)
          throws IOException, WebApplicationException;
}
Interceptors



public interface PreProcessInterceptor {
      ServerResponse preProcess(HttpRequest req,
      ResourceMethod method)
             throws Failure, WebApplicationException;
}




public interface PostProcessInterceptor {
      void postProcess(ServerResponse response);
}
Interceptors



public interface ClientExecutionInterceptor {
    ClientResponse execute(ClientExecutionContext ctx)
                   throws Exception;
}




public interface ClientExecutionContext {
      ClientRequest getRequest();
      ClientResponse proceed() throws Exception;
}
Interceptors


public interface MessageBodyReaderInterceptor {
     Object read(MessageBodyReaderContext    context)
             throws IOException, WebApplicationException;
}


public interface MessageBodyWriterInterceptor {
     void write(MessageBodyWriterContext context)
          throws IOException, WebApplicationException;
}



public interface PreProcessInterceptor {
      ServerResponse preProcess(HttpRequest req,
      ResourceMethod method)
             throws Failure, WebApplicationException;
}
Interceptors



@Provider
@ServerInterceptor
public class MyHeaderDecorator implements
                          MessageBodyWriterInterceptor {
    public void write(MessageBodyWriterContext context)
                throws IOException, WebApplicationException{
        context.getHeaders().add("My-Header", "custom");
        context.proceed();
    }

}
Interceptors



 @Provider
 @ServerInterceptor
 @ClientInterceptor
 @Precedence("ENCODER")
 public class MyCompressionInterceptor
        implements MessageBodyWriterInterceptor {
      …
}
Asynchronous Job

         RESTEasy Asynchronous Job Service
                is an implementation of
             the Asynchronous Job pattern
                       defined in
           O'Reilly's "Restful Web Services"

                        Use:

/asynch/jobs/{job-id}?wait={millisconds}|nowait=true


                   Fire and forget
     http://example.com/myservice?oneway=true
@GZIP


@Consumes("application/xml")
@PUT
public void put(@GZIP Customer customer){
  …
}



@GET
@Produces("application/xml")
@GZIP
public String getFooData() {
  ..
}
@CACHE


  @Cache
    maxAge
    sMaxAge
    noStore
  noTransform
 mustRevalidate
proxyRevalidate
   isPrivate




  @NoCache
Asyncronous
@GET
@Path("basic")
@Produces("text/plain")
public void getBasic(final @Suspend(10000) AsynchronousResponse res)
       throws Exception{

    Thread t = new Thread() {

       @Override
       public void run(){
          try{
               Response jaxrs =
               Response.ok("basic").type(MediaType.TEXT_PLAIN).build();
               res.setResponse(jaxrs);
             }catch (Exception e) {
                 e.printStackTrace();
             }
       }
    };
    t.start();
}
WEB.XML

<servlet>
    <servlet-name>
        Resteasy
    </servlet-name>
    <servlet-class>
  org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
    </servlet-class>
</servlet>
<servlet-mapping>
     <servlet-name>Resteasy</servlet-name>
     <url-pattern>/*</url-pattern>
</servlet-mapping>
RESTEasy With Spring
             Without SpringDispatcherServlet/SpringMVC


<listener>
    <listener-class>
       org.resteasy.plugins.server.servlet.ResteasyBootstrap
    </listener-class>
</listener>
<listener>
    <listener-class>
       org.resteasy.plugins.spring.SpringContextLoaderListener
    </listener-class>
</listener>
<servlet-mapping>
     <servlet-name>Resteasy</servlet-name>
     <url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
  <servlet-name>Resteasy</servlet-name>
  <url-pattern>/*</url-pattern>
</servlet-mapping>
RESTEasy With Spring
              With SpringDispatcherServlet/SpringMVC
 <servlet>
    <servlet-name>Resteasy</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
 </servlet>
 <servlet-mapping>
    <servlet-name>Spring</servlet-name>
    <url-pattern>/*</url-pattern>
 </servlet-mapping>


                Import in your bean's definition
<beans xmlns="http://www.springframework.org/schema/beans"
  ...
<import resource="classpath:springmvc-resteasy.xml"/>
RESTEasy With Spring
import   javax.ws.rs.GET;
import   javax.ws.rs.Path;
import   javax.ws.rs.PathParam;
import   javax.ws.rs.Produces;
...
import   org.springframework.stereotype.Controller;


@Path("rest/services")
@Controller
public class FrontController {

    @GET
    @Path("/{id}")
    @Produces(MediaType.TEXT_HTML)
    public ModelAndView getData(@PathParam("id") String collectionId) {
             ....
    }
Other Features


      ATOM support
      JSON support
   Client Framework
 Multipart Providers
     YAML Provider
    JAXB providers
    Authentication
   EJB Integration
   Seam Integration
Guice 2.0 Integration
JBoss 5.x Integration
Q&A
Thanks for your attention!

       Massimiliano Dessì
       desmax74 at yahoo.it
  massimiliano.dessi at pronetics.it

                   http://twitter.com/desmax74
                    http://jroller.com/desmax
              http://www.linkedin.com/in/desmax74
               http://www.slideshare.net/desmax74
      http://wiki.java.net/bin/view/People/MassimilianoDessi
  http://www.jugsardegna.org/vqwiki/jsp/Wiki?MassimilianoDessi

Contenu connexe

Tendances

The RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleThe RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleEmiliano Pecis
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni InturiSreeni I
 
RESTful services
RESTful servicesRESTful services
RESTful servicesgouthamrv
 
RESTFul Web Services - Intro
RESTFul Web Services - IntroRESTFul Web Services - Intro
RESTFul Web Services - IntroManuel Correa
 
Introduction to REST and the Restlet Framework
Introduction to REST and the Restlet FrameworkIntroduction to REST and the Restlet Framework
Introduction to REST and the Restlet FrameworkPhilip Johnson
 
How to build a rest api.pptx
How to build a rest api.pptxHow to build a rest api.pptx
How to build a rest api.pptxHarry Potter
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web ServiceHoan Vu Tran
 
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey IntroductionseyCwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey Introductionseyelliando dias
 
Restful web services with java
Restful web services with javaRestful web services with java
Restful web services with javaVinay Gopinath
 
REST - Representational state transfer
REST - Representational state transferREST - Representational state transfer
REST - Representational state transferTricode (part of Dept)
 
RESTful Architecture
RESTful ArchitectureRESTful Architecture
RESTful ArchitectureKabir Baidya
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSCarol McDonald
 
Rest and the hypermedia constraint
Rest and the hypermedia constraintRest and the hypermedia constraint
Rest and the hypermedia constraintInviqa
 

Tendances (20)

The RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleThe RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with Oracle
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni Inturi
 
RESTful services
RESTful servicesRESTful services
RESTful services
 
RESTFul Web Services - Intro
RESTFul Web Services - IntroRESTFul Web Services - Intro
RESTFul Web Services - Intro
 
Introduction to REST and the Restlet Framework
Introduction to REST and the Restlet FrameworkIntroduction to REST and the Restlet Framework
Introduction to REST and the Restlet Framework
 
How to build a rest api.pptx
How to build a rest api.pptxHow to build a rest api.pptx
How to build a rest api.pptx
 
Rest web services
Rest web servicesRest web services
Rest web services
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web Service
 
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey IntroductionseyCwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
 
Restful web services with java
Restful web services with javaRestful web services with java
Restful web services with java
 
REST - Representational state transfer
REST - Representational state transferREST - Representational state transfer
REST - Representational state transfer
 
RESTful Architecture
RESTful ArchitectureRESTful Architecture
RESTful Architecture
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RS
 
REST API Design
REST API DesignREST API Design
REST API Design
 
Implementation advantages of rest
Implementation advantages of restImplementation advantages of rest
Implementation advantages of rest
 
Rest and the hypermedia constraint
Rest and the hypermedia constraintRest and the hypermedia constraint
Rest and the hypermedia constraint
 
JSON and REST
JSON and RESTJSON and REST
JSON and REST
 
SOAP vs REST
SOAP vs RESTSOAP vs REST
SOAP vs REST
 
SOAP-based Web Services
SOAP-based Web ServicesSOAP-based Web Services
SOAP-based Web Services
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 

En vedette

SJUG March 2010 Restful design
SJUG March 2010 Restful designSJUG March 2010 Restful design
SJUG March 2010 Restful designMichael Neale
 
JavaDayIV - Leoncini Writing Restful Applications With Resteasy
JavaDayIV - Leoncini Writing Restful Applications With ResteasyJavaDayIV - Leoncini Writing Restful Applications With Resteasy
JavaDayIV - Leoncini Writing Restful Applications With ResteasyJBug Italy
 
FACTORES SOCIOECONÓMICOS QUE EXPLICAN LAS DESIGUALDADES NUTRICIONALES DE NUES...
FACTORES SOCIOECONÓMICOS QUE EXPLICAN LAS DESIGUALDADES NUTRICIONALES DE NUES...FACTORES SOCIOECONÓMICOS QUE EXPLICAN LAS DESIGUALDADES NUTRICIONALES DE NUES...
FACTORES SOCIOECONÓMICOS QUE EXPLICAN LAS DESIGUALDADES NUTRICIONALES DE NUES...Jorge Frisancho
 
Medios Digitales I
Medios Digitales IMedios Digitales I
Medios Digitales IUAGRM
 
La contaminacion ambiental
La contaminacion ambientalLa contaminacion ambiental
La contaminacion ambientalcamilapinillos75
 
Aplicación de las derivadas
Aplicación de las derivadasAplicación de las derivadas
Aplicación de las derivadasGEISLEN_DUBRASKA
 
Biography of abraham lincoln
Biography of abraham lincolnBiography of abraham lincoln
Biography of abraham lincolnErup Enolc
 
Aulas no ca dian 2010
Aulas no ca dian   2010Aulas no ca dian   2010
Aulas no ca dian 2010Tuane Paixão
 
Relatório unaids 2011
Relatório unaids 2011Relatório unaids 2011
Relatório unaids 2011maria25
 
Normativida aplicada a_la_ejecucion_del_control_gubernamental
Normativida aplicada a_la_ejecucion_del_control_gubernamentalNormativida aplicada a_la_ejecucion_del_control_gubernamental
Normativida aplicada a_la_ejecucion_del_control_gubernamentalcalacademica
 
Bce. tema 1. característiques generals desenvolupament.
Bce. tema 1. característiques generals desenvolupament.Bce. tema 1. característiques generals desenvolupament.
Bce. tema 1. característiques generals desenvolupament.LidiaTarrega
 

En vedette (20)

SJUG March 2010 Restful design
SJUG March 2010 Restful designSJUG March 2010 Restful design
SJUG March 2010 Restful design
 
JavaDayIV - Leoncini Writing Restful Applications With Resteasy
JavaDayIV - Leoncini Writing Restful Applications With ResteasyJavaDayIV - Leoncini Writing Restful Applications With Resteasy
JavaDayIV - Leoncini Writing Restful Applications With Resteasy
 
FACTORES SOCIOECONÓMICOS QUE EXPLICAN LAS DESIGUALDADES NUTRICIONALES DE NUES...
FACTORES SOCIOECONÓMICOS QUE EXPLICAN LAS DESIGUALDADES NUTRICIONALES DE NUES...FACTORES SOCIOECONÓMICOS QUE EXPLICAN LAS DESIGUALDADES NUTRICIONALES DE NUES...
FACTORES SOCIOECONÓMICOS QUE EXPLICAN LAS DESIGUALDADES NUTRICIONALES DE NUES...
 
Retirados al 31 de marzo
Retirados al 31 de marzoRetirados al 31 de marzo
Retirados al 31 de marzo
 
Modelos escodoc
Modelos escodocModelos escodoc
Modelos escodoc
 
Medios Digitales I
Medios Digitales IMedios Digitales I
Medios Digitales I
 
La contaminacion ambiental
La contaminacion ambientalLa contaminacion ambiental
La contaminacion ambiental
 
Aplicación de las derivadas
Aplicación de las derivadasAplicación de las derivadas
Aplicación de las derivadas
 
Rush lucas (2)
Rush lucas (2)Rush lucas (2)
Rush lucas (2)
 
Jaja}
Jaja}Jaja}
Jaja}
 
Biography of abraham lincoln
Biography of abraham lincolnBiography of abraham lincoln
Biography of abraham lincoln
 
Resume 8-29-16
Resume 8-29-16Resume 8-29-16
Resume 8-29-16
 
Aulas no ca dian 2010
Aulas no ca dian   2010Aulas no ca dian   2010
Aulas no ca dian 2010
 
Lecciones de amor Edith Piaf
Lecciones de amor Edith PiafLecciones de amor Edith Piaf
Lecciones de amor Edith Piaf
 
Relatório unaids 2011
Relatório unaids 2011Relatório unaids 2011
Relatório unaids 2011
 
Faça seu Curta
Faça seu CurtaFaça seu Curta
Faça seu Curta
 
Normativida aplicada a_la_ejecucion_del_control_gubernamental
Normativida aplicada a_la_ejecucion_del_control_gubernamentalNormativida aplicada a_la_ejecucion_del_control_gubernamental
Normativida aplicada a_la_ejecucion_del_control_gubernamental
 
Home Office
Home OfficeHome Office
Home Office
 
Services in hospitality industry
Services in hospitality industryServices in hospitality industry
Services in hospitality industry
 
Bce. tema 1. característiques generals desenvolupament.
Bce. tema 1. característiques generals desenvolupament.Bce. tema 1. característiques generals desenvolupament.
Bce. tema 1. característiques generals desenvolupament.
 

Similaire à RESTEasy - A Concise Introduction

JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and ODataAnil Allewar
 
Felix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureFelix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureMarcel Offermans
 
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy ClarksonMulti Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy ClarksonJoshua Long
 
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
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVCIndicThreads
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Microservice Come in Systems
Microservice Come in SystemsMicroservice Come in Systems
Microservice Come in SystemsMarkus Eisele
 
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programmingFulvio Corno
 
Java Technology
Java TechnologyJava Technology
Java Technologyifnu bima
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIEyal Vardi
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actionsAren Zomorodian
 
How lagom helps to build real world microservice systems
How lagom helps to build real world microservice systemsHow lagom helps to build real world microservice systems
How lagom helps to build real world microservice systemsMarkus Eisele
 
Microservices Manchester: How Lagom Helps to Build Real World Microservice Sy...
Microservices Manchester: How Lagom Helps to Build Real World Microservice Sy...Microservices Manchester: How Lagom Helps to Build Real World Microservice Sy...
Microservices Manchester: How Lagom Helps to Build Real World Microservice Sy...OpenCredo
 
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
 

Similaire à RESTEasy - A Concise Introduction (20)

JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
 
Felix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureFelix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the future
 
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy ClarksonMulti Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
 
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!
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Microservice Come in Systems
Microservice Come in SystemsMicroservice Come in Systems
Microservice Come in Systems
 
Android and REST
Android and RESTAndroid and REST
Android and REST
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programming
 
Java Technology
Java TechnologyJava Technology
Java Technology
 
RESTing with JAX-RS
RESTing with JAX-RSRESTing with JAX-RS
RESTing with JAX-RS
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web API
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
 
How lagom helps to build real world microservice systems
How lagom helps to build real world microservice systemsHow lagom helps to build real world microservice systems
How lagom helps to build real world microservice systems
 
Microservices Manchester: How Lagom Helps to Build Real World Microservice Sy...
Microservices Manchester: How Lagom Helps to Build Real World Microservice Sy...Microservices Manchester: How Lagom Helps to Build Real World Microservice Sy...
Microservices Manchester: How Lagom Helps to Build Real World Microservice Sy...
 
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
 

Plus de Massimiliano Dessì

When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...Massimiliano Dessì
 
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome Massimiliano Dessì
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudMassimiliano Dessì
 
Web Marketing Training 2014 Community Online
Web Marketing Training 2014 Community OnlineWeb Marketing Training 2014 Community Online
Web Marketing Training 2014 Community OnlineMassimiliano Dessì
 
Vert.X like Node.js but polyglot and reactive on JVM
Vert.X like Node.js but polyglot and reactive on JVMVert.X like Node.js but polyglot and reactive on JVM
Vert.X like Node.js but polyglot and reactive on JVMMassimiliano Dessì
 
Reactive applications Linux Day 2013
Reactive applications Linux Day 2013Reactive applications Linux Day 2013
Reactive applications Linux Day 2013Massimiliano Dessì
 
Scala Italy 2013 extended Scalatra vs Spring MVC
Scala Italy 2013 extended Scalatra vs Spring MVCScala Italy 2013 extended Scalatra vs Spring MVC
Scala Italy 2013 extended Scalatra vs Spring MVCMassimiliano Dessì
 
Codemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_sprayCodemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_sprayMassimiliano Dessì
 
Why we cannot ignore functional programming
Why we cannot ignore functional programmingWhy we cannot ignore functional programming
Why we cannot ignore functional programmingMassimiliano Dessì
 
Three languages in thirty minutes
Three languages in thirty minutesThree languages in thirty minutes
Three languages in thirty minutesMassimiliano Dessì
 

Plus de Massimiliano Dessì (20)

Code One 2018 maven
Code One 2018   mavenCode One 2018   maven
Code One 2018 maven
 
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
When Old Meets New: Turning Maven into a High Scalable, Resource Efficient, C...
 
Hacking Maven Linux day 2017
Hacking Maven Linux day 2017Hacking Maven Linux day 2017
Hacking Maven Linux day 2017
 
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
Microservices in Go_Dessi_Massimiliano_Codemotion_2017_Rome
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloud
 
Docker dDessi november 2015
Docker dDessi november 2015Docker dDessi november 2015
Docker dDessi november 2015
 
Docker linuxday 2015
Docker linuxday 2015Docker linuxday 2015
Docker linuxday 2015
 
Openshift linuxday 2014
Openshift linuxday 2014Openshift linuxday 2014
Openshift linuxday 2014
 
Web Marketing Training 2014 Community Online
Web Marketing Training 2014 Community OnlineWeb Marketing Training 2014 Community Online
Web Marketing Training 2014 Community Online
 
Vert.X like Node.js but polyglot and reactive on JVM
Vert.X like Node.js but polyglot and reactive on JVMVert.X like Node.js but polyglot and reactive on JVM
Vert.X like Node.js but polyglot and reactive on JVM
 
Reactive applications Linux Day 2013
Reactive applications Linux Day 2013Reactive applications Linux Day 2013
Reactive applications Linux Day 2013
 
Scala Italy 2013 extended Scalatra vs Spring MVC
Scala Italy 2013 extended Scalatra vs Spring MVCScala Italy 2013 extended Scalatra vs Spring MVC
Scala Italy 2013 extended Scalatra vs Spring MVC
 
Codemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_sprayCodemotion 2013 scalatra_play_spray
Codemotion 2013 scalatra_play_spray
 
Why we cannot ignore functional programming
Why we cannot ignore functional programmingWhy we cannot ignore functional programming
Why we cannot ignore functional programming
 
Scala linux day 2012
Scala linux day 2012 Scala linux day 2012
Scala linux day 2012
 
Three languages in thirty minutes
Three languages in thirty minutesThree languages in thirty minutes
Three languages in thirty minutes
 
MongoDB dessi-codemotion
MongoDB dessi-codemotionMongoDB dessi-codemotion
MongoDB dessi-codemotion
 
MongoDB Webtech conference 2010
MongoDB Webtech conference 2010MongoDB Webtech conference 2010
MongoDB Webtech conference 2010
 
Spring Roo Internals Javaday IV
Spring Roo Internals Javaday IVSpring Roo Internals Javaday IV
Spring Roo Internals Javaday IV
 
Spring Roo JaxItalia09
Spring Roo JaxItalia09Spring Roo JaxItalia09
Spring Roo JaxItalia09
 

Dernier

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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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 Servicegiselly40
 
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.pptxHampshireHUG
 
🐬 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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In 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
 
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 RobisonAnna Loughnan Colquhoun
 
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.pptxEarley Information Science
 

Dernier (20)

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...
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
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
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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...
 
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
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In 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
 
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
 
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
 

RESTEasy - A Concise Introduction

  • 1. RESTEasy Dessì Massimiliano Jug Meeting Cagliari 29 maggio 2010
  • 2. Author Software Architect and Engineer ProNetics / Sourcesense Presidente JugSardegna Onlus Fondatore e coordinatore SpringFramework Italian User Group Committer - Contributor OpenNMS - MongoDB - MagicBox Autore Spring 2.5 Aspect Oriented Programming
  • 3. REST * Addressable resources * Each resource must be addressable via a URI * Uniform, constrained interface * Http methods to manipulate resources * Representation-oriented * Interact with representations of the service (JSON,XML,HTML) * Stateless communication * * Hypermedia As The Engine Of Application State * data formats drive state transitions in the application
  • 4. Addressability http://www.fruits.com/products/134 http://www.fruits.com/customers/146 http://www.fruits.com/orders/135 http://www.fruits.com/shipments/2468
  • 5. Uniform, Constrained Interface GET read-only idempotent and safe (not change the server state) PUT insert or update idempotent DELETE idempotent POST nonidempotent and unsafe HEAD like GET but return response code and headers OPTIONS information about the communication options
  • 6. Representation Oriented JSON XML YAML ... Content-Type: text/plain text/html application/xml text/html; charset=iso-8859-1 ....
  • 7. Stateless communication no client session data stored on the server it should be held and maintained by the client and transferred to the server with each request as needed The server only manages the state of the resources it exposes
  • 8. HATEOAS Hypermedia is a document-centric approach hypermedia and hyperlinks as sets of information from disparate sources <order id="576"> <customer>http://www.fruits.com/customers/146</customer> <order-entries> <order-entry> <quantity>7</quantity> <product>http://www.fruits.com/products/113</product> ...
  • 10. Read - HTTP GET GET /orders?index=0&size=15 HTTP/1.1 GET /products?index=0&size=15 HTTP/1.1 GET /customers?index=0&size=15 HTTP/1.1 GET /orders/189 HTTP/1.1 HTTP/1.1 200 OK Content-Type: application/xml <order id="189"> ... </order>
  • 11. Read - HTTP GET - RESTEasy way @Path("/orders") public class OrderController { @GET @Path("/{id}") @Produces("application/xml") public StreamingOutput getCustomer(@PathParam("id") int id) { final Order order = DBOrders.get(id); if (order == null) { throw new WebApplicationException(Response.Status.NOT_FOUND); } return new StreamingOutput() { public void write(OutputStream outputStream) throws IOException, WebApplicationException { outputOrder(outputStream, order); } }; }
  • 12. Create - HTTP POST POST /orders HTTP/1.1 Content-Type: application/xml <order> <total>€150.20</total> <date>June 22, 2010 10:30</date> ... </order>
  • 13. Create - HTTP POST – RESTEasy Way @Path("/customers") public class CustomerController { @POST @Consumes("application/xml") public Response createCustomer(InputStream is) { Customer customer = readCustomerFromStream(is); customer.setId(idCounter.getNext()); DB.put(customer); StringBuilder sb = new StringBuilder("/customers/"). append(customer.getId()); return Response.created(URI.create(sb.toString()).build(); }
  • 14. Update - HTTP PUT PUT /orders/232 HTTP/1.1 Content-Type: application/xml <product id="444"> <name>HTC Desire</name> <cost>€450.00</cost> </product>
  • 15. Update - HTTP PUT - RESTEasy Way @Path("/customers") public class CustomerController { @PUT @Path("{id}") @Consumes("application/xml") public void updateCustomer(@PathParam("id") int id,InputStream is){ Customer update = readCustomerFromStream(is); Customer current = DB.get(id); if (current == null) throw new WebApplicationException(Response.Status.NOT_FOUND); current.setFirstName(update.getFirstName()); … DB.update(current); }
  • 16. Delete - HTTP DELETE DELETE /orders/232 HTTP/1.1
  • 17. Delete - HTTP DELETE -RESTEasy way @Path("/customers") public class CustomerController { @Path("{id}") @DELETE public void delete(@PathParam("id") int id) { db.delete(id); }
  • 18. Content Negotiation @Consumes("text/xml") @Produces("application/json") @Produces("text/*") ...
  • 19. Annotations available @PathParam @QueryParam @HeaderParam @MatrixParam @CookieParam @FormParam @Form @Encoded @Context
  • 20. The best is yet to come :) Interceptors like Servlet Filter and AOP Asynchronous calls Asynchronous Job GZIP compression
  • 21. Interceptors public interface MessageBodyReaderInterceptor { Object read(MessageBodyReaderContext context) throws IOException, WebApplicationException; } public interface MessageBodyWriterInterceptor { void write(MessageBodyWriterContext context) throws IOException, WebApplicationException; }
  • 22. Interceptors public interface PreProcessInterceptor { ServerResponse preProcess(HttpRequest req, ResourceMethod method) throws Failure, WebApplicationException; } public interface PostProcessInterceptor { void postProcess(ServerResponse response); }
  • 23. Interceptors public interface ClientExecutionInterceptor { ClientResponse execute(ClientExecutionContext ctx) throws Exception; } public interface ClientExecutionContext { ClientRequest getRequest(); ClientResponse proceed() throws Exception; }
  • 24. Interceptors public interface MessageBodyReaderInterceptor { Object read(MessageBodyReaderContext context) throws IOException, WebApplicationException; } public interface MessageBodyWriterInterceptor { void write(MessageBodyWriterContext context) throws IOException, WebApplicationException; } public interface PreProcessInterceptor { ServerResponse preProcess(HttpRequest req, ResourceMethod method) throws Failure, WebApplicationException; }
  • 25. Interceptors @Provider @ServerInterceptor public class MyHeaderDecorator implements MessageBodyWriterInterceptor { public void write(MessageBodyWriterContext context) throws IOException, WebApplicationException{ context.getHeaders().add("My-Header", "custom"); context.proceed(); } }
  • 26. Interceptors @Provider @ServerInterceptor @ClientInterceptor @Precedence("ENCODER") public class MyCompressionInterceptor implements MessageBodyWriterInterceptor { … }
  • 27. Asynchronous Job RESTEasy Asynchronous Job Service is an implementation of the Asynchronous Job pattern defined in O'Reilly's "Restful Web Services" Use: /asynch/jobs/{job-id}?wait={millisconds}|nowait=true Fire and forget http://example.com/myservice?oneway=true
  • 28. @GZIP @Consumes("application/xml") @PUT public void put(@GZIP Customer customer){ … } @GET @Produces("application/xml") @GZIP public String getFooData() { .. }
  • 29. @CACHE @Cache maxAge sMaxAge noStore noTransform mustRevalidate proxyRevalidate isPrivate @NoCache
  • 30. Asyncronous @GET @Path("basic") @Produces("text/plain") public void getBasic(final @Suspend(10000) AsynchronousResponse res) throws Exception{ Thread t = new Thread() { @Override public void run(){ try{ Response jaxrs = Response.ok("basic").type(MediaType.TEXT_PLAIN).build(); res.setResponse(jaxrs); }catch (Exception e) { e.printStackTrace(); } } }; t.start(); }
  • 31. WEB.XML <servlet> <servlet-name> Resteasy </servlet-name> <servlet-class> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher </servlet-class> </servlet> <servlet-mapping> <servlet-name>Resteasy</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
  • 32. RESTEasy With Spring Without SpringDispatcherServlet/SpringMVC <listener> <listener-class> org.resteasy.plugins.server.servlet.ResteasyBootstrap </listener-class> </listener> <listener> <listener-class> org.resteasy.plugins.spring.SpringContextLoaderListener </listener-class> </listener> <servlet-mapping> <servlet-name>Resteasy</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Resteasy</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
  • 33. RESTEasy With Spring With SpringDispatcherServlet/SpringMVC <servlet> <servlet-name>Resteasy</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>Spring</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> Import in your bean's definition <beans xmlns="http://www.springframework.org/schema/beans" ... <import resource="classpath:springmvc-resteasy.xml"/>
  • 34. RESTEasy With Spring import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; ... import org.springframework.stereotype.Controller; @Path("rest/services") @Controller public class FrontController { @GET @Path("/{id}") @Produces(MediaType.TEXT_HTML) public ModelAndView getData(@PathParam("id") String collectionId) { .... }
  • 35. Other Features ATOM support JSON support Client Framework Multipart Providers YAML Provider JAXB providers Authentication EJB Integration Seam Integration Guice 2.0 Integration JBoss 5.x Integration
  • 36. Q&A
  • 37. Thanks for your attention! Massimiliano Dessì desmax74 at yahoo.it massimiliano.dessi at pronetics.it http://twitter.com/desmax74 http://jroller.com/desmax http://www.linkedin.com/in/desmax74 http://www.slideshare.net/desmax74 http://wiki.java.net/bin/view/People/MassimilianoDessi http://www.jugsardegna.org/vqwiki/jsp/Wiki?MassimilianoDessi