class RefererConfigBean<T> extends RefererConfig<T> implements FactoryBean<T>, BeanFactoryAware, InitializingBean, DisposableBean {

    private static final long serialVersionUID = 8381310907161365567L;

    private transient BeanFactory beanFactory;

    @Override
    public T getObject() throws Exception {
        return getRef();
    }

    @Override
    public Class<?> getObjectType() {
        return getInterface();
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    @Override
    public void destroy() {
        super.destroy();
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        // basicConfig需要首先配置，因为其他可能会依赖于basicConfig的配置
        checkAndConfigBasicConfig();
        if (checkAndConfigMeshClient()) { // 使用MeshClient时不需要检查其他项
            return;
        }

        checkAndConfigProtocols();
        checkAndConfigRegistry();
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
    }

    /**
     * 检查并配置basicConfig
     */
    private void checkAndConfigBasicConfig() {<FILL_FUNCTION_BODY>}

    /**
     * 检查是否有MeshClient相关配置，是否需要配置默认MeshClient
     * 如果使用默认MeshClient，如果初始化失败直接抛出异常，不支持通过check忽略此异常，尽早暴露问题
     *
     * @return true:使用MeshClient， false：不使用MeshClient
     */
    private boolean checkAndConfigMeshClient() {
        if ("default".equals(meshClientString)) {
            meshClient = DefaultMeshClient.getDefault();
        }
        if (meshClient == null && meshClientString == null && getBasicReferer() != null) {
            if ("default".equals(getBasicReferer().getMeshClientString())) {
                meshClient = DefaultMeshClient.getDefault();
            } else {
                meshClient = getBasicReferer().getMeshClient();
            }
        }
        return meshClient != null;
    }

    /**
     * 检查是否已经装配protocols，否则按basicConfig--->default路径查找
     */
    private void checkAndConfigProtocols() {
        if (CollectionUtil.isEmpty(getProtocols()) && getBasicReferer() != null
                && !CollectionUtil.isEmpty(getBasicReferer().getProtocols())) {
            setProtocols(getBasicReferer().getProtocols());
        }
        if (CollectionUtil.isEmpty(getProtocols())) {
            for (String name : MotanNamespaceHandler.protocolDefineNames) {
                ProtocolConfig pc = beanFactory.getBean(name, ProtocolConfig.class);
                if (pc == null) {
                    continue;
                }
                if (MotanNamespaceHandler.protocolDefineNames.size() == 1) {
                    setProtocol(pc);
                } else if (pc.isDefault() != null && pc.isDefault().booleanValue()) {
                    setProtocol(pc);
                }
            }
        }
        if (CollectionUtil.isEmpty(getProtocols())) {
            setProtocol(MotanFrameworkUtil.getDefaultProtocolConfig());
        }
    }

    /**
     * 检查并配置registry
     */
    public void checkAndConfigRegistry() {
        if (CollectionUtil.isEmpty(getRegistries()) && getBasicReferer() != null
                && !CollectionUtil.isEmpty(getBasicReferer().getRegistries())) {
            setRegistries(getBasicReferer().getRegistries());
        }
        if (CollectionUtil.isEmpty(getRegistries())) {
            for (String name : MotanNamespaceHandler.registryDefineNames) {
                RegistryConfig rc = beanFactory.getBean(name, RegistryConfig.class);
                if (rc == null) {
                    continue;
                }
                if (MotanNamespaceHandler.registryDefineNames.size() == 1) {
                    setRegistry(rc);
                } else if (rc.isDefault() != null && rc.isDefault().booleanValue()) {
                    setRegistry(rc);
                }
            }
        }
        if (CollectionUtil.isEmpty(getRegistries())) {
            setRegistry(MotanFrameworkUtil.getDefaultRegistryConfig());
        }
        for (RegistryConfig registryConfig : getRegistries()) {
            SpringBeanUtil.addRegistryParamBean(registryConfig, beanFactory);
        }
    }
}

        if (getBasicReferer() == null) {
            if (MotanNamespaceHandler.basicRefererConfigDefineNames.size() == 0) {
                if (beanFactory instanceof ListableBeanFactory) {
                    ListableBeanFactory listableBeanFactory = (ListableBeanFactory) beanFactory;
                    String[] basicRefererConfigNames = listableBeanFactory.getBeanNamesForType
                            (BasicRefererInterfaceConfig
                                    .class);
                    MotanNamespaceHandler.basicRefererConfigDefineNames.addAll(Arrays.asList(basicRefererConfigNames));
                }
            }
            for (String name : MotanNamespaceHandler.basicRefererConfigDefineNames) {
                BasicRefererInterfaceConfig biConfig = beanFactory.getBean(name, BasicRefererInterfaceConfig.class);
                if (biConfig == null) {
                    continue;
                }
                if (MotanNamespaceHandler.basicRefererConfigDefineNames.size() == 1) {
                    setBasicReferer(biConfig);
                } else if (biConfig.isDefault() != null && biConfig.isDefault().booleanValue()) {
                    setBasicReferer(biConfig);
                }
            }
        }
    
<methods>public non-sealed void <init>() ,public synchronized void destroy() ,public com.weibo.api.motan.config.BasicRefererInterfaceConfig getBasicReferer() ,public List<ClusterSupport<T>> getClusterSupports() ,public java.lang.String getDirectUrl() ,public java.util.concurrent.atomic.AtomicBoolean getInitialized() ,public Class<?> getInterface() ,public List<com.weibo.api.motan.config.MethodConfig> getMethods() ,public T getRef() ,public java.lang.String getServiceInterface() ,public boolean hasMethods() ,public synchronized void initRef() ,public void setBasicReferer(com.weibo.api.motan.config.BasicRefererInterfaceConfig) ,public void setDirectUrl(java.lang.String) ,public void setInterface(Class<T>) ,public void setMethods(List<com.weibo.api.motan.config.MethodConfig>) ,public void setMethods(com.weibo.api.motan.config.MethodConfig) ,public void setServiceInterface(java.lang.String) <variables>private com.weibo.api.motan.config.BasicRefererInterfaceConfig basicReferer,private List<ClusterSupport<T>> clusterSupports,private java.lang.String directUrl,private final java.util.concurrent.atomic.AtomicBoolean initialized,private Class<T> interfaceClass,protected List<com.weibo.api.motan.config.MethodConfig> methods,private T ref,private static final long serialVersionUID,private java.lang.String serviceInterface