In this presentation I will go through latest features being added in Spring 3.1/3.2 one more time and also will try to look behind the scene on what new features are comming in Spring 4 which should be released at the end of this year.
2. About me
Oleg Tsal-Tsalko
• Senior Java Developer in EPAM Systems.
• Mostly working with enterprise business
applications.
• Member of LJC and JUG KPI communities.
4. Spring 3.1
(Previous stop)
• Environment abstraction and profiles
• Java-based application configuration
• Overhaul of the test context framework
• Cache abstraction & declarative caching
• Servlet 3.0 based web applications
• @MVC processing & flash attributes
• Support for Java SE 7
And much more…
10. Profiles in Java based configuration
@Configuration
@Profile("dev")
public class DevProfileConfig {
@Bean(name="dataSource”)
public DataSource dataSource() {…}
}
@Configuration
@Profile("production")
public class ProductionProfileConfig {
@Bean(name="dataSource”)
public DataSource dataSource() {…}
}
@Configuration
@Import( { DevProfileConfig.class, ProductionProfileConfig.class } )
public class BookStoreAppConfig {
@Inject
private DataSource dataSource;
}
11. How to enable active profile?
1) Using JVM property, which is preferred way:
2) Programmatically in standalone app:
-Dspring.profiles.active=dev
3) In web.xml file:
12. Cache abstraction
• CacheManager and Cache abstraction in
org.springframework.cache
• Out of the box support for ConcurrentMap
and EhCache
• Ability to plug any Cache implementation (see
Spring GemFire project for GemFile adapter)
14. Enable caching annotations
@Configuration
@EnableCaching
public class AppConfig {
@Bean
public CacheManager cacheManager() {…}
…
}
<beans …>
<cache:annotation-driven />
<bean id="cacheManager"
class="org.springframework.cache.support.SimpleCacheManager">
…
</bean>
…
</beans>
15. Servlet 3.0 support
• such as Tomcat 7 and GlassFish 3
Explicit support
for Servlet 3.0
containers
• Servlet 3.0's ServletContainerInitializer mechanism
• Spring 3.1's
AnnotationConfigWebApplicationContext
• Spring 3.1's environment abstraction
Support for XML-
free web
application setup
• such as standard Servlet 3.0 file upload behind
Spring's MultipartResolver abstraction
Exposure of native
Servlet 3.0
functionality in
Spring MVC
17. Spring 3.2
(Current stop)
• Gradle-based build
• Sources moved to GitHub
• Sources built against Java 7
• Async MVC processing on Servlet 3.0
• Spring MVC test support
• MVC configuration and SpEL refinements
And much more…
18. Async MVC processing: Callable
- thread managed by Spring MVC
- good for long running database jobs, 3rd party REST API calls, etc
19. Async MVC Processing: DeferredResult
- thread managed outside of Spring MVC
- JMS or AMQP message listener, another HTTP request, etc.
20. Async MVC Processing: WebAsyncTask
- same as Callable, with extra features
- override timeout value for async processing
- lets you specify a specific AsyncTaskExecutor
24. Spring 4
(Next stop)
We are expecting to see:
• Comprehensive Java 8 support
• Support for Java EE 7 APIs
• Focus on message-oriented architectures
• Annotation-driven JMS endpoint model
• Revised application event mechanism
• WebSocket support in Spring MVC
• Next-generation Groovy support
And more…
25. Java 8 & Java EE 7 support
Comprehensive Java 8
support
• Lambdas
• Date and Time API (JSR-310)
• Parameter name discovery
• Repeatable annotations
• Concurrency enhancement
Support for Java EE 7 APIs
• Asynchronous API for RestTemplate
• Bean Validation 1.1 (JSR-349)
• Expression Language 3.0 (JSR-341)
• JMS 2.0 (JSR-343)
• Concurrency Utilities for Java EE (JSR-
236)
• JPA 2.1 (JSR-338)
• Servlet 3.1 (JSR-340)
• JSF 2.2 (JSR-344)
27. Bean Validation 1.1 support
MethodValidationInterceptor autodetects Bean Validation 1.1's ExecutableValidator API now
and uses it in favor of Hibernate Validator 4.2's native variant.
28. JMS 2.0 support
What was done already:
• Added "deliveryDelay" property on JmsTemplate
• Added support for "deliveryDelay" and CompletionListener to
CachedMessageProducer
• Added support for the new "create(Shared)DurableConsumer" variants in
Spring’s CachingConnectionFactory
• Added support for the new "createSession" variants with fewer
parameters in Spring’s SingleConnectionFactory
Known constraints:
• There is no special support for the simplified JMSContext API, and likely
never will be, because of different Spring mechanism of managing
connection pools and sessions
• JmsTemplate has no out-of-the-box support for send calls with an async
completion listener.
29. JEE7 concurrency utilities in Spring 4
This is built into ConcurrentTaskExecutor and ConcurrentTaskScheduler now,
automatically detecting the JSR-236 ExecutorService variants and adapting
to them.
Example of ManagedExecutorService usage introduced in JEE7:
35. JDK8 support in depth
• Implicit use of LinkedHashMap/Set instead of simple
HashMap/Set to preserve ordering diffs in JDK7 and JDK8
• Embed ASM4.1 into Spring codebase to support JDK8
bytecode changes and to keep compatibility with CGLib3.0
• Support for JDK 8 Data & Time (JSR-310) encorporated with
Spring’s Joda Time lib
• Add awaitTerminationSeconds/commonPool properties to
ForkJoinPoolFactoryBean to support JDK8 changes in it.
• Encorporate JDK8 changes in reflection API (such as
java.lang.reflect.Parameter)
36. Other changes…
• Replace Burlap with Hessian (lightweight binary WS protocol)
• Introduced @Conditional annotation (@Profile annotation
has been refactored)
• Updated to Gradle 1.6
37. How to track progress?
• Track JIRA -
https://jira.springsource.org/issues/?jql=proje
ct%20%3D%20SPR%20AND%20labels%20%3D
%20%22major-theme-4.0%22
• Check commits to codebase -
https://github.com/SpringSource/spring-
framework/commits/master
38. Thank you!
Oleg Tsal-Tsalko
Email: oleg.tsalko@gmail.com
Twitter: @tsaltsol
Special thanks to Josh Long (@starbuxman) for
sharing quite useful info…