com.alibaba.dubbo.config.ModuleConfig Java Examples

The following examples show how to use com.alibaba.dubbo.config.ModuleConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DubboConfigConfigurationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void testSingle() throws IOException {

    context.register(DubboConfigConfiguration.Single.class);
    context.refresh();

    // application
    ApplicationConfig applicationConfig = context.getBean("applicationBean", ApplicationConfig.class);
    Assert.assertEquals("dubbo-demo-application", applicationConfig.getName());

    // module
    ModuleConfig moduleConfig = context.getBean("moduleBean", ModuleConfig.class);
    Assert.assertEquals("dubbo-demo-module", moduleConfig.getName());

    // registry
    RegistryConfig registryConfig = context.getBean(RegistryConfig.class);
    Assert.assertEquals("zookeeper://192.168.99.100:32770", registryConfig.getAddress());

    // protocol
    ProtocolConfig protocolConfig = context.getBean(ProtocolConfig.class);
    Assert.assertEquals("dubbo", protocolConfig.getName());
    Assert.assertEquals(Integer.valueOf(20880), protocolConfig.getPort());
}
 
Example #2
Source File: DubboNamespaceHandler.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void init() {
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
Example #3
Source File: DubboNamespaceHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void init() {
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
Example #4
Source File: DubboNamespaceHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void init() {
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
Example #5
Source File: DubboNamespaceHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void init() {
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
Example #6
Source File: DubboAutoConfiguration.java    From spring-boot-starter-dubbo with Apache License 2.0 5 votes vote down vote up
private void registerModule(ModuleConfig module, ConfigurableListableBeanFactory beanFactory) {
	if (module != null) {
		String beanName = module.getId();
		if (StringUtils.isEmpty(beanName)) {
			beanName = "moduleConfig";
		}
		beanFactory.registerSingleton(beanName, module);
	} else {
		logger.debug("dubbo 没有配置模块信息");
	}
}
 
Example #7
Source File: DubboAutoConfiguration.java    From spring-boot-starter-dubbo with Apache License 2.0 5 votes vote down vote up
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
	DubboProperties dubboProperties = this.getPropertiesConfigurationBean(DubboProperties.targetName, DubboProperties.class);
	ApplicationConfig application = dubboProperties.getApplication();
	MonitorConfig monitor = dubboProperties.getMonitor();
	ModuleConfig module = dubboProperties.getModule();
	ProviderConfig provider = dubboProperties.getProvider();
	ConsumerConfig consumer = dubboProperties.getConsumer();
	List<ProtocolConfig> protocols = this.getProtocols(dubboProperties);
	List<RegistryConfig> registryConfigs = this.getRegistrys(dubboProperties);
	List<ReferenceConfig<?>> references = dubboProperties.getReferences();
	List<ServiceConfig<?>> services = dubboProperties.getServices();
	this.registerRegistry(registryConfigs, beanFactory);

	String basePackage = dubboProperties.getBasePackage();

	if (provider != null) {
		provider.setProtocols(this.getProtocol(protocols, "spring.dubbo.provider.protocol"));
		provider.setRegistries(this.getRegistry(registryConfigs, "spring.dubbo.provider.registry"));
	}

	if (consumer != null) {
		consumer.setRegistries(this.getRegistry(registryConfigs, "spring.dubbo.consumer.registry"));
	}

	this.registerThis(basePackage, beanFactory);
	this.registerApplication(application, beanFactory);
	this.registerProtocols(protocols, beanFactory);
	this.registerMonitor(monitor, beanFactory);
	this.registerModule(module, beanFactory);
	this.registerProvider(provider, beanFactory);
	this.registerConsumer(consumer, beanFactory);
	this.registerReferences(references, beanFactory);
	this.registerServices(services, beanFactory);
	super.postProcessBeanFactory(beanFactory);
	super.postProcessAnnotationPackageService();
}
 
Example #8
Source File: DubboNamespaceHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void init() {
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
Example #9
Source File: DubboMonitorConsumerFactory.java    From EasyTransaction with Apache License 2.0 5 votes vote down vote up
public DubboMonitorConsumerFactory(Optional<ApplicationConfig> applicationConfig, Optional<RegistryConfig> registryConfig,Optional<ProtocolConfig> protocolConfig,Optional<ConsumerConfig> consumerConfig,Optional<ModuleConfig> moduleConfig,Optional<MonitorConfig> monitorConfig, Optional<DubboReferanceCustomizationer> customizationer) {
    super();
    this.applicationConfig = applicationConfig.orElse(null);
    this.registryConfig = registryConfig.orElse(null);
    this.protocolConfig = protocolConfig.orElse(null);
    this.customizationer = customizationer.orElse(null);
    this.consumerConfig = consumerConfig.orElse(null);
    this.moduleConfig = moduleConfig.orElse(null);
    this.monitorConfig = monitorConfig.orElse(null);
}
 
Example #10
Source File: DubboMonitorProvider.java    From EasyTransaction with Apache License 2.0 5 votes vote down vote up
public DubboMonitorProvider(String appId, EasyTransFilterChainFactory filterChainFactory, Optional<ApplicationConfig> applicationConfig,
        Optional<RegistryConfig> registryConfig,Optional<ProtocolConfig> protocolConfig,Optional<ProviderConfig> providerConfig,Optional<ModuleConfig> moduleConfig,Optional<MonitorConfig> monitorConfig, Optional<DubboServiceCustomizationer> customizationer,List<EtMonitor> etMonitorList) {
    super();
    this.appId = appId;
    this.applicationConfig = applicationConfig.orElse(null);
    this.registryConfig = registryConfig.orElse(null);
    this.protocolConfig = protocolConfig.orElse(null);
    this.providerConfig = providerConfig.orElse(null);
    this.moduleConfig = moduleConfig.orElse(null);
    this.monitorConfig = monitorConfig.orElse(null);
    this.customizationer = customizationer.orElse(null);
    this.etMonitorList = etMonitorList;
}
 
Example #11
Source File: DubboNamespaceHandler.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
    public void init() {
//        xml配置解析=》
        registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
        registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
        registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
        registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
        registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
        registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
        registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
        registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
        registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
//        annotation解析<dubbo:annotation package="" />xml配置=》
        registerBeanDefinitionParser("annotation", new AnnotationBeanDefinitionParser());
    }
 
Example #12
Source File: EnableDubboConfigTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingle() {

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(TestConfig.class);
    context.refresh();

    // application
    ApplicationConfig applicationConfig = context.getBean("applicationBean", ApplicationConfig.class);
    Assert.assertEquals("dubbo-demo-application", applicationConfig.getName());

    // module
    ModuleConfig moduleConfig = context.getBean("moduleBean", ModuleConfig.class);
    Assert.assertEquals("dubbo-demo-module", moduleConfig.getName());

    // registry
    RegistryConfig registryConfig = context.getBean(RegistryConfig.class);
    Assert.assertEquals("zookeeper://192.168.99.100:32770", registryConfig.getAddress());

    // protocol
    ProtocolConfig protocolConfig = context.getBean(ProtocolConfig.class);
    Assert.assertEquals("dubbo", protocolConfig.getName());
    Assert.assertEquals(Integer.valueOf(20880), protocolConfig.getPort());

    // monitor
    MonitorConfig monitorConfig = context.getBean(MonitorConfig.class);
    Assert.assertEquals("zookeeper://127.0.0.1:32770", monitorConfig.getAddress());

    // provider
    ProviderConfig providerConfig = context.getBean(ProviderConfig.class);
    Assert.assertEquals("127.0.0.1", providerConfig.getHost());


    // consumer
    ConsumerConfig consumerConfig = context.getBean(ConsumerConfig.class);
    Assert.assertEquals("netty", consumerConfig.getClient());

}
 
Example #13
Source File: DubboNamespaceHandlerTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testModuleInfo() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/provider-with-module.xml");
    ctx.start();

    ModuleConfig moduleConfig = ctx.getBean(ModuleConfig.class);
    assertThat(moduleConfig.getName(), is("test-module"));
}
 
Example #14
Source File: DubboEasyTransRpcProviderImpl.java    From EasyTransaction with Apache License 2.0 5 votes vote down vote up
public DubboEasyTransRpcProviderImpl(EasyTransFilterChainFactory filterChainFactory, Optional<ApplicationConfig> applicationConfig,
		Optional<RegistryConfig> registryConfig,Optional<ProtocolConfig> protocolConfig,Optional<ProviderConfig> providerConfig,Optional<ModuleConfig> moduleConfig,Optional<MonitorConfig> monitorConfig, Optional<DubboServiceCustomizationer> customizationer) {
	super();
	this.filterChainFactory = filterChainFactory;
	this.applicationConfig = applicationConfig.orElse(null);
	this.registryConfig = registryConfig.orElse(null);
	this.protocolConfig = protocolConfig.orElse(null);
	this.providerConfig = providerConfig.orElse(null);
	this.moduleConfig = moduleConfig.orElse(null);
	this.monitorConfig = monitorConfig.orElse(null);
	this.customizationer = customizationer.orElse(null);
	injectHelper = this;
}
 
Example #15
Source File: DubboEasyTransRpcConsumerImpl.java    From EasyTransaction with Apache License 2.0 5 votes vote down vote up
public DubboEasyTransRpcConsumerImpl(Optional<ApplicationConfig> applicationConfig, Optional<RegistryConfig> registryConfig,Optional<ProtocolConfig> protocolConfig,Optional<ConsumerConfig> consumerConfig,Optional<ModuleConfig> moduleConfig,Optional<MonitorConfig> monitorConfig, Optional<DubboReferanceCustomizationer> customizationer) {
	super();
	this.applicationConfig = applicationConfig.orElse(null);
	this.registryConfig = registryConfig.orElse(null);
	this.protocolConfig = protocolConfig.orElse(null);
	this.customizationer = customizationer.orElse(null);
	this.consumerConfig = consumerConfig.orElse(null);
	this.moduleConfig = moduleConfig.orElse(null);
	this.monitorConfig = monitorConfig.orElse(null);
}
 
Example #16
Source File: DubboProperties.java    From spring-boot-starter-dubbo with Apache License 2.0 4 votes vote down vote up
public ModuleConfig getModule() {
	return module;
}
 
Example #17
Source File: DubboProperties.java    From spring-boot-starter-dubbo with Apache License 2.0 4 votes vote down vote up
public void setModule(ModuleConfig module) {
	this.module = module;
}
 
Example #18
Source File: DubboEasyTransRpcConfiguration.java    From EasyTransaction with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(EasyTransRpcProvider.class)
public DubboEasyTransRpcProviderImpl onsEasyTransMsgPublisherImpl(EasyTransFilterChainFactory filterChainFactory, Optional<ApplicationConfig> applicationConfig,
		Optional<RegistryConfig> registryConfig,Optional<ProtocolConfig> protocolConfig,Optional<ProviderConfig> providerConfig,Optional<ModuleConfig> moduleConfig,Optional<MonitorConfig> monitorConfig, Optional<DubboServiceCustomizationer> customizationer){
	return new DubboEasyTransRpcProviderImpl(filterChainFactory, applicationConfig, registryConfig, protocolConfig, providerConfig, moduleConfig, monitorConfig, customizationer);
}
 
Example #19
Source File: DubboProperties.java    From dubbo-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
public ModuleConfig getModule() {
  return this.module;
}
 
Example #20
Source File: DubboProperties.java    From dubbo-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
public void setModule(ModuleConfig module) {
  this.module = module;
}
 
Example #21
Source File: DubboProperties.java    From dubbo-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
public Map<String, ModuleConfig> getModules() {
  return this.modules;
}
 
Example #22
Source File: DubboProperties.java    From dubbo-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
public void setModules(Map<String, ModuleConfig> modules) {
  this.modules = modules;
}
 
Example #23
Source File: DubboProperties.java    From spring-boot-starter-dubbo with Apache License 2.0 4 votes vote down vote up
public ModuleConfig getModule() {
	return module;
}
 
Example #24
Source File: DubboProperties.java    From spring-boot-starter-dubbo with Apache License 2.0 4 votes vote down vote up
public void setModule(ModuleConfig module) {
	this.module = module;
}
 
Example #25
Source File: DubboEasyTransRpcConfiguration.java    From EasyTransaction with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(EasyTransRpcConsumer.class)
public DubboEasyTransRpcConsumerImpl dubboEasyTransRpcConsumerImpl(Optional<ApplicationConfig> applicationConfig, Optional<RegistryConfig> registryConfig,Optional<ProtocolConfig> protocolConfig,Optional<ConsumerConfig> consumerConfig,Optional<ModuleConfig> moduleConfig,Optional<MonitorConfig> monitorConfig, Optional<DubboReferanceCustomizationer> customizationer){
	return new DubboEasyTransRpcConsumerImpl(applicationConfig, registryConfig, protocolConfig, consumerConfig, moduleConfig, monitorConfig, customizationer);
}
 
Example #26
Source File: DubboEasyTransRpcConfiguration.java    From EasyTransaction with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(MonitorConsumerFactory.class)
   public MonitorConsumerFactory monitorConsumerFactory(Optional<ApplicationConfig> applicationConfig, Optional<RegistryConfig> registryConfig,Optional<ProtocolConfig> protocolConfig,Optional<ConsumerConfig> consumerConfig,Optional<ModuleConfig> moduleConfig,Optional<MonitorConfig> monitorConfig, Optional<DubboReferanceCustomizationer> customizationer) {
       return new DubboMonitorConsumerFactory(applicationConfig, registryConfig, protocolConfig, consumerConfig, moduleConfig, monitorConfig, customizationer);
   }
 
Example #27
Source File: DubboEasyTransRpcConfiguration.java    From EasyTransaction with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnProperty(name="easytrans.rpc.dubbo.monitor.enabled",havingValue="true",matchIfMissing=true)
public DubboMonitorProvider dubboMonitorProvider(EasyTransFilterChainFactory filterChainFactory, Optional<ApplicationConfig> applicationConfig,
           Optional<RegistryConfig> registryConfig,Optional<ProtocolConfig> protocolConfig,Optional<ProviderConfig> providerConfig,Optional<ModuleConfig> moduleConfig,Optional<MonitorConfig> monitorConfig, Optional<DubboServiceCustomizationer> customizationer,List<EtMonitor> etMonitorList) {
    return new DubboMonitorProvider(applicationName, filterChainFactory, applicationConfig, registryConfig, protocolConfig, providerConfig, moduleConfig, monitorConfig, customizationer, etMonitorList);
}
 
Example #28
Source File: AbstractAnnotationConfigBeanBuilder.java    From dubbo-2.6.5 with Apache License 2.0 3 votes vote down vote up
private void configureModuleConfig(B bean) {

        String moduleConfigBeanName = resolveModuleConfigBeanName(annotation);

        ModuleConfig moduleConfig =
                getOptionalBean(applicationContext, moduleConfigBeanName, ModuleConfig.class);

        bean.setModule(moduleConfig);

    }