Spring IOC Part 3: Parsing of Default Labels

private  void parseDefaultElement(Element ele, BeanDefinitionParserDelegate delegate) {
         // Processing import tags 
        if (delegate.nodeNameEquals(ele, IMPORT_ELEMENT)) {
            importBeanDefinitionResource(it);
        }
        // Processing the alias tag 
        else  if (delegate.nodeNameEquals(ele, ALIAS_ELEMENT)) {
            processAliasRegistration(it);
        }
        // Processing bean tags 
        else  if (delegate.nodeNameEquals(ele, BEAN_ELEMENT)) {
            processBeanDefinition(ele, delegate);
        }
        // Processing the label of beans 
        else  if (delegate.nodeNameEquals(ele, NESTED_BEANS_ELEMENT)) {
             // recurse 
            doRegisterBeanDefinitions(ele);
        }
    }

The processing of new bean tags is mainly divided here , and the others are similar

 

/**
     * Process the given bean element, parsing the bean definition
     * and registering it with the registry.
     */ 
    protected  void processBeanDefinition(Element ele, BeanDefinitionParserDelegate delegate) {      
 // First, entrust the parseBeanDefinitionElement method of the BeanDefinitionParserDelegate class to parse the element, and return the instance BeanDefinitionHolder object. After this method, the bdHolder instance already contains various types of configuration files that we have configured. Attributes, such as: class, id, alias and other attributes. 
        BeanDefinitionHolder bdHolder = delegate.parseBeanDefinitionElement(ele);
         if (bdHolder != null ) {
 // When the returned BeanDefinitionHolder object instance bdHolder is not empty, if there is a custom attribute under the byte point of the default label, it is also required Parse the custom property again. 
            bdHolder = delegate.decorateBeanDefinitionIfRequired(ele, bdHolder);
             try {
                 //Register the final decorated instance.
 // After the parsing is completed, the parsed bdHolder needs to be registered. Similarly, the registration operation is delegated to the registerBeanDefinition method of BeanDefinitionReaderUtils. 
                BeanDefinitionReaderUtils.registerBeanDefinition(bdHolder, getReaderContext().getRegistry());
            }
            catch (BeanDefinitionStoreException ex) {
                getReaderContext().error("Failed to register bean definition with name '" +
                        bdHolder.getBeanName() + "'", ele, ex);
            }
            // Send registration event.
 // Finally, a response event is issued to notify the relevant listeners that the bean has been loaded. 
            getReaderContext().fireComponentRegistered( new BeanComponentDefinition(bdHolder));
        }
    }

 

Guess you like

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