Spring 3.1 Jurgen Holler (Spring Framework Project Lead)
Themes and Trends
Background and Current Trends
Again a mention of the cloud within the principle of war files becoming dominant
Given that most cloud stacks are simple arrangements of best of breed – what happens with the application servers? Only Glassfish supports all, JBoss 6 and Websphere 8 only support the Java EE Profile.
Tomcat 7 is the first server that SS test against. He expects all Clouds to offer Tomcat 7 as a default fairly soon.
From a spring perspective, Spring is DI, AOP and Portable Service Abstractions (Persistence, Scheduling, Transaction Strategies) around simple objects.
Spring 3.0 Review
Annotated component model, including JSR-330 support
Portlet 2.0 support
Declarative Model Validation (JSR-303 Bean Validation)
Spring 3.1 Key Themes
Environment Profile for Bean definitions
Java-based application configuration
Cache abstraction and declarative caching (fully fledged not just some EHCache beans)
Support for Servlet 3.0
Customizable @MVC processing (this was very popular in Spring 3.0)
Environment Profile for Bean definitions
A core api then provides an environment type
It is an SPI
PropertyPlaceholderConfigurer will now delegate
Profiles activate beans depending on attribute in the beans element e.g.
or @Profile on configuration classes or even on individual classes
Activated by -Dspring.profiles.active=production or something else like JNDI or environment variable or even programmatic. IDeally this should be done outside the deployment unit. This works well with Continuous Delivery
The Application Configuration model is very elegant. Able to offer almost as much power as the xml, including the tx name space. Builder classes are used to the session Factory for Hibernate for example. Builders are starting to crop up in Spring 3.1 in JPA for example to set up complex object in Java
SS are still investing in the xml namespace. Shortcut for constructor args, c:namespace. Using the constructor names gets around the issues for reflection (constructors have an index and a type) and other runtime issues. Allows final fields so always nice. But this uses ASM to read the debug symbols so how fragile is it even if it is expressive?
Very important with the rise of distributed caching – (cloud again!)
Before now, only had EhCache support
CA Allows you to integrate the likes of EhCache, Gemfire and Coherence.
The framework may not have specific examples since the caches are often closed source and proprietary
Setup is often on per environment bases so again plays well with the Environment Profiles
Not code, just annotations on methods, concise and readable
Caching bypass @Cacheable(condition=”name.length < 10″),
Strategies are customisable. Simple but powerful for the 80% that is this simple. More complex interactions can be done via the AbstractCacheManager which you can just inject
Also a cache namespace in xml.
Need to create a cacheManager, just like Tx namespace. If you don’t declare one then annotations are just bypassed so nice in dev.
such as Tomcat 7.0 and Glassfish 3
XML free spec (if you want)
Async request processing (Spring 3.1 does not support this yet)
File upload support as standard but how much of a pain point is this?
WebApplicationInitializer allows programmatic startup of the web app. I think that some best practise needs to spring up around this. How many do you want? What is the security implications of web.xml fragments, especially in 3rd party libs.
JPA requires an xml config so that may be the only one your application needs
Jurgen makes a good point that xml config is not necessarily bad. It’s readable and has great support in modern iDEs but now the choice is yours and not made for your by the framework.
Configurable MVC processing
REST support is improved
Arbitary mappings better supported
more flexible lifecycle and storage options
Seems to be more around the integration/management rather than a new scope: isolation between tabs and windows where they share HttpSessions but this is a flag rather than anything more sophisticated.
Spring 3.1 M2 is going to be released this week. No M3 , RC is next
Spring 3.2 planed for Spring 3.2. Direct follow up for 3.1 but based around Java 7 (GA release Q3 2011). JDBC 4.1 support and support for fork-join framework. Also JSF 2.2 and JPA 2.1 updates and maybe Hibernate and Quartz updates
Java 7 offers some new concurrent programming APIs (like java.util.concurrent.ForkJoinPools) that offer really good functionality