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

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


     *
     */
    @Override
    public void inject2Instance(Object object, String key) {

        DisconfCenterItem disconfCenterItem = DisconfCenterStore.getInstance()
                .getConfItemMap().get(key);

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

        //
        // 非静态类
        //
        if (object != null) {
            disconfCenterItem.setObject(object);
        }

        // 根据类型设置值
        //
        // 注入实体
        //
        try {

            if (object != null) {

                // 默认值
                Object defaultValue = disconfCenterItem.getField().get(object);

                LOGGER.debug(disconfCenterItem.getKey()
                        + " is a non-static field. ");

                if (disconfCenterItem.getValue() == null) {

                    // 如果仓库里的值为空,则实例直接使用默认值,
                    disconfCenterItem.getField().set(object, defaultValue);

                    // 仓库里也使用此值
                    disconfCenterItem.setValue(defaultValue);

                } else {

                    // 如果仓库里的值为非空,则实例使用仓库里的值
                    disconfCenterItem.getField().set(object,
                            disconfCenterItem.getValue());
                }

            } else {

                //
                // 静态类
                //
                if (Modifier.isStatic(disconfCenterItem.getField()
                        .getModifiers())) {
                    LOGGER.debug(disconfCenterItem.getKey()
                            + " is a static field. ");
                    disconfCenterItem.getField().set(null,
                            disconfCenterItem.getValue());
                }
            }

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


     *
     */
    @Override
    public Object getConfig(String fileName, String keyName) {

        DisconfCenterItem disconfCenterItem = DisconfCenterStore.getInstance()
                .getConfItemMap().get(keyName);

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

        return disconfCenterItem.getValue();
    }
View Full Code Here

     *
     */
    @Override
    public void inject2Store(String key, DisconfValue disconfValue) {

        DisconfCenterItem disconfCenterItem = DisconfCenterStore.getInstance()
                .getConfItemMap().get(key);

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

        if (disconfValue == null || disconfValue.getValue() == null) {
            LOGGER.error("value is null for {}", key);
            return;
        }

        // 存储
        Class<?> typeClass = disconfCenterItem.getField().getType();

        // 根据类型设置值
        //
        // 注入仓库
        //
        try {

            Object newValue = ClassUtils.getValeByType(typeClass,
                    disconfValue.getValue());
            disconfCenterItem.setValue(newValue);

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

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

     *
     */
    @Override
    public DisConfCommonModel getCommonModel(String keyName) {

        DisconfCenterItem disconfCenterItem = DisconfCenterStore.getInstance()
                .getConfItemMap().get(keyName);

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

        return disconfCenterItem.getDisConfCommonModel();
    }
View Full Code Here

     *
     */
    @Override
    public void inject2Instance(Object object, String key) {

        DisconfCenterItem disconfCenterItem = DisconfCenterStore.getInstance()
                .getConfItemMap().get(key);

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

        //
        // 非静态类
        //
        if (object != null) {
            disconfCenterItem.setObject(object);
        }

        // 根据类型设置值
        //
        // 注入实体
        //
        try {

            if (object != null) {

                // 默认值
                Object defaultValue = disconfCenterItem.getField().get(object);

                LOGGER.debug(disconfCenterItem.getKey()
                        + " is a non-static field. ");

                if (disconfCenterItem.getValue() == null) {

                    // 如果仓库里的值为空,则实例直接使用默认值,
                    disconfCenterItem.getField().set(object, defaultValue);

                    // 仓库里也使用此值
                    disconfCenterItem.setValue(defaultValue);

                } else {

                    // 如果仓库里的值为非空,则实例使用仓库里的值
                    disconfCenterItem.getField().set(object,
                            disconfCenterItem.getValue());
                }

            } else {

                //
                // 静态类
                //
                if (Modifier.isStatic(disconfCenterItem.getField()
                        .getModifiers())) {
                    LOGGER.debug(disconfCenterItem.getKey()
                            + " is a static field. ");
                    disconfCenterItem.getField().set(null,
                            disconfCenterItem.getValue());
                }
            }

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

     *
     */
    @Override
    public Object getConfig(String fileName, String keyName) {

        DisconfCenterItem disconfCenterItem = DisconfCenterStore.getInstance()
                .getConfItemMap().get(keyName);

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

        return disconfCenterItem.getValue();
    }
View Full Code Here

     *
     */
    @Override
    public void inject2Store(String key, DisconfValue disconfValue) {

        DisconfCenterItem disconfCenterItem = DisconfCenterStore.getInstance()
                .getConfItemMap().get(key);

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

        if (disconfValue == null || disconfValue.getValue() == null) {
            LOGGER.error("value is null for {}", key);
            return;
        }

        // 存储
        Class<?> typeClass = disconfCenterItem.getField().getType();

        // 根据类型设置值
        //
        // 注入仓库
        //
        try {

            Object newValue = ClassUtils.getValeByType(typeClass,
                    disconfValue.getValue());
            disconfCenterItem.setValue(newValue);

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

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

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

            LOGGER.debug("==============\tstart to process disconf item: "
                    + key + "\t=============================");

            DisconfCenterItem disconfCenterItem = (DisconfCenterItem) disconfStoreProcessor
                    .getConfData(key);
            if (disconfCenterItem != null) {
                try {
                    updateOneConfItem(key, disconfCenterItem);
                } catch (Exception e) {
View Full Code Here

    /**
     * 更新 一个配置
     */
    public void updateOneConf(String keyName) throws Exception {

        DisconfCenterItem disconfCenterItem = (DisconfCenterItem) disconfStoreProcessor
                .getConfData(keyName);
        if (disconfCenterItem != null) {
            updateOneConfItem(keyName, disconfCenterItem);
        }
    }
View Full Code Here

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

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

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

            if (disconfCenterItem == null) {
                continue;
            }

            try {

                Object object = null;

                Field field = disconfCenterItem.getField();

                //
                // 静态
                //
                if (Modifier.isStatic(field.getModifiers())) {
View Full Code Here

TOP

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

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.