Spring Framework History
Spring Framework has a philosophy of “release early, release often,” because of which maintenance releases and minor enhancements are released every four to six weeks. Major release details with major changes introduced, are as follows, beginning with most recent are as summarized below:
Spring 3.1 (released December 2011)
- Bean definition profiles – better classification and grouping of beans using the concept of profiles, both using annotation (@Profile) and XML is a huge addition in the Spring Framework. Combining with the concept of “Environment”, it provides ease of use of profiles.
- Cache abstraction using declarative configuration – adds support for transparently adding caching behavior by allowing consistent uses of various caching solutions available in the market to existing Spring applications.
- Servlet 3.0-based WebApplicationInitializer – WebApplicationInitializer is an alternate to the traditional web application descriptor file web.xml.
- JPA package scanning without persistence.xml and with support for Hibernate 4.0 – This version supports Hibernate 4.0.
- First class Java 7 support – Supports Java 7 in all aspects.
Spring 3.0 (released December 2009)
- Spring Expression Language – introduction of new expression language similar to Unified EL syntactically but offering advanced and other significant features.
- Inversion of Control enhancements/Java-based bean metadata – The key features in Spring JavaConfig project has been migrated to the core Spring Framework.
- General-purpose-type conversion system and field-formatting system – the package org.springframework.core.convert provides classes which provides general type conversion system which defines SPI to implement conversion logic.
- Object-to-XML mapping functionality (OXM) moved from Spring Web Services project to the core Spring Framework.
- Comprehensive REST support – support for REST based services in the server and client side.
- @MVC additions – Introduction of “mvc” namespace simplifies MVC related configurations in the Spring configuration file. Addition of other annotations makes the annotation based MVC application coding easy, simple and less of configuration.
- Declarative model validation – JSR-303 validation support using Hibernate validation as default provider. There are other validation enhancements also included as part of this release of Spring Framework.
- Early support for Java EE 6 – Core API’s updated to Java 5 utilizing its features as well as early support for Java EE 6.
- Embedded database support – support for embedded databases like HSQL, H2 and Derby in a native fashion. It also hosts extendable API which can be used to plug in to newer emerging databases.
Spring 2.5 (released November 2007)
- Full support for Java 6 and Java EE 5 which includes JDBC 4.0, JTA 1.1, JavaMail 1.4, JAX-WS 2.0 etc.
- Full-featured, annotation-driven dependency injection, such as @Autowired, @Controller, etc., including support for “qualifiers”.
- Auto-detection and Auto-configuration of various application components available in the classpath into the Spring’s IoC container.
- Introduction of new XML configuration namespaces namely “context” and “jms” for more convenience.
- Capability of packaging Spring Framework jars as OSGI-compliant bundles.
Spring 2.0 (released October 2006)
- Easier XML configuration – new XML configuration syntax based on XML Schema along with new and updated DTD.
- New bean scopes – in addition to existing two bean scopes, it adds new additional scopes which can be used according to the environment in which the Spring Framework is deployed. It also adds the capability of writing your own custom bean scopes.
- Easier AOP XML configuration – support for AspectJ along with simplification in AOP configurations in the form of namespace and new annotations.
- Portlet Framework – ships with new Portlet Framework very much similar to the Spring MVC Framework.
- Dynamic language support – support for beans written in other languages. At the moment Spring Framework supports JRuby, Groovy and BeanShell languages.
Spring 1.2 (released May 2005)
- Spring 1.2.6 Framework wins a Jolt productivity award and JAX innovation award.
Spring 1.1 (released September 2004)
- Support for JMS message sending and receiving.
- Using Spring’s consistent data-access abstraction, support for Apache OJB as an ORM alternative introduced.
- Significantly improved JDO support.
- Automatic translation of SQL related exceptions (SQLException) and other JDBC related exceptions.
- When working with JDBC, support for declarative transaction management capable of handling nested transactions and savepoints.
- Enhanced support for Apache Velocity and Freemarker.
Spring 1.0 (released March 2004)
- AOP-interception-framework based.
- Declarative and programmatic transaction management support with plugging in capability which can be used very easily to switch between the two.
- Generic DAO support, providing a generic data-access exception hierarchy for use with any data-access strategy.
- Abstraction of JDBC related services with good support for BLOB/CLOB operation which are conceived more difficult to work on.
- Hibernate support, providing SessionFactory management and transaction-scoped ThreadLocal Sessions.
- Mailing abstraction with full support for JavaMail with advanced support for working with files which needs to be attached along with the mail.
- Scheduling abstraction and support for well know scheduling frameworks like Quartz and JDK’s Timer which can be used for invoking methods in the Spring-managed beans.
- Remoting abstraction and support for RMI, JAX-RPC and Caucho’s Hessian/Burlap which can be made use for exposing Spring-managed beans.
Note: Only important and notable features in each release is covered in this section of the Chapter as packing too much content would not be an ideal start for this ‘beginning’ style Spring book.
Spring Framework Architecture
Spring as always tries to bring in good practices in the industry and also embraces proved best practices with both hands. It gives developers a consistent way of managing the all-important business objects and also encourages to program your logic in interfaces rather than classes. Spring Framework is based on its own well-known (Inversion of Control) IoC container which uses JavaBean and it’s properties. This IoC container is the main building block of Spring and is used in all the architectural tiers in a typical enterprise application.
The Spring Framework is a layered architecture comprising well-defined modules. All the various Spring modules available are built on top of the core IoC container which defines how the various beans in your application are created, configured, and managed. Figure 1-1 displays the various modules of the Spring Framework.
Figure 1 Modules of Spring Framework
Each of the Spring modules can stand on its own or be implemented jointly with one or more modules. The various components include:
- Spring Beans
- Spring Core
- Spring Context
- Spring Expression Language
- Spring AOP (Spring Aspect Oriented Programming)
- Spring Data Access/Integration
- Spring ORM (Spring Object Relational Mapping)
- Spring Web
- Spring Web MVC Remoting
Apart from the above, Spring Framework serves as the foundation for the wider family of open-source projects, some of which can be summarised as shown below:
- Spring Security
- Spring Integration
- Spring Batch
- Spring Data
- Spring Web Flow
- Spring Web Services
- Spring Mobile
- Spring Social
- Spring Android
- Spring Roo
- Spring AMQP, and
- Spring BlazeDS Integration
Note: The following sections briefly describe each of the preceding modules. Detailed explanations are not in the scope of this book, but I briefly explain some important projects, such as Spring Security and Spring Integration.
One package forming the basis for Spring Framework’s IoC container is org.springframework.beans. In Spring, the objects that form the backbone of your application and that are managed by the Spring IoC container are called beans, and this module manages these. The Spring IoC container instantiates, assembles and manages these beans in all aspects. If Spring Framework doesn’t manage it for you, a bean is simply one of many objects in your application. The IoC container uses the configuration metadata in which the various beans and its dependencies are written down.
This provides essential functionality of Spring Framework. The primary component of the so-called core container is the BeanFactory module, an implementation of the factory pattern. It applies the Inversion of Control (IoC) pattern, which separates an applications configuration and dependency specification from the actual application code.
The Spring context is a configuration file that provides context information to the Spring Framework. The Spring context also includes enterprise services, such as JNDI, mail, validation, remoting, and scheduling, among others. It also includes support for the integration with templating frameworks such as Velocity.
Spring Expression Language
The powerful Spring Expression Language (SpEL) supports querying and manipulating an object graph at runtime and in many ways similar to Unified EL (Expression Language) but makes it a point to offer additional features, notable ones being, method invocation and basic string templating functionality (covered in detail later). While SpEL serves as the foundation for expression evaluation within the Spring Framework, it is not directly tied to the Spring container and can be used independently as well.
Spring AOP is used to modularize cross-cutting concerns in an application. Using Spring AOP is simpler than using full AspectJ. Spring AOP is implemented in pure Java. Spring AOP does not need to control the class loader hierarchy and is thus suitable for use in a Java EE web container or application server.
Spring Data Access
Spring has good support for interaction with the data-access layer and business or service layer. Its comprehensive support for transaction management makes it ideal for enterprise applications. Spring Framework provides a consistent abstraction for transaction management.
Spring ORM module helps the application using Spring framework in integratiing with Java Persistence API (JPA), Hibernate, Java Data Objects (JDO), and iBATIS SQL Maps for resource management, various data-access object (DAO) implementations, and most of the transaction management strategies available. It uses Dependency Injection to support all the features of O/R (object relational) mapping tools. The major goal of Spring’s ORM integration is to have clear application layering, using any data-access and transaction technology, and loose coupling of application objects.
In line with the philosophy on which the framework is based—to enable choice—this module looks into the integration of Spring Framework with other favorite web technologies, such as Struts and JSF, showing you how to pick and choose a presentation layer. While Spring allows using your own presentation layer of your choice but gives you advantages associated with using the framework and aids in data-access abstraction, declarative transaction management and flexibility in the overall configuration of your application.
Spring Web MVC
In the case of a Web presentation layer, Spring wanted to give the community something unique and more. This was realized by having its own Web MVC framework, Spring MVC. Spring MVC’s key design principle of “Open for extension and closed for modification” means that the framework is always open to extensions but, because of certain design considerations, some classes are marked as final, which means developers cannot override them to introduce their own specific behaviors.
The Spring Security project is regarded as the de-facto framework for securing Spring applications and provides a powerful and highly customizable authentication and authorization framework. Founded in 2003, it is the most developed and widely used Spring project. Spring Security integrates seamlessly with other Spring technologies such as Spring MVC, Spring Web Flow, Spring Web Services, and other modules within the framework.
Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns. If you are looking for a lightweight message system to integrate into your Spring application, this module is ideal. It offers adapters that can provide you with high-level abstraction over Spring’s support for scheduling, remoting, and messaging.
Spring Batch provides a lightweight and comprehensive batch framework, which allows development of batch applications important to an enterprise application. Bulk processing is an integral part in any mission-critical application, and this module makes it easy and straightforward.
Moving away from conventional data-access technologies, new technologies, such as non-relational databases, map-reduce frameworks, and cloud-based data services, are on the rise. Spring Data aims to make using these easier for developers. Spring Data is an umbrella open-source project (Spring terminology) and contains many subprojects that are specific to a given database. In using this project, Spring also improves relational-database support.
Spring Web Flow
An extension project to Spring MVC, Spring Web Flow allows implementation of the “flows” in a Web application. Spring Web Flow provides a declarative flow-definition language for authoring flows on a higher level of abstraction. Following the Spring philosophy, it can be integrated seamlessly with Spring MVC, JSF, and Portlet Web applications.
Spring Web Services
Spring Web Services is Spring answer to creating document-driven Web services. It facilitates development of contract-first SOAP service development. It allows the creation of flexible Web services using one of the many ways to manipulate XML payloads.
Spring Mobile, an extension to Spring MVC, simplifies the development of mobile Web applications, including intelligent-device detection and progressive rendering options.
If you want to connect your application with Software-as-a-Service (SaaS) providers, such as Facebook and Twitter, Spring Social is tool of choice. It greatly simplifies the process of connecting local user accounts to hosted provider accounts.
If you want to build native Android applications, you can take the advantage of Spring Android. This is an extension project for Spring Framework.
Spring Framework already gives developers a high degree of productivity, but you can be even more productive using Spring Roo, which is branded as a next-generation rapid application-development tool for Java developers. Spring Roo is a lightweight developer tool that makes it fast and easy to deliver instant results using Spring Framework.
If you want to take the advantage of Core Spring for developing an AMQP-based messaging solution, Spring AMQP is your de facto choice. The framework provides “template” as a high-level abstraction for sending and receiving messages. It facilitates management of AMQP resources by using declarative configuration and promoting the use of Dependency Injection.
Spring BlazeDS Integration
Spring BlazeDS Integration, a component of the complete Web stack, is a top-level Spring project. Its main aim is to build a Spring-powered Rich Internet Application (RIA) using Adobe Flex. To do this, it uses open-source Adobe BlazeDS project and its powerful remoting and messaging facilities in combination with the familiar Spring programming model.
Page Visitors: 1791