Topic 3:- 7 Spring Modules

image 2

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

ModuleCore containerApplication context
DescriptionProvides the fundamental features of Spring, such as Inversion of Control (IoC) and Dependency Injection (DI), and the BeanFactoryExtends the BeanFactory to provide more advanced features, such as easy access to application resources and the ability to use other frameworks
Main featuresIOC, DI, BeanFactoryAccess to application resources, integration with other frameworks
PurposeProvides the basic building blocks of Spring and helps manage object creation and lifecycleExtends the Core container to provide additional functionality and simplify configuration for complex applications
ExampleCreating a simple Spring application contextCreating 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.

FeatureBeanFactoryApplicationContext
Bean instantiationLazyLazy or eager
Dependency injectionYesYes
Bean scopesYesYes
Bean post-processingYesYes
AOP supportNoYes
InternationalizationNoYes
Resource loadingNoYes
Environment configurationNoYes
Application eventsNoYes
Web-specific featuresNoYes
Hierarchical contextsYesYes
Startup/shutdown callbacksNoYes
Annotation-based configurationNoYes
XML-based configurationYesYes

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