当前位置: 首页>>代码示例>>Java>>正文


Java DisconfWebPathMgr类代码示例

本文整理汇总了Java中com.baidu.disconf.core.common.path.DisconfWebPathMgr的典型用法代码示例。如果您正苦于以下问题:Java DisconfWebPathMgr类的具体用法?Java DisconfWebPathMgr怎么用?Java DisconfWebPathMgr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DisconfWebPathMgr类属于com.baidu.disconf.core.common.path包,在下文中一共展示了DisconfWebPathMgr类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkNetWork

import com.baidu.disconf.core.common.path.DisconfWebPathMgr; //导入依赖的package包/类
/**
 * @return
 */
@Deprecated
protected boolean checkNetWork() {

    //
    // 如果网络不通则认为测试通过
    //
    try {
        ConfigMgr.init();
    } catch (Exception e) {
        Assert.assertTrue(false);
    }

    if (!NetUtils.pingUrl(DisClientConfig.getInstance().getHostList().get(0) + DisconfWebPathMgr
            .getZooHostsUrl
                    (DisClientSysConfig
                            .getInstance().CONF_SERVER_ZOO_ACTION))) {
        return false;
    }

    return true;
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:25,代码来源:BaseSpringMockTestCase.java

示例2: 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;
}
 
开发者ID:ningyu1,项目名称:disconf-client-ext,代码行数:33,代码来源:StaticScannerNonAnnotationFileMgrImplExt.java

示例3: 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;
}
 
开发者ID:ningyu1,项目名称:disconf-client-ext,代码行数:43,代码来源:ReloadablePropertiesFactoryBeanExt.java

示例4: 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);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:14,代码来源:DisconfWebPathMgrTestCase.java

示例5: 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;
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:36,代码来源:StaticScannerNonAnnotationFileMgrImpl.java

示例6: getWatchMgr

import com.baidu.disconf.core.common.path.DisconfWebPathMgr; //导入依赖的package包/类
/**
 * @throws Exception
 */
public static WatchMgr getWatchMgr(FetcherMgr fetcherMgr) throws Exception {

    if (!ConfigMgr.isInit()) {
        throw new Exception("ConfigMgr should be init before WatchFactory.getWatchMgr");
    }

    if (hosts == null || zooPrefix == null) {
        synchronized(hostsSync) {
            if (hosts == null || zooPrefix == null) {

                // 获取 Zoo Hosts
                try {

                    hosts = fetcherMgr.getValueFromServer(DisconfWebPathMgr.getZooHostsUrl(DisClientSysConfig
                                                                                               .getInstance()
                                                                                               .CONF_SERVER_ZOO_ACTION));

                    zooPrefix = fetcherMgr.getValueFromServer(DisconfWebPathMgr.getZooPrefixUrl(DisClientSysConfig
                                                                                                    .getInstance
                                                                                                         ()
                                                                                                    .CONF_SERVER_ZOO_ACTION));

                    WatchMgr watchMgr = new WatchMgrImpl();
                    watchMgr.init(hosts, zooPrefix, DisClientConfig.getInstance().DEBUG);

                    return watchMgr;

                } catch (Exception e) {

                    LOGGER.error("cannot get watch module", e);

                }
            }
        }
    }

    return null;
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:42,代码来源:WatchFactory.java

示例7: 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;
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:71,代码来源:StaticScannerItemMgrImpl.java

示例8: getZooPrefixUrlTest

import com.baidu.disconf.core.common.path.DisconfWebPathMgr; //导入依赖的package包/类
@Test
public void getZooPrefixUrlTest() {

    String result = DisconfWebPathMgr.getZooPrefixUrl("/test");

    Assert.assertEquals("/test/prefix", result);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:8,代码来源:DisconfWebPathMgrTestCase.java

示例9: getZooHostsUrlTest

import com.baidu.disconf.core.common.path.DisconfWebPathMgr; //导入依赖的package包/类
@Test
public void getZooHostsUrlTest() {

    String result = DisconfWebPathMgr.getZooHostsUrl("/test");

    Assert.assertEquals("/test/hosts", result);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:8,代码来源:DisconfWebPathMgrTestCase.java


注:本文中的com.baidu.disconf.core.common.path.DisconfWebPathMgr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。