Spring core components

Spring core components

 

 

The overall architecture diagram of the Spring framework


     
 

    There are only three core components in the Spring framework: Core, Context and Beans. They build the skeleton of the entire Spring. Without them, it is impossible to have upper-layer features such as AOP and Web.

 

 

 

Spring's Design Philosophy

 

    If you choose the core among the three, then the non-Beans component is none other than the non-Beans component. Why do you say that? Spring is actually Bean-oriented programming (BOP, Bean Oriented Programming), and Bean is the real protagonist in Spring.

 

    The role of Bean in Spring is the same as the meaning of Object to OOP. The concept of no object is like no object-oriented programming. If there is no Bean in Spring, there is no meaning of Spring's existence. It's like a show where the stage is ready but there are no actors. Why is Spring so popular, and why we use Spring, Bean wraps objects, and the Ioc container manages Beans, so that we don't have to manage objects and save a lot of time doing business.

 

    Its design strategy is completely similar to the design concept of Java's implementation of OOP. Of course, the design of Java itself is much more complicated than that of Spring, but it builds a data structure, and then designs its living environment according to this data structure. Let it move continuously in this environment according to certain rules, and design a series of information exchanges with the environment or with other individuals in their continuous movement. Thinking back and forth this way, the other frameworks we've used are largely similar in design.

 

 

 

How the core components work

 

    If you compare Bean to an actor in a performance earlier, the Context is the stage background of the performance, and the Core should be the props of the performance. Only when they are together can they have the most basic conditions to perform a good show. Of course, there are the most basic conditions that can't make this show stand out, and the shows he performs are exciting enough. These shows are the special functions that Spring can provide.

 

    We know that Bean wraps Object, and Object must have data. How to provide a living environment for these data is the problem to be solved by Context. For Context, it is to discover the relationship between each Bean and establish this relationship for them and maintain that relationship. So Context is a collection of Bean relations, which is also called Ioc container. Once the Ioc container is established, Spring can work for you. So what's the use of Core components? In fact, Core is a series of tools needed to discover, establish and maintain the relationship between each Bean. From this point of view, the Core component called Util can make you understand better.

 

The relationship between the three components


     
 

 

 

Detailed explanation of core components

 

Bean component

 

Bean components are in Spring's org.springframework.beans package.

The creation of Bean is a typical factory pattern, and its top-level interface is BeanFactory.


     
    

The main work of BeanFactory

 

  • Definition of Beans
  • Bean creation
  • Analysis of Beans

 

 

Context component

 

Context is in Spring's org.springframework.context package.

The top-level parent class of Context is ApplicationContext.



 

 

The main work of ApplicationContext

 

  • Identify an application environment
  • Use BeanFactory to create Bean objects
  • Save the object (Bean) relationship table
  • Capable of capturing various events
  • Internationalization of MessageSource

 

Core components

 

As the core component of Spring, the Core component contains many key classes, one of which is to define the access method of resources. Resource interface.

 

Core's main work

  • Resource: access resource files
  • Json: Interconversion between Object and Json
  • Format: data format
  • Filter: some filters

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326316308&siteId=291194637