Through the previous introduction, I believe that everyone on the bean parsing, registration of the overall process of understanding, know how spring step to the XML document in the configuration information into the container. There are several very important interfaces that have to be talked about.
1.Beandefinition Interface
This interface can be understood as the data carrier of an XML bean element. It is known by comparing the attribute list of the XML bean tag and the Beandefinition property list.
There is a class Beandefinitionholder,beandefinitionholder, which holds beandefinition by name or alias, it hosts the mapping information for name and Beandefinition.
Beanwarpper:
Provides methods for analyzing and manipulating standard JavaBean: Single or bulk get and set property values, get property descriptors, query properties for readability and legibility, and more. Nested settings for attributes are supported, with no depth limit.
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/78/7C/wKioL1Z98tTw-BFgAACsVhTqWgM923.png "title=" 1.png " alt= "Wkiol1z98ttw-bfgaacsvhtqwgm923.png"/>
Attributeaccessor: The interface defines the most basic modification or acquisition of any object's metadata
Beanmetadataelement: Used to transfer a configurable source object (source code)
Childbeandefinition is a bean definition that can inherit the settings of its parent class. That is, Childbeandefinition has a certain dependency on rootbeandefinition (now the spring source is no longer in use). Childbeandefinition inherits the construction parameter value from the parent class, the property value can override the parent class's method, and the new property or method can be added. (similar to the inheritance relationship for Java classes). Note: Starting with spring 2.5, a better registered Bean definition class genericbeandefinition is provided, which supports the dynamic definition of parent dependencies by Genericbeandefinition.setparentname (java.lang.String), genericbeandefinition can effectively replace the childbeandefinition of the largest division of the use of the occasion. I found that in the spring3.1.2 version, the class was no longer in use.
Genericbeandefinition is a one-stop standard bean definition, in addition to those other bean definition features that have the specified class, optional construction parameter values, and attribute parameters. It also has the flexibility to set the parent bean definition through the Parenetname property.
Typically, the genericbeandefinition is used to register a user-visible bean definition (the visible bean definition means that the bean in that class can Define post-processor on the definition to operate on the bean, even to configure the parent name to extend the preparation. RootBeanDefinition/ parent/child The bean definition of the relationship. ChildBeanDefinition用来预定义具有
A rootbeandefinition definition indicates that it is a consolidated bean definition: A specific bean can be returned during spring beanfactory run. Rootbeandefinition can be used as an important common bean definition view.
The rootbeandefinition is used to register bean definition during the configuration phase. Then, from spring 2.5, there is a better way to write a registered bean definition: genericbeandefinition. Genericbeandefinition supports dynamic definition of parent class dependencies, not hard-coded as root bean definition. where rootbeandefinition is the most common implementation class, it corresponds to a generic <bean> element tag
Parent <bean> and child <bean> can be defined in the configuration file, and the parent <bean> is represented by rootbeandefinition, while the child <bean> is represented by Childbeandefiniton. Instead of the parent <bean> <bean>, use rootbeandefinition to represent it.
2.BeanFactory interface
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/78/7D/wKiom1Z986CTR9YuAACBkxMK_SA754.png "title=" 2.png " alt= "Wkiom1z986ctr9yuaacbkxmk_sa754.png"/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/78/7C/wKioL1Z989-AMApQAAB9dL3Yghw948.png "title=" 3.png " alt= "Wkiol1z989-amapqaab9dl3yghw948.png"/>
These are the main classes or interfaces
Configurablebeanfactory: Provides various methods for configuring factory. Not available for general applications, mainly for Listablebeanfactory and beanfactory support
Listablebeanfactory: Getting the Bean's configuration list based on conditions
Configurablelistablebeanfactory: Gets the functionality of beandefinition and pre-instantiating a singleton bean. Beanfactory configuration checklist, specifying ignore types and interfaces
Autowirecapablebeanfactory: provides automatic assembly functionality, provides creation, injection, initialization, and application of the bean's post-processor
Hierarchicalbeanfactory: Hierarchical Management
If, hard to understand what the meaning of these classes are, a bit bitter. Can think backwards. It would be convenient to think of these factories as a tailor.
Configurablebeanfactory: You asked for the style of the dress.
listablebeanfactory: List of required materials
Autowirecapablebeanfactory: Sewing machine, needlework tool
hierarchicalbeanfactory: Kit use
Configurablelistablebeanfactory: The tailor's assistant
3.ApplicationContext interface
Can be said to be our business system, the main face of the interface. Spring's powerful extended capabilities are all implemented here. The beanfactory is initialized through internal calls and is transparent to the user.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/78/7C/wKioL1Z99hey06K6AAGsyzcfwnc434.png "title=" 5.png " alt= "Wkiol1z99hey06k6aagsyzcfwnc434.png"/>
Abstractrefreshableconfigapplicationcontext: Specifying the configuration path
Abstractrefreshableapplicationcontext: supports multiple calls to refresh. The Refreshbeanfactory method is implemented for Abstractapplicationcontext called.
Abstractapplicationcontext: Template mode Implementation initialization process
publicvoid refresh () throws BeansException, IllegalStateException { synchronized (This.startupshutdownmonitor) { // Prepare this context for refreshing. preparerefresh (); // Tell the subclass to refresh the internal bean Factory. configurablelistablebeanfactory beanfactory = obtainfreshbeanfactory (); // prepare the bean factory for use in this context. preparebeanfactory (beanfactory); try {&Nbsp; // allows post-processing of the bean factory in context subclasses. postprocessbeanfactory (beanfactory); // invoke factory processors registered as beans in the context. invokebeanfactorypostprocessors (beanfactory); // register bean processors that intercept bean creation. Registerbeanpostprocessors (beanfactory); // initialize message source for this context. Initmessagesource (); // initialize event multicaster for this context. initapplicationeventmulticaster (); // Initialize other special beans in specific context subclasses. Onrefresh (); // check for listener beans and register them. registerlisteners (); // instantiate all remaining (Non-lazy-init) singletons. finishbeanfactoryinitialization (beanfactory); // Last step: publish corresponding Event. finishrefresh (); } catch (BEANSEXCEPTION&NBSP;EX) { Logger.warn ("exception encountered during context initialization - cancelling refresh attempt ", ex); // Destroy already created singletons to avoid dangling Resources. &nbsP; destroybeans (); // Reset ' Active ' flag. cancelrefresh (ex); // Propagate exception to caller. throw ex; } } }
The following is an analysis of each step of the process (from spring depth source code analysis)
This article is from a "simple" blog, so be sure to keep this source http://dba10g.blog.51cto.com/764602/1728512
Spring Series four Beandefinition interface, Beanfactory interface