Getting Started
with Spring 3
By Josh Long
Agenda
l
who am I?
l
overview of the latest and greatest in Spring 3
l
why should you care?
Who am I?
Lead Author
“Spring Enterprise Recipes”
“Spring Recipes, 2nd Edition”
Editor on Infoq.com
Blogger on Artima.com
JCP member
International speaker / authority on all things Spring-y
(and bouncy)
Java 5: Generics
ApplicationContext
Java 5: Generics
ApplicationContext
Java 5: Generics
ApplicationContext
Java 5: Generics
ApplicationContext Events
Java 5: Generics
ApplicationContext Events
...
Java 5: Executors
Java
l
j.u.concurrent.AbstractExecutorService
l
j.u.concurrent.DelegatedExecutorService
l
j.u.concurrent.DelegatedScheduledExecutorService
l
j.u.concurrent.FinalizableDelegatedExecutorService
Java 5: Executors
Spring
o.s.core.task.support.
l
ConcurrentExecutorAdapter
l
o.s.scheduling.concurrent.
l
ConcurrentTaskScheduler
l
o.s.core.task.support.
l
ExecutorServiceAdapter
l
o.s.jca.work.glassfish.
l
GlassFishWorkManagerTaskExecutor
l
o.s.jca.work.jboss.
l
JBossWorkManagerTaskExecutor
Java 5: Scheduled Methods
Java 5: Scheduled Methods
...
Java 5: Async Methods
SpEL
l
History in Spring Batch Step Scope
l
History in Spring.NET
l
…
l
Andy Clement’s a rockstar
SpEL: what can it do?
'Hello Shopzilla!'
'ceci n''est pas une String'
1
true
{
Literal values:
SpEL: what can it do?
new String(
'Hello Shopzilla, again!')
new com.shopzilla.Cat(
'Felix')
{
construction
SpEL: what can it do?
'felix'.toUpperCase()
T(java.lang.Math).random()
{
method invocation
SpEL: what can it do?
1 > 2
T(java.lang.Math).random() > .5 ?
'She loves Me' :
'She loves me not'
{
Relational operators
SpEL: what can it do?
myArray[1]
myCollection[1]
MyMap['Shopzilla']
{
collections
SpEL: what can it do?
myArray.?[#this < 10]
myMap.?[value.equals('brie')]
{
selection
SpEL: what can it do?
collectionOfCats.![name]
mapOfProducts.![value.id]
{
projection
SpEL: what can it do?
systemProperties['user.home']
service.client.soTimeout
{
references
SpEL: what can it do?
SpEL: what can it do?
SpEL: what can it do?
SpEL: what can it do?
Annotations
Choices, Choices...
Annotations:
Pros:
Compact, where they apply
Type safe
Cons:
Not always applicable
Not self documenting because the annotations
are interspersed in your code
Choices, Choices...
XML:
Pros:
Compact, where schema applies
Self documenting (one artifact to rule them all)
Cons:
Spring XML support isn't particularly good unless
you're using IntelliJ, Netbeans, Vi, Emacs, JEdit,
Butterflies, JDeveloper, older builds of JBuilder...
Configuration is harder to unit test
(and definitely a place where you should
unit test)
Java Config
Java Config
Java Config
Java Config
My Code Doesn’t Compile!
There is no more spring.jar.
(use spring-core.jar, spring-context.jar, etc..)
There is no more spring-agent.jar
(use spring-instrument.jar)
Spring MVC
Spring MVC
Pretty Annotations for General MVC Goodness
Spring MVC
JSR 303 Validation API
(spearheaded by that other middleware
company, whose name rhymes with “JToss”)
Spring MVC : REST Remix
Spring MVC
<filter>
<filter-name>etagFilter</filter-name>
<filter-class>org.springframework.web.filter.ShallowEtagHeaderFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>etagFilter</filter-name>
<servlet-name>petclinic</servlet-name>
</filter-mapping>
Other Niceties
Embedded Database Support:
o.s.jdbc.datasource.embedded
XPathTemplate
Deprecated
Very little, actually…
Apache OJB support (awww.)
Native Toplink Support (The JPA provider’s still supported)
Spring MVC base controllers
Junit 3 Testing support
Commons Attributes Support
WebLogic 8.1 and WebSphere 5.1
Summary
Spring 3 is an easy upgrade
Simplifies Component code even further
Spring 3 is the baseline for other projects going forward:
Spring BlazeDS
Spring Security
Spring Batch
Spring Integration
Spring MVC
Spring 3 is an evolution,
not a revolution – it's 99% backwards compatible