Package com.baidu.disconf.client.common.model

Examples of com.baidu.disconf.client.common.model.DisconfCenterFile


    /**
     * 存储 一个配置文件
     */
    public void storeOneFile(DisconfCenterBaseModel disconfCenterBaseModel) {

        DisconfCenterFile disconfCenterFile = (DisconfCenterFile) disconfCenterBaseModel;

        String fileName = disconfCenterFile.getFileName();

        if (confFileMap.containsKey(fileName)) {

            LOGGER.error("There are two same fileName!!!! " + "first: "
                    + confFileMap.get(fileName).getCls().toString()
                    + ", Second: " + disconfCenterFile.getCls().toString());
        } else {
            confFileMap.put(fileName, disconfCenterFile);
        }
    }
View Full Code Here


        for (String fileName : disconfStoreProcessor.getConfKeySet()) {

            LOGGER.info("==============\tstart to process disconf file: "
                    + fileName + "\t=============================");

            DisconfCenterFile disconfCenterFile = (DisconfCenterFile) disconfStoreProcessor
                    .getConfData(fileName);

            try {
                updateOneConfFile(fileName, disconfCenterFile);
            } catch (Exception e) {
View Full Code Here

     *
     */
    @Override
    public void updateOneConf(String fileName) throws Exception {

        DisconfCenterFile disconfCenterFile = (DisconfCenterFile) disconfStoreProcessor
                .getConfData(fileName);

        if (disconfCenterFile != null) {
            updateOneConfFile(fileName, disconfCenterFile);
        }
View Full Code Here

        for (String key : disconfStoreProcessor.getConfKeySet()) {

            LOGGER.info("==============\tstart to inject value to disconf file item instance: "
                    + key + "\t=============================");

            DisconfCenterFile disconfCenterFile = (DisconfCenterFile) disconfStoreProcessor
                    .getConfData(key);

            if (disconfCenterFile == null) {
                continue;
            }

            try {

                //
                // 获取实例
                //

                Object object = null;
                try {

                    object = disconfCenterFile.getObject();
                    if (object == null) {
                        object = DisconfCoreProcessUtils
                                .getSpringBean(disconfCenterFile.getCls());
                    }

                } catch (Exception e) {

                    LOGGER.debug(disconfCenterFile.getCls()
                            + " may be a non-java-bean");
                    object = null;
                }

                // 注入实体中
View Full Code Here

        for (String fileName : disConfCenterFileMap.keySet()) {

            LOGGER.info("==============\tstart to process disconf file: "
                    + fileName + "\t=============================");

            DisconfCenterFile disconfCenterFile = disConfCenterFileMap
                    .get(fileName);

            try {
                updateOneConfFile(fileName, disconfCenterFile);
            } catch (Exception e) {
View Full Code Here

    public static void updateOneConfFile(String fileName) throws Exception {

        Map<String, DisconfCenterFile> disConfCenterFileMap = DisconfStoreMgr
                .getInstance().getConfFileMap();

        DisconfCenterFile disconfCenterFile = disConfCenterFileMap
                .get(fileName);

        updateOneConfFile(fileName, disconfCenterFile);
    }
View Full Code Here

    public static void callOneConfFile(String fileName) throws Exception {

        Map<String, DisconfCenterFile> disConfCenterFileMap = DisconfStoreMgr
                .getInstance().getConfFileMap();

        DisconfCenterFile disconfCenterFile = disConfCenterFileMap
                .get(fileName);
        if (disconfCenterFile == null) {
            throw new Exception("cannot find disconfCenterFile " + fileName);
        }

        //
        // 获取回调函数列表
        //
        DisconfCommonCallbackModel disconfCommonCallbackModel = disconfCenterFile
                .getDisconfCommonCallbackModel();
        callFunctions(disconfCommonCallbackModel);
    }
View Full Code Here

     * @param keyName
     * @return
     */
    public Object getConfigFile(String fileName, String keyName) {

        DisconfCenterFile disconfCenterFile = disconfCenterStore
                .getConfFileMap().get(fileName);

        // 校验是否存在
        if (disconfCenterFile == null) {
            LOGGER.info("canot find " + fileName + " in store....");
            return null;
        }

        if (disconfCenterFile.getKeyMaps().get(keyName) == null) {
            LOGGER.info("canot find " + fileName + ", " + keyName
                    + " in store....");
            return null;
        }

        return disconfCenterFile.getKeyMaps().get(keyName).getValue();
    }
View Full Code Here

    /**
     * 将配置文件数据注入到仓库
     */
    public void injectFile2Store(String fileName, Properties properties) {

        DisconfCenterFile disconfCenterFile = disconfCenterStore
                .getConfFileMap().get(fileName);

        // 校验是否存在
        if (disconfCenterFile == null) {
            LOGGER.error("canot find " + fileName + " in store....");
            return;
        }

        // 存储
        Map<String, FileItemValue> keMap = disconfCenterFile.getKeyMaps();
        for (String fileItem : keMap.keySet()) {

            Object object = properties.get(fileItem);
            if (object == null) {
                continue;
            }

            // 根据类型设置值
            try {

                Object value = ClassUtils.getValeByType(keMap.get(fileItem)
                        .getField().getType(), (String) object);
                keMap.get(fileItem).setValue(value);

                // 如果Object非null,则顺便也注入
                if (disconfCenterFile.getObject() != null) {
                    keMap.get(fileItem)
                            .getField()
                            .set(disconfCenterFile.getObject(),
                                    keMap.get(fileItem).getValue());
                }

            } catch (Exception e) {
                LOGGER.error(e.toString(), e);
View Full Code Here

    /*
     * 将配置文件数据注入实体
     */
    public void injectFileItem2Instance(String fileName) {

        DisconfCenterFile disconfCenterFile = disconfCenterStore
                .getConfFileMap().get(fileName);

        // 校验是否存在
        if (disconfCenterFile == null) {
            LOGGER.error("canot find " + fileName + " in store....");
            return;
        }

        // 无实例无值则 无法注入
        if (disconfCenterFile.getObject() == null) {
            LOGGER.warn(fileName + " 's oboject is null");
            return;
        }

        // 根据类型设置值
        //
        // 注入实体
        //
        Map<String, FileItemValue> keMap = disconfCenterFile.getKeyMaps();
        for (String fileItem : keMap.keySet()) {

            // 根据类型设置值
            try {

                keMap.get(fileItem)
                        .getField()
                        .set(disconfCenterFile.getObject(),
                                keMap.get(fileItem).getValue());
            } catch (Exception e) {
                LOGGER.error(e.toString(), e);
            }
        }
View Full Code Here

TOP

Related Classes of com.baidu.disconf.client.common.model.DisconfCenterFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.