Wednesday 21 December 2016

Spring Framework

By,
Santosh

Spring is developed by Rod B. Johnson  and he is an Australian computer specialist so spring was created the Spring Framework and co-founded SpringSource company  . Spring framework does the easy development of Java Enterprise Edition (Java EE) application
It is easy to use and understand and also helpful for beginners and experienced persons for developing JavaEE application.

Spring Framework
Spring is also called as lightweight framework of java and also spring is knows as a framework of frameworks because it provides support or helpful to various frameworks such as JSF, EJB, Tapestry , Hibernate, Struts etc. The framework means in broader sense, defined a structure where we find solution and comfortable technical environment of the various technical problems.
Spring framework contains several modules such as WEB MVC, ORM, DAO, IOC, AOP, Context etc. Let's  start with first module of spring that is IOC and Dependency Injection first.

Inversion Of Control (IOC) and Dependency Injection
We are uses the design patterns to remove dependency from the code. That makes the code easier to maintain and test.
class Student

    Collage collage; 
    Student ()
    { 
        student =new Student (); 
    } 


In above case, here is dependency between the Student and collage it is also called tight coupling and first we have to create the object of Collage and than only we will work on Student only.  So in Inversion of Control module, we do to remove dependency like below code.
class Student

    Collage  collage; 
    Student (Collage  collage )
    { 
        this. collage = collage;
    } 


So, Inversion Of Control makes the code loosely coupled because of that one code is not depend on another code. In such case, In new environment no need to modify the code if our logic is moved.
So in Spring framework, Inversion Of Control Module is responsible to inject the dependency. developer provide metadata to the IOC module either by annotation or XML file.

Dependency Injection Advantage -
•makes the code loosely coupled so easy to maintain
•makes the code easy to test

Advantages of Spring Framework
1) Fast Development :Spring Framework support to various frameworks. So makes the easy development of Java Enterprise Edition application.
2) Lightweight :Spring framework is lightweight because of its POJO implementation.
3) Loose Coupling :Because of dependency injection Spring applications are loosely coupled.
4) Easy to test :The Struts or EJB application require server to run the application but Spring framework doesn't require server.
5) Predefined Templates :It (Spring) provides templates for JPA, Hibernate, JDBC etc. technologies. So there is no need to write too much code.

No comments:

Post a Comment