SlideShare a Scribd company logo
Spring 3.1 Features Worth Knowing About
(Available For Download Today)

Rossen Stoyanchev, Software Engineer




                                                                     CONFIDENTIAL
                                       © 2010 SpringSource, A division of VMware. All rights reserved
Agenda


 Environment

 Java Configuration DSL

 Cache Abstraction




                           CONFIDENTIAL   2
Moving an Application Across Environments




       TRANSFER SERVICE                     DEV



         ACCOUNT DAO

                                            QA
         DATA SOURCE




                                            PROD




                           CONFIDENTIAL            3
Environment-Specific Properties In XML




                                                Property Source:
                                                dev/database.properties




        Property Source: Java system property


                                            dev/database.properties

                                            qa/database.properties
 java -DENV=prod ...
                                            prod/database.properties


                             CONFIDENTIAL                                 4
Environment-Specific Properties In Java

                             Property Source:
                             Java system property?




                       CONFIDENTIAL                  5
Spring EL Expressions in Spring 3.0




 Easier to see where properties originate from




                                CONFIDENTIAL      6
What About “Structural” Differences ?




                CONFIDENTIAL            7
Environment-Specific Configuration in XML




  prod/database-context.xml




                                         dev/database-context.xml



                                             Choose from multiple
  app-context.xml                            files to accommodate
                                             differences

                              CONFIDENTIAL                          8
Environment-Specific Configuration in Java




                                      Accommodate
                                      differences in code




                       CONFIDENTIAL                         9
Spring 3.1 “Environment” Abstraction

 A concrete representation with two key aspects
 • 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.




                                   CONFIDENTIAL                                     10
Managing Property Sources

 In standalone code




 In a Web application
 • Implement ApplicationContextInitializer
 • Register via contextInitializerClasses context parameter in web.xml

 Default property sources
 • JVM properties
 • System envrionment variables



                                  CONFIDENTIAL                           11
Accessing Environment Properties

 In standalone code




 Via @Autowired or EnvironmentAware interface

 In configuration (via placeholders)



 <context:property-placeholder/> also now falls back on
 Environment property sources


                                 CONFIDENTIAL              12
Beans Profiles With XML

 Assign all beans to profile



                            Multiple profiles can be listed


 Assign enclosed beans to a profile




                                  CONFIDENTIAL                13
Bean Profiles In Java




                        CONFIDENTIAL   14
Bean Profile Activation

 In code




 In Web applications




                          CONFIDENTIAL   15
Agenda


 Environment

 Java Configuration DSL

 Cache Abstraction




                           CONFIDENTIAL   16
Custom XML Namespaces

 Custom XML namespaces have become very popular
 • In Spring and in other frameworks

 Succinct and highly expressive




 Each namespace element can result in the registration of any
 number of bean definitions

 Question:
 How do get the same benefits in Java configuration?



                                       CONFIDENTIAL              17
Feature Specifications

 Java configuration equivalent to an XML namespace




 Declared in @FeatureConfiguration classes
                                    Beans declared elsewhere
                                    can be autowired in.




 Results in same bean declarations as <tx:annotation-driven />

                              CONFIDENTIAL                     18
FeatureSpecifications Are Designed For Ease of Use




                       CONFIDENTIAL                  19
Agenda


 Environment

 Java Configuration DSL

 Cache Abstraction




                           CONFIDENTIAL   20
Spring 3.1 Cache Abstraction

 CacheManager and Cache abstractions
 • org.springframework.cache

 Backend adapters for EhCache, GemFire, Coherence, etc.

 Cache namespace
 • <cache:annotation-driven />

 CacheManager SPI
 • EhCacheManager
 • GemFireCacheManager




                               CONFIDENTIAL                21
Annotation-Based Caching

                    Cache name




                                  Custom key




                                       Cache condition




                       CONFIDENTIAL                      22
Spring 3.1 M1 Blog Series:
----------------------------------

http://blog.springsource.com/2008/03/26/spring-java-
configuration-whats-new-in-m3/

https://github.com/cbeams/spring-3.1-profiles-xml
https://github.com/cbeams/spring-3.1-profiles-java
https://github.com/cbeams/spring-3.1-featurespec
https://github.com/rstoyanchev/spring-3.1-mvc-java-config

Review updated Spring Reference Documentation

Provide feedback via JIRA and Forums

                                 CONFIDENTIAL          23
Thank You




   CONFIDENTIAL   24

More Related Content

PDF
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
PDF
JBoss Application Server 7
PDF
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
PDF
Gfp Launch Sailfin Whatis Sreeram
PDF
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
PDF
Running your Java EE applications in the Cloud
PDF
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
PDF
GlassFish REST Administration Backend
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
JBoss Application Server 7
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Gfp Launch Sailfin Whatis Sreeram
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
Running your Java EE applications in the Cloud
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
GlassFish REST Administration Backend

What's hot (20)

PDF
Overview of Java EE 6 by Roberto Chinnici at SFJUG
PPTX
JavaFX and JEE 7
PDF
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
PDF
The State of Java under Oracle at JCertif 2011
PDF
The Java EE 7 Platform: Developing for the Cloud (FISL 12)
PDF
Creating Quick and Powerful Web applications with Oracle, GlassFish and NetBe...
PDF
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
PDF
Sun Java EE 6 Overview
PDF
Java EE 6 & GlassFish v3 @ DevNexus
PDF
GlassFish & Java EE Business Update @ CEJUG
PDF
Running your Java EE 6 applications in the Cloud
PDF
Java EE 6 and GlassFish v3: Paving the path for future
PDF
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
PDF
Java EE 6 Component Model Explained
PDF
Running your Java EE 6 applications in the Cloud @ Silicon Valley Code Camp 2010
PDF
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
PDF
Lo nuevo en Spring 3.0
PDF
GIDS 2012: PaaSing a Java EE Application
PDF
Deep Dive Hands-on in Java EE 6 - Oredev 2010
PDF
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Overview of Java EE 6 by Roberto Chinnici at SFJUG
JavaFX and JEE 7
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
The State of Java under Oracle at JCertif 2011
The Java EE 7 Platform: Developing for the Cloud (FISL 12)
Creating Quick and Powerful Web applications with Oracle, GlassFish and NetBe...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Sun Java EE 6 Overview
Java EE 6 & GlassFish v3 @ DevNexus
GlassFish & Java EE Business Update @ CEJUG
Running your Java EE 6 applications in the Cloud
Java EE 6 and GlassFish v3: Paving the path for future
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 Component Model Explained
Running your Java EE 6 applications in the Cloud @ Silicon Valley Code Camp 2010
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
Lo nuevo en Spring 3.0
GIDS 2012: PaaSing a Java EE Application
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Ad

Similar to Spring 3.1 Features Worth Knowing About (20)

PDF
Spring design-juergen-qcon
PDF
Spring Day | Spring 3.1 in a Nutshell | Sam Brannen
PDF
Spring 3.1 in a Nutshell - JAX London 2011
PPTX
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
PDF
Spring 3.1 in a Nutshell
PDF
Spring 3.1
PPT
Spring 3.1: a Walking Tour
PDF
The Spring 4 Update - Josh Long
PDF
Spring ME JavaOne
PDF
the Spring 4 update
KEY
A Walking Tour of (almost) all of Springdom
PPTX
How to replace an XML Configuration file with a Java Configuration file in a ...
PDF
MongoDB for Java Devs with Spring Data - MongoPhilly 2011
PPTX
Spring MVC framework
PPTX
Spring framework
PDF
MongoDB for Java Developers with Spring Data
PPTX
A first Draft to Java Configuration
PDF
Dependency Injection Styles
PPTX
Strata west 2012_java_cassandra
PPTX
Spring Basics
Spring design-juergen-qcon
Spring Day | Spring 3.1 in a Nutshell | Sam Brannen
Spring 3.1 in a Nutshell - JAX London 2011
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 in a Nutshell
Spring 3.1
Spring 3.1: a Walking Tour
The Spring 4 Update - Josh Long
Spring ME JavaOne
the Spring 4 update
A Walking Tour of (almost) all of Springdom
How to replace an XML Configuration file with a Java Configuration file in a ...
MongoDB for Java Devs with Spring Data - MongoPhilly 2011
Spring MVC framework
Spring framework
MongoDB for Java Developers with Spring Data
A first Draft to Java Configuration
Dependency Injection Styles
Strata west 2012_java_cassandra
Spring Basics
Ad

More from Rossen Stoyanchev (6)

PDF
Reactive Web Applications
PDF
Spring MVC 4.2: New and Noteworthy
PDF
Intro To Reactive Programming
PDF
Resource Handling in Spring MVC 4.1
PDF
Spring 4 Web App
PDF
Testing Web Apps with Spring Framework 3.2
Reactive Web Applications
Spring MVC 4.2: New and Noteworthy
Intro To Reactive Programming
Resource Handling in Spring MVC 4.1
Spring 4 Web App
Testing Web Apps with Spring Framework 3.2

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation theory and applications.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
August Patch Tuesday
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Empathic Computing: Creating Shared Understanding
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Machine Learning_overview_presentation.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Machine learning based COVID-19 study performance prediction
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PPTX
A Presentation on Artificial Intelligence
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation theory and applications.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
cloud_computing_Infrastucture_as_cloud_p
August Patch Tuesday
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Group 1 Presentation -Planning and Decision Making .pptx
Assigned Numbers - 2025 - Bluetooth® Document
Empathic Computing: Creating Shared Understanding
Encapsulation_ Review paper, used for researhc scholars
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Machine Learning_overview_presentation.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Machine learning based COVID-19 study performance prediction
Heart disease approach using modified random forest and particle swarm optimi...
A Presentation on Artificial Intelligence
Unlocking AI with Model Context Protocol (MCP)
Agricultural_Statistics_at_a_Glance_2022_0.pdf

Spring 3.1 Features Worth Knowing About

  • 1. Spring 3.1 Features Worth Knowing About (Available For Download Today) Rossen Stoyanchev, Software Engineer CONFIDENTIAL © 2010 SpringSource, A division of VMware. All rights reserved
  • 2. Agenda  Environment  Java Configuration DSL  Cache Abstraction CONFIDENTIAL 2
  • 3. Moving an Application Across Environments TRANSFER SERVICE DEV ACCOUNT DAO QA DATA SOURCE PROD CONFIDENTIAL 3
  • 4. Environment-Specific Properties In XML Property Source: dev/database.properties Property Source: Java system property dev/database.properties qa/database.properties java -DENV=prod ... prod/database.properties CONFIDENTIAL 4
  • 5. Environment-Specific Properties In Java Property Source: Java system property? CONFIDENTIAL 5
  • 6. Spring EL Expressions in Spring 3.0  Easier to see where properties originate from CONFIDENTIAL 6
  • 7. What About “Structural” Differences ? CONFIDENTIAL 7
  • 8. Environment-Specific Configuration in XML prod/database-context.xml dev/database-context.xml Choose from multiple app-context.xml files to accommodate differences CONFIDENTIAL 8
  • 9. Environment-Specific Configuration in Java Accommodate differences in code CONFIDENTIAL 9
  • 10. Spring 3.1 “Environment” Abstraction  A concrete representation with two key aspects • 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. CONFIDENTIAL 10
  • 11. Managing Property Sources  In standalone code  In a Web application • Implement ApplicationContextInitializer • Register via contextInitializerClasses context parameter in web.xml  Default property sources • JVM properties • System envrionment variables CONFIDENTIAL 11
  • 12. Accessing Environment Properties  In standalone code  Via @Autowired or EnvironmentAware interface  In configuration (via placeholders)  <context:property-placeholder/> also now falls back on Environment property sources CONFIDENTIAL 12
  • 13. Beans Profiles With XML  Assign all beans to profile Multiple profiles can be listed  Assign enclosed beans to a profile CONFIDENTIAL 13
  • 14. Bean Profiles In Java CONFIDENTIAL 14
  • 15. Bean Profile Activation  In code  In Web applications CONFIDENTIAL 15
  • 16. Agenda  Environment  Java Configuration DSL  Cache Abstraction CONFIDENTIAL 16
  • 17. Custom XML Namespaces  Custom XML namespaces have become very popular • In Spring and in other frameworks  Succinct and highly expressive  Each namespace element can result in the registration of any number of bean definitions  Question: How do get the same benefits in Java configuration? CONFIDENTIAL 17
  • 18. Feature Specifications  Java configuration equivalent to an XML namespace  Declared in @FeatureConfiguration classes Beans declared elsewhere can be autowired in.  Results in same bean declarations as <tx:annotation-driven /> CONFIDENTIAL 18
  • 19. FeatureSpecifications Are Designed For Ease of Use CONFIDENTIAL 19
  • 20. Agenda  Environment  Java Configuration DSL  Cache Abstraction CONFIDENTIAL 20
  • 21. Spring 3.1 Cache Abstraction  CacheManager and Cache abstractions • org.springframework.cache  Backend adapters for EhCache, GemFire, Coherence, etc.  Cache namespace • <cache:annotation-driven />  CacheManager SPI • EhCacheManager • GemFireCacheManager CONFIDENTIAL 21
  • 22. Annotation-Based Caching Cache name Custom key Cache condition CONFIDENTIAL 22
  • 23. Spring 3.1 M1 Blog Series: ---------------------------------- http://blog.springsource.com/2008/03/26/spring-java- configuration-whats-new-in-m3/ https://github.com/cbeams/spring-3.1-profiles-xml https://github.com/cbeams/spring-3.1-profiles-java https://github.com/cbeams/spring-3.1-featurespec https://github.com/rstoyanchev/spring-3.1-mvc-java-config Review updated Spring Reference Documentation Provide feedback via JIRA and Forums CONFIDENTIAL 23
  • 24. Thank You CONFIDENTIAL 24