Spring Introduction

What is Spring? Spring is an open source framework, which is light weight. It resolves commonly and repeatedly occurred problems. Spring is famous for its modularity, which means we can use only those parts of spring that we need to build our application. Rest of the parts can be ignored. Spring is more flexible when compared to Struts, because struts is a framework which is used to develop only web based applications. Whereas spring framework can be used to develop both stand alone applications as well as web based applications. Spring framework uses MVC (Model-View-Controller) architecture.
Below are the main concepts on which spring was built.

Inversion of control (IoC)

Inversion of control or IoC is the core of spring framework. As the name suggests IoC manages java objects from construction to destruction. In other words it manages the life cycle of the object. For example, a person X is supposed to do a work. Instead of person X, person Y has done the work. The outcome of the person Y work is used by person X. We call this as "Inversion of Control". In struts we create the DAO object and call the methods. If we use spring IoC, spring is responsible to create DAO class object. Developer is responsible to call the methods of DAO.

Dependency Injection (DI)

Dependency Injection (DI) is a flavor of Inversion of Control. The inversion of control is more general concept and dependency injection is a concrete form of IoC. Dependency is a process whereby objects define their dependency. There are two ways using which dependency injection can be achieved in spring. One is Setter method injection and the other is using Constructor injection.

Aspect Oriented Programming (AOP)

In simple words Aspect Oriented Programming (AOP) concept is similar to the triggers concept in data base. Using aspects Spring can add additional functionality to a method execution. This additional functionality could be before a method execution or after method execution.

No comments:

Post a Comment