use of com.baidu.disconf.client.common.model.DisconfCenterFile in project disconf by knightliao.
the class DisconfStoreFileProcessorImpl method inject2Store.
/**
*
*/
@Override
public void inject2Store(String fileName, DisconfValue disconfValue) {
DisconfCenterFile disconfCenterFile = getInstance().getConfFileMap().get(fileName);
// 校验是否存在
if (disconfCenterFile == null) {
LOGGER.error("cannot find " + fileName + " in store....");
return;
}
if (disconfValue == null || disconfValue.getFileData() == null) {
LOGGER.error("value is null for {}", fileName);
return;
}
// 存储
Map<String, FileItemValue> keMap = disconfCenterFile.getKeyMaps();
if (keMap.size() > 0) {
for (String fileItem : keMap.keySet()) {
Object object = disconfValue.getFileData().get(fileItem);
if (object == null) {
LOGGER.error("cannot find {} to be injected. file content is: {}", fileItem, disconfValue.getFileData().toString());
continue;
}
// 根据类型设置值
try {
Object value = keMap.get(fileItem).getFieldValueByType(object);
keMap.get(fileItem).setValue(value);
} catch (Exception e) {
LOGGER.error("inject2Store filename: " + fileName + " " + e.toString(), e);
}
}
}
// 使用过 XML式配置
if (disconfCenterFile.isTaggedWithNonAnnotationFile()) {
if (disconfCenterFile.getSupportFileTypeEnum().equals(SupportFileTypeEnum.PROPERTIES)) {
// 如果是采用XML进行配置的,则需要利用spring的reload将数据reload到bean里
ReloadConfigurationMonitor.reload();
}
disconfCenterFile.setAdditionalKeyMaps(disconfValue.getFileData());
}
}
Aggregations