Search in sources :

Example 16 with ListableBeanFactory

use of org.springframework.beans.factory.ListableBeanFactory in project motan by weibocom.

the class RefererConfigBean method checkAndConfigBasicConfig.

/**
     * 检查并配置basicConfig
     */
private void checkAndConfigBasicConfig() {
    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);
            }
        }
    }
}
Also used : BasicRefererInterfaceConfig(com.weibo.api.motan.config.BasicRefererInterfaceConfig) ListableBeanFactory(org.springframework.beans.factory.ListableBeanFactory)

Example 17 with ListableBeanFactory

use of org.springframework.beans.factory.ListableBeanFactory in project motan by weibocom.

the class ServiceConfigBean method checkAndConfigBasicConfig.

/**
     * 检查并配置basicConfig
     */
private void checkAndConfigBasicConfig() {
    if (getBasicServiceConfig() == null) {
        if (MotanNamespaceHandler.basicServiceConfigDefineNames.size() == 0) {
            if (beanFactory instanceof ListableBeanFactory) {
                ListableBeanFactory listableBeanFactory = (ListableBeanFactory) beanFactory;
                String[] basicServiceConfigNames = listableBeanFactory.getBeanNamesForType(BasicServiceInterfaceConfig.class);
                MotanNamespaceHandler.basicServiceConfigDefineNames.addAll(Arrays.asList(basicServiceConfigNames));
            }
        }
        for (String name : MotanNamespaceHandler.basicServiceConfigDefineNames) {
            BasicServiceInterfaceConfig biConfig = beanFactory.getBean(name, BasicServiceInterfaceConfig.class);
            if (biConfig == null) {
                continue;
            }
            if (MotanNamespaceHandler.basicServiceConfigDefineNames.size() == 1) {
                setBasicServiceConfig(biConfig);
            } else if (biConfig.isDefault() != null && biConfig.isDefault().booleanValue()) {
                setBasicServiceConfig(biConfig);
            }
        }
    }
}
Also used : BasicServiceInterfaceConfig(com.weibo.api.motan.config.BasicServiceInterfaceConfig) ListableBeanFactory(org.springframework.beans.factory.ListableBeanFactory)

Aggregations

ListableBeanFactory (org.springframework.beans.factory.ListableBeanFactory)17 BeanFactory (org.springframework.beans.factory.BeanFactory)4 BeansException (org.springframework.beans.BeansException)2 FileSystemXmlApplicationContext (org.springframework.context.support.FileSystemXmlApplicationContext)2 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)2 BasicRefererInterfaceConfig (com.weibo.api.motan.config.BasicRefererInterfaceConfig)1 BasicServiceInterfaceConfig (com.weibo.api.motan.config.BasicServiceInterfaceConfig)1 List (java.util.List)1 Map (java.util.Map)1 DataSource (javax.sql.DataSource)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 Test (org.junit.Test)1 Scheduler (org.quartz.Scheduler)1 BeanClassLoaderAware (org.springframework.beans.factory.BeanClassLoaderAware)1 FactoryBean (org.springframework.beans.factory.FactoryBean)1 HierarchicalBeanFactory (org.springframework.beans.factory.HierarchicalBeanFactory)1 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)1 ListFactoryBean (org.springframework.beans.factory.config.ListFactoryBean)1 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)1 PropertySourcesPlaceholderConfigurer (org.springframework.context.support.PropertySourcesPlaceholderConfigurer)1