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.
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.
In the above case, we have a dependency between the employee and the address. In the inversion of control. The example is like
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
- 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.
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.
Here the dependency injection feature of the spring framework assists many numerous frameworks making the easy development of the JavaEE application.
It will provide a powerful abstraction to JavaEE specifications like JMS, JDBC, JPA and JTA.
It will give us declarative support for caching, validation, transactions and formatting.
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
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.
The module supports internationalisation, EJB, JMS, and basic remoting.
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.
This group comprises JDBC, ORM, OXM and all the transaction modules. The modules will provide the assistance to interact with the database.
The group consists of web, web servlet,web-struts and web portlet. These modules will help us to create a web application
- What is spring? Explain
- What are the advantages of the spring framework?