Tuesday, May 24, 2011

Spring at a glance

Spring

Spring is an open source framework created to address the complexity of enterprise application development.

Advantages of Spring framework

Spring is a layered architecture. We can use what is required from those and leave others.

Spring enables POJO programming. POJO facilitates continuous integration, easier upgrades and switching.

The IOC feature of Spring simplifies JDBC

Open source framework.


POJO -Plain Old Java Object


Maintaining an enterprise java application for few years is even difficult to imagine due to their tightly coupled infrastructure frameworks which evolves rapidly.

Solution is using POJO. There is no magic in POJOs. There the classes don't implement infrastructure framework-specific interfaces. They are just plain Java classes. Therefore POJO decouples applications from changing frameworks. As a result, upgrading or switching to a new framework and integration will be easier and less risky.


Inversion of Control (IOC)


The concept of IOC pattern is that objects are not created,but described how they should be created. Here you do not connect your components and  services together on the code, but describe which services are needed by which components in a configuration file. In Spring, IOC container handles the hooking up all these. 
In Spring there are two types of IOC.

1. Constructor injection- Dependencies are provided as constructor parameters.
2. Setter Injection- Dependencies are given through javabean properties which are setter methods.


IOC benefits
  • Services can be easily connected by adding a new constructor or a setter method with less configuration.This minimizes the amount of code in an application.
  • IOC allows manually injecting any objects needed into the object under test. This makes unit testing more easy.
  • Loosely coupling is promoted as the dependencies are injected to the piece of requesting code.

2 comments: