SlideShare ist ein Scribd-Unternehmen logo
1 von 53
What’s New in
Spring 3.0
Sam Brannen
Senior Software Consultant
Spring Geek Night
Zürich Switzerland
25 February 2010
Speaker Profile
Senior Software Consultant – Swiftmind GmbH
Spring Framework Core Developer
Previous SpringSource dm Server™ developer: OSGi-enabled
Web deployment models, Tomcat integration, Test Framework
Java developer with 12+ years' experience
Regular speaker at conferences on Spring, dm Server, Java,
OSGi, and testing
Co-author of Spring in a Nutshell;
chief technical reviewer for Spring Recipes
2Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Agenda
Review of Spring 2.0 & 2.5
Spring 3.0 Releases
Deprecations in Spring 3.0
What’s New in Spring 3.0
Spring 3.0 Examples
Q&A
3Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 2.0
4Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 2.0 Review
Java 5, Bean scopes, JPA, Message-driven POJOs
XML Namespaces: beans, p, aop, tx, jee, lang, util
Annotations: @AspectJ, @Transactional, @Required,
@PersistenceContext, @PersistenceUnit
SimpleJdbcTemplate, NamedParameterJdbcTemplate
Web:
JSP form tag library
Convention over configuration
Dynamic language support: JRuby, Groovy, Beanshell
Testing: AbstractJpaTests and annotations
5Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 2.5
6Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 2.5 Review
Annotation-driven configuration & component scanning
@Autowired, @Qualifier
JSR-250: @Resource, @PostConstruct, @PreDestroy
@Component, @Service, @Repository, @Controller
XML Namespaces: context, jms
Spring Web @MVC: @RequestMapping, @RequestParam,
@ModelAttribute, @InitBinder, @SessionAttributes
Spring TestContext Framework
JUnit 3.8, JUnit 4.4, TestNG 5.5
@ContextConfiguration, @TestExecutionListeners,
@BeforeTransaction, @AfterTransaction, …
7Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0
8Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0.0.M1
Java 5+ and J2EE 1.4+
Java 5 language features: generics and var-args
Spring EL parser
Support for #{…} expressions in bean definitions
@PathVariable for URI template handling
@RequestParam defaultValue attribute
@RequestHeader for HTTP header attribute handling
AbstractAtomFeedView & AbstractRssFeedView
<spring:url /> & <spring:param /> JSP tags
9Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0.0.M2
Further Java 5 updates
Generic Collections and Maps
Generified FactoryBean
Generified ApplicationListener
Generified callback interfaces: TransactionCallback,
HibernateCallback, …
Concurrency and TaskExecutor abstraction
java.util.concurrent integration
JSR 236: “Concurrency Utilities for Java EE 6”
@Async & EJB 3.1’s @Asynchronous
OXM module moved from Spring-WS to core
Portlet 2.0 and early JPA 2.0 support
10Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0.0.M3
Distributed with reference guide
Annotated Factory methods and JavaConfig in core
@Bean, @Lazy, @Primary
@Configuration, @Scope
Mix and match with XML configuration
Meta-annotations a la @TransactionalService
Extended TaskExecutor abstraction
ScheduledExecutorServices, CommonJ TimerManager
Trigger API and CronTrigger implementation
Type conversion subsystem from SWF
Java 5 based, stateless, and replaces PropertyEditors
11Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0.0.M4
XML Namespaces: task, jdbc
BeanWrapper and DefaultListableBeanFactory accept a custom
ConversionService
Scoped proxies are serializable for web scopes and singleton
beans
@Primary, @Lazy, and @DependsOn supported as meta-
annotations
@Transactional supports qualifier value for choosing
transaction manager
Upgraded to JUnit 4.6* and TestNG 5.9; @DirtiesContext
supported at class level
12Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0.0.RC1
@Value supports dynamic #{…} expressions or static
${…} placeholders
JSR 330: “Dependency Injection for Java”
@Inject, @Qualifier, @Named, …
JSR 303: “Bean Validation” and Hibernate Validator
@Valid, @NotNull, @Min, @Max, @Size, …
Formatting subsystem and annotation support
PropertyPlaceholderConfigurer supports
"${key:defaultValue}" defaulting syntax
Upgraded to JUnit 4.7* and TestNG 5.10
13Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0.0.RC2
XML Namespaces: mvc
Fully compliant with the JSR 330 TCK
AnnotationConfigApplicationContext and
AnnotationConfigWebApplicationContext
Revised lifecycle management and LifecycleProcessor
Additional enhancements and bug fixes
14Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0.0.RELEASE
Released December 16, 2009
No major new features
Updated JPA 2.0 support to final spec
Full support for Glassfish V3
Bug fixes
Documentation and Reference Manual
15Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0.1.RELEASE
Released February 18, 2010
3.0.1.RELEASE-A for OSGi compatibility
Support for Hibernate 3.5, Tiles 2.2.1, and further support for
JPA 2.0
spring:eval tag for evaluating SpEL expressions in JSPs
Further vararg support in BeanDefinitionReader,
ClassPathXmlApplicationContext,
FileSystemXmlApplicationContext, JdbcTemplate
Various minor bug fixes
16Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0.2.RELEASE
Scheduled for March 11, 2010
Last release in the 3.0.x branch
Upgraded to Hibernate Validator 4.0.2 and Jackson 1.4.2
No new features
Minor bug fixes
17Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0 – Deprecations
PetClinic now in spring-samples repository
Commons attributes support
Traditional TopLink API
Struts 1.x
SimpleFormController class hierarchy
JUnit 3.8 legacy test class hierarchy
@NotTransactional
18Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring Expression Language
19Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
What is SpEL?
EL for querying and manipulating an object graph at runtime
Similar to Unified EL syntax but with more features
Single, well supported EL across the Spring Portfolio
Supports:
Literal expressions
Boolean expressions and relational operators
Regular expressions
Class expressions
Templated expressions
20Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
SpEL Features (continued)
Accessing properties, arrays, lists, maps
Method and constructor invocation
Assignment
Ternary operator
Variables
User-defined functions
Collection projection and selection
Implicit variables: systemProperties, systemEnvironment,
request, session, …
21Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
SpEL Programmatic Usage
ExpressionParser parser = new
SpelExpressionParser();
Expression exp =
parser.parseExpression("'Hello World'");
assertEquals("Hello World", exp.getValue());
exp = parser.parseExpression(
"new String('hello world').toUpperCase()");
assertEquals("HELLO WORLD",
exp.getValue(String.class));
22Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
SpEL with Context
class Foo { String getBar() { return "bar”; }}
Foo foo = new Foo();
EvaluationContext context = new
StandardEvaluationContext(foo);
ExpressionParser parser = new
SpelExpressionParser();
Expression exp =
parser.parseExpression("bar");
assertEquals("bar”, exp.getValue(context));
23Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
SpEL with Bean Definitions
24Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
SpEL and @Value
25Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
SpEL Expressions
26Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0 MVC
27Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
@RequestParam Default Value
@RequestMapping("/category")
public ModelAndView displayCategory(
@RequestParam(value="id", defaultValue="1") Long id){
return new ModelAndView(
"category")
.addObject(service.findById(id));
}
Example URL: http://example.com/category?id=9
28Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
@PathVariable
@RequestMapping("/category/{id}”)
public ModelAndView displayCategory(
@PathVariable("id") Long id) {
return new ModelAndView(
"category")
.addObject(service.findById(id));
}
Example URL: http://example.com/category/9
29Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
@RequestHeader
@RequestMapping("/view")
public ModelAndView view(
@RequestHeader("accept-language") String lang) {
// do something with lang …
}
30Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
@CookieValue
@RequestMapping("/view")
public ModelAndView view(
@CookieValue("lang") String lang) {
// do something with lang …
}
31Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Before <mvc /> Namespace
32Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
After <mvc /> Namespace
<mvc:annotation-driven conversion-service="conversionService"
validator="validator" />
<bean id="conversionService"
class="org…FormattingConversionService" />
<bean id="validator" class="org…LocalValidatorFactoryBean" />
Or simply…
<mvc:annotation-driven />
33Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
The jdbc Namespace
34Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Embedded Database in XML
<jdbc:embedded-database id="dataSource" type="H2">
<jdbc:script location="classpath:/my-schema.sql" />
<jdbc:script location="classpath:/my-data.sql" />
</jdbc:embedded-database>
Or simply…
<jdbc:embedded-database id="dataSource" />
35Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Embedded Database in Code
36Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Populate Database in XML
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="classpath:/schema_01.sql" />
<jdbc:script location="classpath:/schema_02.sql" />
<jdbc:script location="classpath:/data_01.sql" />
<jdbc:script location="classpath:/data_02.sql" />
</jdbc:initialize-database>
37Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
The task Namespace
38Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Scheduling Tasks in XML
<task:scheduled-tasks scheduler="taskScheduler">
<task:scheduled ref="worker" method="work" fixed-rate="1000" />
<task:scheduled ref="worker" method="work" fixed-delay="3000" />
<task:scheduled ref="worker" method="work"
cron="*/4 * 9-17 * * MON-FRI" />
</task:scheduled-tasks>
<task:scheduler id=”taskScheduler" />
<bean id="worker" class="org.example.Worker" />
39Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Annotation-driven Scheduling
40Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Spring 3.0 Configuration
41Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Java-based Configuration
42Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
JSR 303 Validation
43Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Declarative Bean Validation
44Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
public class AppointmentForm {
@NotNull
private Long doctor;
@NotNull
private Long client;
@NotNull
private Long patient;
@NotNull
private LocalDate date = new LocalDate();
@NotNull
private LocalTime time = new LocalTime();
// …
Bean Validation & Spring MVC
45Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
@RequestMapping(method = RequestMethod.POST)
public String add(@Valid AppointmentForm appointment,
BindingResult result) {
if (result.hasErrors()) {
return "appointments/new";
}
appointmentBook.addAppointment(appointment);
return "redirect:/appointments”;
}
Spring Formatting
46Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Formatter API
47Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Formatter Implementations
48Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
NumberFormatter: A general-purpose Number formatter
CurrencyFormatter: BigDecimal formatter for currency values
DateFormatter: A formatter for Date types
NumberFormatAnnotationFormatterFactory: supports fields
annotated with @NumberFormat
DateTimeFormatAnnotationFormatterFactory: supports fields
annotated with @DateTimeFormat (Joda Time)
Formatting & Spring MVC
49Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
@RequestMapping(value="/{day}”, method=RequestMethod.GET)
public String getForDay(@PathVariable
@DateTimeFormat(iso=ISO.DATE) LocalDate day,
Model model)
{
DoctorAppointments appointments =
appointmentBook.getAppointmentsForDay(day);
model.addAttribute("doctorAppointmentsMap",
appointments.asMap());
return "appointments";
}
Summary
50Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Summary
Java 5 language features
Spring Expression Language
New task, jdbc, and mvc namespaces
REST support
New @MVC annotations
Java-based configuration
JSR 303 Bean Validation
JSR 330 DI for Java
Formatting and Conversion systems
51Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Further Resources
Spring Framework:
http://springframework.org
Spring Forums:
http://forum.springframework.org
Spring JIRA:
http://jira.springframework.org
SpringSource Team Blog:
http://blog.springsource.com
Swiftmind GmbH
http://www.swiftmind.com
“Spring in a Nutshell”
available from O’Reilly in Spring of 2010
52Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
Q&A
Sam Brannen
sam.brannen [at] swiftmind [dot] com
http://www.swiftmind.com
http://twitter.com/sam_brannen
53Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.

Weitere ähnliche Inhalte

Ähnlich wie What's New in Spring 3.0

Spring framework
Spring frameworkSpring framework
Spring framework
srmelody
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New Evolution
Allan Huang
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
Satish Verma
 

Ähnlich wie What's New in Spring 3.0 (20)

Lo nuevo en Spring 3.0
Lo nuevo  en Spring 3.0Lo nuevo  en Spring 3.0
Lo nuevo en Spring 3.0
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New Evolution
 
Tech Days 2010
Tech  Days 2010Tech  Days 2010
Tech Days 2010
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Java EE 7 in practise - OTN Hyderabad 2014
Java EE 7 in practise - OTN Hyderabad 2014Java EE 7 in practise - OTN Hyderabad 2014
Java EE 7 in practise - OTN Hyderabad 2014
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
Developing Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring toolsDeveloping Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring tools
 
What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6
 
Project Reactor Now and Tomorrow
Project Reactor Now and TomorrowProject Reactor Now and Tomorrow
Project Reactor Now and Tomorrow
 
React & Redux JS
React & Redux JS React & Redux JS
React & Redux JS
 
JEE5 New Features
JEE5 New FeaturesJEE5 New Features
JEE5 New Features
 
Java EE7
Java EE7Java EE7
Java EE7
 
Using state-engine-as-sca-component-final
Using state-engine-as-sca-component-finalUsing state-engine-as-sca-component-final
Using state-engine-as-sca-component-final
 
From SOA to SCA and FraSCAti
From SOA to SCA and FraSCAtiFrom SOA to SCA and FraSCAti
From SOA to SCA and FraSCAti
 
SpringOne Tour: Spring Boot 3 and Beyond
SpringOne Tour: Spring Boot 3 and BeyondSpringOne Tour: Spring Boot 3 and Beyond
SpringOne Tour: Spring Boot 3 and Beyond
 
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVC
 
Being Reactive with Spring
Being Reactive with SpringBeing Reactive with Spring
Being Reactive with Spring
 
Introducing Spring Framework 5.3
Introducing Spring Framework 5.3Introducing Spring Framework 5.3
Introducing Spring Framework 5.3
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EE
 

Mehr von Sam 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.2
Sam Brannen
 

Mehr von 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: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An Introduction
 
Testing with Spring 4.x
Testing with Spring 4.xTesting with Spring 4.x
Testing with Spring 4.x
 
Spring Framework 4.1
Spring Framework 4.1Spring Framework 4.1
Spring Framework 4.1
 
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
 
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 to 4.1
Spring Framework 4.0 to 4.1Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1
 
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 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
 

Kürzlich hochgeladen

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
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
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...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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...
 
+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...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

What's New in Spring 3.0

  • 1. What’s New in Spring 3.0 Sam Brannen Senior Software Consultant Spring Geek Night Zürich Switzerland 25 February 2010
  • 2. Speaker Profile Senior Software Consultant – Swiftmind GmbH Spring Framework Core Developer Previous SpringSource dm Server™ developer: OSGi-enabled Web deployment models, Tomcat integration, Test Framework Java developer with 12+ years' experience Regular speaker at conferences on Spring, dm Server, Java, OSGi, and testing Co-author of Spring in a Nutshell; chief technical reviewer for Spring Recipes 2Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 3. Agenda Review of Spring 2.0 & 2.5 Spring 3.0 Releases Deprecations in Spring 3.0 What’s New in Spring 3.0 Spring 3.0 Examples Q&A 3Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 4. Spring 2.0 4Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 5. Spring 2.0 Review Java 5, Bean scopes, JPA, Message-driven POJOs XML Namespaces: beans, p, aop, tx, jee, lang, util Annotations: @AspectJ, @Transactional, @Required, @PersistenceContext, @PersistenceUnit SimpleJdbcTemplate, NamedParameterJdbcTemplate Web: JSP form tag library Convention over configuration Dynamic language support: JRuby, Groovy, Beanshell Testing: AbstractJpaTests and annotations 5Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 6. Spring 2.5 6Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 7. Spring 2.5 Review Annotation-driven configuration & component scanning @Autowired, @Qualifier JSR-250: @Resource, @PostConstruct, @PreDestroy @Component, @Service, @Repository, @Controller XML Namespaces: context, jms Spring Web @MVC: @RequestMapping, @RequestParam, @ModelAttribute, @InitBinder, @SessionAttributes Spring TestContext Framework JUnit 3.8, JUnit 4.4, TestNG 5.5 @ContextConfiguration, @TestExecutionListeners, @BeforeTransaction, @AfterTransaction, … 7Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 8. Spring 3.0 8Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 9. Spring 3.0.0.M1 Java 5+ and J2EE 1.4+ Java 5 language features: generics and var-args Spring EL parser Support for #{…} expressions in bean definitions @PathVariable for URI template handling @RequestParam defaultValue attribute @RequestHeader for HTTP header attribute handling AbstractAtomFeedView & AbstractRssFeedView <spring:url /> & <spring:param /> JSP tags 9Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 10. Spring 3.0.0.M2 Further Java 5 updates Generic Collections and Maps Generified FactoryBean Generified ApplicationListener Generified callback interfaces: TransactionCallback, HibernateCallback, … Concurrency and TaskExecutor abstraction java.util.concurrent integration JSR 236: “Concurrency Utilities for Java EE 6” @Async & EJB 3.1’s @Asynchronous OXM module moved from Spring-WS to core Portlet 2.0 and early JPA 2.0 support 10Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 11. Spring 3.0.0.M3 Distributed with reference guide Annotated Factory methods and JavaConfig in core @Bean, @Lazy, @Primary @Configuration, @Scope Mix and match with XML configuration Meta-annotations a la @TransactionalService Extended TaskExecutor abstraction ScheduledExecutorServices, CommonJ TimerManager Trigger API and CronTrigger implementation Type conversion subsystem from SWF Java 5 based, stateless, and replaces PropertyEditors 11Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 12. Spring 3.0.0.M4 XML Namespaces: task, jdbc BeanWrapper and DefaultListableBeanFactory accept a custom ConversionService Scoped proxies are serializable for web scopes and singleton beans @Primary, @Lazy, and @DependsOn supported as meta- annotations @Transactional supports qualifier value for choosing transaction manager Upgraded to JUnit 4.6* and TestNG 5.9; @DirtiesContext supported at class level 12Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 13. Spring 3.0.0.RC1 @Value supports dynamic #{…} expressions or static ${…} placeholders JSR 330: “Dependency Injection for Java” @Inject, @Qualifier, @Named, … JSR 303: “Bean Validation” and Hibernate Validator @Valid, @NotNull, @Min, @Max, @Size, … Formatting subsystem and annotation support PropertyPlaceholderConfigurer supports "${key:defaultValue}" defaulting syntax Upgraded to JUnit 4.7* and TestNG 5.10 13Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 14. Spring 3.0.0.RC2 XML Namespaces: mvc Fully compliant with the JSR 330 TCK AnnotationConfigApplicationContext and AnnotationConfigWebApplicationContext Revised lifecycle management and LifecycleProcessor Additional enhancements and bug fixes 14Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 15. Spring 3.0.0.RELEASE Released December 16, 2009 No major new features Updated JPA 2.0 support to final spec Full support for Glassfish V3 Bug fixes Documentation and Reference Manual 15Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 16. Spring 3.0.1.RELEASE Released February 18, 2010 3.0.1.RELEASE-A for OSGi compatibility Support for Hibernate 3.5, Tiles 2.2.1, and further support for JPA 2.0 spring:eval tag for evaluating SpEL expressions in JSPs Further vararg support in BeanDefinitionReader, ClassPathXmlApplicationContext, FileSystemXmlApplicationContext, JdbcTemplate Various minor bug fixes 16Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 17. Spring 3.0.2.RELEASE Scheduled for March 11, 2010 Last release in the 3.0.x branch Upgraded to Hibernate Validator 4.0.2 and Jackson 1.4.2 No new features Minor bug fixes 17Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 18. Spring 3.0 – Deprecations PetClinic now in spring-samples repository Commons attributes support Traditional TopLink API Struts 1.x SimpleFormController class hierarchy JUnit 3.8 legacy test class hierarchy @NotTransactional 18Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 19. Spring Expression Language 19Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 20. What is SpEL? EL for querying and manipulating an object graph at runtime Similar to Unified EL syntax but with more features Single, well supported EL across the Spring Portfolio Supports: Literal expressions Boolean expressions and relational operators Regular expressions Class expressions Templated expressions 20Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 21. SpEL Features (continued) Accessing properties, arrays, lists, maps Method and constructor invocation Assignment Ternary operator Variables User-defined functions Collection projection and selection Implicit variables: systemProperties, systemEnvironment, request, session, … 21Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 22. SpEL Programmatic Usage ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression("'Hello World'"); assertEquals("Hello World", exp.getValue()); exp = parser.parseExpression( "new String('hello world').toUpperCase()"); assertEquals("HELLO WORLD", exp.getValue(String.class)); 22Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 23. SpEL with Context class Foo { String getBar() { return "bar”; }} Foo foo = new Foo(); EvaluationContext context = new StandardEvaluationContext(foo); ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression("bar"); assertEquals("bar”, exp.getValue(context)); 23Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 24. SpEL with Bean Definitions 24Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 25. SpEL and @Value 25Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 26. SpEL Expressions 26Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 27. Spring 3.0 MVC 27Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 28. @RequestParam Default Value @RequestMapping("/category") public ModelAndView displayCategory( @RequestParam(value="id", defaultValue="1") Long id){ return new ModelAndView( "category") .addObject(service.findById(id)); } Example URL: http://example.com/category?id=9 28Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 29. @PathVariable @RequestMapping("/category/{id}”) public ModelAndView displayCategory( @PathVariable("id") Long id) { return new ModelAndView( "category") .addObject(service.findById(id)); } Example URL: http://example.com/category/9 29Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 30. @RequestHeader @RequestMapping("/view") public ModelAndView view( @RequestHeader("accept-language") String lang) { // do something with lang … } 30Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 31. @CookieValue @RequestMapping("/view") public ModelAndView view( @CookieValue("lang") String lang) { // do something with lang … } 31Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 32. Before <mvc /> Namespace 32Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 33. After <mvc /> Namespace <mvc:annotation-driven conversion-service="conversionService" validator="validator" /> <bean id="conversionService" class="org…FormattingConversionService" /> <bean id="validator" class="org…LocalValidatorFactoryBean" /> Or simply… <mvc:annotation-driven /> 33Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 34. The jdbc Namespace 34Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 35. Embedded Database in XML <jdbc:embedded-database id="dataSource" type="H2"> <jdbc:script location="classpath:/my-schema.sql" /> <jdbc:script location="classpath:/my-data.sql" /> </jdbc:embedded-database> Or simply… <jdbc:embedded-database id="dataSource" /> 35Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 36. Embedded Database in Code 36Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 37. Populate Database in XML <jdbc:initialize-database data-source="dataSource"> <jdbc:script location="classpath:/schema_01.sql" /> <jdbc:script location="classpath:/schema_02.sql" /> <jdbc:script location="classpath:/data_01.sql" /> <jdbc:script location="classpath:/data_02.sql" /> </jdbc:initialize-database> 37Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 38. The task Namespace 38Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 39. Scheduling Tasks in XML <task:scheduled-tasks scheduler="taskScheduler"> <task:scheduled ref="worker" method="work" fixed-rate="1000" /> <task:scheduled ref="worker" method="work" fixed-delay="3000" /> <task:scheduled ref="worker" method="work" cron="*/4 * 9-17 * * MON-FRI" /> </task:scheduled-tasks> <task:scheduler id=”taskScheduler" /> <bean id="worker" class="org.example.Worker" /> 39Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 40. Annotation-driven Scheduling 40Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 41. Spring 3.0 Configuration 41Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 42. Java-based Configuration 42Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 43. JSR 303 Validation 43Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 44. Declarative Bean Validation 44Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited. public class AppointmentForm { @NotNull private Long doctor; @NotNull private Long client; @NotNull private Long patient; @NotNull private LocalDate date = new LocalDate(); @NotNull private LocalTime time = new LocalTime(); // …
  • 45. Bean Validation & Spring MVC 45Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited. @RequestMapping(method = RequestMethod.POST) public String add(@Valid AppointmentForm appointment, BindingResult result) { if (result.hasErrors()) { return "appointments/new"; } appointmentBook.addAppointment(appointment); return "redirect:/appointments”; }
  • 46. Spring Formatting 46Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 47. Formatter API 47Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 48. Formatter Implementations 48Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited. NumberFormatter: A general-purpose Number formatter CurrencyFormatter: BigDecimal formatter for currency values DateFormatter: A formatter for Date types NumberFormatAnnotationFormatterFactory: supports fields annotated with @NumberFormat DateTimeFormatAnnotationFormatterFactory: supports fields annotated with @DateTimeFormat (Joda Time)
  • 49. Formatting & Spring MVC 49Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited. @RequestMapping(value="/{day}”, method=RequestMethod.GET) public String getForDay(@PathVariable @DateTimeFormat(iso=ISO.DATE) LocalDate day, Model model) { DoctorAppointments appointments = appointmentBook.getAppointmentsForDay(day); model.addAttribute("doctorAppointmentsMap", appointments.asMap()); return "appointments"; }
  • 50. Summary 50Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 51. Summary Java 5 language features Spring Expression Language New task, jdbc, and mvc namespaces REST support New @MVC annotations Java-based configuration JSR 303 Bean Validation JSR 330 DI for Java Formatting and Conversion systems 51Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 52. Further Resources Spring Framework: http://springframework.org Spring Forums: http://forum.springframework.org Spring JIRA: http://jira.springframework.org SpringSource Team Blog: http://blog.springsource.com Swiftmind GmbH http://www.swiftmind.com “Spring in a Nutshell” available from O’Reilly in Spring of 2010 52Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.
  • 53. Q&A Sam Brannen sam.brannen [at] swiftmind [dot] com http://www.swiftmind.com http://twitter.com/sam_brannen 53Copyright 2009-2010 Sam Brannen. Copying, publishing or distributing without express written permission is prohibited.