Step 3- Spring Modules (IOC/AOP/MVC)

Spring Modules –

Spring has 7 modules

Let’s take a look for first 3 modules,

ModuleCore containerApplication contextAOP
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 frameworksProvides Aspect-Oriented Programming (AOP) support, including the ability to define method interceptors and plugging in other AOP frameworks
Main featuresIOC, DI, BeanFactoryAccess to application resources, integration with other frameworksMethod interception, pluggable AOP 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 applicationsProvides a way to modularize cross-cutting concerns such as logging, security, and transactions
ExampleCreating a simple Spring application contextCreating an application context with configuration filesDefining an aspect to log method execution time

1,2- [Comparsion between Core Container and Application Context modules]-

1- Core Container Module – It’s original and old ways and it uses BeanFactory class and provides basic features.

2- 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.

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

– IOC (Inversion of control)-

Read here in details- Step 3

3- AOP (Aspect Oriented Programming) –

Read here in details- Step 4

4-JDBC Abstraction and DAO-

Read here in details- Step 5

5- O/R mapping integration –

Read here in details- Step 6

6- Web Module

Read here in details- Step 7

7- MVC Framework Module

Read here in details – Step 8