All IT Courses 50% Off
JAVA Tutorials

Spring Framework

Spring is a development framework used to develop Java-based web applications. The spring framework will be called a lightweight framework. This is called the framework of the frameworks as it supports different sub frameworks like struts and hibernates, Tapestry, EJB, and JSF. This framework in a wider sense can be defined as a structure to find the solution to many technologies or may be technical problems.

spring framework tutorial

This spring framework consists of several modules like IOC, AOP, DAO, Context, ORM, and WEB MVC.

Inversion of control and Dependency Injection (IOC)

We have many design patterns which are used to remove dependency from the programming code. They will make the code very easier to test.

For example

class Employee{  

All IT Courses 50% Off

Address address;  

Employee(){  

address=new Address();  

}  

}  

In the above case, we have a dependency between the employee and the address. In the inversion of control. The example is like

class Employee{  

Address address;  

Employee(Address address){  

this.address=address;  

}  

}

The IOC will make the code loosely coupled where there is no need for modification of the logic which is moved in the environment. In the spring framework, the IOC container is responsible in to inject the dependency. We will provide the metadata to the IOC container by the XML file or may be an annotation.

The advantages of Dependency injection are:

It always makes the code loosely coupled that will be maintained easily.

It always makes the code easy to test.

Advantages of spring framework:

  The advantages of the spring framework. They are

  1. Predefined Templates:

Here the spring framework will provide templates for all the JDBC, Hibernate, JPA etc technologies. As there is no need to write much code. It is hidden as basic steps of these technologies. For example with JDBC Template, we don’t have to write the code for all the exception handling, creating connections, creating statements committing transactions, closing connections etc.

2) Loose coupling:

For the spring applications are loosely connected or coupled.

3) Easy to test

The Dependency Injection is very easy to test the application. The EJB struts applications require the server to run the application but the spring framework doesn’t require any server.

4) Lightweight

Spring framework or lightweight as it is its POJO implementation. The spring framework will not force the programmer to inherit any class or may implement any interface.

5)Fast Development

Here the dependency injection feature of the spring framework assists many numerous frameworks making the easy development of the JavaEE application.

6)Powerful abstraction:

It will provide a powerful abstraction to JavaEE specifications like JMS, JDBC, JPA and JTA.

7)Declarative support:

It will give us declarative support for caching, validation, transactions and formatting.

Spring Modules

The spring framework consists of many modules like core, beans, context, expression language, AOP, Aspects and Instrumentation, JDBC, ORM, OXM, JMS, Transaction, Web Servlet, struts. These modules will be grouped into Test, Core container, AOP, aspects, Instrumentation, Data Access/Integration, web-like

Test

It is a layer which gives support to testing JUnit and TestNG

Spring Core Container

The spring core container will contain a core, beans, context and expression language modules.

Core and Beans

The above modules provide IOC and dependency injection features.

Context

The module supports internationalisation, EJB, JMS, and basic remoting.

Expression language

It will be an extension of the EL defined in the JSP. It provides the support to set and also getting property values, method invocation, accessing collections and indexers, named variables, logical and arithmetic operators, and retrieval of objects by name.

AOP/Aspects and Instrumentation

These modules will assist the aspect-oriented programming implementation while we can use advice, and pointcuts to decouple the code.

The aspects will provide support to combine with the AspectJ.

Data Access/Integration

This group comprises JDBC, ORM, OXM and all the transaction modules. The modules will provide the assistance to interact with the database.

Web

The group consists of web, web servlet,web-struts and web portlet. These modules will help us to create a web application

Questions

  1. What is spring? Explain
  2. What are the advantages of the spring framework?
Facebook Comments

One Comment

  1. 1.What is spring? Explain
    The Spring Framework (Spring) is an open-source application framework that provides infrastructure support for developing Java applications.
    2.What are the advantages of the spring framework?
    1.Predefined Templates:
    2.Loose coupling.
    3. Easy to test
    4.Lightweight
    5.Fast Development
    6.Powerful abstraction:
    7.Declarative support:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles

Back to top button