Spring is a lightweight framework based on code first published in the book Expert One-on-One J2EE Design and Development by Rod Johnson. Spring’s main goal is to simplify building Java EE applications. Spring does this by providing a layered architecture that is based on the principals of Inversion of Control (IoC) and emphasizes the POJO programming model. Spring does not try to solve problems that have already been addressed by Java EE specifications and other open source projects. Instead, it offers an abstraction that helps integrate these technologies and make their use simpler and more fun.
At the core of the Spring framework lies an IoC container. The concepts of IoC are often expressed as the Hollywood Principal: “Don’t call us, we’ll call you”. IoC helps to move infrastructure responsibilities away from application code and into the framework, which frees developers to focus on business logic. Spring fully supports the concept of Dependency Injection by removing the requirement that application code depend on the container API (EJB) or use the cumbersome Service Locator pattern. Spring accomplishes this by injecting collaborating objects or configuration values into the target object using regular Java methods (Setter Injection) or constructor arguments (Constructor Injection). This approach to configuration also ensures that the system is self documenting.
Spring is also an aspect-oriented programming (AOP) framework. It makes available an AOP Alliance compliant implementation that allows developers to define method-interceptors and pointcuts to separate crosscutting concerns like transactions and security from application code. Since version 2.0, Spring also has full support for AspectJ-based AOP implementation which has even more features. With AspectJ’s help, Spring can now provide dependency injection for objects created outside of the Spring container for example with new operator. This capability is truly powerful as domain objects can now be injected with container services.
Although Spring does not directly compete with other open source projects, there are some areas of overlap. The major one is Web frameworks. Spring does provide it’s own implementation of action based Web MVC framework. It is tightly integrated with Spring Core and adheres to the same principals. At the same time Spring has integration layers for any number of Web frameworks, including Struts, WebWork and JSF.
Spring does not force the developers to use all of its features. Because of it’s modular architecture, developers can start using Spring in small chunks, making it easy to introduce Spring incrementally into an existing project.