SlideShare a Scribd company logo
Multi Client Development with Spring MVC
@ Java2Days
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 Josh Long

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




                             2
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




                             3
Why Are We Here?




       โ€œ   Software entities (classes,
           modules, functions, etc.) should
           be open for extension, but closed
           for modification.
                                               โ€
                             -Bob Martin




                                                   4
Why Are We Here?



                   do NOT reinvent
                   the Wheel!




                                     5
Springโ€™s aim:
 bring simplicity to java development
                                                                data
  web tier
                                 batch       integration &     access
    &         service tier                                                      mobile
                              processing      messaging      / NoSQL /
   RIA
                                                             Big Data


                             The Spring framework
the cloud:                     lightweight                      traditional
       CloudFoundry                                                   WebSphere
                                           tc Server
     Google App Engine                                                 JBoss AS
                                            Tomcat
     Amazon BeanStalk                                                 WebLogic
                                              Jetty
          Others                                                  (on legacy versions, too!)




                                                                                               6
Not All Sides Are Equal




                          7
Spring Web Support




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

         AnnotationCon๏ฌgWebApplicationContext ac =
                   new AnnotationCon๏ฌgWebApplicationContext();
         ac.setServletContext(sc);
         ac.scan( โ€œa.package.full.of.servicesโ€, โ€œa.package.full.of.controllersโ€ );

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

     }
 }




                                                                                       9
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




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

 @Controller
 public class CustomerController {


 }




                                          13
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

                                                   14
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

                                                    15
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

                                                                      16
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

                                                                                       17
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

                                                                       18
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

                                                                                   19
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โ€;
     }

 }




                                                                                   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 View processTheRequest( HttpServletRequest request, Model model) {
         return new XsltView(...);
     }

 }




                                                                                 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 InputStream processTheRequest( HttpServletRequest request, Model model) {
         return new FileInputStream( ...) ;
     }

 }




                                                                                        22
DEMO
๏‚ง Demos
 โ€ข Simple Spring MVC based Application




                             Not confidential. Tell everyone.
the new hotness...




                     24
dumb terminals ruled the earth....




                                     25
then something magical happened: the web




                                           26
but the web didnโ€™t know how to do UI state... so we hacked...




                                                                27
....then the web stopped sucking




                                   28
How Powerful is JavaScript? ...It Boots Linux!!




                                                  29
REST




       30
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
                                                                                        31
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
                                                                                 34
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
                                                            35
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;

 }




                                                                  36
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

                                                                                      37
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

                                                                                      38
What About the Browsers, Man?

โ€ข Problem: modern browsers only speak GET and POST
โ€ข Solution: use Springโ€™s HiddenHttpMethodFilter only then send _method request
 parameter in the request

<๏ฌlter>
    <๏ฌlter-name>hiddenHttpMethodFilter</๏ฌlter-name>
    <๏ฌlter-class>org.springframework.web.๏ฌlter.HiddenHttpMethodFilter</๏ฌlter-class
  </๏ฌlter>
  <๏ฌlter-mapping>
    <๏ฌlter-name>hiddenHttpMethodFilter</๏ฌlter-name>
    <url-pattern>/</url-pattern>
    <servlet-name>appServlet</servlet-name>
  </๏ฌlter-mapping>
DEMO
๏‚ง Demos:
โ€ข Spring REST service
โ€ข Spring REST client




                        Not confidential. Tell everyone.
Spring Mobile




                41
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??)




                                                                  42
DEMO
๏‚ง Demos:
โ€ข Mobile clients using client specific rendering




                                  Not confidential. Tell everyone.
Spring Android




                 44
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




                                                                45
OK, so.....




              46
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));
!    }




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

๏‚ง Demos:
โ€ข consuming the Spring REST service from Android
And The REST of it

โ€ข Spring Data REST - exposes (JPA, MongoDB, GemFire, Neo4J, Redis) repositories built
 on Spring Data repositories (See my friend Sergiโ€™s talk!)
โ€ข Spring HATEOAS - take your REST-fu to the next level with support for HTTP as the
 engine of application state
โ€ข Spring Security OAuth - secure RESTful web services using OAuth, the same security
 technology that Twitter, Facebook, etc.
โ€ข Spring Social - RestTemplate is powerful, but some APIs are overwhelming, and OAuth
 client communication can be daunting. Spring Social makes it easier.
@starbuxman | josh.long@springsource.com
        http://slideshare.net/joshlong




           Questions?
Ad

More Related Content

What's hot (20)

Spring MVC
Spring MVCSpring MVC
Spring MVC
Emprovise
ย 
Spring Boot Actuator
Spring Boot ActuatorSpring Boot Actuator
Spring Boot Actuator
Rowell Belen
ย 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
kamal kotecha
ย 
Spring MVC Basics
Spring MVC BasicsSpring MVC Basics
Spring MVC Basics
Bozhidar Bozhanov
ย 
Spring boot for buidling microservices
Spring boot for buidling microservicesSpring boot for buidling microservices
Spring boot for buidling microservices
Nilanjan Roy
ย 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depth
Vinay Kumar
ย 
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
Guy Nir
ย 
a Running Tour of Cloud Foundry
a Running Tour of Cloud Foundrya Running Tour of Cloud Foundry
a Running Tour of Cloud Foundry
Joshua Long
ย 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Guo Albert
ย 
Spring4 whats up doc?
Spring4 whats up doc?Spring4 whats up doc?
Spring4 whats up doc?
David Gรณmez Garcรญa
ย 
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
David Gรณmez Garcรญa
ย 
Don't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadDon't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 Instead
WASdev Community
ย 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
Guy Nir
ย 
Spring Portlet MVC
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVC
John Lewis
ย 
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
Joshua Long
ย 
Spring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerSpring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen Hoeller
ZeroTurnaround
ย 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
deepak kumar
ย 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsi krishna
ย 
ASP.NET MVC 4 Request Pipeline Internals
ASP.NET MVC 4 Request Pipeline InternalsASP.NET MVC 4 Request Pipeline Internals
ASP.NET MVC 4 Request Pipeline Internals
Lukasz Lysik
ย 
Web Tech Java Servlet Update1
Web Tech   Java Servlet Update1Web Tech   Java Servlet Update1
Web Tech Java Servlet Update1
vikram singh
ย 
Spring MVC
Spring MVCSpring MVC
Spring MVC
Emprovise
ย 
Spring Boot Actuator
Spring Boot ActuatorSpring Boot Actuator
Spring Boot Actuator
Rowell Belen
ย 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
kamal kotecha
ย 
Spring boot for buidling microservices
Spring boot for buidling microservicesSpring boot for buidling microservices
Spring boot for buidling microservices
Nilanjan Roy
ย 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depth
Vinay Kumar
ย 
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
Guy Nir
ย 
a Running Tour of Cloud Foundry
a Running Tour of Cloud Foundrya Running Tour of Cloud Foundry
a Running Tour of Cloud Foundry
Joshua Long
ย 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Guo Albert
ย 
Don't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadDon't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 Instead
WASdev Community
ย 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
Guy Nir
ย 
Spring Portlet MVC
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVC
John Lewis
ย 
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
Joshua Long
ย 
Spring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerSpring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen Hoeller
ZeroTurnaround
ย 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
deepak kumar
ย 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsi krishna
ย 
ASP.NET MVC 4 Request Pipeline Internals
ASP.NET MVC 4 Request Pipeline InternalsASP.NET MVC 4 Request Pipeline Internals
ASP.NET MVC 4 Request Pipeline Internals
Lukasz Lysik
ย 
Web Tech Java Servlet Update1
Web Tech   Java Servlet Update1Web Tech   Java Servlet Update1
Web Tech Java Servlet Update1
vikram singh
ย 

Similar to Multi Client Development with Spring (20)

Spring MVC introduction HVA
Spring MVC introduction HVASpring MVC introduction HVA
Spring MVC introduction HVA
Peter Maas
ย 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
Tuna Tore
ย 
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
Tuna Tore
ย 
Unit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptxUnit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptx
AbhijayKulshrestha1
ย 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web Framework
Luther Baker
ย 
Jinal desai .net
Jinal desai .netJinal desai .net
Jinal desai .net
rohitkumar1987in
ย 
A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom
Joshua Long
ย 
Module 5.ppt.............................
Module 5.ppt.............................Module 5.ppt.............................
Module 5.ppt.............................
Betty333100
ย 
Spring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUGSpring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUG
Ted Pennings
ย 
Spring5 New Features
Spring5 New FeaturesSpring5 New Features
Spring5 New Features
Jay Lee
ย 
Struts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web ApplicationsStruts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web Applications
elliando dias
ย 
MVC 1.0 als alternative Webtechnologie
MVC 1.0 als alternative WebtechnologieMVC 1.0 als alternative Webtechnologie
MVC 1.0 als alternative Webtechnologie
OPEN KNOWLEDGE GmbH
ย 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
Mayank Srivastava
ย 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
Minal Maniar
ย 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
GWTcon
ย 
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
Joshua Long
ย 
Easy integration of Bluemix services with your applications
Easy integration of Bluemix services with your applicationsEasy integration of Bluemix services with your applications
Easy integration of Bluemix services with your applications
Jack-Junjie Cai
ย 
Spring 3.1: a Walking Tour
Spring 3.1: a Walking TourSpring 3.1: a Walking Tour
Spring 3.1: a Walking Tour
Joshua Long
ย 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
SachinSingh217687
ย 
ASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web developmentASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web development
Volodymyr Voytyshyn
ย 
Spring MVC introduction HVA
Spring MVC introduction HVASpring MVC introduction HVA
Spring MVC introduction HVA
Peter Maas
ย 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
Tuna Tore
ย 
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
Tuna Tore
ย 
Unit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptxUnit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptx
AbhijayKulshrestha1
ย 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web Framework
Luther Baker
ย 
A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom
Joshua Long
ย 
Module 5.ppt.............................
Module 5.ppt.............................Module 5.ppt.............................
Module 5.ppt.............................
Betty333100
ย 
Spring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUGSpring MVC Intro / Gore - Nov NHJUG
Spring MVC Intro / Gore - Nov NHJUG
Ted Pennings
ย 
Spring5 New Features
Spring5 New FeaturesSpring5 New Features
Spring5 New Features
Jay Lee
ย 
Struts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web ApplicationsStruts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web Applications
elliando dias
ย 
MVC 1.0 als alternative Webtechnologie
MVC 1.0 als alternative WebtechnologieMVC 1.0 als alternative Webtechnologie
MVC 1.0 als alternative Webtechnologie
OPEN KNOWLEDGE GmbH
ย 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
Mayank Srivastava
ย 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
Minal Maniar
ย 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
GWTcon
ย 
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
Joshua Long
ย 
Easy integration of Bluemix services with your applications
Easy integration of Bluemix services with your applicationsEasy integration of Bluemix services with your applications
Easy integration of Bluemix services with your applications
Jack-Junjie Cai
ย 
Spring 3.1: a Walking Tour
Spring 3.1: a Walking TourSpring 3.1: a Walking Tour
Spring 3.1: a Walking Tour
Joshua Long
ย 
ASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web developmentASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web development
Volodymyr Voytyshyn
ย 
Ad

More from Joshua Long (20)

Economies of Scaling Software
Economies of Scaling SoftwareEconomies of Scaling Software
Economies of Scaling Software
Joshua Long
ย 
Bootiful Code with Spring Boot
Bootiful Code with Spring BootBootiful Code with Spring Boot
Bootiful Code with Spring Boot
Joshua Long
ย 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
Joshua Long
ย 
Boot It Up
Boot It UpBoot It Up
Boot It Up
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 2013
Joshua 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 Clarkson
Joshua Long
ย 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
Joshua Long
ย 
Extending spring
Extending springExtending spring
Extending spring
Joshua Long
ย 
The spring 32 update final
The spring 32 update finalThe spring 32 update final
The spring 32 update final
Joshua 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 Foundry
Joshua Long
ย 
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
Joshua Long
ย 
Spring in-the-cloud
Spring in-the-cloudSpring in-the-cloud
Spring in-the-cloud
Joshua Long
ย 
Spring Batch Behind the Scenes
Spring Batch Behind the ScenesSpring Batch Behind the Scenes
Spring Batch Behind the Scenes
Joshua Long
ย 
Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
Joshua Long
ย 
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
Joshua Long
ย 
Extending Spring for Custom Usage
Extending Spring for Custom UsageExtending Spring for Custom Usage
Extending Spring for Custom Usage
Joshua Long
ย 
Using Spring's IOC Model
Using Spring's IOC ModelUsing Spring's IOC Model
Using Spring's IOC Model
Joshua 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 Foundry
Joshua Long
ย 
Cloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and VaadinCloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and Vaadin
Joshua Long
ย 
Economies of Scaling Software
Economies of Scaling SoftwareEconomies of Scaling Software
Economies of Scaling Software
Joshua Long
ย 
Bootiful Code with Spring Boot
Bootiful Code with Spring BootBootiful Code with Spring Boot
Bootiful Code with Spring Boot
Joshua Long
ย 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
Joshua Long
ย 
Boot It Up
Boot It UpBoot It Up
Boot It Up
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 2013
Joshua 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 Clarkson
Joshua Long
ย 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
Joshua Long
ย 
Extending spring
Extending springExtending spring
Extending spring
Joshua Long
ย 
The spring 32 update final
The spring 32 update finalThe spring 32 update final
The spring 32 update final
Joshua 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 Foundry
Joshua Long
ย 
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
Joshua Long
ย 
Spring in-the-cloud
Spring in-the-cloudSpring in-the-cloud
Spring in-the-cloud
Joshua Long
ย 
Spring Batch Behind the Scenes
Spring Batch Behind the ScenesSpring Batch Behind the Scenes
Spring Batch Behind the Scenes
Joshua Long
ย 
Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
Joshua Long
ย 
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
Joshua Long
ย 
Extending Spring for Custom Usage
Extending Spring for Custom UsageExtending Spring for Custom Usage
Extending Spring for Custom Usage
Joshua Long
ย 
Using Spring's IOC Model
Using Spring's IOC ModelUsing Spring's IOC Model
Using Spring's IOC Model
Joshua 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 Foundry
Joshua Long
ย 
Cloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and VaadinCloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and Vaadin
Joshua Long
ย 
Ad

Recently uploaded (20)

Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
ย 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
ย 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
ย 
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
ย 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
ย 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
ย 
Learn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step GuideLearn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step Guide
Marcel David
ย 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
ย 
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy ConsumptionDrupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Exove
ย 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
ย 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
ย 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
ย 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
ย 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
ย 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
ย 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
ย 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
ย 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
ย 
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
ย 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
ย 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
ย 
Learn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step GuideLearn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step Guide
Marcel David
ย 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
ย 
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy ConsumptionDrupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Exove
ย 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
ย 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
ย 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
ย 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
ย 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
ย 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
ย 

Multi Client Development with Spring

  • 1. Multi Client Development with Spring MVC @ Java2Days Josh Long Spring Developer Advocate SpringSource, a Division of VMware http://www.joshlong.com || @starbuxman || [email protected] ยฉ 2009 VMware Inc. All rights reserved
  • 2. About Josh Long Spring Developer Advocate twitter: @starbuxman [email protected] 2
  • 3. About Josh Long Spring Developer Advocate twitter: @starbuxman [email protected] Contributor To: โ€ขSpring Integration โ€ขSpring Batch โ€ขSpring Hadoop โ€ขActiviti Workflow Engine โ€ขAkka Actor engine 3
  • 4. Why Are We Here? โ€œ Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification. โ€ -Bob Martin 4
  • 5. Why Are We Here? do NOT reinvent the Wheel! 5
  • 6. Springโ€™s aim: bring simplicity to java development data web tier batch integration & access & service tier mobile processing messaging / NoSQL / RIA Big Data The Spring framework the cloud: lightweight traditional CloudFoundry WebSphere tc Server Google App Engine JBoss AS Tomcat Amazon BeanStalk WebLogic Jetty Others (on legacy versions, too!) 6
  • 7. Not All Sides Are Equal 7
  • 9. 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 { AnnotationCon๏ฌgWebApplicationContext ac = new AnnotationCon๏ฌgWebApplicationContext(); ac.setServletContext(sc); ac.scan( โ€œa.package.full.of.servicesโ€, โ€œa.package.full.of.controllersโ€ ); sc.addServlet("spring", new DispatcherServlet(webContext)); } } 9
  • 10. 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
  • 11. 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
  • 12. Thin, Thick, Web, Mobile and Rich Clients: Spring MVC 12
  • 13. The Anatomy of a Spring MVC @Controller Spring MVC configuration - config @Controller public class CustomerController { } 13
  • 14. 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 14
  • 15. 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 15
  • 16. 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 16
  • 17. 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 17
  • 18. 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 18
  • 19. 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 19
  • 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( HttpServletRequest request, Model model) { return โ€œhomeโ€; } } 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 View processTheRequest( HttpServletRequest request, Model model) { return new XsltView(...); } } 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 InputStream processTheRequest( HttpServletRequest request, Model model) { return new FileInputStream( ...) ; } } 22
  • 23. DEMO ๏‚ง Demos โ€ข Simple Spring MVC based Application Not confidential. Tell everyone.
  • 25. dumb terminals ruled the earth.... 25
  • 26. then something magical happened: the web 26
  • 27. but the web didnโ€™t know how to do UI state... so we hacked... 27
  • 28. ....then the web stopped sucking 28
  • 29. How Powerful is JavaScript? ...It Boots Linux!! 29
  • 30. REST 30
  • 31. 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 31
  • 32. 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
  • 33. 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)
  • 34. 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 34
  • 35. 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 35
  • 36. 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; } 36
  • 37. 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 37
  • 38. 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 38
  • 39. What About the Browsers, Man? โ€ข Problem: modern browsers only speak GET and POST โ€ข Solution: use Springโ€™s HiddenHttpMethodFilter only then send _method request parameter in the request <๏ฌlter> <๏ฌlter-name>hiddenHttpMethodFilter</๏ฌlter-name> <๏ฌlter-class>org.springframework.web.๏ฌlter.HiddenHttpMethodFilter</๏ฌlter-class </๏ฌlter> <๏ฌlter-mapping> <๏ฌlter-name>hiddenHttpMethodFilter</๏ฌlter-name> <url-pattern>/</url-pattern> <servlet-name>appServlet</servlet-name> </๏ฌlter-mapping>
  • 40. DEMO ๏‚ง Demos: โ€ข Spring REST service โ€ข Spring REST client Not confidential. Tell everyone.
  • 42. 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??) 42
  • 43. DEMO ๏‚ง Demos: โ€ข Mobile clients using client specific rendering Not confidential. Tell everyone.
  • 45. 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 45
  • 47. 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)); ! } 47
  • 48. Thin, Thick, Web, Mobile and Rich Clients: Mobile ๏‚ง Demos: โ€ข consuming the Spring REST service from Android
  • 49. And The REST of it โ€ข Spring Data REST - exposes (JPA, MongoDB, GemFire, Neo4J, Redis) repositories built on Spring Data repositories (See my friend Sergiโ€™s talk!) โ€ข Spring HATEOAS - take your REST-fu to the next level with support for HTTP as the engine of application state โ€ข Spring Security OAuth - secure RESTful web services using OAuth, the same security technology that Twitter, Facebook, etc. โ€ข Spring Social - RestTemplate is powerful, but some APIs are overwhelming, and OAuth client communication can be daunting. Spring Social makes it easier.
  • 50. @starbuxman | [email protected] http://slideshare.net/joshlong Questions?

Editor's Notes

  • #2: \n
  • #3: \n\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: 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
  • #6: \n
  • #7: \n
  • #8: these different framerworks let u tackle any problem youre likely to want to solve today \n- we support javee1.4 + 1.5 + 1.6; \n\nsits above target platform \nruns in cloud \n\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: 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
  • #14: 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
  • #15: \n
  • #16: \n
  • #17: \n
  • #18: \n
  • #19: \n
  • #20: \n
  • #21: \n
  • #22: \n
  • #23: \n
  • #24: \n
  • #25: 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
  • #26: \n
  • #27: \n
  • #28: \n
  • #29: \n
  • #30: \n
  • #31: \n
  • #32: \n
  • #33: \n
  • #34: \n
  • #35: 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
  • #36: 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
  • #37: \n
  • #38: \n
  • #39: \n
  • #40: \n
  • #41: \n
  • #42: 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
  • #43: 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
  • #44: \n
  • #45: \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: \n
  • #50: \n
  • #51: 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
  • #52: \n
  • #53: 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
  • #54: \n
  • #55: 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
  • #56: another example of the fact that often the client side model won&amp;#x2019;t represent the server side model \n\n
  • #57: \n
  • #58: \n
  • #59: \n
  • #60: \n
  • #61: \n
  • #62: \n
  • #63: \n
  • #64: \n
  • #65: \n
  • #66: \n
  • #67: \n
  • #68: \n
  • #69: \n
  • #70: \n
  • #71: \n
  • #72: \n
  • #73: \n
  • #74: \n
  • #75: \n
  • #76: \n
  • #77: \n
  • #78: \n
  • #79: \n
  • #80: \n
  • #81: \n
  • #82: \n
  • #83: \n
  • #84: \n
  • #85: \n
  • #86: \n
  • #87: \n
  • #88: \n
  • #89: \n
  • #90: \n
  • #91: \n
  • #92: \n
  • #93: \n
  • #94: \n
  • #95: \n
  • #96: \n
  • #97: \n
  • #98: \n
  • #99: \n
  • #100: \n
  • #101: \n
  • #102: \n
  • #103: \n
  • #104: \n
  • #105: \n
  • #106: \n
  • #107: \n
  • #108: \n
  • #109: \n
  • #110: \n
  • #111: \n
  • #112: \n
  • #113: \n
  • #114: \n
  • #115: \n
  • #116: \n
  • #117: \n
  • #118: \n
  • #119: \n
  • #120: \n
  • #121: \n
  • #122: \n
  • #123: \n
  • #124: \n
  • #125: \n
  • #126: \n
  • #127: \n
  • #128: \n
  • #129: \n
  • #130: \n
  • #131: \n
  • #132: \n
  • #133: \n
  • #134: \n
  • #135: \n
  • #136: \n
  • #137: \n
  • #138: \n
  • #139: 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
  • #140: \n