SlideShare a Scribd company logo
1 of 37
Download to read offline
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

More Related Content

What's hot

Database connect
Database connectDatabase connect
Database connectYoga Raja
 
Java Servlet
Java ServletJava Servlet
Java ServletYoga Raja
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESYoga Raja
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web servicesnbuddharaju
 
Easy rest service using PHP reflection api
Easy rest service using PHP reflection apiEasy rest service using PHP reflection api
Easy rest service using PHP reflection apiMatthieu Aubry
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web APIhabib_786
 
Whats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix MeschbergerWhats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix Meschbergermfrancis
 
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
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RSFahad Golra
 
RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with JerseyScott Leberknight
 
Getting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent EventsGetting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent EventsArun Gupta
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVCIndicThreads
 
MVC on the server and on the client
MVC on the server and on the clientMVC on the server and on the client
MVC on the server and on the clientSebastiano Armeli
 

What's hot (20)

Mule caching strategy with redis cache
Mule caching strategy with redis cacheMule caching strategy with redis cache
Mule caching strategy with redis cache
 
Database connect
Database connectDatabase connect
Database connect
 
Java Servlet
Java ServletJava Servlet
Java Servlet
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
Easy rest service using PHP reflection api
Easy rest service using PHP reflection apiEasy rest service using PHP reflection api
Easy rest service using PHP reflection api
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
Whats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix MeschbergerWhats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix Meschberger
 
Rest hello world_tutorial
Rest hello world_tutorialRest hello world_tutorial
Rest hello world_tutorial
 
JEE5 New Features
JEE5 New FeaturesJEE5 New Features
JEE5 New Features
 
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
 
Psr-7
Psr-7Psr-7
Psr-7
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
 
RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with Jersey
 
Library Project
Library ProjectLibrary Project
Library Project
 
Getting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent EventsGetting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent Events
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
Spring Mvc Rest
Spring Mvc RestSpring Mvc Rest
Spring Mvc Rest
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
 
MVC on the server and on the client
MVC on the server and on the clientMVC on the server and on the client
MVC on the server and on the client
 

Viewers also liked

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
 
Revelados b/n Estenopeicas
Revelados b/n   EstenopeicasRevelados b/n   Estenopeicas
Revelados b/n Estenopeicascynthia
 
May 2010 - Drools flow
May 2010 - Drools flowMay 2010 - Drools flow
May 2010 - Drools flowJBug Italy
 
October 2009 - News From JBoss World 09
October 2009 - News From JBoss World 09October 2009 - News From JBoss World 09
October 2009 - News From JBoss World 09JBug Italy
 
Infinispan and Enterprise Data Grid
Infinispan and Enterprise Data GridInfinispan and Enterprise Data Grid
Infinispan and Enterprise Data GridJBug Italy
 
Composicion
ComposicionComposicion
Composicioncynthia
 
April 2010 - Seam unifies JEE5
April 2010 - Seam unifies JEE5April 2010 - Seam unifies JEE5
April 2010 - Seam unifies JEE5JBug Italy
 
Intro JBug Milano - September 2011
Intro JBug Milano - September 2011Intro JBug Milano - September 2011
Intro JBug Milano - September 2011JBug Italy
 
The Global Leadership Challenge
The Global Leadership ChallengeThe Global Leadership Challenge
The Global Leadership ChallengeDavidCozens
 
Advertising
AdvertisingAdvertising
Advertisingmssd
 

Viewers also liked (18)

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
 
Revelados b/n Estenopeicas
Revelados b/n   EstenopeicasRevelados b/n   Estenopeicas
Revelados b/n Estenopeicas
 
May 2010 - Drools flow
May 2010 - Drools flowMay 2010 - Drools flow
May 2010 - Drools flow
 
My Resume
My ResumeMy Resume
My Resume
 
October 2009 - News From JBoss World 09
October 2009 - News From JBoss World 09October 2009 - News From JBoss World 09
October 2009 - News From JBoss World 09
 
time to grow.key
time to grow.keytime to grow.key
time to grow.key
 
Infinispan and Enterprise Data Grid
Infinispan and Enterprise Data GridInfinispan and Enterprise Data Grid
Infinispan and Enterprise Data Grid
 
Composicion
ComposicionComposicion
Composicion
 
How to grow in recession
How to grow in recessionHow to grow in recession
How to grow in recession
 
April 2010 - Seam unifies JEE5
April 2010 - Seam unifies JEE5April 2010 - Seam unifies JEE5
April 2010 - Seam unifies JEE5
 
Intro JBug Milano - September 2011
Intro JBug Milano - September 2011Intro JBug Milano - September 2011
Intro JBug Milano - September 2011
 
The Global Leadership Challenge
The Global Leadership ChallengeThe Global Leadership Challenge
The Global Leadership Challenge
 
compo
compocompo
compo
 
Geo Gebra
Geo GebraGeo Gebra
Geo Gebra
 
AS7
AS7AS7
AS7
 
AS7 and CLI
AS7 and CLIAS7 and CLI
AS7 and CLI
 
JBoss AS7
JBoss AS7JBoss AS7
JBoss AS7
 
Advertising
AdvertisingAdvertising
Advertising
 

Similar to May 2010 - RestEasy

JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and ODataAnil Allewar
 
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
 
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
 
Java Technology
Java TechnologyJava Technology
Java Technologyifnu bima
 
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programmingFulvio Corno
 
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
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with SpringJoshua Long
 
Understanding ASP.NET Under The Cover - Miguel A. Castro
Understanding ASP.NET Under The Cover - Miguel A. CastroUnderstanding ASP.NET Under The Cover - Miguel A. Castro
Understanding ASP.NET Under The Cover - Miguel A. CastroMohammad Tayseer
 
CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2Geoffrey Fox
 

Similar to May 2010 - RestEasy (20)

JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
 
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!
 
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
 
Java Technology
Java TechnologyJava Technology
Java Technology
 
Android and REST
Android and RESTAndroid and REST
Android and REST
 
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programming
 
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
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
RESTing with JAX-RS
RESTing with JAX-RSRESTing with JAX-RS
RESTing with JAX-RS
 
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...
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Java
 
Rest
RestRest
Rest
 
Understanding ASP.NET Under The Cover - Miguel A. Castro
Understanding ASP.NET Under The Cover - Miguel A. CastroUnderstanding ASP.NET Under The Cover - Miguel A. Castro
Understanding ASP.NET Under The Cover - Miguel A. Castro
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2
 

More from JBug Italy

JBoss Wise: breaking barriers to WS testing
JBoss Wise: breaking barriers to WS testingJBoss Wise: breaking barriers to WS testing
JBoss Wise: breaking barriers to WS testingJBug Italy
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBossJBug Italy
 
Intro jbug milano_26_set2012
Intro jbug milano_26_set2012Intro jbug milano_26_set2012
Intro jbug milano_26_set2012JBug Italy
 
Faster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzFaster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzJBug Italy
 
Infinispan,Lucene,Hibername OGM
Infinispan,Lucene,Hibername OGMInfinispan,Lucene,Hibername OGM
Infinispan,Lucene,Hibername OGMJBug Italy
 
JBoss BRMS - The enterprise platform for business logic
JBoss BRMS - The enterprise platform for business logicJBoss BRMS - The enterprise platform for business logic
JBoss BRMS - The enterprise platform for business logicJBug Italy
 
JBoss AS7 Overview
JBoss AS7 OverviewJBoss AS7 Overview
JBoss AS7 OverviewJBug Italy
 
Intro JBug Milano - January 2012
Intro JBug Milano - January 2012Intro JBug Milano - January 2012
Intro JBug Milano - January 2012JBug Italy
 
JBoss AS7 Webservices
JBoss AS7 WebservicesJBoss AS7 Webservices
JBoss AS7 WebservicesJBug Italy
 
All the cool stuff of JBoss BRMS
All the cool stuff of JBoss BRMSAll the cool stuff of JBoss BRMS
All the cool stuff of JBoss BRMSJBug Italy
 
Drools Introduction
Drools IntroductionDrools Introduction
Drools IntroductionJBug Italy
 
September 2010 - Arquillian
September 2010 - ArquillianSeptember 2010 - Arquillian
September 2010 - ArquillianJBug Italy
 
September 2010 - Gatein
September 2010 - GateinSeptember 2010 - Gatein
September 2010 - GateinJBug Italy
 
May 2010 - Infinispan
May 2010 - InfinispanMay 2010 - Infinispan
May 2010 - InfinispanJBug Italy
 
May 2010 - Hibernate search
May 2010 - Hibernate searchMay 2010 - Hibernate search
May 2010 - Hibernate searchJBug Italy
 
April 2010 - JBoss Web Services
April 2010 - JBoss Web ServicesApril 2010 - JBoss Web Services
April 2010 - JBoss Web ServicesJBug Italy
 
November 2009 - Walking on thin ice… from SOA to EDA
November 2009 - Walking on thin ice… from SOA to EDANovember 2009 - Walking on thin ice… from SOA to EDA
November 2009 - Walking on thin ice… from SOA to EDAJBug Italy
 
November 2009 - JSR-299 Context & Dependency Injection
November 2009 - JSR-299 Context & Dependency InjectionNovember 2009 - JSR-299 Context & Dependency Injection
November 2009 - JSR-299 Context & Dependency InjectionJBug Italy
 
November 2009 - Whats Cooking At JBoss Tools
November 2009 - Whats Cooking At JBoss ToolsNovember 2009 - Whats Cooking At JBoss Tools
November 2009 - Whats Cooking At JBoss ToolsJBug Italy
 
October 2009 - JBoss Cloud
October 2009 - JBoss CloudOctober 2009 - JBoss Cloud
October 2009 - JBoss CloudJBug Italy
 

More from JBug Italy (20)

JBoss Wise: breaking barriers to WS testing
JBoss Wise: breaking barriers to WS testingJBoss Wise: breaking barriers to WS testing
JBoss Wise: breaking barriers to WS testing
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBoss
 
Intro jbug milano_26_set2012
Intro jbug milano_26_set2012Intro jbug milano_26_set2012
Intro jbug milano_26_set2012
 
Faster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzFaster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzz
 
Infinispan,Lucene,Hibername OGM
Infinispan,Lucene,Hibername OGMInfinispan,Lucene,Hibername OGM
Infinispan,Lucene,Hibername OGM
 
JBoss BRMS - The enterprise platform for business logic
JBoss BRMS - The enterprise platform for business logicJBoss BRMS - The enterprise platform for business logic
JBoss BRMS - The enterprise platform for business logic
 
JBoss AS7 Overview
JBoss AS7 OverviewJBoss AS7 Overview
JBoss AS7 Overview
 
Intro JBug Milano - January 2012
Intro JBug Milano - January 2012Intro JBug Milano - January 2012
Intro JBug Milano - January 2012
 
JBoss AS7 Webservices
JBoss AS7 WebservicesJBoss AS7 Webservices
JBoss AS7 Webservices
 
All the cool stuff of JBoss BRMS
All the cool stuff of JBoss BRMSAll the cool stuff of JBoss BRMS
All the cool stuff of JBoss BRMS
 
Drools Introduction
Drools IntroductionDrools Introduction
Drools Introduction
 
September 2010 - Arquillian
September 2010 - ArquillianSeptember 2010 - Arquillian
September 2010 - Arquillian
 
September 2010 - Gatein
September 2010 - GateinSeptember 2010 - Gatein
September 2010 - Gatein
 
May 2010 - Infinispan
May 2010 - InfinispanMay 2010 - Infinispan
May 2010 - Infinispan
 
May 2010 - Hibernate search
May 2010 - Hibernate searchMay 2010 - Hibernate search
May 2010 - Hibernate search
 
April 2010 - JBoss Web Services
April 2010 - JBoss Web ServicesApril 2010 - JBoss Web Services
April 2010 - JBoss Web Services
 
November 2009 - Walking on thin ice… from SOA to EDA
November 2009 - Walking on thin ice… from SOA to EDANovember 2009 - Walking on thin ice… from SOA to EDA
November 2009 - Walking on thin ice… from SOA to EDA
 
November 2009 - JSR-299 Context & Dependency Injection
November 2009 - JSR-299 Context & Dependency InjectionNovember 2009 - JSR-299 Context & Dependency Injection
November 2009 - JSR-299 Context & Dependency Injection
 
November 2009 - Whats Cooking At JBoss Tools
November 2009 - Whats Cooking At JBoss ToolsNovember 2009 - Whats Cooking At JBoss Tools
November 2009 - Whats Cooking At JBoss Tools
 
October 2009 - JBoss Cloud
October 2009 - JBoss CloudOctober 2009 - JBoss Cloud
October 2009 - JBoss Cloud
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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 organizationRadu Cotescu
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 

Recently uploaded (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
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...
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
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
 

May 2010 - RestEasy

  • 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