sustain/src/main/java/net/happyonroad/component/container/support/DefaultComponentLoader.java
@Override
    public void load(Component component) throws Exception {
        if (isLoaded(component)) return;
        logger.debug("Before loading {}", component);
        //首先加载父组件
        if (component.getParent() != null) {
            //上面会自动检测是否已经加载，防止重复加载
            load(component.getParent());
        }
        //而后加载依赖的组件
        for (Component depended : component.getDependedComponents()) {
            //上面会自动检测是否已经加载，防止重复加载
            Dependency textualDependency = new Dependency(depended.getGroupId(), depended.getArtifactId());
            Dependency actualDependency = component.getDependency(textualDependency);
            if( actualDependency.isProvided() || actualDependency.isTest() )
                continue;
            load(depended);
        }
        quickLoad(component);
        //最后，加载自身
        logger.debug("After  loaded  {}", component);
    }
@Override
    public void load(Component component) throws Exception {
        if (isLoaded(component)) return;
        logger.debug("Before loading {}", component);
        //首先加载父组件
        if (component.getParent() != null) {
            //上面会自动检测是否已经加载，防止重复加载
            load(component.getParent());
        }
        //而后加载依赖的组件
        for (Component depended : component.getDependedComponents()) {
            //上面会自动检测是否已经加载，防止重复加载
            Dependency textualDependency = new Dependency(depended.getGroupId(), depended.getArtifactId());
            Dependency actualDependency = component.getDependency(textualDependency);
            if( actualDependency.isProvided() || actualDependency.isTest() )
                continue;
            load(depended);
        }
        quickLoad(component);
        //最后，加载自身
        logger.debug("After  loaded  {}", component);
    }
@ Override public void load ( Component component ) throws Exception { if ( isLoaded ( component ) ) return ; logger . debug ( "Before loading {}" , component ) ; //首先加载父组件 if ( component . getParent ( ) != null ) { //上面会自动检测是否已经加载，防止重复加载 load ( component . getParent ( ) ) ; } //而后加载依赖的组件 for ( Component depended : component . getDependedComponents ( ) ) { //上面会自动检测是否已经加载，防止重复加载 Dependency textualDependency = new Dependency ( depended . getGroupId ( ) , depended . getArtifactId ( ) ) ; Dependency actualDependency = component . getDependency ( textualDependency ) ; if ( actualDependency . isProvided ( ) || actualDependency . isTest ( ) ) continue ; load ( depended ) ; } quickLoad ( component ) ; //最后，加载自身 logger . debug ( "After  loaded  {}" , component ) ; }
自顶向下的加载组件

@param component 被加载的组件
自顶向下的加载组件