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


Java DisconfStoreProcessorFactory类代码示例

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


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

示例1: getByFile

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
@Override
public Map<String, Object> getByFile(String fileName) {

    DisconfStoreProcessor disconfStoreProcessor =
            DisconfStoreProcessorFactory.getDisconfStoreFileProcessor();

    DisconfCenterFile disconfCenterFile = (DisconfCenterFile) disconfStoreProcessor.getConfData(fileName);
    if (disconfCenterFile == null) {
        return new HashMap<String, Object>();
    }

    return disconfCenterFile.getKV();
}
 
开发者ID:ningyu1,项目名称:disconf-client-ext,代码行数:14,代码来源:DisconfDataGetterDefaultImpl.java

示例2: getByItem

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
@Override
public Object getByItem(String itemName) {

    DisconfStoreProcessor disconfStoreProcessor =
            DisconfStoreProcessorFactory.getDisconfStoreItemProcessor();

    DisconfCenterItem disconfCenterItem = (DisconfCenterItem) disconfStoreProcessor.getConfData(itemName);

    if (disconfCenterItem == null) {
        return null;
    }

    return disconfCenterItem.getValue();
}
 
开发者ID:ningyu1,项目名称:disconf-client-ext,代码行数:15,代码来源:DisconfDataGetterDefaultImpl.java

示例3: scanData2Store

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
 *
 */
public static void scanData2Store(String fileName) {

 DisconfCenterBaseModel disconfCenterBaseModel = null;
 if(isGlobalFile(fileName)) {
  disconfCenterBaseModel =
             StaticScannerNonAnnotationFileMgrImplExt.getDisconfCenterFile(fileName);
 } else {
  disconfCenterBaseModel =
             StaticScannerNonAnnotationFileMgrImpl.getDisconfCenterFile(fileName);
 }

    DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().transformScanData(disconfCenterBaseModel);
}
 
开发者ID:ningyu1,项目名称:disconf-client-ext,代码行数:17,代码来源:StaticScannerNonAnnotationFileMgrImplExt.java

示例4: transformPipelineService

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
 * 第二次扫描<br/>
 * 转换 pipeline 回调函数,将其写到 仓库中
 */
private static void transformPipelineService(IDisconfUpdatePipeline iDisconfUpdatePipeline) {

    DisconfStorePipelineProcessor disconfStorePipelineProcessor = DisconfStoreProcessorFactory
            .getDisconfStorePipelineProcessor();
    disconfStorePipelineProcessor.setDisconfUpdatePipeline(iDisconfUpdatePipeline);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:11,代码来源:ScanDynamicStoreAdapter.java

示例5: scanData2Store

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
@Override
public void scanData2Store(ScanStaticModel scanModel) {

    // 转换配置项
    List<DisconfCenterBaseModel> disconfCenterItems = getDisconfItems(scanModel);
    DisconfStoreProcessorFactory.getDisconfStoreItemProcessor().transformScanData(disconfCenterItems);

}
 
开发者ID:knightliao,项目名称:disconf,代码行数:9,代码来源:StaticScannerItemMgrImpl.java

示例6: scanData2Store

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
 *
 */
@Override
public void scanData2Store(ScanStaticModel scanModel) {

    // 转换配置文件
    List<DisconfCenterBaseModel> disconfCenterFiles = getDisconfFiles(scanModel);
    DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().transformScanData(disconfCenterFiles);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:11,代码来源:StaticScannerFileMgrImpl.java

示例7: scanData2Store

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
 *
 */
@Override
public void scanData2Store(ScanStaticModel scanModel) {

    //
    //
    //
    List<DisconfCenterBaseModel> disconfCenterBaseModels = getDisconfCenterFiles(scanModel.getJustHostFiles());

    DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().transformScanData(disconfCenterBaseModels);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:14,代码来源:StaticScannerNonAnnotationFileMgrImpl.java

示例8: decideAccess

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
 * 获取配置项数据, 只有开启disconf远程才会进行切面
 *
 * @throws Throwable
 */
@Around("anyPublicMethod() && @annotation(disconfItem)")
public Object decideAccess(ProceedingJoinPoint pjp, DisconfItem disconfItem) throws Throwable {

    if (DisClientConfig.getInstance().ENABLE_DISCONF) {
        //
        // 请求仓库配置数据
        //
        DisconfStoreProcessor disconfStoreProcessor = DisconfStoreProcessorFactory.getDisconfStoreItemProcessor();
        Object ret = disconfStoreProcessor.getConfig(null, disconfItem.key());
        if (ret != null) {
            LOGGER.debug("using disconf store value: (" + disconfItem.key() + " , " + ret + ")");
            return ret;
        }
    }

    Object rtnOb;

    try {
        // 返回原值
        rtnOb = pjp.proceed();
    } catch (Throwable t) {
        LOGGER.info(t.getMessage());
        throw t;
    }

    return rtnOb;
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:33,代码来源:DisconfAspectJ.java

示例9: secondScan

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
 * 第二次扫描, 动态扫描, for annotation config
 */
protected synchronized void secondScan() {

    // 该函数必须第一次运行后才能运行
    if (!isFirstInit) {
        LOGGER.info("should run First Scan before Second Scan.");
        return;
    }

    // 第二次扫描也只能做一次
    if (isSecondInit) {
        LOGGER.info("should not run twice.");
        return;
    }

    LOGGER.info("******************************* DISCONF START SECOND SCAN *******************************");

    try {

        // 扫描回调函数
        if (scanMgr != null) {
            scanMgr.secondScan();
        }

        // 注入数据至配置实体中
        // 获取数据/注入/Watch
        if (disconfCoreMgr != null) {
            disconfCoreMgr.inject2DisconfInstance();
        }

    } catch (Exception e) {
        LOGGER.error(e.toString(), e);
    }

    isSecondInit = true;

    //
    // 不开启 则不要启动timer和打印变量map
    //
    if (DisClientConfig.getInstance().ENABLE_DISCONF) {
        //
        // start timer
        //
        //startTimer();

        //
        LOGGER.info("Conf File Map: {}", DisconfStoreProcessorFactory.getDisconfStoreFileProcessor()
                .confToString());
        //
        LOGGER.info("Conf Item Map: {}", DisconfStoreProcessorFactory.getDisconfStoreItemProcessor()
                .confToString());
    }
    LOGGER.info("******************************* DISCONF END *******************************");
}
 
开发者ID:ningyu1,项目名称:disconf-client-ext,代码行数:57,代码来源:DisconfMgrExt.java

示例10: transformUpdateService

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
 * 第二次扫描<br/>
 * 转换 更新 回调函数,将其写到 仓库中
 */
private static void transformUpdateService(Map<DisconfKey,
        List<IDisconfUpdate>> disconfUpdateServiceInverseIndexMap) {

    DisconfStoreProcessor disconfStoreProcessorFile = DisconfStoreProcessorFactory.getDisconfStoreFileProcessor();
    DisconfStoreProcessor disconfStoreProcessorItem = DisconfStoreProcessorFactory.getDisconfStoreItemProcessor();

    for (DisconfKey disconfKey : disconfUpdateServiceInverseIndexMap.keySet()) {

        //
        //
        //

        try {
            if (disconfKey.getDisConfigTypeEnum().equals(DisConfigTypeEnum.FILE)) {

                if (!disconfStoreProcessorFile.hasThisConf(disconfKey.getKey())) {
                    throw new Exception();
                }

                disconfStoreProcessorFile.addUpdateCallbackList(disconfKey.getKey(),
                        disconfUpdateServiceInverseIndexMap
                                .get(disconfKey));

            } else if (disconfKey.getDisConfigTypeEnum().equals(DisConfigTypeEnum.ITEM)) {

                if (!disconfStoreProcessorItem.hasThisConf(disconfKey.getKey())) {
                    throw new Exception();
                }

                disconfStoreProcessorItem.addUpdateCallbackList(disconfKey.getKey(),
                        disconfUpdateServiceInverseIndexMap
                                .get(disconfKey));
            }

        } catch (Exception e) {
            // 找不到回调对应的配置,这是用户配置 错误了
            StringBuffer sb = new StringBuffer();
            sb.append("cannot find " + disconfKey + "for: ");
            for (IDisconfUpdate serClass : disconfUpdateServiceInverseIndexMap.get(disconfKey)) {
                sb.append(serClass.toString() + "\t");
            }
            LOGGER.error(sb.toString());
        }
    }
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:50,代码来源:ScanDynamicStoreAdapter.java

示例11: exclude

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
 *
 */
@Override
public void exclude(Set<String> keySet) {
    DisconfStoreProcessorFactory.getDisconfStoreItemProcessor().exclude(keySet);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:8,代码来源:StaticScannerItemMgrImpl.java

示例12: exclude

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
 *
 */
@Override
public void exclude(Set<String> keySet) {
    DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().exclude(keySet);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:8,代码来源:StaticScannerFileMgrImpl.java

示例13: secondScan

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
 * 第二次扫描, 动态扫描, for annotation config
 */
protected synchronized void secondScan() {

    // 该函数必须第一次运行后才能运行
    if (!isFirstInit) {
        LOGGER.info("should run First Scan before Second Scan.");
        return;
    }

    // 第二次扫描也只能做一次
    if (isSecondInit) {
        LOGGER.info("should not run twice.");
        return;
    }

    LOGGER.info("******************************* DISCONF START SECOND SCAN *******************************");

    try {

        // 扫描回调函数
        if (scanMgr != null) {
            scanMgr.secondScan();
        }

        // 注入数据至配置实体中
        // 获取数据/注入/Watch
        if (disconfCoreMgr != null) {
            disconfCoreMgr.inject2DisconfInstance();
        }

    } catch (Exception e) {
        LOGGER.error(e.toString(), e);
    }

    isSecondInit = true;

    //
    // 不开启 则不要打印变量map
    //
    if (DisClientConfig.getInstance().ENABLE_DISCONF) {

        //
        String data = DisconfStoreProcessorFactory.getDisconfStoreFileProcessor()
                .confToString();
        if (!StringUtils.isEmpty(data)) {
            LOGGER.info("Conf File Map: {}", data);
        }

        //
        data = DisconfStoreProcessorFactory.getDisconfStoreItemProcessor()
                .confToString();
        if (!StringUtils.isEmpty(data)) {
            LOGGER.info("Conf Item Map: {}", data);
        }
    }
    LOGGER.info("******************************* DISCONF END *******************************");
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:60,代码来源:DisconfMgr.java

示例14: demo

import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
@Test
public void demo() {

    //
    // mock up factory method
    //
    new MockUp<DisconfCoreFactory>() {

        @Mock
        public DisconfCoreMgr getDisconfCoreMgr(Registry registry) throws Exception {

            FetcherMgr fetcherMgr = FetcherFactory.getFetcherMgr();

            // Watch 模块
            final WatchMgr watchMgr = new WatchMgrMock().getMockInstance();
            watchMgr.init("", "", true);

            // registry
            DisconfCoreMgr disconfCoreMgr = new DisconfCoreMgrImpl(watchMgr, fetcherMgr,
                    registry);

            return disconfCoreMgr;
        }
    };

    //
    // 正式测试
    //
    try {

        LOGGER.info("================ BEFORE DISCONF ==============================");

        LOGGER.info("before disconf values:");
        LOGGER.info(String.valueOf("varA: " + confA.getVarA()));
        LOGGER.info(String.valueOf("varA2: " + confA.getVarA2()));
        LOGGER.info(String.valueOf("varAA: " + serviceA.getVarAA()));

        LOGGER.info("================ BEFORE DISCONF ==============================");

        //
        // start it
        //
        Set<String> fileSet = new HashSet<String>();
        fileSet.add("atomserverl.properties");
        fileSet.add("atomserverm_slave.properties");
        DisconfCenterHostFilesStore.getInstance().addJustHostFileSet(fileSet);

        DisconfMgr.getInstance().setApplicationContext(applicationContext);
        DisconfMgr.getInstance().start(StringUtil.parseStringToStringList(ScanPackTestCase.SCAN_PACK_NAME,
                DisconfMgrBean.SCAN_SPLIT_TOKEN));

        //
        LOGGER.info(DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().confToString());

        //
        LOGGER.info(DisconfStoreProcessorFactory.getDisconfStoreItemProcessor().confToString());

        LOGGER.info("================ AFTER DISCONF ==============================");

        LOGGER.info(String.valueOf("varA: " + confA.getVarA()));
        Assert.assertEquals(new Long(1000), confA.getVarA());

        LOGGER.info(String.valueOf("varA2: " + confA.getVarA2()));
        Assert.assertEquals(new Long(2000), confA.getVarA2());

        LOGGER.info(String.valueOf("varAA: " + serviceA.getVarAA()));
        Assert.assertEquals(new Integer(1000).intValue(), serviceA.getVarAA());

        LOGGER.info(String.valueOf("static var: " + StaticConf.getStaticvar()));
        Assert.assertEquals(new Integer(50).intValue(), StaticConf.getStaticvar());

        testDynamicGetter();

        LOGGER.info("================ AFTER DISCONF ==============================");

    } catch (Exception e) {

        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:82,代码来源:DisconfMgrTestCase.java


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