spring source read (b) Bean loads of custom labels loaded

Then the article on the spring loaded default label, look at this one self-loading custom label

Continues from the point of view DefaultBeanDefinitionDocumentReader

protected void parseBeanDefinitions(Element root, BeanDefinitionParserDelegate delegate) {
        if (delegate.isDefaultNamespace(root)) {
            NodeList nl = root.getChildNodes();

            for(int i = 0; i < nl.getLength(); ++i) {
                Node node = nl.item(i);
                if (node instanceof Element) {
                    Element ele = (Element)node;
                    if (delegate.isDefaultNamespace(ele)) {
                        this.parseDefaultElement(ele, delegate); // default tag resolution 
                    }the else{
                         delegate.parseCustomElement (ELE); // custom tag resolution 
                    }
                }
            }
        }the else{
             delegate.parseCustomElement (the root);   // custom tag resolution 
        }

    }

Written on the front of things, combined with the recent "clean architecture of the Road" and "spring source depth analysis" two books together and watching it develop some of the principles of object-oriented architecture hang neatly described the interface isolation / Single Responsibility / ceremonies / dependency inversion / replacement in the formula

These principles can be described by the head of the source in the spring, especially single responsibility / interface isolation, the two look at the source code, especially when there is experience, before themselves in project development, in fact, there is no such a thing, just follow business division split interface, and do not care whether it is a single responsibility / interface isolation whether these things actually make us better single responsibility to develop and maintain our code. Including the interface isolation in fact such a purpose. Be able to comply with these rules, we will be able to code in line with a greater level of maintainability / low coupling these requirements will also be able to achieve maximum optimization of development efficiency of this matter.

Well, pull some way, we continue to work to resolve the custom labels:

public BeanDefinition parseCustomElement(Element ele) {
        return this.parseCustomElement(ele, (BeanDefinition)null);
    }
public BeanDefinition parseCustomElement(Element ele, BeanDefinition containingBd) {
        String namespaceUri = this.getNamespaceURI(ele);
        NamespaceHandler handler = this.readerContext.getNamespaceHandlerResolver().resolve(namespaceUri);
        if (handler == null) {
            this.error("Unable to locate Spring NamespaceHandler for XML schema namespace [" + namespaceUri + "]", ele);
            return null;
        } else {
            return handler.parse(ele, new ParserContext(this.readerContext, this, containingBd));
        }
    }

 

Guess you like

Origin www.cnblogs.com/aquariusm/p/11122227.html