SlideShare una empresa de Scribd logo
1 de 73
Descargar para leer sin conexión
Spring 3.1 in a Nutshell
  Sam Brannen / Swiftmind
Speaker Profile


•    Spring & Java consultant @ Swiftmind
•    Developing Java for over 13 years
•    Spring Framework Core Developer
•    Spring Trainer
•    Lead author of “Spring in a Nutshell”
Agenda
•    Major Themes in 3.x
•    Environment and Profiles
•    Java-based Configuration
•    Testing
•    Caching
•    MVC and REST
•    Servlet 3.0
•    Odds & Ends
Major Themes in Spring 3.0
Java-based configuration
custom stereotypes
annotated factory methods
JSR-330 – DI for Java
Spring Expression Language
REST support in Spring MVC
Portlet API 2.0
JSR-303 – bean validation
Java EE 6 support: JPA 2.0, JSF 2.0
Major Themes in Spring 3.1

–  Environment abstraction
–  Java-based application configuration
–  @Configuration class test support
–  High-level cache API
–  Customizable @MVC processing
–  Flash maps and redirect attributes
–  Explicit support for Servlet 3.0
Environment and Profiles
Environment Abstraction
–  Injectable environment abstraction API
     •  org.springframework.core.env.Environment


–  Two core concepts
     •  Property Sources
     •  Bean Profiles

Property Source:                 Bean Profile:

A variety of sources: property   A logical group of bean
files, system properties,        definitions. Registered only if
servlet context, JNDI, etc.      the profile is active.
Property Source Abstraction

–  Property source

–  Property resolution

–  Placeholders
PropertySource(s)

–  PropertySource
  •  a single property source


–  PropertySources
  •  a hierarchy of PropertySource objects
  •  potentially varying across deployment environments
Property Resolution SPI

–  org.springframework.core.env.PropertyResolver

–  Environment extends PropertyResolver
Custom resolution of
          placeholders
–  dependent on the actual environment

–  PropertySourcesPlaceholderConfigurer
   supersedes PropertyPlaceholderConfigurer
Managing Property Sources

–  Stand-alone code




–  Web application
  •  Implement ApplicationContextInitializer
  •  Register via contextInitializerClasses context
     parameter in web.xml
Accessing Properties

–  By injecting the Environment
Bean Definition Profiles

–  Logical grouping of bean definitions
  •  for activation in specific environments
  •  e.g., dev, staging, prod
  •  possibly different deployment platforms


–  Configuration
  •  XML via <beans profile=“…”>
  •  Java-based configuration via @Profile
Configuring Profiles in XML
–  All bean definitions




–  Subset of bean definitions
Configuring Profiles in Java
           Config




                                               25


–  @Profile can also be used on components
  •  @Component, @Service, @Repository, etc.
Profile Activation Options

–  programmatically

–  system property

–  in web.xml

–  in tests via @ActiveProfiles
Activating Profiles…
 programmatically
Activating Profiles…
      via system properties

-Dspring.profiles.active=“dev”

-Dspring.profiles.default=“common”
Activating Profiles…
    in web apps
Activating Profiles…
 in integration tests
Java-based Configuration
Java Config ~= XML

–  XML namespaces à @Enable*
–  FactoryBeans à builders
–  GenericXmlContextLoader à
   AnnotationConfigContextLoader

–  Not a one-to-one mapping
  •  Make the most of what Java has to offer
  •  Intuitive annotation-oriented container configuration
Typical Infrastructure Setup

–  Transactions

–  Scheduling

–  MVC customization

–  AOP
@Enable* Annotations

–  Applied at the class-level on @Configuration
   classes

–  Roughly equivalent to their XML namespace
   counterparts
@Enable* in 3.1 RC1

–  @EnableTransactionManagement
–  @EnableAsync
–  @EnableScheduling
–  @EnableAspectJAutoProxy
–  @EnableLoadTimeWeaving
–  @EnableWebMvc
Hibernate and JPA

–  Hibernate LocalSessionFactoryBuilder API
  •  Hibernate 4 replacement for both
     LocalSessionFactoryBean and
     AnnotationSessionFactoryBean


–  XML-free JPA configuration
  •  LocalContainerEntityManagerFactoryBean has a
     new property
  •  packagesToScan: analogous to
     AnnotationSessionFactoryBean
Java Configuration Example


                 Actually:
                 LocalSessionFactoryBuilder
New Testing Features in 3.1

–  @Configuration class support
–  Environment profile support
–  SmartContextLoader
–  AnnotationConfigContextLoader
–  DelegatingSmartContextLoader
–  Updated context cache key generation
SmartContextLoader SPI

–  Supersedes ContextLoader
–  Strategy for loading application contexts
–  From @Configuration classes or resource
   locations
–  Supports environment profiles
@ContextConfiguration

accepts a new `classes` attribute...
Ex: @Configuration Test #1
Ex: @Configuration Test #2
Caching
Caching Abstraction

–  Declarative caching for Spring applications
  •  Minimal impact on code
  •  Plug in various caching solutions

–  Key annotations @Cacheable and
   @CacheEvict
Cache Key

–  All method arguments used by default




–  Use SpEL to select more specifically (use class,
   method, or argument name)
Conditional Caching
Cache Providers (1/2)

–  Cache and CacheManager SPI
  •  org.springframework.cache


–  Cache Implementations
  •  EhCacheCache
  •  ConcurrentMapCache and
     ConcurrentMapCacheFactoryBean
Cache Providers (2/2)

–  CacheManager Implementations
  •  EhCacheCacheManager
  •  ConcurrentMapCacheManager
  •  SimpleCacheManager
  •  NoOpCacheManager


–  Any other implementation can be plugged in
  •  GemFire, Coherence, etc.
Cache Configuration

–  Cache namespace
  •  <cache:annotation-driven />
  •  “cacheManager” bean
MVC and REST
@MVC 3.0 Config
–  Built-in defaults
   •  Based on DispatcherServlet.properties

–  Spring MVC namespace
   •  <mvc:annotation:driven>, <mvc:interceptors>, …
Java-based @MVC 3.1 Config

–  Most Spring MVC configuration is in Java
   already
  •  @Controller, @RequestMapping, etc.

–  Servlet 3.0 enhancements will further reduce
   the need for web.xml

–  XML namespace is convenient but …
  •  Not transparent
  •  Not easy to offer the right degree of customization
@EnableWebMvc

–  Enables Spring MVC default configuration
  •  Registers components expected by the
     DispatcherServlet




–  Allows for configuration similar to the
   Spring MVC namespace
  •  … and the DispatcherServlet.properties combined
A More Complete Example …
–  Add component scanning for @Controllers
   and other beans
Q: Where is the “Enabled”
      Configuration ?!
–  A: a framework-provided @Configuration class
   (actually DelegatingWebMvcConfiguration)
How Do I Customize All This?
–  Simply implement the WebMvcConfigurer
   interface
                               Allows selective overriding
HandlerMethod Abstraction
–  HandlerMethod
    •  A proper abstraction for the selected “handler” in Spring
       MVC

–  Not just for @RequestMapping methods
    •  Also @InitBinder, @ModelAttribute, @ExceptionHandler
       methods

–  “HandlerMethod” support classes
    •  RequestMappingHandlerMapping
    •  RequestMappingHandlerAdapter
    •  ExceptionHandlerExceptionResolver
Path Variables in the Model

–  @PathVariable arguments automatically
   added to the model




                             These can be deleted
URI Templates in Redirect
          Strings
–  URL templates supported in “redirect:”
   strings




                 Expanded from model attributes,
                which now include @PathVariables
URI Template Variables in
        Data Binding
–  URI template variables used in data binding
Matching MediaTypes < @MVC 3.1

  –  Using the 'headers' condition
Matching MediaTypes in @MVC 3.1

  –  The 'consumes' and 'produces' conditions



                   If not matched, results in:
                   UNSUPPORTED_MEDIA_TYPE (415)




                          If not matched, results in:
                          NOT_ACCEPTABLE (406)
Servlet 3.0
Servlet 3.0 Containers

•  Tomcat 7 and GlassFish 3
  –  Explicitly supported

•  While preserving compatibility with Servlet
   2.4+
XML-free Web-app Config

•  Support for XML-free web application setup
  –  no web.xml


•  Made possible via:
  –  Servlet 3.0's ServletContainerInitializer
  –  Spring 3.1's
     AnnotationConfigWebApplicationContext
  –  Spring 3.1’s environment abstraction
Native Servlet 3.0 in @MVC

•  Asynchronous request processing

•  Standard Servlet 3.0 file upload
  –  behind Spring's MultipartResolver abstraction
Odds & Ends
"c:" Namespace

–  Shortcut for <constructor-arg>
  •  inline argument values
  •  analogous to existing "p:" namespace
–  Use of constructor argument names
  •  recommended for readability
  •  debug symbols have to be available in the
     application's class files
The Spring Roadmap

•  Spring 3.1 RC2: mid November

•  Spring 3.1 GA:     Before end of 2011

•  Spring 3.2:        Planned for early 2012
  –  Java EE: JSF 2.2, JPA 2.1, etc.
Spring 3.1 in a Nutshell

•    Environment and Profiles
•    Java-based Configuration and @Enable*
•    Testing with @Configuration and Profiles
•    Cache Abstraction
•    MVC and REST Improvements
•    Servlet 3.0
•    c: Namespace
Further Resources

•  Spring Framework
  –  http://springframework.org
  –  Spring Reference Manual
  –  JavaDoc
•  Spring Forums
  –  http://forum.springframework.org
•  Spring JIRA
  –  http://jira.springframework.org
Blogs

•  SpringSource Team Blog – category 3.1
  –  http://blog.springsource.com/category/spring/31/


•  Swiftmind Blog
  –  http://www.swiftmind.com/blog/
Q&A


Sam Brannen                         twitter: @sam_brannen
Swiftmind                           www.slideshare.net/sbrannen
                                    www.swiftmind.com



“Spring in a Nutshell”
http://oreilly.com/catalog/9780596801946
available from O’Reilly in 2012

Más contenido relacionado

La actualidad más candente

Java colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rsJava colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rsSagara Gunathunga
 
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
 
JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup Sagara Gunathunga
 
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJosh Juneau
 
WebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload ProtectionWebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload ProtectionJames Bayer
 
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010Arun Gupta
 
Weblogic performance tuning2
Weblogic performance tuning2Weblogic performance tuning2
Weblogic performance tuning2Aditya Bhuyan
 
WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleJames Bayer
 
Oracle Weblogic Server 11g: System Administration I
Oracle Weblogic Server 11g: System Administration IOracle Weblogic Server 11g: System Administration I
Oracle Weblogic Server 11g: System Administration ISachin Kumar
 
weblogic training | oracle weblogic online training | weblogic server course
weblogic training | oracle weblogic online training | weblogic server courseweblogic training | oracle weblogic online training | weblogic server course
weblogic training | oracle weblogic online training | weblogic server courseNancy Thomas
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session ManagementFahad Golra
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Robert Scholte
 
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 InsteadWASdev Community
 
.NET Core, ASP.NET Core Course, Session 10
.NET Core, ASP.NET Core Course, Session 10.NET Core, ASP.NET Core Course, Session 10
.NET Core, ASP.NET Core Course, Session 10aminmesbahi
 
Core web application development
Core web application developmentCore web application development
Core web application developmentBahaa Farouk
 

La actualidad más candente (19)

Java colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rsJava colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rs
 
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
 
JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup
 
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVC
 
WebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload ProtectionWebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload Protection
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
 
Weblogic performance tuning2
Weblogic performance tuning2Weblogic performance tuning2
Weblogic performance tuning2
 
WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan Example
 
Oracle Weblogic Server 11g: System Administration I
Oracle Weblogic Server 11g: System Administration IOracle Weblogic Server 11g: System Administration I
Oracle Weblogic Server 11g: System Administration I
 
weblogic training | oracle weblogic online training | weblogic server course
weblogic training | oracle weblogic online training | weblogic server courseweblogic training | oracle weblogic online training | weblogic server course
weblogic training | oracle weblogic online training | weblogic server course
 
jsf2 Notes
jsf2 Notesjsf2 Notes
jsf2 Notes
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session Management
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 
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
 
Weblogic server cluster
Weblogic server clusterWeblogic server cluster
Weblogic server cluster
 
Introduction to weblogic
Introduction to weblogicIntroduction to weblogic
Introduction to weblogic
 
.NET Core, ASP.NET Core Course, Session 10
.NET Core, ASP.NET Core Course, Session 10.NET Core, ASP.NET Core Course, Session 10
.NET Core, ASP.NET Core Course, Session 10
 
Core web application development
Core web application developmentCore web application development
Core web application development
 

Destacado

Spring Framework 4.1
Spring Framework 4.1Spring Framework 4.1
Spring Framework 4.1Sam Brannen
 
SQLAlchemy Core: An Introduction
SQLAlchemy Core: An IntroductionSQLAlchemy Core: An Introduction
SQLAlchemy Core: An IntroductionJason Myers
 
Lvs mini-howto
Lvs mini-howtoLvs mini-howto
Lvs mini-howtoSanjib Dey
 
LXF #102 - Linux Virtual Server
LXF #102 - Linux Virtual ServerLXF #102 - Linux Virtual Server
LXF #102 - Linux Virtual Serverguest69bec2
 
LXF #102 - Linux Virtual Server
LXF #102 - Linux Virtual Server LXF #102 - Linux Virtual Server
LXF #102 - Linux Virtual Server guest69bec2
 
OpenStack DVR_What is DVR?
OpenStack DVR_What is DVR?OpenStack DVR_What is DVR?
OpenStack DVR_What is DVR?Yongyoon Shin
 

Destacado (6)

Spring Framework 4.1
Spring Framework 4.1Spring Framework 4.1
Spring Framework 4.1
 
SQLAlchemy Core: An Introduction
SQLAlchemy Core: An IntroductionSQLAlchemy Core: An Introduction
SQLAlchemy Core: An Introduction
 
Lvs mini-howto
Lvs mini-howtoLvs mini-howto
Lvs mini-howto
 
LXF #102 - Linux Virtual Server
LXF #102 - Linux Virtual ServerLXF #102 - Linux Virtual Server
LXF #102 - Linux Virtual Server
 
LXF #102 - Linux Virtual Server
LXF #102 - Linux Virtual Server LXF #102 - Linux Virtual Server
LXF #102 - Linux Virtual Server
 
OpenStack DVR_What is DVR?
OpenStack DVR_What is DVR?OpenStack DVR_What is DVR?
OpenStack DVR_What is DVR?
 

Similar a Spring 3.1 in a Nutshell - JAX London 2011

Spring 3.1 in a Nutshell
Spring 3.1 in a NutshellSpring 3.1 in a Nutshell
Spring 3.1 in a NutshellSam Brannen
 
Spring 3.1: a Walking Tour
Spring 3.1: a Walking TourSpring 3.1: a Walking Tour
Spring 3.1: a Walking TourJoshua Long
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsSam Brannen
 
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010Arun Gupta
 
Spring data presentation
Spring data presentationSpring data presentation
Spring data presentationOleksii Usyk
 
Spring design-juergen-qcon
Spring design-juergen-qconSpring design-juergen-qcon
Spring design-juergen-qconYiwei Ma
 
A first Draft to Java Configuration
A first Draft to Java ConfigurationA first Draft to Java Configuration
A first Draft to Java ConfigurationAnatole Tresch
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 UpdateRyan Cuprak
 
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
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Arun Gupta
 
JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0Arun Gupta
 
4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part II4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part IIRohit Rao
 
Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Rossen Stoyanchev
 
Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Sam Brannen
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGArun Gupta
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An IntroductionSam Brannen
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionArun Gupta
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerArun Gupta
 

Similar a Spring 3.1 in a Nutshell - JAX London 2011 (20)

Spring 3.1 in a Nutshell
Spring 3.1 in a NutshellSpring 3.1 in a Nutshell
Spring 3.1 in a Nutshell
 
Spring 3.1: a Walking Tour
Spring 3.1: a Walking TourSpring 3.1: a Walking Tour
Spring 3.1: a Walking Tour
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web Applications
 
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
Servlets 3.0 - Asynchronous, Easy, Extensible @ Silicon Valley Code Camp 2010
 
Spring data presentation
Spring data presentationSpring data presentation
Spring data presentation
 
Next stop: Spring 4
Next stop: Spring 4Next stop: Spring 4
Next stop: Spring 4
 
Spring design-juergen-qcon
Spring design-juergen-qconSpring design-juergen-qcon
Spring design-juergen-qcon
 
A first Draft to Java Configuration
A first Draft to Java ConfigurationA first Draft to Java Configuration
A first Draft to Java Configuration
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
 
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
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
 
JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0
 
4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part II4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part II
 
Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2
 
Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An Introduction
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
 
Maven
MavenMaven
Maven
 

Más de Sam Brannen

Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Sam Brannen
 
Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022Sam Brannen
 
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019JUnit 5 - Evolution and Innovation - SpringOne Platform 2019
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019Sam Brannen
 
JUnit 5: What's New and What's Coming - Spring I/O 2019
JUnit 5: What's New and What's Coming - Spring I/O 2019JUnit 5: What's New and What's Coming - Spring I/O 2019
JUnit 5: What's New and What's Coming - Spring I/O 2019Sam Brannen
 
JUnit 5 - New Opportunities for Testing on the JVM
JUnit 5 - New Opportunities for Testing on the JVMJUnit 5 - New Opportunities for Testing on the JVM
JUnit 5 - New Opportunities for Testing on the JVMSam Brannen
 
Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2Sam Brannen
 
JUnit 5 - from Lambda to Alpha and beyond
JUnit 5 - from Lambda to Alpha and beyondJUnit 5 - from Lambda to Alpha and beyond
JUnit 5 - from Lambda to Alpha and beyondSam Brannen
 
Testing with Spring 4.x
Testing with Spring 4.xTesting with Spring 4.x
Testing with Spring 4.xSam Brannen
 
Composable Software Architecture with Spring
Composable Software Architecture with SpringComposable Software Architecture with Spring
Composable Software Architecture with SpringSam Brannen
 
Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Sam Brannen
 
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013Sam Brannen
 
Spring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSpring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSam Brannen
 
Spring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4DevelopersSpring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4DevelopersSam Brannen
 
Effective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4DevelopersEffective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4DevelopersSam Brannen
 
Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012Sam Brannen
 
Spring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSpring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSam Brannen
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Effective out-of-container Integration Testing
Effective out-of-container Integration TestingEffective out-of-container Integration Testing
Effective out-of-container Integration TestingSam Brannen
 
What's New in Spring 3.0
What's New in Spring 3.0What's New in Spring 3.0
What's New in Spring 3.0Sam Brannen
 
Modular Web Applications with OSGi
Modular Web Applications with OSGiModular Web Applications with OSGi
Modular Web Applications with OSGiSam Brannen
 

Más de Sam Brannen (20)

Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
 
Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022
 
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019JUnit 5 - Evolution and Innovation - SpringOne Platform 2019
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019
 
JUnit 5: What's New and What's Coming - Spring I/O 2019
JUnit 5: What's New and What's Coming - Spring I/O 2019JUnit 5: What's New and What's Coming - Spring I/O 2019
JUnit 5: What's New and What's Coming - Spring I/O 2019
 
JUnit 5 - New Opportunities for Testing on the JVM
JUnit 5 - New Opportunities for Testing on the JVMJUnit 5 - New Opportunities for Testing on the JVM
JUnit 5 - New Opportunities for Testing on the JVM
 
Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2
 
JUnit 5 - from Lambda to Alpha and beyond
JUnit 5 - from Lambda to Alpha and beyondJUnit 5 - from Lambda to Alpha and beyond
JUnit 5 - from Lambda to Alpha and beyond
 
Testing with Spring 4.x
Testing with Spring 4.xTesting with Spring 4.x
Testing with Spring 4.x
 
Composable Software Architecture with Spring
Composable Software Architecture with SpringComposable Software Architecture with Spring
Composable Software Architecture with Spring
 
Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2
 
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
 
Spring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSpring Framework 3.2 - What's New
Spring Framework 3.2 - What's New
 
Spring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4DevelopersSpring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4Developers
 
Effective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4DevelopersEffective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4Developers
 
Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012
 
Spring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSpring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing Support
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Effective out-of-container Integration Testing
Effective out-of-container Integration TestingEffective out-of-container Integration Testing
Effective out-of-container Integration Testing
 
What's New in Spring 3.0
What's New in Spring 3.0What's New in Spring 3.0
What's New in Spring 3.0
 
Modular Web Applications with OSGi
Modular Web Applications with OSGiModular Web Applications with OSGi
Modular Web Applications with OSGi
 

Último

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Último (20)

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

Spring 3.1 in a Nutshell - JAX London 2011

  • 1. Spring 3.1 in a Nutshell Sam Brannen / Swiftmind
  • 2. Speaker Profile •  Spring & Java consultant @ Swiftmind •  Developing Java for over 13 years •  Spring Framework Core Developer •  Spring Trainer •  Lead author of “Spring in a Nutshell”
  • 3. Agenda •  Major Themes in 3.x •  Environment and Profiles •  Java-based Configuration •  Testing •  Caching •  MVC and REST •  Servlet 3.0 •  Odds & Ends
  • 4. Major Themes in Spring 3.0
  • 8. JSR-330 – DI for Java
  • 10. REST support in Spring MVC
  • 12. JSR-303 – bean validation
  • 13. Java EE 6 support: JPA 2.0, JSF 2.0
  • 14. Major Themes in Spring 3.1 –  Environment abstraction –  Java-based application configuration –  @Configuration class test support –  High-level cache API –  Customizable @MVC processing –  Flash maps and redirect attributes –  Explicit support for Servlet 3.0
  • 16. Environment Abstraction –  Injectable environment abstraction API •  org.springframework.core.env.Environment –  Two core concepts •  Property Sources •  Bean Profiles Property Source: Bean Profile: A variety of sources: property A logical group of bean files, system properties, definitions. Registered only if servlet context, JNDI, etc. the profile is active.
  • 17. Property Source Abstraction –  Property source –  Property resolution –  Placeholders
  • 18. PropertySource(s) –  PropertySource •  a single property source –  PropertySources •  a hierarchy of PropertySource objects •  potentially varying across deployment environments
  • 19. Property Resolution SPI –  org.springframework.core.env.PropertyResolver –  Environment extends PropertyResolver
  • 20. Custom resolution of placeholders –  dependent on the actual environment –  PropertySourcesPlaceholderConfigurer supersedes PropertyPlaceholderConfigurer
  • 21. Managing Property Sources –  Stand-alone code –  Web application •  Implement ApplicationContextInitializer •  Register via contextInitializerClasses context parameter in web.xml
  • 22. Accessing Properties –  By injecting the Environment
  • 23. Bean Definition Profiles –  Logical grouping of bean definitions •  for activation in specific environments •  e.g., dev, staging, prod •  possibly different deployment platforms –  Configuration •  XML via <beans profile=“…”> •  Java-based configuration via @Profile
  • 24. Configuring Profiles in XML –  All bean definitions –  Subset of bean definitions
  • 25. Configuring Profiles in Java Config 25 –  @Profile can also be used on components •  @Component, @Service, @Repository, etc.
  • 26. Profile Activation Options –  programmatically –  system property –  in web.xml –  in tests via @ActiveProfiles
  • 28. Activating Profiles… via system properties -Dspring.profiles.active=“dev” -Dspring.profiles.default=“common”
  • 29. Activating Profiles… in web apps
  • 30. Activating Profiles… in integration tests
  • 32. Java Config ~= XML –  XML namespaces à @Enable* –  FactoryBeans à builders –  GenericXmlContextLoader à AnnotationConfigContextLoader –  Not a one-to-one mapping •  Make the most of what Java has to offer •  Intuitive annotation-oriented container configuration
  • 33. Typical Infrastructure Setup –  Transactions –  Scheduling –  MVC customization –  AOP
  • 34. @Enable* Annotations –  Applied at the class-level on @Configuration classes –  Roughly equivalent to their XML namespace counterparts
  • 35. @Enable* in 3.1 RC1 –  @EnableTransactionManagement –  @EnableAsync –  @EnableScheduling –  @EnableAspectJAutoProxy –  @EnableLoadTimeWeaving –  @EnableWebMvc
  • 36. Hibernate and JPA –  Hibernate LocalSessionFactoryBuilder API •  Hibernate 4 replacement for both LocalSessionFactoryBean and AnnotationSessionFactoryBean –  XML-free JPA configuration •  LocalContainerEntityManagerFactoryBean has a new property •  packagesToScan: analogous to AnnotationSessionFactoryBean
  • 37. Java Configuration Example Actually: LocalSessionFactoryBuilder
  • 38. New Testing Features in 3.1 –  @Configuration class support –  Environment profile support –  SmartContextLoader –  AnnotationConfigContextLoader –  DelegatingSmartContextLoader –  Updated context cache key generation
  • 39. SmartContextLoader SPI –  Supersedes ContextLoader –  Strategy for loading application contexts –  From @Configuration classes or resource locations –  Supports environment profiles
  • 40. @ContextConfiguration accepts a new `classes` attribute...
  • 44. Caching Abstraction –  Declarative caching for Spring applications •  Minimal impact on code •  Plug in various caching solutions –  Key annotations @Cacheable and @CacheEvict
  • 45. Cache Key –  All method arguments used by default –  Use SpEL to select more specifically (use class, method, or argument name)
  • 47. Cache Providers (1/2) –  Cache and CacheManager SPI •  org.springframework.cache –  Cache Implementations •  EhCacheCache •  ConcurrentMapCache and ConcurrentMapCacheFactoryBean
  • 48. Cache Providers (2/2) –  CacheManager Implementations •  EhCacheCacheManager •  ConcurrentMapCacheManager •  SimpleCacheManager •  NoOpCacheManager –  Any other implementation can be plugged in •  GemFire, Coherence, etc.
  • 49. Cache Configuration –  Cache namespace •  <cache:annotation-driven /> •  “cacheManager” bean
  • 51. @MVC 3.0 Config –  Built-in defaults •  Based on DispatcherServlet.properties –  Spring MVC namespace •  <mvc:annotation:driven>, <mvc:interceptors>, …
  • 52. Java-based @MVC 3.1 Config –  Most Spring MVC configuration is in Java already •  @Controller, @RequestMapping, etc. –  Servlet 3.0 enhancements will further reduce the need for web.xml –  XML namespace is convenient but … •  Not transparent •  Not easy to offer the right degree of customization
  • 53. @EnableWebMvc –  Enables Spring MVC default configuration •  Registers components expected by the DispatcherServlet –  Allows for configuration similar to the Spring MVC namespace •  … and the DispatcherServlet.properties combined
  • 54. A More Complete Example … –  Add component scanning for @Controllers and other beans
  • 55. Q: Where is the “Enabled” Configuration ?! –  A: a framework-provided @Configuration class (actually DelegatingWebMvcConfiguration)
  • 56. How Do I Customize All This? –  Simply implement the WebMvcConfigurer interface Allows selective overriding
  • 57. HandlerMethod Abstraction –  HandlerMethod •  A proper abstraction for the selected “handler” in Spring MVC –  Not just for @RequestMapping methods •  Also @InitBinder, @ModelAttribute, @ExceptionHandler methods –  “HandlerMethod” support classes •  RequestMappingHandlerMapping •  RequestMappingHandlerAdapter •  ExceptionHandlerExceptionResolver
  • 58. Path Variables in the Model –  @PathVariable arguments automatically added to the model These can be deleted
  • 59. URI Templates in Redirect Strings –  URL templates supported in “redirect:” strings Expanded from model attributes, which now include @PathVariables
  • 60. URI Template Variables in Data Binding –  URI template variables used in data binding
  • 61. Matching MediaTypes < @MVC 3.1 –  Using the 'headers' condition
  • 62. Matching MediaTypes in @MVC 3.1 –  The 'consumes' and 'produces' conditions If not matched, results in: UNSUPPORTED_MEDIA_TYPE (415) If not matched, results in: NOT_ACCEPTABLE (406)
  • 64. Servlet 3.0 Containers •  Tomcat 7 and GlassFish 3 –  Explicitly supported •  While preserving compatibility with Servlet 2.4+
  • 65. XML-free Web-app Config •  Support for XML-free web application setup –  no web.xml •  Made possible via: –  Servlet 3.0's ServletContainerInitializer –  Spring 3.1's AnnotationConfigWebApplicationContext –  Spring 3.1’s environment abstraction
  • 66. Native Servlet 3.0 in @MVC •  Asynchronous request processing •  Standard Servlet 3.0 file upload –  behind Spring's MultipartResolver abstraction
  • 68. "c:" Namespace –  Shortcut for <constructor-arg> •  inline argument values •  analogous to existing "p:" namespace –  Use of constructor argument names •  recommended for readability •  debug symbols have to be available in the application's class files
  • 69. The Spring Roadmap •  Spring 3.1 RC2: mid November •  Spring 3.1 GA: Before end of 2011 •  Spring 3.2: Planned for early 2012 –  Java EE: JSF 2.2, JPA 2.1, etc.
  • 70. Spring 3.1 in a Nutshell •  Environment and Profiles •  Java-based Configuration and @Enable* •  Testing with @Configuration and Profiles •  Cache Abstraction •  MVC and REST Improvements •  Servlet 3.0 •  c: Namespace
  • 71. Further Resources •  Spring Framework –  http://springframework.org –  Spring Reference Manual –  JavaDoc •  Spring Forums –  http://forum.springframework.org •  Spring JIRA –  http://jira.springframework.org
  • 72. Blogs •  SpringSource Team Blog – category 3.1 –  http://blog.springsource.com/category/spring/31/ •  Swiftmind Blog –  http://www.swiftmind.com/blog/
  • 73. Q&A Sam Brannen twitter: @sam_brannen Swiftmind www.slideshare.net/sbrannen www.swiftmind.com “Spring in a Nutshell” http://oreilly.com/catalog/9780596801946 available from O’Reilly in 2012