What is Spring ?
- Spring is a Framework, it Provides an infrastructure of classes that make it easier to accomplish tasks.
- Spring is a Container,it Creates objects and makes them available to your application.
- A lightweight framework that addresses each tier in a Web application.
- Presentation layer : An MVC framework that is most similar to Struts but is more powerful and easy to use.
- Business layer : Lightweight IoC container and AOP support (including built in aspects).
- Persistence layer : DAO template support for popular ORMs and JDBC
- Promotes decoupling and reusability.
- POJO Based.
- Removes common code issues like leaking connections and more.
- Built in aspects such as transaction management.
- Lightweight container and framework
- Most of your code will be unaware of the Spring framework
- Use only the parts you of Spring you want
- Manages dependencies between your objects
- Encourages use of interfaces.
- Lessens “coupling” between objects.
- Cleaner separation of responsibilities.
- Put logic that applies to many objects in one single place.
- Separate the class’s core responsibility from other duties.
- Simplifies database integration
- Spring JDBC
- Hibernate
- iBATIS
- Java Persistence API
Simplify your code with Spring :
- Enables you to stop polluting code
- No more custom singleton objects
- Beans are defined in a centralized configuration file
- No more custom factory object to build and/or locate other objects
- DAO simplification
- Consistent CRUD
- Data access templates
- No more copy-paste try/catch/finally blocks
- No more passing Connection objects between methods
- No more leaked connections
- POJO Based
- Refactoring experience with Spring
- Caution Spring is addictive.
IoC(Inversion of Control) container :
- Setter based and constructor based dependency injection
- Portable across application servers
- Promotes good use of OO practices such as programming to interfaces.
- Beans managed by an IoC container are reusable and decoupled from business logic
AOP (Aspect-Oriented Programming):
- Spring uses Dynamic AOP Proxy objects to provide cross-cutting services
- Reusable components
- Aopalliance support today
- Integrates with the IoC container
- AspectJ support in Spring 1.1