Spring Framework provides us an easy way to build lightweight enterprise applications.
The classes we write using Spring Framework are not tightly coupled to the API of Spring Framework and hence, the enterprise applications using Spring Framework are easy to code, maintain and reuse.
Spring Framework also provides support for making
an enterprise application that works with various other frameworks and technologies such as Hibernate, JDBC, Java Mail etc.
Features supported by Spring Framework
Spring Framework provides some very important features which allow us to develop loostly coupled, scalable, modifiable and easy to code enterprise applications.
Let's discuss these features and what exactly they are used for.
Dependency Injection is a feature of Spring Framework which allows us inject primitive values as well as an object(bean) value into another object(bean).
In dependency injection, a dependency could be a primitive value or an object(bean).
An injection is the passing of a such dependency(primitive value or an object) to a dependent object that would use it.
Dependency injection can be performed in two ways -
By setter methods
Java Collection Framework Support
A collection of objects could be stored in an array or we could use Java a collection such as - list, set, map to hold objects of similar type.
Spring Framework provides different tags which allows us to work with Java array or collections within an enterprise application.
Spring Framework provides various classes to easily work with JDBC and perform JDBC operations, such as -
Creating a connection with the database.
Creating the Statement object.
Executing the queries.
Handling the exceptions.
Spring Framework processes our query and get the result after executing it on the database.
Transaction Management is to manage the transaction operations in a way that maintains the consistency and integrity of data within the database.
There are two ways to perform transaction management -
Programmatic Transaction Management - Programmatic Transaction Management involves writing the code performing the transaction management.
To perform the transaction management programmatically, Spring Framework provide us a org.springframework.transaction.support.TransactionTemplate class.
Declarative Transaction Management - Unlike the programmatic transaction management approach, the declarative transaction management
approach doesn't require us to write or modify the source code to perform transaction management.
Declarative Transaction Management involves performing the transaction management through the configuration xml file i.e.
you can declared all the transaction elements within the configuration xml file of your project.
This configuration xml file is maintained by the Spring Container in Spring Framework.
Object Relational Mapping(ORM) Support
Spring Framework provides support for working with Object Relational Mapping(ORM) Framework like Hibernate.
Only using an Object Relational Mapping(ORM) Framework with your
enterprise application requires one to write a lot of code which can be reduced by using Spring Framework.
Spring Framework makes the working with an Object Relational Mapping(ORM) Framework very easy and thus make an enterprise application easy to code and maintain.
Aspect Oriented Programming(AOP) Support
An application code may have many several points in it at which an important module can be introduced.
Using Aspect Oriented Programming(AOP), we can introduce new features in an existing application without changing its design.
Spring Framework provides support for working with Aspect Oriented Programming(AOP)in an enterprise application.
Java Mail Support
Spring Framework provides support for working with Java Mail API to allow an enterprise application to send e-mail messages.
Directly using an Java Mail API with your
enterprise application requires one to write a lot of code which can be reduced by using classes provided by Spring Framework to support Java Mail features.