Spring Framework is a lightweight framework which supports various frameworks such as Struts, Hibernate, EJB & JSF etc. It was developed by Rod Johnson in 2003 which makes the easy development of Java application. The Spring framework comprises various modules such as IOC, ORM, MVC etc.Spring is the most powerful app development framework for Java Programming. Spring Framework is used by millions of peoples worldwide to create high performing, easily testable, and reusable code.Spring framework makes J2EE application development easier and delivers good programming practices by enabling a POJO-based programming model. Spring Framework 5.0 is the major release of the Spring Framework project which lead first Spring Framework 5.0 on July 28, 2016.[sociallocker id=”2334″] 40-Ways-to-increase-website-traffic.pdf (483 downloads) [/sociallocker]
Top 7 New Features and Enhancements in Spring Framework 5.0
- Spring Web MVC
- Reactive Programming Model
- Spring Web Flux
- JDK 8+ and Java EE 7+ Baseline
- Spring Core Container
- Testing improvements
- Functional Programming With Kotlin 1.1
1. Spring Web MVC
It provides full Servlet signature support in Spring Filter implementations with servlet PushBuilder argument in Spring MVC methods. It includes Unified support for common media using MediaTypeFactory delegate & Java Activation Framework.
The Spring Web model-view-controller framework is designed to dispatch requests to handlers by configuring handler mappings, view resolution, time zone and theme resolution. It also supports for uploading files as well as a wide range of flexible handling methods based on controller & request mapping.
Features of Spring Framework Web MVC
- Spring Web Flow is the best support & solution for the web application management where page flow integrates with existing frameworks like MVC and JSF, which includes Servlet and Portlet too.
- It allows capturing logical page flows as well as self-contained modules which are reusable to build web application modules that help to guide the user during controlled navigations for driving business processes.
- Spring web flow offers best web support features such as clear separation, Each role controller, role validator, command form object, model object, Servlet & mapping etc.
- It enables powerful configuration of both framework and application classes in a form of JavaBeans. This configuration includes easy reference across contexts as web controllers, business objects, and validators.
- The best spring web MVC feature is the Customizable binding and validation. It includes Type mismatch in app level validation that keep the localized date and number binding, String form objects with manual parsing and conversion to business objects.
2. Reactive Programming Model
- A new feature introduces in Spring 5 release is the new reactive stack web framework. A fully reactive and non-blocking stack is useful for event loop style processing that can scale by a small number of threads.
- The Reactive API is officially part of Java 9 whereas Java 8 includes a dependency for the Reactive API specification.The reactive stack is an API which is developed by the developer from Netflix, Pivotal, Typesafe, Red Hat, Oracle, and Twitter.
- It provides a common API for reactive programming and its implementations such as JPA for Hibernate where JPA is an API and Hibernate is an implementation.
- Spring Framework 5.0 has streaming support built on Project Reactor which is a fourth-generation Reactive library for building non-blocking applications on the JVM based on the reactive stream specification.
3. Spring WebFlux
- Spring Framework 5.0 comes with a new spring web flux module that supports reactive HTTP and WebSocket clients.
- Best Spring Framework 5.0 also support reactive web applications on servers such as REST, HTML, and WebSocket etc.
Two Programming Model Spring Framework Webflux Server-side:
- Annotation-based with @Controller style, annotation-based on programming model, to Spring MVC, in WebFlux, that runs on a reactive stack.
- Functional style routing and handling with Java 8 lambda with fully asynchronous and non-blocking. It support an event-loop execution model as well as traditional large thread pool with thread-per-request execution model.
4. JDK 8+ and Java EE 7+ Baseline
- The complete Spring Framework 5.0 code runs on Java 8. Hence, Java 8 is Spring Framework 5.0 minimum work requirement. The new feature is the part of the modern web framework in Java 8 releases.
- Spring Framework 5.0 expected to release with Java 9. Whereas, Java 9 release expected in September so spring developer team decided to decouple the Spring Framework 5.0 release from Java 9.
- This powerful framework has improved readability through generics, lambdas and also provide conditional support for java8 features. It offers compatibility with JDK 9 on runtime, classpath & automatic modules too.
5. Core Container
- Spring Framework 5 CCI works in the classpath scanner where CCI replaces with classpath scanning.
- An application can define its own spring.components file & meta INF for the current project. Hence, the source model gets examine with JPA entities and Spring Components.
- Reading entities from the index is helpful for large projects rather than scanning the classpath. Loading the component index is easy & startup time remains constant when the number of classes increases. It means on large spring projects, the startup time for applications reduces.
Some Other New And Enhanced Features Are:
- It implements functional programming style in GenericApplicationContext and AnnotationConfigApplicationContext.
- Consistent detection of a transaction, caching, and async annotations on interface methods.
- XML configuration namespaces streamlined towards unversioned schemas.
- Support for latest XSD files with no support for deprecated features.
- Version-specific declarations support but validation against latest schema.
6. Testing Improvements
- Spring Framework 5.0 provides support for Junit4 as well as new JUnit 5 Jupiter to write tests and extensions in JUnit 5.
- The Jupiter project provides support for programming and extension model in test engine to run Jupiter-based tests on Spring Framework. It offers parallel test execution in Spring TestContext Framework.
- Spring Framework 5 includes WebTestClient for integrating testing support for Spring WebFlux. As well as for reactive programming model & spring-testing.
- New WebTestClient & MockMvc does not need the running server so it can bind directly to the WebFlux server infrastructure & design.
- The print() and log() function in Spring MVC Test can print the request body when the character encoding is set.
- The redirected URL() and forwarded URL() function in Spring MVC Test now support URI templates with variable expansion.
7. Functional Programming Kotlin 1.1
- Spring Framework 5.0 introduces powerful JetBrains Kotlin language which is an object-oriented language with functional programming style.
- It runs on top of the JVM where Spring developers focus on functional Spring programming as well as functional Web endpoints and bean registration.
- Kotlin extensions are provided in order to allow idiomatic Kotlin code for developing Spring Framework 5 applications.
- Kotlin provides null-safety support for @Autowired/@Inject and @RequestParam/@RequestHeader/etc annotation so as to determine the parameter/bean is require or not.
- It also offers functional bean registration Kotlin DSL for GenericApplicationContext & Functional routing Kotlin DSL for WebFlux too.