本文整理汇总了Java中com.baidu.disconf.core.common.path.DisconfWebPathMgr.getRemoteUrlParameter方法的典型用法代码示例。如果您正苦于以下问题:Java DisconfWebPathMgr.getRemoteUrlParameter方法的具体用法?Java DisconfWebPathMgr.getRemoteUrlParameter怎么用?Java DisconfWebPathMgr.getRemoteUrlParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.baidu.disconf.core.common.path.DisconfWebPathMgr
的用法示例。
在下文中一共展示了DisconfWebPathMgr.getRemoteUrlParameter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDisconfCenterFile
import com.baidu.disconf.core.common.path.DisconfWebPathMgr; //导入方法依赖的package包/类
/**
*
*/
public static DisconfCenterBaseModel getDisconfCenterFile(String fileName) {
DisconfCenterFile disconfCenterFile = new DisconfCenterFile();
fileName = fileName.trim();
//
// file name
disconfCenterFile.setFileName(fileName);
// file type
disconfCenterFile.setSupportFileTypeEnum(SupportFileTypeEnum.getByFileName(fileName));
//
// disConfCommonModel
DisConfCommonModel disConfCommonModel = makeDisConfCommonModel(DisClientConfigExt.GLOBAL_APP, "", DisClientConfigExt.GLOBAL_VERSION);
disconfCenterFile.setDisConfCommonModel(disConfCommonModel);
// Remote URL
String url = DisconfWebPathMgr.getRemoteUrlParameter(DisClientSysConfig.getInstance().CONF_SERVER_STORE_ACTION,
disConfCommonModel.getApp(),
disConfCommonModel.getVersion(),
disConfCommonModel.getEnv(),
disconfCenterFile.getFileName(),
DisConfigTypeEnum.FILE);
disconfCenterFile.setRemoteServerUrl(url);
return disconfCenterFile;
}
示例2: loadGlobalItem
import com.baidu.disconf.core.common.path.DisconfWebPathMgr; //导入方法依赖的package包/类
/**
* 加载global配置项,获取global文件列表
*/
private String[] loadGlobalItem() {
String keyName = "global";
String value = null;
String[] fileNames = null;
//
// 开启disconf才需要远程下载, 否则就用默认值
//
if (DisClientConfig.getInstance().ENABLE_DISCONF) {
//
// 下载配置
//
try {
FetcherMgr fetcherMgr = FetcherFactory.getFetcherMgr();
// Disconf-web url
String url = DisconfWebPathMgr.getRemoteUrlParameter(DisClientSysConfig.getInstance().CONF_SERVER_STORE_ACTION,
DisClientConfigExt.GLOBAL_APP,
DisClientConfigExt.GLOBAL_VERSION,
DisClientConfig.getInstance().ENV,
DisClientConfigExt.GLOBAL_KEY,
DisConfigTypeEnum.ITEM);
value = fetcherMgr.getValueFromServer(url);
if (value != null) {
log.debug("value: " + value);
//value获取global文件列表
fileNames = value.split(",");
for(int i=0;i<fileNames.length;i++) {
fileNames[i] = "classpath:/" + fileNames[i];
}
}
log.info("loaded global prop ok.");
} catch (Exception e) {
log.error("cannot use remote configuration: " + keyName, e);
log.info("skip variable: " + keyName);
}
}
return fileNames;
}
示例3: getRemoteUrlParameterTest
import com.baidu.disconf.core.common.path.DisconfWebPathMgr; //导入方法依赖的package包/类
@Test
public void getRemoteUrlParameterTest() {
String fileUrl =
DisconfWebPathMgr.getRemoteUrlParameter("test", "app", "version", "env", "key", DisConfigTypeEnum.FILE);
System.out.println(fileUrl);
Assert.assertEquals("test/file?version=version&app=app&env=env&key=key&type=0", fileUrl);
String itemUrl =
DisconfWebPathMgr.getRemoteUrlParameter("test", "app", "version", "env", "key", DisConfigTypeEnum.ITEM);
System.out.println(fileUrl);
Assert.assertEquals("test/item?version=version&app=app&env=env&key=key&type=1", itemUrl);
}
示例4: getDisconfCenterFile
import com.baidu.disconf.core.common.path.DisconfWebPathMgr; //导入方法依赖的package包/类
/**
*
*/
public static DisconfCenterBaseModel getDisconfCenterFile(String fileName) {
DisconfCenterFile disconfCenterFile = new DisconfCenterFile();
fileName = fileName.trim();
//
// file name
disconfCenterFile.setFileName(fileName);
// 非注解式
disconfCenterFile.setIsTaggedWithNonAnnotationFile(true);
// file type
disconfCenterFile.setSupportFileTypeEnum(SupportFileTypeEnum.getByFileName(fileName));
//
// disConfCommonModel
DisConfCommonModel disConfCommonModel = makeDisConfCommonModel("", "", "");
disconfCenterFile.setDisConfCommonModel(disConfCommonModel);
// Remote URL
String url = DisconfWebPathMgr.getRemoteUrlParameter(DisClientSysConfig.getInstance().CONF_SERVER_STORE_ACTION,
disConfCommonModel.getApp(),
disConfCommonModel.getVersion(),
disConfCommonModel.getEnv(),
disconfCenterFile.getFileName(),
DisConfigTypeEnum.FILE);
disconfCenterFile.setRemoteServerUrl(url);
return disconfCenterFile;
}
示例5: transformScanItem
import com.baidu.disconf.core.common.path.DisconfWebPathMgr; //导入方法依赖的package包/类
/**
* 转换配置项
*/
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(" ", "");
// get setter method
Method setterMethod = MethodUtils.getSetterMethodFromField(cls, field);
disconfCenterItem.setSetMethod(setterMethod);
// 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.app(), 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;
}