use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.
the class ReferenceConfigCacheTest method buildMockReferenceConfig.
private MockReferenceConfig buildMockReferenceConfig(String service, String group, String version) {
MockReferenceConfig config = new MockReferenceConfig();
config.setApplication(new ApplicationConfig("cache"));
config.setRegistry(new RegistryConfig("multicast://224.5.6.7:1234"));
config.setCheck(false);
config.setInterface(service);
config.setGroup(group);
config.setVersion(version);
return config;
}
use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.
the class ServiceOrientedRegistryTest method init.
@BeforeEach
public void init() {
registry = ServiceDiscoveryRegistry.create(registryURL);
metadataService = WritableMetadataService.getDefaultExtension();
notifyListener = new MyNotifyListener();
ApplicationModel.getConfigManager().setApplication(new ApplicationConfig("Test"));
}
use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.
the class DubboConfigBeanDefinitionConflictApplicationListenerTest method testDuplicatedConfigsCase.
@Test
public void testDuplicatedConfigsCase() {
context.register(PropertySourceConfig.class, DubboConfig.class);
context.register(XmlConfig.class);
context.refresh();
Map<String, ApplicationConfig> beansMap = context.getBeansOfType(ApplicationConfig.class);
ApplicationConfig applicationConfig = beansMap.get("dubbo-consumer-2.7.x");
Assert.assertEquals(1, beansMap.size());
Assert.assertEquals("dubbo-consumer-2.7.x", applicationConfig.getName());
}
use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.
the class DubboConfigBeanDefinitionConflictApplicationListener method resolveUniqueApplicationConfigBean.
/**
* Resolve the unique {@link ApplicationConfig} Bean
* @param registry {@link BeanDefinitionRegistry} instance
* @param beanFactory {@link ConfigurableListableBeanFactory} instance
* @see EnableDubboConfig
*/
private void resolveUniqueApplicationConfigBean(BeanDefinitionRegistry registry, ListableBeanFactory beanFactory) {
String[] beansNames = beanNamesForTypeIncludingAncestors(beanFactory, ApplicationConfig.class);
if (beansNames.length < 2) {
// If the number of ApplicationConfig beans is less than two, return immediately.
return;
}
Environment environment = beanFactory.getBean(ENVIRONMENT_BEAN_NAME, Environment.class);
// Remove ApplicationConfig Beans that are configured by "dubbo.application.*"
Stream.of(beansNames).filter(beansName -> isConfiguredApplicationConfigBeanName(environment, beansName)).forEach(registry::removeBeanDefinition);
beansNames = beanNamesForTypeIncludingAncestors(beanFactory, ApplicationConfig.class);
if (beansNames.length > 1) {
throw new IllegalStateException(String.format("There are more than one instances of %s, whose bean definitions : %s", ApplicationConfig.class.getSimpleName(), Stream.of(beansNames).map(registry::getBeanDefinition).collect(Collectors.toList())));
}
}
use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.
the class ServiceAnnotationTestConfiguration2 method applicationConfig.
/**
* Current application configuration, to replace XML config:
* <prev>
* <dubbo:application name="dubbo-demo-application"/>
* </prev>
*
* @return {@link ApplicationConfig} Bean
*/
@Bean("dubbo-demo-application")
public ApplicationConfig applicationConfig() {
ApplicationConfig applicationConfig = new ApplicationConfig();
applicationConfig.setName("dubbo-demo-application");
return applicationConfig;
}
Aggregations