
Play Store Application link β Spring Framework in 9 steps – Apps on Google Play
Spring Modules –
Spring has 7 modules–
1- Core Container (Bean Factory)/ Application Context
Module | Core container | Application context |
---|---|---|
Description | Provides the fundamental features of Spring, such as Inversion of Control (IoC) and Dependency Injection (DI), and the BeanFactory | Extends the BeanFactory to provide more advanced features, such as easy access to application resources and the ability to use other frameworks |
Main features | IOC, DI, BeanFactory | Access to application resources, integration with other frameworks |
Purpose | Provides the basic building blocks of Spring and helps manage object creation and lifecycle | Extends the Core container to provide additional functionality and simplify configuration for complex applications |
Example | Creating a simple Spring application context | Creating an application context with configuration files |
– [Comparsion between Core Container and Application Context modules]-
A- Core Container Module – It’s original and old ways and it uses BeanFactory class and provides basic features.
B– Application Context Module – It’s modern and new way, it uses ApplicationContext class which is created using BeanFactory class.
So We can say,
ApplicationContext = BeanFactory + other features.
Because, ApplicationContext interface extends the BeanFactory interface and provides all the features of BeanFactory, such as object creation and dependency injection. In addition, ApplicationContext provides additional features such as internationalization support, event publishing, resource loading, and application context hierarchy.
–Differences between ApplicationContext
and BeanFactory
–
In Spring Framework, an ApplicationContext
can be created using a BeanFactory
under the hood. The ApplicationContext
interface extends the BeanFactory
interface, which means that an ApplicationContext
is also a BeanFactory
.
When you create an ApplicationContext
instance, it actually creates and initializes a BeanFactory
behind the scenes. The BeanFactory
is responsible for managing the beans defined in the application context.
The main difference between the two is that an ApplicationContext
provides additional features like support for annotation-based and XML-based configuration, internationalization, resource loading, and more. Additionally, an ApplicationContext
may eagerly instantiate singletons by default, while a BeanFactory
lazily instantiates all beans by default.
When you create an ApplicationContext
, Spring first creates and initializes a BeanFactory
to manage the beans. The ApplicationContext
then wraps the BeanFactory
and provides additional functionality on top of it. This means that you can still access the underlying BeanFactory
from an ApplicationContext
and use its basic functionality.
In layman’s terms, you can think of an ApplicationContext
as a more advanced version of a BeanFactory
that provides additional features and functionality. It’s like a “supercharged” BeanFactory
.
Feature | BeanFactory | ApplicationContext |
---|---|---|
Bean instantiation | Lazy | Lazy or eager |
Dependency injection | Yes | Yes |
Bean scopes | Yes | Yes |
Bean post-processing | Yes | Yes |
AOP support | No | Yes |
Internationalization | No | Yes |
Resource loading | No | Yes |
Environment configuration | No | Yes |
Application events | No | Yes |
Web-specific features | No | Yes |
Hierarchical contexts | Yes | Yes |
Startup/shutdown callbacks | No | Yes |
Annotation-based configuration | No | Yes |
XML-based configuration | Yes | Yes |
2- IOC (Inversion of control)-
Read here in details- Step 4
3- AOP (Aspect Oriented Programming) –
Read here in details- Step 5
4-JDBC Abstraction and DAO-
Read here in details- Step 6
5- O/R mapping integration –
Read here in details- Step 7
6- Web Module
Read here in details- Step 8
7- MVC Framework Module
Read here in details – Step 9