Spring IOC – Bean life cycle instantiation

As mentioned in the Spring startup process article, the initialization of the container starts with the refresh method, which calls the finishBeanFactoryInitialization method during the initialization process. In this method, the DefaultListableBeanFactory#preInstantiateSingletons method will be called. The core function of this method is to initialize non-lazy-loaded beans, and provides two extension points. The source code […]

Spring IOC – BeanDefinition parsing

1. Properties of BeanDefinition BeanDefinition as an interface defines the get and set methods of properties. These attributes are basically defined in its direct implementation class AbstractBeanDefinition. The meaning of each attribute is as shown in the following table: Type Name Meaning Constant SCOPE_DEFAULT Default scope: singleton mode AUTOWIRE_NO no autowiring AUTOWIRE_BY_NAME Autowire by name […]

SpringSpring IOC & DI

Spring IOC & DI Getting Started with IOC DI What is Spring What is a container What is IOC Introduction to IOC traditional program development solution DI Detailed explanation of IOC Bean storage @Controller(controller storage) @Service(service storage) @Repository(warehouse storage) @Component(component storage) @Configuration(configuration storage) Why do we need so many class annotations? Relationship between class annotations […]

final finally finalize difference stream stream Stream method mvc aop ioc understanding the difference between Collection and Collections Nacos AP, CP

Method to create thread 1. The class inherits Thread and overrides the run() method 2. The class implements the Runnable interface and overrides the run() method (no return value, no exception will be thrown) 3. Implement the Callable interface and implement the call() method (with a return value and an exception will be thrown) To […]

How to manually obtain the IOC container (global context object) in spring/springboot?

IDE: IntelliJ IDEA 2022.2.3 x64 Operating system: win10 x64 bit home edition JDK: 1.8 Article directory Preface 1. How to manually obtain the spring container [ApplicationContext]? Method ①: Get the spring container in the startup class Method ②: Customize the tool class to implement the ServletContextListener interface to obtain the spring container [recommended web project] […]

4 ways for IOC containers to create bean instances

Personal public account: 😕 Can be programmed? Personal Creed: Be content with what you are satisfied with and know what you are not enough to do. Do something or not do something. Both doing and not doing are acceptable Introduction to this article: This article records 4 ways for IOC containers to create bean instances. […]

Example of IOC control program for DC power supply based on EPICS stream module

This example program implements network control and access to the UDP6720 series DC power supply. First, let’s introduce the hardware used in this project: 1. UDP6721 DC power supply: controlled equipment 2. moxa serial port server 5150: converts the UDP6721 DC power supply device serial port connection into a network connection 3. Orange Pie Zero3: […]

IOC and AOP of Spring system

Foreword Spring is a lightweight Inversion of Control (IoC) and Aspect-Oriented (AOP) container framework. IOC 1. Concept of IOC Inversion of Control (IoC=Inversion of Control) IoC, in vernacular terms, means that the container controls the (dependency) relationship between programs, instead of being directly controlled by program code in traditional implementations. This is the so-called “inversion […]

Spring IOC – ConfigurationClassPostProcessor source code analysis

As mentioned above, Spring will manually register 5 Processor classes into the beanDefinitionMap during the Bean scanning process. ConfigurationClassPostProcessor is what this article will explain. This class will be called in the refresh() method by calling invokeBeanFactoryPosstProcessors(beanFactory). The list of 5 Processor classes is as follows: Class name Whether BeanDefinitionRegistryPostProcessor Whether BeanFactoryPostProcessor Whether BeanPostProcessor ConfigurationClassPostProcessor […]