在ofbiz中,有一个非常重要的配置文件ofbiz-component.xml,这个文件告诉ofbiz需要加载那些容器和类,在start.properties中有如下定义

//ofbiz容器加载类,用来加载其他容器,ofbiz
ofbiz.start.loader1=org.ofbiz.base.container.ContainerLoader
//ofbiz加载的组件级别
ofbiz.start.loader1.loaders=main,rmi

ContainerLoader根据framework\base\config\ofbiz-containers.xml中定义的容器按顺序启动容器

//此处的loaders="main,rmi,pos,install",包含start.properties中的加载级别,该容器是符合要求的启动容器,事实上生产模式上只启动这一个容器


    
        
        
    

    
        
    

    

component-container是组件加载容器,根据framework\base\config\component-load.xml中定义的组件目录查找component-load.xml文件然后加载这些文件

这些配置都存放在org.ofbiz.base.component.ComponentConfig中

// this is not a UtilCache because reloading may cause problems
//普通组件配置文件存放位置
    protected static Map componentConfigs = FastMap.newInstance();
    //web组件配置文件存放位置
    protected static Map> serverWebApps = FastMap.newInstance();

下边看一个最基本的component-load.xml文件结构


    
    
    
    

    

    
    

    
    
        
        
    

    
    
    
    

这些配置文件都会被加载到ComponentCofig类中,在这个类中有相应的字段用来存放这些配置

protected String globalName = null;
    protected String rootLocation = null;
    protected String componentName = null;
    protected boolean enabled = true;

    protected Map resourceLoaderInfos = FastMap.newInstance();
    protected List classpathInfos = FastList.newInstance();
    protected List entityResourceInfos = FastList.newInstance();
    protected List serviceResourceInfos = FastList.newInstance();
    protected List testSuiteInfos = FastList.newInstance();
    protected List keystoreInfos = FastList.newInstance();
    protected List webappInfos = FastList.newInstance();
    protected List containers = FastList.newInstance();

最后通过Map将这些配置保存,提供给下一步使用

总结:

以上流程可以通过下图进行展示

ofbiz中的ofbiz-component.xml和加载过程_第1张图片

个人见解,如有错误,请不吝赐教