Search in sources :

Example 6 with ModuleConfig

use of org.apache.dubbo.config.ModuleConfig in project dubbo by alibaba.

the class ModuleBuilder method build.

public ModuleConfig build() {
    ModuleConfig moduleConfig = new ModuleConfig();
    super.build(moduleConfig);
    moduleConfig.setDefault(isDefault);
    moduleConfig.setMonitor(monitor);
    moduleConfig.setName(name);
    moduleConfig.setOrganization(organization);
    moduleConfig.setOwner(owner);
    moduleConfig.setRegistries(registries);
    moduleConfig.setVersion(version);
    return moduleConfig;
}
Also used : ModuleConfig(org.apache.dubbo.config.ModuleConfig)

Example 7 with ModuleConfig

use of org.apache.dubbo.config.ModuleConfig in project dubbo by alibaba.

the class ModuleBuilderTest method build.

@Test
void build() {
    RegistryConfig registry = new RegistryConfig();
    MonitorConfig monitor = new MonitorConfig();
    ModuleBuilder builder = new ModuleBuilder();
    builder.name("name").version("version").owner("owner").organization("organization").addRegistry(registry).monitor(monitor).isDefault(false);
    ModuleConfig config = builder.build();
    ModuleConfig config2 = builder.build();
    Assertions.assertEquals("name", config.getName());
    Assertions.assertEquals("version", config.getVersion());
    Assertions.assertEquals("owner", config.getOwner());
    Assertions.assertEquals("organization", config.getOrganization());
    Assertions.assertTrue(builder.build().getRegistries().contains(registry));
    Assertions.assertSame(monitor, builder.build().getMonitor());
    Assertions.assertFalse(config.isDefault());
    Assertions.assertNotSame(config, config2);
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ModuleConfig(org.apache.dubbo.config.ModuleConfig) MonitorConfig(org.apache.dubbo.config.MonitorConfig) Test(org.junit.jupiter.api.Test)

Example 8 with ModuleConfig

use of org.apache.dubbo.config.ModuleConfig in project dubbo by alibaba.

the class AnnotatedInterfaceConfigBeanBuilder method configureModuleConfig.

private void configureModuleConfig(C configBean) {
    String moduleConfigBeanName = resolveModuleConfigBeanName(attributes);
    ModuleConfig moduleConfig = getOptionalBean(applicationContext, moduleConfigBeanName, ModuleConfig.class);
    configBean.setModule(moduleConfig);
}
Also used : ModuleConfig(org.apache.dubbo.config.ModuleConfig)

Example 9 with ModuleConfig

use of org.apache.dubbo.config.ModuleConfig in project dubbo by alibaba.

the class AbstractAnnotationConfigBeanBuilder method configureModuleConfig.

private void configureModuleConfig(B bean) {
    String moduleConfigBeanName = resolveModuleConfigBeanName(annotation);
    ModuleConfig moduleConfig = getOptionalBean(applicationContext, moduleConfigBeanName, ModuleConfig.class);
    bean.setModule(moduleConfig);
}
Also used : ModuleConfig(org.apache.dubbo.config.ModuleConfig)

Example 10 with ModuleConfig

use of org.apache.dubbo.config.ModuleConfig in project dubbo by alibaba.

the class EnableDubboConfigTest method testSingle.

@Test
public void testSingle() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(TestConfig.class);
    context.refresh();
    // application
    ApplicationConfig applicationConfig = context.getBean("applicationBean", ApplicationConfig.class);
    Assertions.assertEquals("dubbo-demo-application", applicationConfig.getName());
    // module
    ModuleConfig moduleConfig = context.getBean("moduleBean", ModuleConfig.class);
    Assertions.assertEquals("dubbo-demo-module", moduleConfig.getName());
    // registry
    RegistryConfig registryConfig = context.getBean(RegistryConfig.class);
    Assertions.assertEquals("zookeeper://192.168.99.100:32770", registryConfig.getAddress());
    // protocol
    ProtocolConfig protocolConfig = context.getBean(ProtocolConfig.class);
    Assertions.assertEquals("dubbo", protocolConfig.getName());
    Assertions.assertEquals(Integer.valueOf(20880), protocolConfig.getPort());
    // monitor
    MonitorConfig monitorConfig = context.getBean(MonitorConfig.class);
    Assertions.assertEquals("zookeeper://127.0.0.1:32770", monitorConfig.getAddress());
    // provider
    ProviderConfig providerConfig = context.getBean(ProviderConfig.class);
    Assertions.assertEquals("127.0.0.1", providerConfig.getHost());
    // consumer
    ConsumerConfig consumerConfig = context.getBean(ConsumerConfig.class);
    Assertions.assertEquals("netty", consumerConfig.getClient());
    // asserts aliases
    assertFalse(hasAlias(context, "org.apache.dubbo.config.RegistryConfig#0", "zookeeper"));
    assertFalse(hasAlias(context, "org.apache.dubbo.config.MonitorConfig#0", "zookeeper"));
    context.close();
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ProviderConfig(org.apache.dubbo.config.ProviderConfig) ModuleConfig(org.apache.dubbo.config.ModuleConfig) ConsumerConfig(org.apache.dubbo.config.ConsumerConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) MonitorConfig(org.apache.dubbo.config.MonitorConfig) Test(org.junit.jupiter.api.Test)

Aggregations

ModuleConfig (org.apache.dubbo.config.ModuleConfig)11 Test (org.junit.jupiter.api.Test)7 RegistryConfig (org.apache.dubbo.config.RegistryConfig)4 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)3 MonitorConfig (org.apache.dubbo.config.MonitorConfig)3 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)2 AbstractInterfaceConfig (org.apache.dubbo.config.AbstractInterfaceConfig)1 ConfigCenterConfig (org.apache.dubbo.config.ConfigCenterConfig)1 ConsumerConfig (org.apache.dubbo.config.ConsumerConfig)1 MetadataReportConfig (org.apache.dubbo.config.MetadataReportConfig)1 ProviderConfig (org.apache.dubbo.config.ProviderConfig)1 ConfigTest (org.apache.dubbo.config.spring.ConfigTest)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1