SlideShare una empresa de Scribd logo
1 de 55
Multi Client Development with Spring

Josh Long
Spring Developer Advocate
SpringSource, a Division of VMware
http://www.joshlong.com || @starbuxman || josh.long@springsource.com




                                                              © 2009 VMware Inc. All rights reserved
About

 SpringSource is the organization that develops the Spring
 framework, the leading enterprise Java framework

 SpringSource was acquired by VMware in 2009

 VMware and SpringSource bring you to the cloud and
 deliver on the mission of “build, run, manage”
 • established partnerships with the major players in the business, including
   Adobe, SalesForce, and Google to help deliver the best experience for
   Spring users across multiple platforms


 Leading contributor to projects like
 Apache HTTPD and Apache Tomcat




                                                                                2
About Josh Long

Spring Developer Advocate
twitter: @starbuxman
josh.long@springsource.com




                             3
About Josh Long

Spring Developer Advocate
twitter: @starbuxman
josh.long@springsource.com

Contributor To:

•Spring Integration
•Spring Batch
•Spring Hadoop
•Activiti Workflow Engine
•Akka Actor engine




                             4
multi client development with Spring

Spring Primer




                                       5
The Spring ApplicationContext

 Spring Beans are Managed by An ApplicationContext
 • whether you’re in an application server, a web server, in regular Java SE application, in
  the cloud, Spring is initialized through an ApplicationContext
 • In a Java SE application:

       ApplicationContext ctx =
         new GenericAnnotationApplicationContext( “com.foo.bar.my.package”);

 • In a web application, you will configure an application context in your web.xml


      <servlet>
          <servlet-name>Spring Dispatcher Servlet</servlet-name>
          <servlet-
      class>org.springframework.web.servlet.DispatcherServlet</servlet-
      class>
          <init-param>
             <param-name>contextConfigLocation</param-name>
             <param-value>/WEB-INF/spring/myAppContext*.xml</param-value>
          </init-param>
          <load-on-startup>1</load-on-startup>
        </servlet>



                                                                                               6
I want Database Access ... with Hibernate 4 Support
 @Service
 public class CustomerService {

     public Customer createCustomer(String firstName,
                                   String lastName,
                                   Date signupDate) {
       ...
     }

 }




                                    CONFIDENTIAL
                                                        7
I want Database Access ... with Hibernate 4 Support
 @Service
 public class CustomerService {

     @Inject
     private SessionFactory sessionFactory;

     public Customer createCustomer(String firstName,
                                   String lastName,
                                   Date signupDate) {
       Customer customer = new Customer();
       customer.setFirstName(firstName);
       customer.setLastName(lastName);
       customer.setSignupDate(signupDate);

         sessionFactory.getCurrentSession().save(customer);
         return customer;
     }

 }




                                      CONFIDENTIAL
                                                              8
I want Database Access ... with Hibernate 4 Support
 @Service
 public class CustomerService {

     @Inject
     private SessionFactory sessionFactory;

     @Transactional
     public Customer createCustomer(String firstName,
                                   String lastName,
                                   Date signupDate) {
       Customer customer = new Customer();
       customer.setFirstName(firstName);
       customer.setLastName(lastName);
       customer.setSignupDate(signupDate);

         sessionFactory.getCurrentSession().save(customer);
         return customer;
     }

 }



                                        CONFIDENTIAL
                                                              9
I want Declarative Cache Management...
 @Service
 public class CustomerService {

     @Inject
     private SessionFactory sessionFactory;

     @Transactional
     @Cacheable(“customers”)
     public Customer createCustomer(String firstName,
                                   String lastName,
                                   Date signupDate) {
       Customer customer = new Customer();
       customer.setFirstName(firstName);
       customer.setLastName(lastName);
       customer.setSignupDate(signupDate);

         sessionFactory.getCurrentSession().save(customer);
         return customer;
     }
 }



                                        CONFIDENTIAL
                                                              10
I want a RESTful Endpoint...
 package org.springsource.examples.spring31.web;
 ..

 @Controller
 public class CustomerController {

     @Inject
     private CustomerService customerService;

     @RequestMapping(value = "/customer/{id}",
                       produces = MediaType.APPLICATION_JSON_VALUE)
     public @ResponseBody Customer customerById(@PathVariable("id") Integer id) {
         return customerService.getCustomerById(id);
     }
      ...
 }




                                      CONFIDENTIAL
                                                                                11
DEMO
• the 80% case!




                  Not confidential. Tell everyone.
multi client development with Spring

Spring Web Support




                                       13
Setting up Spring on the Web is Easy

  <servlet>
      <servlet-name>Spring Dispatcher Servlet</servlet-name>
      <servlet-
  class>org.springframework.web.servlet.DispatcherServlet</servlet-
  class>
      <init-param>
         <param-name>contextConfigLocation</param-name>
         <param-value>/WEB-INF/spring/myAppContext*.xml</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>




                                                                        14
New in 3.1: XML-free web applications

 In a servlet 3 container, you can also use Java configuration,
 negating the need for web.xml:


 public class SampleWebApplicationInitializer implements WebApplicationInitializer {

     public void onStartup(ServletContext sc) throws ServletException {

         AnnotationConfigWebApplicationContext ac =
                   new AnnotationConfigWebApplicationContext();
         ac.setServletContext(sc);
         ac.scan( “a.package.full.of.services”, “a.package.full.of.controllers” );

         sc.addServlet("spring", new DispatcherServlet(webContext));

     }
 }




                                                                                       15
Thin, Thick, Web, Mobile and Rich Clients: Web Core

 Spring Dispatcher Servlet
 • Objects don’t have to be web-specific.
 • Spring web supports lower-level web machinery: ‘
   • HttpRequestHandler (supports remoting: Caucho, Resin, JAX RPC)
   • DelegatingFilterProxy.
   • HandlerInterceptor wraps requests to HttpRequestHandlers
   • ServletWrappingController lets you force requests to a servlet through the Spring Handler chain
   • OncePerRequestFilter ensures that an action only occurs once, no matter how many filters are
    applied. Provides a nice way to avoid duplicate filters
 • Spring provides access to the Spring application context using
  WebApplicationContextUtils, which has a static method to look up the context, even in
  environments where Spring isn’t managing the web components
Thin, Thick, Web, Mobile and Rich Clients: Web Core

 Spring provides the easiest way to integrate with your web
 framework of choice
 • Spring Faces for JSF 1 and 2
 • Struts support for Struts 1
 • Tapestry, Struts 2, Stripes, Wicket, Vaadin, Play framework, etc.
 • GWT, Flex
Thin, Thick, Web, Mobile and Rich Clients: Spring MVC




                                                        18
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {


 }




                                          19
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

@Controller
public class CustomerController {

    @RequestMapping(value=”/url/of/my/resource”)
    public String processTheRequest() {
        // ...
        return “home”;
    }

}




GET http://127.0.0.1:8080/url/of/my/resource

                                                   20
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {

     @RequestMapping(value=”/url/of/my/resource”,
                     method = RequestMethod.GET)
     public String processTheRequest() {
         // ...
         return “home”;
     }

 }




GET http://127.0.0.1:8080/url/of/my/resource

                                                    21
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {

     @RequestMapping(value=”/url/of/my/resource”,
                     method = RequestMethod.GET)
     public String processTheRequest( HttpServletRequest request) {
         String contextPath = request.getContextPath();
         // ...
         return “home”;
     }

 }




GET http://127.0.0.1:8080/url/of/my/resource

                                                                      22
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {

     @RequestMapping(value=”/url/of/my/resource”,
                     method = RequestMethod.GET)
     public String processTheRequest( @RequestParam(“search”) String searchQuery ) {
         // ...
         return “home”;
     }

 }




GET http://127.0.0.1:8080/url/of/my/resource?search=Spring

                                                                                       23
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {

     @RequestMapping(value=”/url/of/my/{id}”,
                     method = RequestMethod.GET)
     public String processTheRequest( @PathVariable(“id”) Long id) {
         // ...
         return “home”;
     }

 }




GET http://127.0.0.1:8080/url/of/my/2322

                                                                       24
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {

     @RequestMapping(value=”/url/of/my/{id}” )
     public String processTheRequest( @PathVariable(“id”) Long customerId,
                                      Model model ) {
         model.addAttribute(“customer”, service.getCustomerById( customerId ) );
         return “home”;
     }

     @Autowired CustomerService service;

 }




GET http://127.0.0.1:8080/url/of/my/232

                                                                                   25
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {

     @RequestMapping(value=”/url/of/my/resource”,
                     method = RequestMethod.GET)
     public String processTheRequest( HttpServletRequest request, Model model) {
         return “home”;
     }

 }




                                                                                   26
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {

     @RequestMapping(value=”/url/of/my/resource”,
                     method = RequestMethod.GET)
     public View processTheRequest( HttpServletRequest request, Model model) {
         return new XsltView(...);
     }

 }




                                                                                 27
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {

     @RequestMapping(value=”/url/of/my/resource”,
                     method = RequestMethod.GET)
     public InputStream processTheRequest( HttpServletRequest request, Model model) {
         return new FileInputStream( ...) ;
     }

 }




                                                                                        28
DEMO
 Demos
 • Simple Spring MVC based Application




                             Not confidential. Tell everyone.
multi client development with Spring

the new hotness




                                       30
dumb terminals ruled the earth....




                                     31
then something magical happened: the web




                                           32
but the web didn’t know how to do UI state... so we hacked...




                                                                33
....then the web stopped sucking




                                   34
multi client development with Spring

REST




                                       35
Thin, Thick, Web, Mobile and Rich Clients: REST

 Origin
 • The term Representational State Transfer was introduced and defined in 2000 by Roy
   Fielding in his doctoral dissertation.
 His paper suggests these four design principles:
 • Use HTTP methods explicitly.
   • POST, GET, PUT, DELETE
   • CRUD operations can be mapped to these existing methods
 • Be stateless.
   • State dependencies limit or restrict scalability
 • Expose directory structure-like URIs.
   • URI’s should be easily understood
 • Transfer XML, JavaScript Object Notation (JSON), or both.
   • Use XML or JSON to represent data objects or attributes




                                                CONFIDENTIAL
                                                                                        36
REST on the Server

 Spring MVC is basis for REST support
 • Spring’s server side REST support is based on the standard controller model
 JavaScript and HTML5 can consume JSON-data payloads
REST on the Client

 RestTemplate
 • provides dead simple, idiomatic RESTful services consumption
 • can use Spring OXM, too.
 • Spring Integration and Spring Social both build on the RestTemplate where possible.
 Spring supports numerous converters out of the box
 • JAXB
 • JSON (Jackson)
Building clients for your RESTful services: RestTemplate

 Google search example
RestTemplate restTemplate = new RestTemplate();
String url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q={query}";
String result = restTemplate.getForObject(url, String.class, "SpringSource");


 Multiple parameters
RestTemplate restTemplate = new RestTemplate();
String url = "http://example.com/hotels/{hotel}/bookings/{booking}";
String result = restTemplate.getForObject(url, String.class, "42", “21”);




                                        CONFIDENTIAL
                                                                                 39
Thin, Thick, Web, Mobile and Rich Clients: RestTemplate

 RestTemplate class is the heart the client-side story
 • Entry points for the six main HTTP methods
   • DELETE - delete(...)
   • GET - getForObject(...)
   • HEAD - headForHeaders(...)
   • OPTIONS - optionsForAllow(...)
   • POST - postForLocation(...)
   • PUT - put(...)
   • any HTTP operation - exchange(...) and execute(...)




                                             CONFIDENTIAL
                                                            40
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {

     @RequestMapping(value=”/url/of/my/resource”,
                     method = RequestMethod.GET)
     public @ResponseBody Customer processTheRequest(   ... ) {
        Customer c = service.getCustomerById( id) ;
        return c;
     }

     @Autowired CustomerService service;

 }




                                                                  41
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {

     @RequestMapping(value=”/url/of/my/someurl”,
                     method = RequestMethod.POST)
     public String processTheRequest( @RequestBody Customer postedCustomerObject) {
         // ...
         return “home”;
     }

 }




POST http://127.0.0.1:8080/url/of/my/someurl

                                                                                      42
The Anatomy of a Spring MVC @Controller
Spring MVC configuration - config

 @Controller
 public class CustomerController {

     @RequestMapping(value=”/url/of/my/{id}”,
                     method = RequestMethod.POST)
     public String processTheRequest( @PathVariable(“id”) Long customerId,
                                      @RequestBody Customer postedCustomerObject) {
         // ...
         return “home”;
     }

 }




POST http://127.0.0.1:8080/url/of/my/someurl

                                                                                      43
DEMO
 Demos:
• Spring REST service
• Spring REST client




                        Not confidential. Tell everyone.
DEMO
 Demos:
• Using REST from Ajax




                         Not confidential. Tell everyone.
multi client development with Spring

Spring Mobile




                                       46
Thin, Thick, Web, Mobile and Rich Clients: Mobile

 Best strategy? Develop Native
 • Fallback to client-optimized web applications
 Spring MVC 3.1 mobile client-specific content negotiation and
 rendering
 • for other devices
   • (there are other devices besides Android??)




                                                                  47
DEMO
 Demos:
• Mobile clients using client specific rendering




                                  Not confidential. Tell everyone.
multi client development with Spring

Spring Android




                                       49
Thin, Thick, Web, Mobile and Rich Clients: Mobile

               Spring REST is ideal for mobile devices
               Spring MVC 3.1 mobile client-specific content
                negotiation and rendering
                • for other devices
               Spring Android
                • RestTemplate




                                                                50
OK, so.....




              51
Thin, Thick, Web, Mobile and Rich Clients: Mobile

     CustomerServiceClient - client



!    private <T> T extractResponse( ResponseEntity<T> response) {
!    !     if (response != null && response().value() == 200) {
!    !     !    return response.getBody();
!    !     }
!    !     throw new RuntimeException("couldn't extract response.");
!    }

!    @Override
!    public Customer updateCustomer(long id, String fn, String ln) {
!    !     String urlForPath = urlForPath("customer/{customerId}");!!
!    !     return extractResponse(this.restTemplate.postForEntity(
                   urlForPath, new Customer(id, fn, ln), Customer.class, id));
!    }




                                                                                 52
Thin, Thick, Web, Mobile and Rich Clients: Mobile

 Demos:
• consuming the Spring REST service from Android
One Other approach

                      HTML5 all the way!
                      • HTML5 on the desktop browser interface
                      • HTML5 + PhoneGap on the client
                      • RESTful services on the server side to connect it all
springsource.org | cloudfoundry.org




            Questions?
                 Say hi!
@starbuxman | josh.long@springsource.com

Más contenido relacionado

La actualidad más candente

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
 
Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Michał Orman
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJoshua Long
 
the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 updateJoshua Long
 
a Running Tour of Cloud Foundry
a Running Tour of Cloud Foundrya Running Tour of Cloud Foundry
a Running Tour of Cloud FoundryJoshua Long
 
Spring Portlet MVC
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVCJohn Lewis
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsGuy Nir
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892Tuna Tore
 
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
 
Spring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundrySpring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundryJoshua Long
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkGuo Albert
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentationsourabh aggarwal
 
The Cloud Foundry bootcamp talk from SpringOne On The Road - Europe
The Cloud Foundry bootcamp talk from SpringOne On The Road - EuropeThe Cloud Foundry bootcamp talk from SpringOne On The Road - Europe
The Cloud Foundry bootcamp talk from SpringOne On The Road - EuropeJoshua Long
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods pptkamal kotecha
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 UpdateRyan Cuprak
 
Vue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue routerVue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue routerKaty Slemon
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depthVinay Kumar
 

La actualidad más candente (20)

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
 
Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with Spring
 
the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 update
 
a Running Tour of Cloud Foundry
a Running Tour of Cloud Foundrya Running Tour of Cloud Foundry
a Running Tour of Cloud Foundry
 
Spring Portlet MVC
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVC
 
JAX-WS Basics
JAX-WS BasicsJAX-WS Basics
JAX-WS Basics
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
 
Spring4 whats up doc?
Spring4 whats up doc?Spring4 whats up doc?
Spring4 whats up doc?
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 
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
 
Spring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundrySpring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud Foundry
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC Framework
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentation
 
The Cloud Foundry bootcamp talk from SpringOne On The Road - Europe
The Cloud Foundry bootcamp talk from SpringOne On The Road - EuropeThe Cloud Foundry bootcamp talk from SpringOne On The Road - Europe
The Cloud Foundry bootcamp talk from SpringOne On The Road - Europe
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
 
Vue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue routerVue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue router
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depth
 

Destacado

using Spring and MongoDB on Cloud Foundry
using Spring and MongoDB on Cloud Foundryusing Spring and MongoDB on Cloud Foundry
using Spring and MongoDB on Cloud FoundryJoshua Long
 
Extending spring
Extending springExtending spring
Extending springJoshua Long
 
Spring in-the-cloud
Spring in-the-cloudSpring in-the-cloud
Spring in-the-cloudJoshua Long
 
The spring 32 update final
The spring 32 update finalThe spring 32 update final
The spring 32 update finalJoshua Long
 
Integration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud FoundryIntegration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud FoundryJoshua Long
 
Bootiful Code with Spring Boot
Bootiful Code with Spring BootBootiful Code with Spring Boot
Bootiful Code with Spring BootJoshua Long
 
Economies of Scaling Software
Economies of Scaling SoftwareEconomies of Scaling Software
Economies of Scaling SoftwareJoshua Long
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with SpringJoshua Long
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring BootJoshua Long
 

Destacado (10)

using Spring and MongoDB on Cloud Foundry
using Spring and MongoDB on Cloud Foundryusing Spring and MongoDB on Cloud Foundry
using Spring and MongoDB on Cloud Foundry
 
Extending spring
Extending springExtending spring
Extending spring
 
Spring in-the-cloud
Spring in-the-cloudSpring in-the-cloud
Spring in-the-cloud
 
The spring 32 update final
The spring 32 update finalThe spring 32 update final
The spring 32 update final
 
Integration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud FoundryIntegration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud Foundry
 
Boot It Up
Boot It UpBoot It Up
Boot It Up
 
Bootiful Code with Spring Boot
Bootiful Code with Spring BootBootiful Code with Spring Boot
Bootiful Code with Spring Boot
 
Economies of Scaling Software
Economies of Scaling SoftwareEconomies of Scaling Software
Economies of Scaling Software
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
 

Similar a Multi Client Development with Spring

Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenJoshua Long
 
Unit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptxUnit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptxAbhijayKulshrestha1
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Michael Plöd
 
Managing user's data with Spring Session
Managing user's data with Spring SessionManaging user's data with Spring Session
Managing user's data with Spring SessionDavid Gómez García
 
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Arun Gupta
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasyJBug Italy
 
JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0Arun Gupta
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Jasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-casJasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-casellentuck
 
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Dan Wahlin
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web FrameworkLuther Baker
 
Building microservices sample application
Building microservices sample applicationBuilding microservices sample application
Building microservices sample applicationAnil Allewar
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Tuna Tore
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauSpiffy
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the TrenchesJonathan Wage
 

Similar a Multi Client Development with Spring (20)

Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in Heaven
 
Unit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptxUnit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptx
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6
 
Managing user's data with Spring Session
Managing user's data with Spring SessionManaging user's data with Spring Session
Managing user's data with Spring Session
 
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
 
Stripes Framework
Stripes FrameworkStripes Framework
Stripes Framework
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
 
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter LehtoJavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
 
JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Servlets
ServletsServlets
Servlets
 
Jasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-casJasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-cas
 
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web Framework
 
Building microservices sample application
Building microservices sample applicationBuilding microservices sample application
Building microservices sample application
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 

Más de Joshua Long

Have You Seen Spring Lately?
Have You Seen Spring Lately?Have You Seen Spring Lately?
Have You Seen Spring Lately?Joshua Long
 
the Spring Update from JavaOne 2013
the Spring Update from JavaOne 2013the Spring Update from JavaOne 2013
the Spring Update from JavaOne 2013Joshua Long
 
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
 
Spring Batch Behind the Scenes
Spring Batch Behind the ScenesSpring Batch Behind the Scenes
Spring Batch Behind the ScenesJoshua Long
 
Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry BootcampJoshua Long
 
Extending Spring for Custom Usage
Extending Spring for Custom UsageExtending Spring for Custom Usage
Extending Spring for Custom UsageJoshua Long
 
Using Spring's IOC Model
Using Spring's IOC ModelUsing Spring's IOC Model
Using Spring's IOC ModelJoshua Long
 
Enterprise Integration and Batch Processing on Cloud Foundry
Enterprise Integration and Batch Processing on Cloud FoundryEnterprise Integration and Batch Processing on Cloud Foundry
Enterprise Integration and Batch Processing on Cloud FoundryJoshua Long
 
Cloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and VaadinCloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and VaadinJoshua Long
 

Más de Joshua Long (10)

Have You Seen Spring Lately?
Have You Seen Spring Lately?Have You Seen Spring Lately?
Have You Seen Spring Lately?
 
the Spring Update from JavaOne 2013
the Spring Update from JavaOne 2013the Spring Update from JavaOne 2013
the Spring Update from JavaOne 2013
 
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
 
Spring Batch Behind the Scenes
Spring Batch Behind the ScenesSpring Batch Behind the Scenes
Spring Batch Behind the Scenes
 
Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
 
Extending Spring for Custom Usage
Extending Spring for Custom UsageExtending Spring for Custom Usage
Extending Spring for Custom Usage
 
Using Spring's IOC Model
Using Spring's IOC ModelUsing Spring's IOC Model
Using Spring's IOC Model
 
Enterprise Integration and Batch Processing on Cloud Foundry
Enterprise Integration and Batch Processing on Cloud FoundryEnterprise Integration and Batch Processing on Cloud Foundry
Enterprise Integration and Batch Processing on Cloud Foundry
 
Cloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and VaadinCloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and Vaadin
 
Messaging sz
Messaging szMessaging sz
Messaging sz
 

Último

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Último (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

Multi Client Development with Spring

  • 1. Multi Client Development with Spring Josh Long Spring Developer Advocate SpringSource, a Division of VMware http://www.joshlong.com || @starbuxman || josh.long@springsource.com © 2009 VMware Inc. All rights reserved
  • 2. About  SpringSource is the organization that develops the Spring framework, the leading enterprise Java framework  SpringSource was acquired by VMware in 2009  VMware and SpringSource bring you to the cloud and deliver on the mission of “build, run, manage” • established partnerships with the major players in the business, including Adobe, SalesForce, and Google to help deliver the best experience for Spring users across multiple platforms  Leading contributor to projects like Apache HTTPD and Apache Tomcat 2
  • 3. About Josh Long Spring Developer Advocate twitter: @starbuxman josh.long@springsource.com 3
  • 4. About Josh Long Spring Developer Advocate twitter: @starbuxman josh.long@springsource.com Contributor To: •Spring Integration •Spring Batch •Spring Hadoop •Activiti Workflow Engine •Akka Actor engine 4
  • 5. multi client development with Spring Spring Primer 5
  • 6. The Spring ApplicationContext  Spring Beans are Managed by An ApplicationContext • whether you’re in an application server, a web server, in regular Java SE application, in the cloud, Spring is initialized through an ApplicationContext • In a Java SE application: ApplicationContext ctx = new GenericAnnotationApplicationContext( “com.foo.bar.my.package”); • In a web application, you will configure an application context in your web.xml <servlet> <servlet-name>Spring Dispatcher Servlet</servlet-name> <servlet- class>org.springframework.web.servlet.DispatcherServlet</servlet- class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/myAppContext*.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> 6
  • 7. I want Database Access ... with Hibernate 4 Support @Service public class CustomerService { public Customer createCustomer(String firstName, String lastName, Date signupDate) { ... } } CONFIDENTIAL 7
  • 8. I want Database Access ... with Hibernate 4 Support @Service public class CustomerService { @Inject private SessionFactory sessionFactory; public Customer createCustomer(String firstName, String lastName, Date signupDate) { Customer customer = new Customer(); customer.setFirstName(firstName); customer.setLastName(lastName); customer.setSignupDate(signupDate); sessionFactory.getCurrentSession().save(customer); return customer; } } CONFIDENTIAL 8
  • 9. I want Database Access ... with Hibernate 4 Support @Service public class CustomerService { @Inject private SessionFactory sessionFactory; @Transactional public Customer createCustomer(String firstName, String lastName, Date signupDate) { Customer customer = new Customer(); customer.setFirstName(firstName); customer.setLastName(lastName); customer.setSignupDate(signupDate); sessionFactory.getCurrentSession().save(customer); return customer; } } CONFIDENTIAL 9
  • 10. I want Declarative Cache Management... @Service public class CustomerService { @Inject private SessionFactory sessionFactory; @Transactional @Cacheable(“customers”) public Customer createCustomer(String firstName, String lastName, Date signupDate) { Customer customer = new Customer(); customer.setFirstName(firstName); customer.setLastName(lastName); customer.setSignupDate(signupDate); sessionFactory.getCurrentSession().save(customer); return customer; } } CONFIDENTIAL 10
  • 11. I want a RESTful Endpoint... package org.springsource.examples.spring31.web; .. @Controller public class CustomerController { @Inject private CustomerService customerService; @RequestMapping(value = "/customer/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Customer customerById(@PathVariable("id") Integer id) { return customerService.getCustomerById(id); } ... } CONFIDENTIAL 11
  • 12. DEMO • the 80% case! Not confidential. Tell everyone.
  • 13. multi client development with Spring Spring Web Support 13
  • 14. Setting up Spring on the Web is Easy <servlet> <servlet-name>Spring Dispatcher Servlet</servlet-name> <servlet- class>org.springframework.web.servlet.DispatcherServlet</servlet- class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/myAppContext*.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> 14
  • 15. New in 3.1: XML-free web applications  In a servlet 3 container, you can also use Java configuration, negating the need for web.xml: public class SampleWebApplicationInitializer implements WebApplicationInitializer { public void onStartup(ServletContext sc) throws ServletException { AnnotationConfigWebApplicationContext ac = new AnnotationConfigWebApplicationContext(); ac.setServletContext(sc); ac.scan( “a.package.full.of.services”, “a.package.full.of.controllers” ); sc.addServlet("spring", new DispatcherServlet(webContext)); } } 15
  • 16. Thin, Thick, Web, Mobile and Rich Clients: Web Core  Spring Dispatcher Servlet • Objects don’t have to be web-specific. • Spring web supports lower-level web machinery: ‘ • HttpRequestHandler (supports remoting: Caucho, Resin, JAX RPC) • DelegatingFilterProxy. • HandlerInterceptor wraps requests to HttpRequestHandlers • ServletWrappingController lets you force requests to a servlet through the Spring Handler chain • OncePerRequestFilter ensures that an action only occurs once, no matter how many filters are applied. Provides a nice way to avoid duplicate filters • Spring provides access to the Spring application context using WebApplicationContextUtils, which has a static method to look up the context, even in environments where Spring isn’t managing the web components
  • 17. Thin, Thick, Web, Mobile and Rich Clients: Web Core  Spring provides the easiest way to integrate with your web framework of choice • Spring Faces for JSF 1 and 2 • Struts support for Struts 1 • Tapestry, Struts 2, Stripes, Wicket, Vaadin, Play framework, etc. • GWT, Flex
  • 18. Thin, Thick, Web, Mobile and Rich Clients: Spring MVC 18
  • 19. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { } 19
  • 20. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/resource”) public String processTheRequest() { // ... return “home”; } } GET http://127.0.0.1:8080/url/of/my/resource 20
  • 21. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/resource”, method = RequestMethod.GET) public String processTheRequest() { // ... return “home”; } } GET http://127.0.0.1:8080/url/of/my/resource 21
  • 22. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/resource”, method = RequestMethod.GET) public String processTheRequest( HttpServletRequest request) { String contextPath = request.getContextPath(); // ... return “home”; } } GET http://127.0.0.1:8080/url/of/my/resource 22
  • 23. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/resource”, method = RequestMethod.GET) public String processTheRequest( @RequestParam(“search”) String searchQuery ) { // ... return “home”; } } GET http://127.0.0.1:8080/url/of/my/resource?search=Spring 23
  • 24. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/{id}”, method = RequestMethod.GET) public String processTheRequest( @PathVariable(“id”) Long id) { // ... return “home”; } } GET http://127.0.0.1:8080/url/of/my/2322 24
  • 25. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/{id}” ) public String processTheRequest( @PathVariable(“id”) Long customerId, Model model ) { model.addAttribute(“customer”, service.getCustomerById( customerId ) ); return “home”; } @Autowired CustomerService service; } GET http://127.0.0.1:8080/url/of/my/232 25
  • 26. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/resource”, method = RequestMethod.GET) public String processTheRequest( HttpServletRequest request, Model model) { return “home”; } } 26
  • 27. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/resource”, method = RequestMethod.GET) public View processTheRequest( HttpServletRequest request, Model model) { return new XsltView(...); } } 27
  • 28. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/resource”, method = RequestMethod.GET) public InputStream processTheRequest( HttpServletRequest request, Model model) { return new FileInputStream( ...) ; } } 28
  • 29. DEMO  Demos • Simple Spring MVC based Application Not confidential. Tell everyone.
  • 30. multi client development with Spring the new hotness 30
  • 31. dumb terminals ruled the earth.... 31
  • 32. then something magical happened: the web 32
  • 33. but the web didn’t know how to do UI state... so we hacked... 33
  • 34. ....then the web stopped sucking 34
  • 35. multi client development with Spring REST 35
  • 36. Thin, Thick, Web, Mobile and Rich Clients: REST  Origin • The term Representational State Transfer was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation.  His paper suggests these four design principles: • Use HTTP methods explicitly. • POST, GET, PUT, DELETE • CRUD operations can be mapped to these existing methods • Be stateless. • State dependencies limit or restrict scalability • Expose directory structure-like URIs. • URI’s should be easily understood • Transfer XML, JavaScript Object Notation (JSON), or both. • Use XML or JSON to represent data objects or attributes CONFIDENTIAL 36
  • 37. REST on the Server  Spring MVC is basis for REST support • Spring’s server side REST support is based on the standard controller model  JavaScript and HTML5 can consume JSON-data payloads
  • 38. REST on the Client  RestTemplate • provides dead simple, idiomatic RESTful services consumption • can use Spring OXM, too. • Spring Integration and Spring Social both build on the RestTemplate where possible.  Spring supports numerous converters out of the box • JAXB • JSON (Jackson)
  • 39. Building clients for your RESTful services: RestTemplate  Google search example RestTemplate restTemplate = new RestTemplate(); String url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q={query}"; String result = restTemplate.getForObject(url, String.class, "SpringSource");  Multiple parameters RestTemplate restTemplate = new RestTemplate(); String url = "http://example.com/hotels/{hotel}/bookings/{booking}"; String result = restTemplate.getForObject(url, String.class, "42", “21”); CONFIDENTIAL 39
  • 40. Thin, Thick, Web, Mobile and Rich Clients: RestTemplate  RestTemplate class is the heart the client-side story • Entry points for the six main HTTP methods • DELETE - delete(...) • GET - getForObject(...) • HEAD - headForHeaders(...) • OPTIONS - optionsForAllow(...) • POST - postForLocation(...) • PUT - put(...) • any HTTP operation - exchange(...) and execute(...) CONFIDENTIAL 40
  • 41. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/resource”, method = RequestMethod.GET) public @ResponseBody Customer processTheRequest( ... ) { Customer c = service.getCustomerById( id) ; return c; } @Autowired CustomerService service; } 41
  • 42. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/someurl”, method = RequestMethod.POST) public String processTheRequest( @RequestBody Customer postedCustomerObject) { // ... return “home”; } } POST http://127.0.0.1:8080/url/of/my/someurl 42
  • 43. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { @RequestMapping(value=”/url/of/my/{id}”, method = RequestMethod.POST) public String processTheRequest( @PathVariable(“id”) Long customerId, @RequestBody Customer postedCustomerObject) { // ... return “home”; } } POST http://127.0.0.1:8080/url/of/my/someurl 43
  • 44. DEMO  Demos: • Spring REST service • Spring REST client Not confidential. Tell everyone.
  • 45. DEMO  Demos: • Using REST from Ajax Not confidential. Tell everyone.
  • 46. multi client development with Spring Spring Mobile 46
  • 47. Thin, Thick, Web, Mobile and Rich Clients: Mobile  Best strategy? Develop Native • Fallback to client-optimized web applications  Spring MVC 3.1 mobile client-specific content negotiation and rendering • for other devices • (there are other devices besides Android??) 47
  • 48. DEMO  Demos: • Mobile clients using client specific rendering Not confidential. Tell everyone.
  • 49. multi client development with Spring Spring Android 49
  • 50. Thin, Thick, Web, Mobile and Rich Clients: Mobile  Spring REST is ideal for mobile devices  Spring MVC 3.1 mobile client-specific content negotiation and rendering • for other devices  Spring Android • RestTemplate 50
  • 52. Thin, Thick, Web, Mobile and Rich Clients: Mobile CustomerServiceClient - client ! private <T> T extractResponse( ResponseEntity<T> response) { ! ! if (response != null && response().value() == 200) { ! ! ! return response.getBody(); ! ! } ! ! throw new RuntimeException("couldn't extract response."); ! } ! @Override ! public Customer updateCustomer(long id, String fn, String ln) { ! ! String urlForPath = urlForPath("customer/{customerId}");!! ! ! return extractResponse(this.restTemplate.postForEntity( urlForPath, new Customer(id, fn, ln), Customer.class, id)); ! } 52
  • 53. Thin, Thick, Web, Mobile and Rich Clients: Mobile  Demos: • consuming the Spring REST service from Android
  • 54. One Other approach  HTML5 all the way! • HTML5 on the desktop browser interface • HTML5 + PhoneGap on the client • RESTful services on the server side to connect it all
  • 55. springsource.org | cloudfoundry.org Questions? Say hi! @starbuxman | josh.long@springsource.com

Notas del editor

  1. \n
  2. \n\n
  3. Hello, thank you or having me. Im pleased to have the opportunity to introduce you today to Spring and the SpringSource Tool Suite \n\nMy anem is Josh Long. I serve as the developer advocate for the Spring framework. I&amp;#x2019;ve used it in earnest and advocated it for many years now. i&amp;#x2019;m an author on 3 books on the technology, as well as a comitter to many of the Spring projects. Additionally, I take community activism very seriously and do my best to participate in the community. Sometimes this means answering question on Twitter, or in the forums, or helping contribute to the InfoQ.com and Artima.com communities\n
  4. Hello, thank you or having me. Im pleased to have the opportunity to introduce you today to Spring and the SpringSource Tool Suite \n\nMy anem is Josh Long. I serve as the developer advocate for the Spring framework. I&amp;#x2019;ve used it in earnest and advocated it for many years now. i&amp;#x2019;m an author on 3 books on the technology, as well as a comitter to many of the Spring projects. Additionally, I take community activism very seriously and do my best to participate in the community. Sometimes this means answering question on Twitter, or in the forums, or helping contribute to the InfoQ.com and Artima.com communities\n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pices are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  13. \n
  14. \n
  15. \n
  16. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pices are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  17. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pices are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  18. Familiar to somebody who&amp;#x2019;s used Struts:\n Models (like Struts ActionForms)\n Views (like Struts views: tiles, .jsp(x)s, velocity, PDF, Excel, etc.) \n Controllers (like Struts Actions)\n\n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pices are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pieces are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  39. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pieces are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pices are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  46. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pices are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  47. \n
  48. \n
  49. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pices are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  50. \n
  51. \n
  52. \n
  53. \n
  54. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pices are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  55. \n
  56. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pices are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  57. \n
  58. talk about how convenient the messaging support is, then roll back and start looking at how u might do the same thing manually. Explain that many of the pices are already there, and then seguqe into a discussion about the core Spring APIs. Lets imagine we&amp;#x2019;re going to build ourselves a file system poller to notify us of when something&amp;#x2019;s happened on the file system\n\n
  59. another example of the fact that often the client side model won&amp;#x2019;t represent the server side model \n\n
  60. \n