153
What’s New in Spring 3

What's new in Spring 3?

Embed Size (px)

DESCRIPTION

Craig Walls' presentation on what's to come in Spring 3 as given at Dallas Tech Fest 2009 in Frisco, TX, June 19, 2009.

Citation preview

Page 1: What's new in Spring 3?

What’s New in Spring 3

Page 2: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Who Am I?

Page 3: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Who Am I?

Java, Spring, and OSGi fanatic

Page 4: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Who Am I?

Java, Spring, and OSGi fanaticPrincipal Consultant with Improving

Page 5: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Who Am I?

Java, Spring, and OSGi fanaticPrincipal Consultant with Improving

AuthorXDoclet in Action (Manning)

Spring in Action (Manning)

Modular Java (Pragmatic Bookshelf)

Page 6: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Who Am I?

Java, Spring, and OSGi fanaticPrincipal Consultant with Improving

AuthorXDoclet in Action (Manning)

Spring in Action (Manning)

Modular Java (Pragmatic Bookshelf)

Page 7: What's new in Spring 3?

Where we’ve been

Spring: This is your life!

Page 8: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Evolution of Spring

Page 9: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Evolution of Spring

<bean class="..."></bean>

Spring 1.x

Page 10: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Evolution of Spring

<bean class="..."></bean>

<tx:/>

Spring 1.x

Spring 2.0

Page 11: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Evolution of Spring

<bean class="..."></bean>

<tx:/>

Spring 1.x

Spring 2.0

@Component@Autowired

Spring 2.5

Page 12: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Evolution of Spring

<bean class="..."></bean>

<tx:/>

Spring 1.x

Spring 2.0

@Component@Autowired

Spring 2.5

Spring 3.0?

Page 13: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Evolution of Spring

<bean class="..."></bean>

<tx:/>

Spring 1.x

Spring 2.0

@Component@Autowired

Spring 2.5

Spring 3.0?

Page 14: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 1.0

Page 15: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 1.0

Dependency injection

Page 16: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 1.0

Dependency injection

POJO-oriented development

Page 17: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 1.0

Dependency injection

POJO-oriented development

Declarative AOP and transactions

Page 18: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 1.0

Dependency injection

POJO-oriented development

Declarative AOP and transactions

MVC framework

Page 19: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.0

Page 20: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.0

Problem-specific XML

Page 21: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.0

Problem-specific XML

Extensible configuration

Page 22: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.0

Problem-specific XML

Extensible configuration

Bean scoping

Page 23: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.0

Problem-specific XML

Extensible configuration

Bean scoping

Groovy, JRuby, and BeanShell

Page 24: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.0

Problem-specific XML

Extensible configuration

Bean scoping

Groovy, JRuby, and BeanShell

JSP tag library

Page 25: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.0

Problem-specific XML

Extensible configuration

Bean scoping

Groovy, JRuby, and BeanShell

JSP tag library

Java 5 autoboxing and generics

Page 26: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.5

Page 27: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.5

Annotation-driven wiring

Page 28: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.5

Annotation-driven wiring

Automatic bean configuration

Page 29: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.5

Annotation-driven wiring

Automatic bean configuration

New annotation-driven MVC framework

Page 30: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.5

Annotation-driven wiring

Automatic bean configuration

New annotation-driven MVC framework

JUnit 4-based integration testing

Page 31: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 1.0

Page 32: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 1.0

<bean id="linus" class="com.springinaction.peanuts.Linus"> <property name="blanket"> <ref bean="blanket" /> </property></bean>

<bean id="blanket" class="com.springinaction.peanuts.Blanket"> <property name="color"> <value>blue</value> </property></bean>

Page 33: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 1.1

Page 34: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 1.1

<bean id="linus" class="com.springinaction.peanuts.Linus"> <property name="blanket" ref="blanket" /></bean>

<bean id="blanket" class="com.springinaction.peanuts.Blanket"> <property name="color" value="blue" /></bean>

Page 35: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.0

Page 36: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.0

<bean id="linus" class="com.springinaction.peanuts.Linus" p:blanket-ref="blanket" />

<bean id="blanket" class="com.springinaction.peanuts.Blanket" p:color="blue" />

Page 37: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.5

Page 38: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring 2.5

<context:component-scan base-package="com.springinaction.peanuts" />

<bean id="blanket" class="com.springinaction.peanuts.Blanket" p:color="blue" />

Page 39: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Annotation-Driven Wiring

Page 40: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Annotation-Driven Wiring

Java:

Page 41: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Annotation-Driven Wiring@Componentpublic class Linus { @Autowired private Blanket blanket;

public Blanket getBlanket() { return blanket; }}

Java:

Page 42: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Annotation-Driven Wiring@Componentpublic class Linus { @Autowired private Blanket blanket;

public Blanket getBlanket() { return blanket; }}

Java:

Spring: Context

Page 43: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Annotation-Driven Wiring@Componentpublic class Linus { @Autowired private Blanket blanket;

public Blanket getBlanket() { return blanket; }}

<context:component-scan base-package="com.springinaction.peanuts" />

Java:

Spring: Context

Page 44: What's new in Spring 3?

What’s new in Spring 3?

Page 45: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring Expression Language

Page 46: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring Expression Language

Wires values evaluated from expressionsWorks in XML and annotations

Page 47: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring Expression Language

Wires values evaluated from expressionsWorks in XML and annotations

<bean class="com.springinaction.peanuts.Blanket"> <property name="color" value="#{someOtherBean.color}" /></bean>

Page 48: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring Expression Language

Wires values evaluated from expressionsWorks in XML and annotations

@Componentpublic class Blanket { @Value("#{someOtherBean.color}") private String color;

public Blanket() { }

// ...}

Page 49: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Expression variables

Page 50: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Expression variables

Any bean ID

Page 51: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Expression variables

Any bean IDsystemProperties

Page 52: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Expression variables

Any bean IDsystemProperties

Scope/Context-specific...contextProperties

contextAttributes

request

session

Page 53: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

SpEL examples

Page 54: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

SpEL examplesReferencing bean properties

Page 55: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

SpEL examplesReferencing bean properties

"#{settingBean.databaseUrl}"

Page 56: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

SpEL examplesReferencing bean properties

"#{settingBean.databaseUrl}"

Referencing system properties

Page 57: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

SpEL examplesReferencing bean properties

"#{settingBean.databaseUrl}"

Referencing system properties"#{systemProperties.favoriteColor}"

Page 58: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

SpEL examplesReferencing bean properties

"#{settingBean.databaseUrl}"

Referencing system properties"#{systemProperties.favoriteColor}"

Evaluating truth

Page 59: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

SpEL examplesReferencing bean properties

"#{settingBean.databaseUrl}"

Referencing system properties"#{systemProperties.favoriteColor}"

Evaluating truth"#{systemProperties.favoriteColor == 'red'}"

Page 60: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

SpEL examplesReferencing bean properties

"#{settingBean.databaseUrl}"

Referencing system properties"#{systemProperties.favoriteColor}"

Evaluating truth"#{systemProperties.favoriteColor == 'red'}"

Using static methods

Page 61: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

SpEL examplesReferencing bean properties

"#{settingBean.databaseUrl}"

Referencing system properties"#{systemProperties.favoriteColor}"

Evaluating truth"#{systemProperties.favoriteColor == 'red'}"

Using static methods"#{T(java.lang.Math).random()}"

Page 62: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

SpEL examplesReferencing bean properties

"#{settingBean.databaseUrl}"

Referencing system properties"#{systemProperties.favoriteColor}"

Evaluating truth"#{systemProperties.favoriteColor == 'red'}"

Using static methods"#{T(java.lang.Math).random()}"

Templated Strings

Page 63: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

SpEL examplesReferencing bean properties

"#{settingBean.databaseUrl}"

Referencing system properties"#{systemProperties.favoriteColor}"

Evaluating truth"#{systemProperties.favoriteColor == 'red'}"

Using static methods"#{T(java.lang.Math).random()}"

Templated Strings"The time is #{T(java.lang.System).currentTimeMillis()}"

Page 64: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

One more SpEL example

Page 65: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

One more SpEL example

Collection projection

Page 66: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

One more SpEL example

Collection projection"#{snoopyPersonas.![name]}"

Page 67: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

@PathVariable

Page 68: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

@PathVariable

Spring 2.5:@Controllerpublic class SpittleListController { @RequestMapping("/spittleList.htm") public String displaySpittleList(@RequestParam("username") String userName) { // ... return "spittleList"; }}

http://localhost:8080/spitter/spittleList.htm?username=habuma

Page 69: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

@PathVariable

Spring 3.0:@Controllerpublic class SpittleListController { @RequestMapping("/{username}/list") public String displaySpittleList(@PathVariable("username") String userName) { // ... return "spittleList"; }}

http://localhost:8080/spitter/habuma/list

Page 70: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

@RequestHeader

Page 71: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

@RequestHeader

Spring 2.5:@Controllerpublic class HomeController { @RequestMapping("/home") public String displayHomePage(HttpServletRequest request) { String userAgent = request.getHeader("User-Agent"); // ... return "home"; }}

Page 72: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

@RequestHeader

Spring 3.0:@Controllerpublic class HomeController { @RequestMapping("/home") public String displayHomePage(@RequestHeader("User-Agent") String userAgent) { // ... return "home"; }}

Page 73: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

@CookieValue

Page 74: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

@CookieValue

Spring 2.5:@Controllerpublic class HomeController { @RequestMapping("/home") public String displayHomePage(HttpServletRequest request) { String lastVisit = "never"; Cookie[] cookies = request.getCookies(); for (Cookie cookie : cookies) { if("LastVisit".equals(cookie.getName())) { lastVisit = cookie.getValue(); } } // ... return "home"; }}

Page 75: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

@CookieValue

Spring 3.0:@Controllerpublic class HomeController { @RequestMapping("/home") public String displayHomePage(@CookieValue("LastVisit") String lastVisit) { // ... return "home"; }}

Page 76: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

default values

Page 77: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

default values

New for @RequestParam@RequestParam(value="productId", defaultValue="1234") String productId

Page 78: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

default values

New for @RequestParam@RequestParam(value="productId", defaultValue="1234") String productId

Standard issue for @RequestHeader and @CookieValue

Page 79: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

default values

New for @RequestParam@RequestParam(value="productId", defaultValue="1234") String productId

Standard issue for @RequestHeader and @CookieValue

@RequestHeader(value="User-Agent", defaultValue="1234") String userAgent

Page 80: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

default values

New for @RequestParam@RequestParam(value="productId", defaultValue="1234") String productId

Standard issue for @RequestHeader and @CookieValue

@RequestHeader(value="User-Agent", defaultValue="1234") String userAgent

@CookieValue(value="LastVisit", defaultValue="1234") String lastVisit

Page 81: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

<spring:url>

Page 82: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

<spring:url>

New JSP tagGenerates context-senstive URL

Page 83: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

<spring:url>

New JSP tagGenerates context-senstive URL

<spring:url value="/spittle/{id}/edit" var="editUrl" escapeXml="true"> <spring:param name="id" value="${spittle.id}" /></spring:url>

<a href="${editUrl}">Do something</a>

Page 84: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Declarative Validation

Page 85: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Declarative Validation

Based on JSR-303 validators

Page 86: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Declarative Validation

Based on JSR-303 validators

Hibernate Validator as default implementation

Page 87: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Declarative Validation

Based on JSR-303 validators

Hibernate Validator as default implementation

Primarily used to validate inputs to Spring MVC controllers

Page 88: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Declarative Validation

Based on JSR-303 validators

Hibernate Validator as default implementation

Primarily used to validate inputs to Spring MVC controllers

Configured automatically with <mvc:annotation-driven/>

Page 89: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

More on validation

@RequestMapping(method=POST) public String addSpittle( @Valid Spittle spittle, BindingResult result) { if(result.hasErrors()) { return "spittle/form"; } spitterService.addSpittle(spittle); return "redirect:/home"; }

In Spring MVCcontroller

@Column(name="spittleText") @NotNull @Size(min=1, max=140) public String getText() { return this.text; }

In entityclass

Page 90: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

ETag Support

Page 91: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

ETag Support

ShallowEtagHeaderFilter

Page 92: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

ETag Support

<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>spitter</servlet-name> </filter-mapping>

ShallowEtagHeaderFilter

Page 93: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

ETag Support

<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>spitter</servlet-name> </filter-mapping>

ShallowEtagHeaderFilter

Returns HTTP 304 if content is unmodifiedif-none-match

(MD5 Hash comparison)

Saves bandwidth

Page 94: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

HTTP Method Conversion

Page 95: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

HTTP Method ConversionHTTP defines four methods:

GET, POST, DELETE, and PUT

Page 96: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

HTTP Method ConversionHTTP defines four methods:

GET, POST, DELETE, and PUTHTML only supports 2:

GET and POST

Page 97: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

HTTP Method ConversionHTTP defines four methods:

GET, POST, DELETE, and PUTHTML only supports 2:

GET and POSTSpring 3’s HiddenHttpMethodFilter fixes that

Page 98: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

HTTP Method ConversionHTTP defines four methods:

GET, POST, DELETE, and PUTHTML only supports 2:

GET and POSTSpring 3’s HiddenHttpMethodFilter fixes that

<filter> <filter-name>hiddenMethodFilter</filter-name> <filter-class> org.springframework.web.filter.HiddenHttpMethodFilter </filter-class> </filter> <filter-mapping> <filter-name>hiddenMethodFilter</filter-name> <servlet-name>spitter</servlet-name> </filter-mapping>

Page 99: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

HTTP Methods in Spring MVC

Page 100: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

HTTP Methods in Spring MVC

Spring MVC form tags support hidden HTTP methods

Page 101: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

HTTP Methods in Spring MVC

Spring MVC form tags support hidden HTTP methods

<form:form method="delete"> <p class="submit"><input type="submit" value="Delete Spittle"/></p></form:form>

Page 102: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

HTTP Methods in Spring MVC

Spring MVC form tags support hidden HTTP methods

<form:form method="delete"> <p class="submit"><input type="submit" value="Delete Spittle"/></p></form:form>

Controllers can handle all HTTP methods

Page 103: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

HTTP Methods in Spring MVC

Spring MVC form tags support hidden HTTP methods

<form:form method="delete"> <p class="submit"><input type="submit" value="Delete Spittle"/></p></form:form>

Controllers can handle all HTTP methods@RequestMapping(method = RequestMethod.DELETE)public String deleteSpittle(@PathVariable long spittleId) { spittleService.deleteSpittle(spittleId); return "redirect:/home";}

Page 104: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Content negotiation

Page 105: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Content negotiation

ContentNegotiatingViewResolverChooses a view based on HTTP Accepts header, JAF

content type, format parameter, or request path extension

Page 106: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Content negotiation

ContentNegotiatingViewResolverChooses a view based on HTTP Accepts header, JAF

content type, format parameter, or request path extension

New view resolversAbstractAtomFeedViewAbstractRssFeedView

MarshallingViewMappingJacksonJsonView

Page 107: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

REST consumption

Page 108: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

REST consumption

New RestTemplate

Page 109: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

REST consumption

New RestTemplate

ReadRestTemplate template = new RestTemplate();template.getForObject("http://localhost:8080/spitter/users/${id}", String.class, userId);

Page 110: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

REST consumption

New RestTemplate

ReadRestTemplate template = new RestTemplate();template.getForObject("http://localhost:8080/spitter/users/${id}", String.class, userId);

Create RestTemplate template = new RestTemplate();SpitterUser user = new SpitterUser(userName, password);template.postForLocation("http://localhost:8080/spitter/users/${id}", user, userId);

Page 111: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

REST consumption

New RestTemplate

ReadRestTemplate template = new RestTemplate();template.getForObject("http://localhost:8080/spitter/users/${id}", String.class, userId);

Delete RestTemplate template = new RestTemplate();template.delete("http://localhost:8080/spitter/users/${id}", userId);

Create RestTemplate template = new RestTemplate();SpitterUser user = new SpitterUser(userName, password);template.postForLocation("http://localhost:8080/spitter/users/${id}", user, userId);

Page 112: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

JavaConfig

Page 113: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

JavaConfig@Configurationpublic class PeanutsConfiguration {

@Bean public Linus linus() { Linus linus = new Linus(); linus.setBlanket(blanket()); return linus; } @Bean private Blanket blanket() { Blanket blanket = new Blanket(); blanket.setColor("blue"); return blanket; }}

Page 114: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

JavaConfig in Components

Page 115: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

JavaConfig in Components

@Componentpublic class KiteEatingTree implements DeciduousTree {

public void shedLeaves() { // ... }

@Bean public Kite kite() { return new Kite(); }}

Page 116: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Asynchronous Methods

Page 117: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Asynchronous Methods

@Asyncpublic void backgroundJob(){ ... }

Annotate a bean method

Page 118: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Asynchronous Methods

@Asyncpublic void backgroundJob(){ ... }

<task:annotation-driven/>

Annotate a bean method

In Spring configuration:

Page 119: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Scheduling

Page 120: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Scheduling

@Scheduled(fixedDelay=3000L) public void ping() { ... }

Page 121: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Scheduling

@Scheduled(fixedDelay=3000L) public void ping() { ... }

@Scheduled(fixedRate=3000L) public void ping() { ... }

Page 122: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Scheduling

@Scheduled(fixedDelay=3000L) public void ping() { ... }

@Scheduled(fixedRate=3000L) public void ping() { ... }

@Scheduled(cron="0 0 0 * * SAT) public void ping() { ... }

Page 123: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Miscellaneous

Page 124: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Miscellaneous

Object-to-XML mapping from Spring-WS

Page 125: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Miscellaneous

Object-to-XML mapping from Spring-WSEmbracing Java 5 (generics, autoboxing,

annotations, etc).

Page 126: What's new in Spring 3?

What’s going away

Page 127: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Bye bye

Page 128: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Bye bye

Spring MVC controller hierarchy (deprecated)

Page 129: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Bye bye

Spring MVC controller hierarchy (deprecated)

JUnit 3 testing

Page 130: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Bye bye

Spring MVC controller hierarchy (deprecated)

JUnit 3 testingCommons Attributes

Page 131: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Bye bye

Spring MVC controller hierarchy (deprecated)

JUnit 3 testingCommons Attributes

Native TopLink support

Page 132: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Bye bye

Spring MVC controller hierarchy (deprecated)

JUnit 3 testingCommons Attributes

Native TopLink supportWebLogic 8.1 and WebSphere 5.1

Page 133: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Bye bye

Spring MVC controller hierarchy (deprecated)

JUnit 3 testingCommons Attributes

Native TopLink supportWebLogic 8.1 and WebSphere 5.1

spring.jar

Page 134: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Bye bye

Page 135: What's new in Spring 3?

What else?

Page 136: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Keep your eye on...

Page 137: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Keep your eye on...

Spring Web Flow 2.0

Page 138: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Keep your eye on...

Spring Web Flow 2.0Spring BlazeDS

Page 139: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Keep your eye on...

Spring Web Flow 2.0Spring BlazeDS

Spring Security 3.0

Page 140: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Keep your eye on...

Spring Web Flow 2.0Spring BlazeDS

Spring Security 3.0Spring Dynamic Modules (Spring-DM)

Page 141: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Keep your eye on...

Spring Web Flow 2.0Spring BlazeDS

Spring Security 3.0Spring Dynamic Modules (Spring-DM)

SpringSource dm Server

Page 142: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Keep your eye on...

Spring Web Flow 2.0Spring BlazeDS

Spring Security 3.0Spring Dynamic Modules (Spring-DM)

SpringSource dm ServerSpringSource tc Server

Page 143: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Keep your eye on...

Spring Web Flow 2.0Spring BlazeDS

Spring Security 3.0Spring Dynamic Modules (Spring-DM)

SpringSource dm ServerSpringSource tc Server

Roo

Page 144: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Keep your eye on...

Spring Web Flow 2.0Spring BlazeDS

Spring Security 3.0Spring Dynamic Modules (Spring-DM)

SpringSource dm ServerSpringSource tc Server

RooGroovy/Grails

Page 145: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Keep your eye on...

Spring Web Flow 2.0Spring BlazeDS

Spring Security 3.0Spring Dynamic Modules (Spring-DM)

SpringSource dm ServerSpringSource tc Server

RooGroovy/Grails

SpringSource Tool Suite

Page 146: What's new in Spring 3?

In summary...

Page 147: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring simplifies

Page 148: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring simplifies

Spring’s initial focus was to simplify enterprise Java

Page 149: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring simplifies

Spring’s initial focus was to simplify enterprise Java

Now simplification efforts turn inward

Page 150: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring simplifies

Spring’s initial focus was to simplify enterprise Java

Now simplification efforts turn inwardTrending away from XML toward annotations

Page 151: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring simplifies

Spring’s initial focus was to simplify enterprise Java

Now simplification efforts turn inwardTrending away from XML toward annotations

All the while, offering more power

Page 152: What's new in Spring 3?

E-mail: [email protected] Blog: http://www.springinaction.com Twitter: habuma

Spring simplifies

Page 153: What's new in Spring 3?

Thank You

Don’t forget the evals!