Skip to content

Commit

Permalink
Polish apache#458 : dubbo.metadata-report.address propertie descripti…
Browse files Browse the repository at this point in the history
…on not provided
  • Loading branch information
mercyblitz committed Mar 20, 2019
1 parent 4c5d205 commit 49aef0b
Show file tree
Hide file tree
Showing 7 changed files with 298 additions and 1,116 deletions.
7 changes: 0 additions & 7 deletions dubbo-spring-boot-actuator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@
<optional>true</optional>
</dependency>

<!-- @ConfigurationProperties annotation processing (metadata for IDEs) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<!-- Dubbo autoconfigure -->
<dependency>
<groupId>org.apache.dubbo</groupId>
Expand Down
7 changes: 0 additions & 7 deletions dubbo-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@
<optional>true</optional>
</dependency>

<!-- @ConfigurationProperties annotation processing (metadata for IDEs) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<!-- Dubbo -->
<dependency>
<groupId>org.apache.dubbo</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
import org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpoint;
import org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration;
import org.apache.dubbo.spring.boot.autoconfigure.DubboRelaxedBindingAutoConfiguration;

import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -41,6 +43,7 @@
DubboAutoConfiguration.class,
DubboRelaxedBindingAutoConfiguration.class
})
@EnableConfigurationProperties(DubboEndpoint.class)
public class DubboEndpointAutoConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor;
import org.apache.dubbo.config.spring.context.annotation.DubboConfigConfiguration;
import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.PropertyResolver;

import java.util.Set;
Expand All @@ -53,6 +56,7 @@
@ConditionalOnProperty(prefix = DUBBO_PREFIX, name = "enabled", matchIfMissing = true)
@Configuration
@AutoConfigureAfter(DubboRelaxedBindingAutoConfiguration.class)
@EnableConfigurationProperties(DubboConfigurationProperties.class)
public class DubboAutoConfiguration {

/**
Expand Down Expand Up @@ -87,7 +91,7 @@ public ReferenceAnnotationBeanPostProcessor referenceAnnotationBeanPostProcessor
* @see EnableDubboConfig
* @see DubboConfigConfiguration.Single
*/
@EnableDubboConfig
@Import(DubboConfigConfiguration.Single.class)
protected static class SingleDubboConfigConfiguration {
}

Expand All @@ -98,7 +102,7 @@ protected static class SingleDubboConfigConfiguration {
* @see DubboConfigConfiguration.Multiple
*/
@ConditionalOnProperty(prefix = DUBBO_CONFIG_PREFIX, name = MULTIPLE_CONFIG_PROPERTY_NAME, matchIfMissing = true)
@EnableDubboConfig(multiple = true)
@Import(DubboConfigConfiguration.Multiple.class)
protected static class MultipleDubboConfigConfiguration {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.spring.boot.autoconfigure;

import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ConsumerConfig;
import org.apache.dubbo.config.MetadataReportConfig;
import org.apache.dubbo.config.ModuleConfig;
import org.apache.dubbo.config.MonitorConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ProviderConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.spring.ConfigCenterBean;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

import static org.apache.dubbo.spring.boot.util.DubboUtils.DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE;
import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_PREFIX;

/**
* Dubbo {@link ConfigurationProperties Config Properties} only used to generate JSON metadata(non-public class)
*
* @since 2.7.1
*/
@ConfigurationProperties(DUBBO_PREFIX)
class DubboConfigurationProperties {

@NestedConfigurationProperty
private Config config = new Config();

@NestedConfigurationProperty
private Scan scan = new Scan();

// Single Config Bindings

private ApplicationConfig application = new ApplicationConfig();

private ModuleConfig module = new ModuleConfig();

private RegistryConfig registry = new RegistryConfig();

private ProtocolConfig protocol = new ProtocolConfig();

private MonitorConfig monitor = new MonitorConfig();

private ProviderConfig provider = new ProviderConfig();

private ConsumerConfig consumer = new ConsumerConfig();

private ConfigCenterBean configCenter = new ConfigCenterBean();

private MetadataReportConfig metadataReport = new MetadataReportConfig();

// Multiple Config Bindings

private Map<String, ApplicationConfig> applications = new LinkedHashMap<>();

private Map<String, ModuleConfig> modules = new LinkedHashMap<>();

private Map<String, RegistryConfig> registrys = new LinkedHashMap<>();

private Map<String, ProtocolConfig> protocols = new LinkedHashMap<>();

private Map<String, MonitorConfig> monitors = new LinkedHashMap<>();

private Map<String, ProviderConfig> providers = new LinkedHashMap<>();

private Map<String, ConsumerConfig> consumers = new LinkedHashMap<>();

private Map<String, ConfigCenterBean> configCenters = new LinkedHashMap<>();

private Map<String, MetadataReportConfig> metadataReports = new LinkedHashMap<>();

public Config getConfig() {
return config;
}

public void setConfig(Config config) {
this.config = config;
}

public Scan getScan() {
return scan;
}

public void setScan(Scan scan) {
this.scan = scan;
}

public ApplicationConfig getApplication() {
return application;
}

public void setApplication(ApplicationConfig application) {
this.application = application;
}

public ModuleConfig getModule() {
return module;
}

public void setModule(ModuleConfig module) {
this.module = module;
}

public RegistryConfig getRegistry() {
return registry;
}

public void setRegistry(RegistryConfig registry) {
this.registry = registry;
}

public ProtocolConfig getProtocol() {
return protocol;
}

public void setProtocol(ProtocolConfig protocol) {
this.protocol = protocol;
}

public MonitorConfig getMonitor() {
return monitor;
}

public void setMonitor(MonitorConfig monitor) {
this.monitor = monitor;
}

public ProviderConfig getProvider() {
return provider;
}

public void setProvider(ProviderConfig provider) {
this.provider = provider;
}

public ConsumerConfig getConsumer() {
return consumer;
}

public void setConsumer(ConsumerConfig consumer) {
this.consumer = consumer;
}

public ConfigCenterBean getConfigCenter() {
return configCenter;
}

public void setConfigCenter(ConfigCenterBean configCenter) {
this.configCenter = configCenter;
}

public MetadataReportConfig getMetadataReport() {
return metadataReport;
}

public void setMetadataReport(MetadataReportConfig metadataReport) {
this.metadataReport = metadataReport;
}

public Map<String, ApplicationConfig> getApplications() {
return applications;
}

public void setApplications(Map<String, ApplicationConfig> applications) {
this.applications = applications;
}

public Map<String, ModuleConfig> getModules() {
return modules;
}

public void setModules(Map<String, ModuleConfig> modules) {
this.modules = modules;
}

public Map<String, RegistryConfig> getRegistrys() {
return registrys;
}

public void setRegistrys(Map<String, RegistryConfig> registrys) {
this.registrys = registrys;
}

public Map<String, ProtocolConfig> getProtocols() {
return protocols;
}

public void setProtocols(Map<String, ProtocolConfig> protocols) {
this.protocols = protocols;
}

public Map<String, MonitorConfig> getMonitors() {
return monitors;
}

public void setMonitors(Map<String, MonitorConfig> monitors) {
this.monitors = monitors;
}

public Map<String, ProviderConfig> getProviders() {
return providers;
}

public void setProviders(Map<String, ProviderConfig> providers) {
this.providers = providers;
}

public Map<String, ConsumerConfig> getConsumers() {
return consumers;
}

public void setConsumers(Map<String, ConsumerConfig> consumers) {
this.consumers = consumers;
}

public Map<String, ConfigCenterBean> getConfigCenters() {
return configCenters;
}

public void setConfigCenters(Map<String, ConfigCenterBean> configCenters) {
this.configCenters = configCenters;
}

public Map<String, MetadataReportConfig> getMetadataReports() {
return metadataReports;
}

public void setMetadataReports(Map<String, MetadataReportConfig> metadataReports) {
this.metadataReports = metadataReports;
}

static class Config {

/**
* Indicates multiple properties binding from externalized configuration or not.
*/
private boolean multiple = DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE;

public boolean isMultiple() {
return multiple;
}

public void setMultiple(boolean multiple) {
this.multiple = multiple;
}
}

static class Scan {

/**
* The basePackages to scan , the multiple-value is delimited by comma
*
* @see EnableDubbo#scanBasePackages()
*/
private Set<String> basePackages = new LinkedHashSet<>();

public Set<String> getBasePackages() {
return basePackages;
}

public void setBasePackages(Set<String> basePackages) {
this.basePackages = basePackages;
}
}
}
Loading

0 comments on commit 49aef0b

Please sign in to comment.