liferay portal 5.23 tomcat 源码解析之加载配置文件<2>

在监听器 PortalContextLoaderListener调用contextInitialized() 方法后。再去加载 上下文参数 contextClass 对应的 com.liferay.portal.spring.context.PortalApplicationContext 类并调用loadBeanDefinitions方法加载资源文件。在加载资源文件时,先去PropsUtil 类中得到spring 的配置文件数组。
String[] configLocations = PropsUtil.getArray(PropsKeys.SPRING_CONFIGS);


PropsKeys 类定义了liferay Portal 相关配置文件的Key。 Key 一般来自portal.properties 以其的扩展配置文件。
PropsKeys.SPRING_CONFIGS 的值是 “spring.configs” 该键值就存储在 Portal.properties 文件中。
PropsUtil是一个单实例类 调用 getArray() 方法前初始static 代码块。加载自身的实例以及调用 私有构造函数
private PropsUtil() {
SystemProperties.set("default.liferay.home", _getDefaultLiferayHome());

_configuration = new ConfigurationImpl(
PropsUtil.class.getClassLoader(), PropsFiles.PORTAL);

String liferayHome = _get(PropsKeys.LIFERAY_HOME);

SystemProperties.set(
"ehcache.disk.store.dir", liferayHome + "/data/ehcache");

if (GetterUtil.getBoolean(
SystemProperties.get("company-id-properties"))) {

_configurations = new HashMap<Long, Configuration>();
}
}


在上面的构造函数中调用了
SystemProperties.set("default.liferay.home", _getDefaultLiferayHome());

是将 liferay.home目录设置到系统的配置项中
然后在初始化ConfigurationImpl 类。该类会加载portal 所有的配置文件。
在 ConfigurationImpl构造方法中加载 portal.properties 文件的相关配置。
在 getArray(String key) 方法中 会调用 ConfigurationImpl 的 getArray()方法。ConfigurationImpl 类中引用了easyconf 组件。使用easyconf 加载 portal.properties 文件。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值