*
* @return
*/
private static DisconfCenterItem transformScanItem(Method method) {
DisconfCenterItem disconfCenterItem = new DisconfCenterItem();
// class
Class<?> cls = method.getDeclaringClass();
// fields
Field[] expectedFields = cls.getDeclaredFields();
// field
Field field = MethodUtils.getFieldFromMethod(method, expectedFields,
DisConfigTypeEnum.ITEM);
if (field == null) {
return null;
}
// 获取标注
DisconfItem disconfItem = method.getAnnotation(DisconfItem.class);
// 去掉空格
String key = disconfItem.key().replace(" ", "");
// field
disconfCenterItem.setField(field);
// key
disconfCenterItem.setKey(key);
// access
field.setAccessible(true);
// object
disconfCenterItem.setObject(null);
// value
if (Modifier.isStatic(field.getModifiers())) {
try {
disconfCenterItem.setValue(field.get(null));
} catch (Exception e) {
LOGGER.error(e.toString());
disconfCenterItem.setValue(null);
}
} else {
disconfCenterItem.setValue(null);
}
//
// disConfCommonModel
DisConfCommonModel disConfCommonModel = makeDisConfCommonModel(
disconfItem.env(), disconfItem.version());
disconfCenterItem.setDisConfCommonModel(disConfCommonModel);
// Disconf-web url
String url = DisconfWebPathMgr.getRemoteUrlParameter(
DisClientSysConfig.getInstance().CONF_SERVER_STORE_ACTION,
disConfCommonModel.getApp(), disConfCommonModel.getVersion(),
disConfCommonModel.getEnv(), key, DisConfigTypeEnum.ITEM);
disconfCenterItem.setRemoteServerUrl(url);
return disconfCenterItem;
}