Chapter 5. Time Travelling with Spring

Spring 4.0 is the Java 8-enabled latest release of the Spring Framework. In this chapter, we'll discover the major changes in the Spring 4.x release and the four important features of the Spring 4 framework. We will cover the following topics in depth:

  • @RestController
  • AsyncRestTemplate
  • Async tasks
  • Caching

Discovering the new Spring release

This section deals with the new features and enhancements in Spring Framework 4.0. The following are the features:

  • Spring 4 supports Java 8 features such as Java lambda expressions and java.time. Spring 4 supports JDK 6 as the minimum.
  • All deprecated packages/methods are removed.
  • Java Enterprise Edition 6 or 7 are the base of Spring 4, which is based on JPA 2 and Servlet 3.0.
  • Bean configuration using the Groovy DSL is supported in Spring Framework 4.0.
  • Hibernate 4.3 is supported by Spring 4.
  • Custom annotations are supported in Spring 4.
  • Autowired lists and arrays can be ordered. The @Order annotation and the Ordered interface are supported.
  • The @Lazy annotation can now be used on injection points as well as on the @Bean definitions.
  • For the REST application, Spring 4 provides a new @RestController annotation. We will discuss this in detail in the following section.
  • The AsyncRestTemplate feature (class) is added for asynchronous REST client development.
  • Different time zones are supported in Spring 4.0.
  • New spring-websocket and spring-messaging modules have been added.
  • The SocketUtils class is added to examine the free TCP and UDP server ports on localhost.
  • All the mocks under the org.springframework.mock.web package are now based on the Servlet 3.0 specification.
  • Spring supports JCache annotations and new improvements have been made in caching.
  • The @Conditional annotation has been added to conditionally enable or disable an @Configuration class or even individual @Bean methods.
  • In the test module, SQL script execution can now be configured declaratively via the new @Sql and @SqlConfig annotations on a per-class or per-method basis.

You can visit the Spring Framework reference at http://docs.spring.io/spring/docs/4.1.2.BUILD-SNAPSHOT/spring-framework-reference/htmlsingle/#spring-whats-new for more details.

Also, you can watch a video at http://zeroturnaround.com/rebellabs/spring-4-on-java-8-geekout-2013-video/ for more details on the changes in Spring 4.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.22.164