Spring Dependency Injection and Inversion of Control Container Concepts: Difference between revisions
Line 29: | Line 29: | ||
====Dependency Injection==== | ====Dependency Injection==== | ||
=Application Context= | |||
https://docs.spring.io/spring-framework/docs/5.1.0.RELEASE/javadoc-api/org/springframework/context/ApplicationContext.html | https://docs.spring.io/spring-framework/docs/5.1.0.RELEASE/javadoc-api/org/springframework/context/ApplicationContext.html |
Revision as of 03:41, 9 October 2018
Internal
Overview
At the heart of the Spring Framework are the modules that implement the core container, including a configuration model and a dependency injection mechanism. Support for different application architectures, including messaging, transactions and persistence is built in top of the core container.
Inversion of Control Container
Configuration Model
This section refers to component configuration. Configuration as in external data that is provided to the application in form of properties or environment variables, and that potentially modifies the behavior of the application, is addressed in the "Application Configuration Concepts" section.
XML-based Configuration
Java-based Configuration (@Configuration). Annotation injection is performed before XML injection, thus the XML configuration overrides the annotations for properties wired through both approaches.
Configuration time. Define what that is.
Configuration class.
Component scanning.
Autowiring. @Autowired.
Automatic configuration (Spring Boot autoconfiguration).
Dependency Injection
Application Context
The application context provides:
- Bean factory functionality, inherited from ListableBeanFactory.
- Ability to load file resources, inherited from ResourceLoader.
- Ability to publish events to registered listeners, inherited from ApplicationEventPublisher.
- Ability to resolve messages, inherited from MessageSource.
- Inheritance from a parent context.
The application context is created during the bootstrapping phase of a Spring application.
Beans
Bean name
Collaborator beans
Describe bean initialization process. Who does it?
Stereotypes.