BAP存储属性的思想

xiaoxiao2026-05-21  22

一、UMConstant:人员部分的常量定义

包: com.smartdot.bap.pmi.user.globale

概要:定义了一些静态常量,一部分的值已经在页面上写死,一部门通过

PropertyGetter.getString("user-manager","键名");取值

 

 

二、PropertyGetter类:用于获取相应整个系统内所用的属性。

包:com.smartdot.bap.util

概要:

1、使用了apache common configuration中的多个属性文件的使用,可以参考:Commons Configuration学习。

2、这个类装载了配置文件(用了apache common configuration的多个配置文件的方式),保存到一个configuration的静态对象中,又配置了多个getType("属性文件名","key名");

3、本类中有一个私有变量RuntimeCachingPropertySet rcps ,是用来缓存属性的,但是没有初始化,所以缓存机制在这里是没有用的。

这个类的优点:比较灵活,可以随时改变属性文件名,但是如果已经访问过一次这个属性文件,则不需要重新加载,从static对象中获取即可。而读取属性值时用以下代码:

public static boolean getBoolean(String module, String key, boolean defaultValue) { if (module == null || key == null) throw new IllegalArgumentException(MSG_ILLEGAL_ARGUMENT); if(rcps != null){ if (rcps.exists(key)) return rcps.getBoolean(key); } return getConfiguration(module).getBoolean(key, defaultValue); }

 

先存缓存中读,这样就不用每次从configuration对象中读取,可以由于缓存中的数据没有补始化的地方,缓存形同虚设。

 

三、RuntimeCachingPropertySet:用于缓存属性的类

  包:package com.smartdot.bap.util.propertyset

利用了开源的propertyset技术,细节可查看propertyset学习一

  待续

相关资源:bap2mat(有详细格式说明)
转载请注明原文地址: https://www.6miu.com/read-5049127.html

最新回复(0)