类com.opensymphony.xwork2.config.providers.XmlConfigurationProvider

 类com.opensymphony.xwork2.config.providers.XmlConfigurationProvider负责配置文件的读取和解析, addAction()方法负责读取<action>标签,并将数据保存在ActionConfig中;addResultTypes()方法负责将<result-type>标签转化为ResultTypeConfig对象;loadInterceptors()方法负责将<interceptor>标签转化为InterceptorConfig对象;loadInterceptorStack()方法负责将<interceptor-ref>标签转化为InterceptorStackConfig对象;loadInterceptorStacks()方法负责将<interceptor-stack>标签转化成InterceptorStackConfig对象。而上面的方法最终会被addPackage()方法调用,将所读取到的数据汇集到PackageConfig对象中,细节请参考代码清单16

  代码清单16XmlConfigurationProvider.addPackage()方法

protected PackageConfig addPackage (Element packageElement) throws ConfigurationExcepiton{

PackageConfig newPackage = buildPackageContext(packageElement);

if(newPackage.isNeedsRefresh()){

return newPackage;

}

if(LOG.isDebugEnable())

{

LOG.debug("Loaded");

}

// add result types (and default result) to this package

addResultTypes(newPackage,packageElement);

// load the interceptors and interceptor stacks for this package

loadInterceptors(newPackage, packageElement);
    // load the default interceptor reference for this package
    loadDefaultInterceptorRef(newPackage, packageElement);
    // load the default class ref for this package
    loadDefaultClassRef(newPackage, packageElement);
    // load the global result list for this package
    loadGlobalResults(newPackage, packageElement);
    // load the global exception handler list for this package
    loadGlobalExceptionMappings(newPackage, packageElement);
    // get actions
    NodeList actionList = packageElement.getElementsByTagName("action");
    for (int i = 0; i < actionList.getLength(); i++) {
      Element actionElement = (Element) actionList.item(i);
      addAction(actionElement, newPackage);
    }
    // load the default action reference for this package
    loadDefaultActionRef(newPackage, packageElement);
    configuration.addPackageConfig(newPackage.getName(), newPackage);
    return newPackage;
  }

   }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值