What's Coming in Spring 3.1
Spring 3.1.0 M1 is expected to be released on Feb 10, 2011. There are many exciting new features expected for the final release which is scheduled for June 2011.
Environment Profiles
Many times we want separate configuration for different environments such as development, qa, production. Also, we may want to provide different bean configuration for traditional or cloud environments as well.
- Beans can be configured in XML with the additional "profile" attribute
- Activate 1..n profiles in code or with java arg
-Dspring.profiles.active="dev,qa" ParamNameforDispatcherServlet"spring.profiles.active"- Integration Tests Class
GenericXmlApplicationContext - Nested "beans" in other words, tag can have other tags within allowing multiple bean sets for different profiles in the same config file
- The variable “environment” is already registered for SpEL
@Profile(“development”)
public class MyClass() { ... }
#{environment[‘prop.key’]} public String myProp; The "c" Namespace
Much like the existing "p" namespace, the "c" namespace supports constructor arguments. This has the additional benefit of allowing us to reference the constructor arguments by name.
Cache Abstractions
- Cache Abstractions will be available – not just EHCache, also for Gemfire, Coherence
- Package:
org.springframework.cache - Annotation Package:
org.springframework.cache.annotation namespace
//referencing "cacheManager" @Cacheable //field or method @Cacheable(condition=“name.length @CacheEvict // remove field from cache public void clearMyField() { ... } Servlet 3.0
ServletContainerInitializer – XML Free config (no web.xml)
package org.springframework.web.context.support.AnnotationConfigWebApplicationContext
Async request processing
Standard file upload support
HTTP Session Improvements
Share information across multiple browser instances
Uses Shared Cookie
packageorg.springframework.web.bind.support.SessionAttributeStore
Conversation "scope"
Useful for MVC & JSF, Web Flow
Groovy Support
Groovy/Grails BeanBuilder inclusion
Groovy based template files (alternative to Velocity and Freemarker)
Feature Configuration
For Bean @Configuration - To support applications with Java based configuration.
packageorg.springframework.context.annotation
Picked up viaAnnotationConfigApplicationContext// Standalone application context, accepting annotated classes as input
Allows scanning for@Configurationclasses
@FeatureConfiguration// class level - specify the name of the Spring bean definition
@Feature// Method w/i@FeatureConfigurationClass
Customizable @MVC
Custom@ExceptionHandlersupport for @Controller methods
Custom@ExceptionHandlersupport for@RequestBody&@ResponseBody
You can write a BeanPostProcessor to change AnnotationMethodHandlerAdapter after construction
Auto-detection of customHttpMessageConverters- for example custom MyMappingJacksonHttpMessageConverter
Support for custom message codes resolver with
REST Enhancements
Interceptors forRestTemplate
ClientHttpRequestInterceptor
bufferRequestBodyproperty to theSimpleClientHttpRequestFactoryto handle large payloads withRestTemplate
NewWebRequest.checkNotModified(String)// only had long support previously
New@ResponseEntity
To support OAuth withClientHttpRequestInterceptors
Summary
Many of the items included here are specific features for 3.1.0.M1, there are many more improvements coming for MVC customization and REST improvements in M2.