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

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


        for (String key : confItemMap.keySet()) {

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

            DisconfCenterItem disconfCenterItem = confItemMap.get(key);

            try {

                Object object = null;

                Field field = disconfCenterItem.getField();

                object = getSpringBean(field.getDeclaringClass());
                if (object != null) {
                    disconfCenterItem.setObject(object);
                    DisconfStoreMgr.getInstance().injectItem2Instance(key);
                }

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


        for (String key : confItemMap.keySet()) {

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

            DisconfCenterItem disconfCenterItem = confItemMap.get(key);

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

    public static void updateOneConfItem(String keyName) throws Exception {

        Map<String, DisconfCenterItem> confItemMap = DisconfStoreMgr
                .getInstance().getConfItemMap();

        DisconfCenterItem disconfCenterItem = confItemMap.get(keyName);

        updateOneConfItem(keyName, disconfCenterItem);
    }
View Full Code Here

    public static void callOneConfItem(String keyName) throws Exception {

        Map<String, DisconfCenterItem> confItemMap = DisconfStoreMgr
                .getInstance().getConfItemMap();

        DisconfCenterItem disconfCenterItem = confItemMap.get(keyName);
        if (disconfCenterItem == null) {
            throw new Exception("cannot find disconfCenterItem " + keyName);
        }

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

     * @param keyName
     * @return
     */
    public Object getConfigItem(String keyName) {

        DisconfCenterItem disconfCenterItem = disconfCenterStore
                .getConfItemMap().get(keyName);

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

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

    /**
     * 将配置项数据注入到仓库
     */
    public void injectItem2Store(String key, String value) {

        DisconfCenterItem disconfCenterItem = disconfCenterStore
                .getConfItemMap().get(key);

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

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

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

            Object newValue = ClassUtils.getValeByType(typeClass, value);
            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

    /**
     * 将配置项数据注入实体
     */
    public void injectItem2Instance(String key) {

        DisconfCenterItem disconfCenterItem = disconfCenterStore
                .getConfItemMap().get(key);

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

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

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

            disconfCenterItem.getField().set(disconfCenterItem.getObject(),
                    disconfCenterItem.getValue());

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

     * @param fileName
     * @return
     */
    public String getItemZooPath(String key) {

        DisconfCenterItem disconfCenterItem = disconfCenterStore
                .getConfItemMap().get(key);

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

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

     *
     * @return
     */
    private static DisconfCenterItem transformScanFile(Method method) {

        DisconfCenterItem disconfCenterItem = new DisconfCenterItem();

        // class
        Class<?> cls = method.getDeclaringClass();

        // fields
        Field[] expectedFields = cls.getDeclaredFields();

        // field
        Field field = ScanVerify.getFieldFromMethod(method, expectedFields,
                DisConfigTypeEnum.ITEM);

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

        // 获取标注
        DisconfItem disconfItem = method.getAnnotation(DisconfItem.class);

        // 去掉空格
        String key = disconfItem.key().replace(" ", "");

        // 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.env(), disconfItem.version(), ZooPathMgr.joinPath(
                        WatchMgr.getInstance().getClientDisconfItemZooPath(),
                        key));
        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;
    }
View Full Code Here

        List<DisconfCenterItem> disconfCenterItems = new ArrayList<DisconfCenterItem>();

        Set<Method> methods = scanModel.getDisconfItemMethodSet();
        for (Method method : methods) {

            DisconfCenterItem disconfCenterItem = transformScanFile(method);

            if (disconfCenterItem != null) {
                disconfCenterItems.add(disconfCenterItem);
            }
        }
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.