From e42a710a893c2ba9c05c7dbd05f3867a09ad7385 Mon Sep 17 00:00:00 2001 From: oxsean Date: Thu, 2 Nov 2023 08:59:05 +0800 Subject: [PATCH] feat(config): #13299 Enhance spring boot configuration metadata --- .../apache/dubbo/config/AbstractConfig.java | 22 +- .../dubbo/config/AbstractInterfaceConfig.java | 84 ++++---- .../dubbo/config/AbstractMethodConfig.java | 34 ++-- .../dubbo/config/AbstractServiceConfig.java | 50 +++-- .../dubbo/config/ApplicationConfig.java | 108 ++++++---- .../dubbo/config/ConfigCenterConfig.java | 66 ++++-- .../dubbo/config/MetadataReportConfig.java | 47 +++-- .../apache/dubbo/config/MetricsConfig.java | 47 +++-- .../org/apache/dubbo/config/ModuleConfig.java | 24 +-- .../apache/dubbo/config/MonitorConfig.java | 19 +- .../apache/dubbo/config/ProtocolConfig.java | 102 +++++----- .../apache/dubbo/config/ProviderConfig.java | 58 +++--- .../dubbo/config/ReferenceConfigBase.java | 13 +- .../apache/dubbo/config/RegistryConfig.java | 79 +++++--- .../dubbo/config/ServiceConfigBase.java | 18 +- .../org/apache/dubbo/config/SslConfig.java | 71 ++++++- .../apache/dubbo/config/TracingConfig.java | 11 +- .../dubbo/config/annotation/DubboService.java | 1 - .../dubbo/config/annotation/ProvidedBy.java | 1 - .../dubbo/config/annotation/Service.java | 1 - .../config/context/AbstractConfigManager.java | 4 - .../dubbo/config/context/ConfigManager.java | 4 - .../config/context/ModuleConfigManager.java | 3 - .../config/nested/AggregationConfig.java | 23 ++- .../dubbo/config/nested/BaggageConfig.java | 6 + .../dubbo/config/nested/ExporterConfig.java | 9 + .../dubbo/config/nested/HistogramConfig.java | 24 +++ .../dubbo/config/nested/PrometheusConfig.java | 5 +- .../config/nested/PropagationConfig.java | 3 + .../dubbo/config/nested/SamplingConfig.java | 3 + .../apache/dubbo/config/support/Nested.java | 1 - .../apache/dubbo/config/ReferenceConfig.java | 8 +- .../autoconfigure/pom.xml | 31 ++- .../autoconfigure/DubboAutoConfiguration.java | 5 +- .../DubboConfigurationProperties.java | 189 ++++++++---------- .../metadata/README.md | 27 +++ .../metadata/pom.xml | 185 +++++++++++++++++ ...ubboMetadataGenerateAutoConfiguration.java | 25 +++ ...itional-spring-configuration-metadata.json | 44 ++++ .../dubbo-spring-boot-compatible/pom.xml | 1 + 40 files changed, 977 insertions(+), 479 deletions(-) create mode 100644 dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/README.md create mode 100644 dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/pom.xml create mode 100644 dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboMetadataGenerateAutoConfiguration.java create mode 100644 dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/src/main/resources/META-INF/additional-spring-configuration-metadata.json diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java index cda3390abd15..26eff722b9f5 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java @@ -68,7 +68,6 @@ import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_REFLECTIVE_OPERATION_FAILED; import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION; import static org.apache.dubbo.common.utils.ClassUtils.isSimpleType; -import static org.apache.dubbo.common.utils.ReflectUtils.findMethodByMethodSignature; import static org.apache.dubbo.config.Constants.PARAMETERS; /** @@ -76,11 +75,13 @@ * * @export */ +@SuppressWarnings({"unchecked", "rawtypes"}) public abstract class AbstractConfig implements Serializable { - protected static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractConfig.class); private static final long serialVersionUID = 4267533505537413570L; + protected static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractConfig.class); + /** * tag name cache, speed up get tag name frequently */ @@ -97,19 +98,22 @@ public abstract class AbstractConfig implements Serializable { private static final String[] SUFFIXES = new String[]{"Config", "Bean", "ConfigBase"}; /** - * The config id + * Identifier for this configuration. */ private String id; + /** + * Indicates whether the configuration has been refreshed (true if refreshed). + */ protected final AtomicBoolean refreshed = new AtomicBoolean(false); /** - * Indicate that if current config needs to being refreshed, default is true + * Specifies if this configuration should be refreshed (true for refreshing). */ protected transient volatile boolean needRefresh = true; /** - * Is default config or not + * Indicates if this is the default configuration (true for default). */ protected Boolean isDefault; @@ -158,16 +162,12 @@ public static void appendParameters(Map parameters, Object confi appendParameters(parameters, config, null); } - @SuppressWarnings("unchecked") public static void appendParameters(Map parameters, Object config, String prefix) { appendParameters0(parameters, config, prefix, true); } /** * Put attributes of specify 'config' into 'parameters' argument - * - * @param parameters - * @param config */ public static void appendAttributes(Map parameters, Object config) { appendParameters0(parameters, config, null, false); @@ -292,7 +292,7 @@ private static String calculateAttributeFromGetter(String getter) { private static void invokeSetParameters(Class c, Object o, Map map) { try { - Method method = findMethodByMethodSignature(c, "setParameters", new String[]{Map.class.getName()}); + Method method = ReflectUtils.findMethodByMethodSignature(c, "setParameters", new String[]{Map.class.getName()}); if (method != null && isParametersSetter(method)) { method.invoke(o, map); } @@ -304,7 +304,7 @@ private static void invokeSetParameters(Class c, Object o, Map map) { private static Map invokeGetParameters(Class c, Object o) { try { - Method method = findMethodByMethodSignature(c, "getParameters", null); + Method method = ReflectUtils.findMethodByMethodSignature(c, "getParameters", null); if (method != null && isParametersGetter(method)) { return (Map) method.invoke(o); } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java index 3d48ae2a9608..cad5d4f9e945 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java @@ -58,9 +58,8 @@ import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMETHEUS; import static org.apache.dubbo.config.Constants.DEFAULT_NATIVE_PROXY; - /** - * AbstractDefaultConfig + * Abstract configuration for the interface. * * @export */ @@ -69,134 +68,148 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig { private static final long serialVersionUID = -1559314110797223229L; /** - * The interface name of the exported service + * Interface name of the exported service. */ protected String interfaceName; /** - * The classLoader of interface belong to + * ClassLoader associated with the interface. */ protected transient ClassLoader interfaceClassLoader; /** - * The remote service version the customer/provider side will reference + * Version of the remote service referenced by the consumer/provider. */ protected String version; /** - * The remote service group the customer/provider side will reference + * Group of the remote service referenced by the consumer/provider. */ protected String group; + /** + * Service metadata configuration. + */ protected ServiceMetadata serviceMetadata; + /** - * Local impl class name for the service interface + * Local implementation class name for the service interface. */ protected String local; /** - * Local stub class name for the service interface + * Local stub class name for the service interface. */ protected String stub; /** - * Service monitor + * Service monitoring configuration. */ protected MonitorConfig monitor; /** - * Strategies for generating dynamic agents,there are two strategies can be chosen: jdk and javassist + * Strategy for generating dynamic agents (options: "jdk" or "javassist"). */ protected String proxy; /** - * Cluster type + * Cluster type for service. */ protected String cluster; /** - * The {@code Filter} when the provider side exposed a service or the customer side references a remote service used, - * if there are more than one, you can use commas to separate them + * Filters for service exposure or reference (multiple filters can be separated by commas). */ protected String filter; /** - * The Listener when the provider side exposes a service or the customer side references a remote service used - * if there are more than one, you can use commas to separate them + * Listeners for service exposure or reference (multiple listeners can be separated by commas). */ protected String listener; /** - * The owner of the service providers + * Owner of the service providers. */ protected String owner; /** - * Connection limits, 0 means shared connection, otherwise it defines the connections delegated to the current service + * Connection limits: 0 for shared connection, otherwise specifying connections for the service. */ protected Integer connections; /** - * The layer of service providers + * Layer of service providers. */ protected String layer; /** - * The application info + * Application configuration for the service. */ protected ApplicationConfig application; /** - * The module info + * Module configuration for the service. */ protected ModuleConfig module; /** - * The registry list the service will register to - * Also see {@link #registryIds}, only one of them will work. + * Registries where the service will be registered (use this or registryIds, not both). */ protected List registries; /** - * The method configuration + * Method-specific configuration. */ private List methods; /** - * The id list of registries the service will register to - * Also see {@link #registries}, only one of them will work. + * Registry IDs for service registration (use this or registries, not both). */ protected String registryIds; - // connection events + /** + * Event handler for connection establishment. + */ protected String onconnect; /** - * Disconnection events + * Event handler for disconnection. */ protected String ondisconnect; /** - * The metadata report configuration + * Metadata report configuration. */ protected MetadataReportConfig metadataReportConfig; + /** + * Configuration center settings. + */ protected ConfigCenterConfig configCenter; - // callback limits + /** + * Callback limits for the service. + */ private Integer callbacks; - // the scope for referring/exporting a service, if it's local, it means searching in current JVM only. + + /** + * Service scope ("local" implies searching in the current JVM only). + */ private String scope; + /** + * Custom tag for the service configuration. + */ protected String tag; + /** + * Enable service authentication. + */ private Boolean auth; - /*Indicates to create separate instances or not for services/references that have the same serviceKey. - * By default, all services/references that have the same serviceKey will share the same instance and process. - * - * This key currently can only work when using ReferenceConfig and SimpleReferenceCache together. - * Call ReferenceConfig.get() directly will not check this attribute. + /** + * Use separate instances for services with the same serviceKey (applies when using ReferenceConfig and SimpleReferenceCache together). + * Directly calling ReferenceConfig.get() will not check this attribute. */ private Boolean singleton; @@ -733,7 +746,6 @@ public void setRegistryIds(String registryIds) { this.registryIds = registryIds; } - public List getMethods() { return methods; } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java index f0367c6c5df3..0e29d5a27bf0 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java @@ -28,7 +28,7 @@ import java.util.Optional; /** - * AbstractMethodConfig + * Abstract configuration for the method. * * @export */ @@ -37,73 +37,67 @@ public abstract class AbstractMethodConfig extends AbstractConfig { private static final long serialVersionUID = 5809761483000878437L; /** - * The timeout for remote invocation in milliseconds + * Timeout for remote invocation in milliseconds. */ protected Integer timeout; /** - * The retry times + * Retry times for failed invocations. */ protected Integer retries; /** - * max concurrent invocations + * Maximum concurrent invocations allowed. */ protected Integer actives; /** - * The load balance + * Load balancing strategy for service invocation. */ protected String loadbalance; /** - * Whether to async - * note that: it is an unreliable asynchronous that ignores return values and does not block threads. + * Enable asynchronous invocation. Note that it is unreliable asynchronous, ignoring return values and not blocking threads. */ protected Boolean async; /** - * Whether to ack async-sent + * Acknowledge asynchronous-sent invocations. */ protected Boolean sent; /** - * The name of mock class which gets called when a service fails to execute - *

- * note that: the mock doesn't support on the provider side,and the mock is executed when a non-business exception - * occurs after a remote service call + * Mock class name to be called when a service fails to execute. The mock doesn't support on the provider side, + * and it is executed when a non-business exception occurs after a remote service call. */ protected String mock; /** - * Merger + * Merger for result data. */ protected String merger; /** - * Cache the return result with the call parameter as key, the following options are available: lru, threadlocal, - * jcache, etc. + * Cache provider for caching return results. available options: lru, threadlocal, jcache etc. */ protected String cache; /** - * Whether JSR303 standard annotation validation is enabled or not, if enabled, annotations on method parameters will - * be validated + * Enable JSR303 standard annotation validation for method parameters. */ protected String validation; /** - * The customized parameters + * Customized parameters for configuration. */ protected Map parameters; /** - * Forks for forking cluster + * Forks for forking cluster. */ protected Integer forks; public AbstractMethodConfig() { - } public AbstractMethodConfig(ModuleModel moduleModel) { diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractServiceConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractServiceConfig.java index 6b5545c62f6f..00345114836f 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractServiceConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractServiceConfig.java @@ -33,7 +33,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.SERVICE_FILTER_KEY; /** - * AbstractServiceConfig + * Abstract configuration for the service. * * @export */ @@ -42,100 +42,98 @@ public abstract class AbstractServiceConfig extends AbstractInterfaceConfig { private static final long serialVersionUID = -9026290350363878309L; /** - * The service version + * The service version. */ protected String version; /** - * The service group + * The service group. */ protected String group; /** - * whether the service is deprecated + * Whether the service is deprecated. */ - protected Boolean deprecated; // false; + protected Boolean deprecated; /** - * The time delay register service (milliseconds) + * The time delay to register the service (in milliseconds). */ protected Integer delay; /** - * Whether to export the service + * Whether to export the service. */ protected Boolean export; /** - * The service weight + * The service weight. */ protected Integer weight; /** - * Document center + * Document center for the service. */ protected String document; /** - * Whether to register as a dynamic service or not on register center, the value is true, the status will be enabled - * after the service registered,and it needs to be disabled manually; if you want to disable the service, you also need - * manual processing + * Whether to register the service as a dynamic service on the registry. If true, the service + * will be enabled automatically after registration, and manual disabling is required to stop it. */ - protected Boolean dynamic; // true; + protected Boolean dynamic; /** - * Whether to use token + * Whether to use a token for authentication. */ protected String token; /** - * Whether to export access logs to logs + * Whether to export access logs to logs. */ protected String accesslog; /** - * The protocol list the service will export with - * Also see {@link #protocolIds}, only one of them will work. + * List of protocols the service will export with (use this or protocolIds, not both). */ protected List protocols; /** - * The id list of protocols the service will export with - * Also see {@link #protocols}, only one of them will work. + * Id list of protocols the service will export with (use this or protocols, not both). */ protected String protocolIds; /** - * Max allowed executing times + * Max allowed executing times. */ private Integer executes; /** - * Whether to register + * Whether to register the service. */ private Boolean register; /** - * Warm up period + * Warm-up period for the service. */ private Integer warmup; /** - * The serialization type + * Serialization type for service communication. */ private String serialization; /** - * If the parameter has a value, the consumer will read the parameter first. + * Specifies the preferred serialization method for the consumer. + * If specified, the consumer will use this parameter first. * If the Dubbo Sdk you are using contains the serialization type, the serialization method specified by the argument is used. *

* When this parameter is null or the serialization type specified by this parameter does not exist in the Dubbo SDK, the serialization type specified by serialization is used. * If the Dubbo SDK if still does not exist, the default type of the Dubbo SDK is used. * For Dubbo SDK >= 3.2, preferSerialization takes precedence over serialization *

- * The configuration supports multiple, which are separated by commas.Such as:fastjson2,fastjson,hessian2 + * Supports multiple values separated by commas, e.g., "fastjson2,fastjson,hessian2". */ - private String preferSerialization; // default:fastjson2,hessian2 + private String preferSerialization; // Default: fastjson2, hessian2 /** * Weather the service is export asynchronously diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ApplicationConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ApplicationConfig.java index f1243755cb47..804cce327bf3 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/ApplicationConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ApplicationConfig.java @@ -74,186 +74,223 @@ import static org.apache.dubbo.config.Constants.TEST_ENVIRONMENT; /** - * The application info + * Configuration for the dubbo application. * * @export */ public class ApplicationConfig extends AbstractConfig { - private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(ApplicationConfig.class); private static final long serialVersionUID = 5508512956753757169L; + private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(ApplicationConfig.class); + /** - * Application name + * The Application name. */ private String name; /** - * The application version + * The application version. */ private String version; /** - * Application owner + * The application owner. */ private String owner; /** - * Application's organization (BU) + * The application's organization (BU). */ private String organization; /** - * Architecture layer + * Architecture layer. */ private String architecture; /** - * Environment, e.g. dev, test or production + * Environment, e.g., dev, test, or production. */ private String environment; /** - * Java compiler + * Java compiler. */ private String compiler; /** - * The type of the log access + * The type of log access. */ private String logger; /** - * Registry centers + * Registry centers. */ private List registries; + + /** + * The comma-separated list of registry IDs to which the service will be registered. + */ private String registryIds; /** - * Monitor center + * Monitor center. */ private MonitorConfig monitor; /** - * Directory for saving thread dump + * Directory for saving thread dump. */ private String dumpDirectory; /** - * Whether to enable saving thread dump or not + * Whether to enable saving thread dump or not. */ private Boolean dumpEnable; /** - * Whether to enable qos or not + * Whether to enable Quality of Service (QoS) or not. */ private Boolean qosEnable; /** - * Whether qos should start success or not, will check qosEnable first + * Whether QoS should start successfully or not, will check qosEnable first. */ private Boolean qosCheck; /** - * The qos host to listen + * The QoS host to listen. */ private String qosHost; /** - * The qos port to listen + * The QoS port to listen. */ private Integer qosPort; /** - * Should we accept foreign ip or not? + * Should we accept foreign IP or not? */ private Boolean qosAcceptForeignIp; /** - * When we disable accept foreign ip, support specify foreign ip in the whitelist + * When we disable accepting foreign IP, support specifying foreign IPs in the whitelist. */ private String qosAcceptForeignIpWhitelist; /** - * the anonymous(any foreign ip) access permission level, default is NONE, can not access any cmd + * The anonymous (any foreign IP) access permission level, default is NONE, which means no access to any command. */ private String qosAnonymousAccessPermissionLevel; /** - * the anonymous(any foreign ip) allow commands, default is empty, can not access any cmd + * The anonymous (any foreign IP) allowed commands, default is empty, which means no access to any command. */ private String qosAnonymousAllowCommands; /** - * Customized parameters + * Customized parameters. */ private Map parameters; /** - * Config the shutdown.wait + * Config the shutdown wait. */ private String shutwait; + /** + * Hostname. + */ private String hostname; /** - * Metadata type, local or remote, if choose remote, you need to further specify metadata center. + * Metadata type, local or remote. If 'remote' is chosen, you need to specify a metadata center further. */ private String metadataType; /** - * Used to control whether register instance to registry or not. Set to 'false' only when instance is pure consumer. + * Used to control whether to register the instance with the registry or not. Set to 'false' only when the instance is a pure consumer. */ private Boolean registerConsumer; + /** + * Repository. + */ private String repository; + /** + * Whether to enable file caching. + */ private Boolean enableFileCache; /** - * The preferred protocol(name) of this application - * convenient for places where it's hard to determine which is the preferred protocol + * The preferred protocol (name) of this application, convenient for places where it's hard to determine the preferred protocol. */ private String protocol; /** - * The protocol used for peer-to-peer metadata transmission + * The protocol used for peer-to-peer metadata transmission. */ private String metadataServiceProtocol; /** - * Metadata Service, used in Service Discovery + * Metadata Service, used in Service Discovery. */ private Integer metadataServicePort; /** - * The retry interval of service name mapping + * The retry interval of service name mapping. */ private Integer mappingRetryInterval; /** - * used to set extensions of probe in qos + * Used to set extensions of the probe in QoS. */ private String livenessProbe; + /** + * The probe for checking the readiness of the application. + */ private String readinessProbe; + /** + * The probe for checking the startup of the application. + */ private String startupProbe; + /** + * Register mode. + */ private String registerMode; + /** + * Whether to enable protection against empty objects. + */ private Boolean enableEmptyProtection; + /** + * The status of class serialization checking. + */ private String serializeCheckStatus; + /** + * Whether to automatically trust serialized classes. + */ private Boolean autoTrustSerializeClass; + /** + * The trust level for serialized classes. + */ private Integer trustSerializeClassLevel; + /** + * Whether to check serializable. + */ private Boolean checkSerializable; /** - * thread pool management: default/isolation + * Thread pool management mode: 'default' or 'isolation'. */ private String executorManagementMode; @@ -361,7 +398,7 @@ public RegistryConfig getRegistry() { } public void setRegistry(RegistryConfig registry) { - List registries = new ArrayList(1); + List registries = new ArrayList<>(1); registries.add(registry); this.registries = registries; } @@ -517,7 +554,6 @@ public void setQosAnonymousAllowCommands(String qosAnonymousAllowCommands) { /** * The format is the same as the springboot, including: getQosEnableCompatible(), getQosPortCompatible(), getQosAcceptForeignIpCompatible(). * - * @return */ @Parameter(key = QOS_ENABLE_COMPATIBLE, excluded = true, attribute = false) public Boolean getQosEnableCompatible() { @@ -688,7 +724,6 @@ public void setMetadataServiceProtocol(String metadataServiceProtocol) { this.metadataServiceProtocol = metadataServiceProtocol; } - @Parameter(key = LIVENESS_PROBE_KEY) public String getLivenessProbe() { return livenessProbe; @@ -716,7 +751,6 @@ public void setStartupProbe(String startupProbe) { this.startupProbe = startupProbe; } - public String getSerializeCheckStatus() { return serializeCheckStatus; } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java index 494c8b515d9c..eca4322be586 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java @@ -39,77 +39,99 @@ import static org.apache.dubbo.config.Constants.ZOOKEEPER_PROTOCOL; /** - * ConfigCenterConfig + * Configuration for the config center. */ public class ConfigCenterConfig extends AbstractConfig { + private final AtomicBoolean initialized = new AtomicBoolean(false); + /** + * The protocol used for accessing the config center. + */ private String protocol; + + /** + * The address (URL or hostname) of the config center server. + */ private String address; + + /** + * The port number for the config center server. + */ private Integer port; /** - * The config center cluster, it's real meaning may very on different Config Center products. + * The config center cluster, its actual meaning may vary depending on the specific config center product. */ private String cluster; /** - * The namespace of the config center, generally it's used for multi-tenant, - * but it's real meaning depends on the actual Config Center you use. - * The default value is CommonConstants.DUBBO + * The namespace of the config center, generally used for multi-tenancy. + * Its actual meaning depends on the specific config center you use. Default value is CommonConstants.DUBBO. */ private String namespace; /** - * The group of the config center, generally it's used to identify an isolated space for a batch of config items, - * but it's real meaning depends on the actual Config Center you use. - * The default value is CommonConstants.DUBBO + * The group of the config center, often used to identify an isolated space for a batch of config items. + * Its actual meaning depends on the specific config center you use. Default value is CommonConstants.DUBBO. */ private String group; + + /** + * Username for authentication with the config center. + */ private String username; + + /** + * Password for authentication with the config center. + */ private String password; /** - * The default value is 30000L; + * The timeout for accessing the config center. Default value is 30000L. */ private Long timeout; /** - * If the Config Center is given the highest priority, it will override all the other configurations - * The default value is true - * @deprecated no longer used + * If the config center should have the highest priority and override all other configurations. + * Deprecated and no longer used. Default value is true. */ private Boolean highestPriority; /** - * Decide the behaviour when initial connection try fails, 'true' means interrupt the whole process once fail. - * The default value is true + * Behavior when the initial connection attempt to the config center fails. + * 'true' means interrupt the whole process once a failure occurs. Default value is true. */ private Boolean check; /** - * Used to specify the key that your properties file mapping to, most of the time you do not need to change this parameter. - * Notice that for Apollo, this parameter is meaningless, set the 'namespace' is enough. - * The default value is CommonConstants.DEFAULT_DUBBO_PROPERTIES + * Key mapping for properties files. Most of the time, you do not need to change this parameter. + * Default value is CommonConstants.DEFAULT_DUBBO_PROPERTIES. */ private String configFile; /** - * the properties file under 'configFile' is global shared while .properties under this one is limited only to this application + * The properties file under 'configFile' is global shared, while '.properties' under this one is limited only to this application. */ private String appConfigFile; /** - * If the Config Center product you use have some special parameters that is not covered by this class, you can add it to here. + * Additional parameters specific to your config center product can be added here. * For example, with XML: - * - * - * + * + * + * */ private Map parameters; + /** + * External configuration for the config center. + */ private Map externalConfiguration; + /** + * Application-specific external configuration for the config center. + */ private Map appExternalConfiguration; public ConfigCenterConfig() { diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java index ac0506554ec8..0e7d5052724a 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java @@ -39,7 +39,7 @@ import static org.apache.dubbo.common.utils.StringUtils.isEmpty; /** - * MetadataReportConfig + * Configuration for the metadata report. * * @export */ @@ -47,80 +47,95 @@ public class MetadataReportConfig extends AbstractConfig { private static final long serialVersionUID = 55233L; + /** + * The protocol for the metadata center. + */ private String protocol; /** - * metadata center address + * The address of the metadata center. */ private String address; /** - * Default port for metadata center + * The default port for the metadata center. */ private Integer port; /** - * Username to login metadata center + * The username used to log in to the metadata center. */ private String username; /** - * Password to login metadata center + * The password used to log in to the metadata center. */ private String password; /** - * Request timeout in milliseconds for metadata center + * The request timeout in milliseconds for the metadata center. */ private Integer timeout; /** - * The group the metadata in . It is the same as registry + * The group for the metadata center, which is similar to the registry group. */ private String group; /** - * Customized parameters + * Customized parameters for the metadata center. */ private Map parameters; + /** + * The number of retry times when connecting to the metadata center. + */ private Integer retryTimes; + /** + * The retry period in milliseconds when connecting to the metadata center. + */ private Integer retryPeriod; + /** - * By default, the metadata store will store full metadata repeatedly every day . + * By default, the metadata store will store full metadata repeatedly every day. */ private Boolean cycleReport; /** - * Sync report, default async + * Synchronization report, with the default value as asynchronous. */ private Boolean syncReport; /** - * cluster + * Whether to use a cluster configuration for the metadata center. */ private Boolean cluster; /** - * registry id + * The registry ID for the metadata center. */ private String registry; /** - * File for saving metadata center dynamic list + * The file path for saving the metadata center's dynamic list. */ private String file; /** - * Decide the behaviour when initial connection try fails, - * 'true' means interrupt the whole process once fail. - * The default value is true + * Decide the behavior when the initial connection attempt fails, where 'true' means interrupt the whole process once it fails. + * The default value is true. */ private Boolean check; + /** + * Whether to report metadata. + */ private Boolean reportMetadata; + /** + * Whether to report definition. + */ private Boolean reportDefinition; public MetadataReportConfig() { diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/MetricsConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/MetricsConfig.java index 02380edb112b..7bf36399b131 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/MetricsConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/MetricsConfig.java @@ -28,98 +28,111 @@ import java.util.Map; /** - * MetricsConfig + * Configuration for the metrics. */ public class MetricsConfig extends AbstractConfig { private static final long serialVersionUID = -9089919311611546383L; + /** + * Protocol used for metrics. + */ private String protocol; /** - * Enable jvm metrics when collecting. + * Whether to enable JVM metrics collection. */ private Boolean enableJvm; /** - * Enable threadpool metrics when collecting. + * Whether to enable thread pool metrics collection. */ private Boolean enableThreadpool; /** - * Enable registry metrics. + * Whether to enable registry metrics collection. */ private Boolean enableRegistry; /** - * Enable metadata metrics. + * Whether to enable metadata metrics collection. */ private Boolean enableMetadata; /** - * Export metrics service. + * Whether to export metrics service. */ private Boolean exportMetricsService; /** - * Enable netty metrics. + * Whether to enable Netty metrics collection. */ private Boolean enableNetty; /** - * Enable metrics init. + * Whether to enable metrics initialization. */ private Boolean enableMetricsInit; /** - * Enable collector sync. + * Whether to enable collector synchronization. */ private Boolean enableCollectorSync; /** - * Collector sync period. + * Collector synchronization period. */ private Integer collectorSyncPeriod; /** - * @deprecated After metrics config is refactored. - * This parameter should no longer use and will be deleted in the future. + * Deprecated: This parameter should no longer be used and will be removed in the future. */ @Deprecated private String port; /** - * The prometheus metrics config + * Configuration for Prometheus metrics collection. */ @Nested private PrometheusConfig prometheus; /** - * The metrics aggregation config + * Configuration for metrics aggregation. */ @Nested private AggregationConfig aggregation; + /** + * Configuration for metrics histogram. + */ @Nested private HistogramConfig histogram; + /** + * Protocol used for metrics collection and export. + */ private String exportServiceProtocol; + /** + * Port used for exporting metrics services. + */ private Integer exportServicePort; /** - * Decide whether to use the global registry of the micrometer. + * Decide whether to use the global registry of Micrometer. */ private Boolean useGlobalRegistry; + /** + * Whether to enable RPC (Remote Procedure Call) metrics collection. + */ private Boolean enableRpc; /** - * The level of the metrics, the value can be "SERVICE", "METHOD", default is method. + * The level of metrics collection, which can be "SERVICE" or "METHOD". The default is "METHOD". */ private String rpcLevel; - public MetricsConfig() { } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ModuleConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ModuleConfig.java index 859d6678e46f..c88a52bce3c9 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/ModuleConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ModuleConfig.java @@ -27,7 +27,7 @@ import java.util.List; /** - * The module info + * Configuration for the module. * * @export */ @@ -36,22 +36,22 @@ public class ModuleConfig extends AbstractConfig { private static final long serialVersionUID = 5508512956753757169L; /** - * Module name + * The module name */ private String name; /** - * Module version + * The module version */ private String version; /** - * Module owner + * The module owner */ private String owner; /** - * Module's organization + * The module's organization */ private String organization; @@ -66,35 +66,35 @@ public class ModuleConfig extends AbstractConfig { private MonitorConfig monitor; /** - * Whether start module in background. - * If start in background, do not await finish on Spring ContextRefreshedEvent. + * Whether to start the module in the background. + * If started in the background, it does not await finish on Spring ContextRefreshedEvent. * * @see org.apache.dubbo.config.spring.context.DubboDeployApplicationListener */ private Boolean background; /** - * Weather the reference is referred asynchronously + * Whether the reference is referred asynchronously. */ private Boolean referAsync; /** - * Thread num for asynchronous refer pool size + * The thread number for asynchronous reference pool size. */ private Integer referThreadNum; /** - * Weather the service is export asynchronously + * Whether the service is exported asynchronously. */ private Boolean exportAsync; /** - * Thread num for asynchronous export pool size + * The thread number for asynchronous export pool size. */ private Integer exportThreadNum; /** - * The timeout to check references + * The timeout to check references. */ private Long checkReferenceTimeout; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/MonitorConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/MonitorConfig.java index b3755878f8be..bebfc716c1b9 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/MonitorConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/MonitorConfig.java @@ -24,7 +24,7 @@ import java.util.Map; /** - * MonitorConfig + * Configuration for the monitor. * * @export */ @@ -33,8 +33,8 @@ public class MonitorConfig extends AbstractConfig { private static final long serialVersionUID = -1184681514659198203L; /** - * The protocol of the monitor, if the value is registry, it will search the monitor address from the registry center, - * otherwise, it will directly connect to the monitor center + * The protocol of the monitor. If the value is "registry" it will search the monitor address from the registry center. + * Otherwise, it will directly connect to the monitor center. */ private String protocol; @@ -49,18 +49,27 @@ public class MonitorConfig extends AbstractConfig { private String username; /** - * The password + * The monitor password */ private String password; + /** + * The monitor group + */ private String group; + /** + * The monitor version + */ private String version; + /** + * The monitor reporting interval + */ private String interval; /** - * customized parameters + * Customized parameters */ private Map parameters; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java index 20220945ae15..d88d5e3ed93c 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java @@ -33,7 +33,7 @@ import static org.apache.dubbo.common.constants.ProviderConstants.DEFAULT_PREFER_SERIALIZATION; /** - * ProtocolConfig + * Configuration for the protocol. * * @export */ @@ -42,194 +42,198 @@ public class ProtocolConfig extends AbstractConfig { private static final long serialVersionUID = 6913423882496634749L; /** - * Protocol name + * The name of the protocol. */ private String name; /** - * Service ip address (when there are multiple network cards available) + * The service's IP address (useful when there are multiple network cards available). */ private String host; /** - * Service port + * The service's port number. */ private Integer port; /** - * Context path + * The context path for the service. */ private String contextpath; /** - * Thread pool + * The name of the thread pool. */ private String threadpool; /** - * Thread pool name - */ - private String threadname; - - /** - * Thread pool core thread size + * The core thread size of the thread pool. */ private Integer corethreads; /** - * Thread pool size (fixed size) + * The fixed size of the thread pool. */ private Integer threads; /** - * IO thread pool size (fixed size) + * The fixed size of the IO thread pool. */ private Integer iothreads; /** - * Thread pool keepAliveTime, default unit TimeUnit.MILLISECONDS + * The keep-alive time for threads in the thread pool (default unit is TimeUnit.MILLISECONDS). */ private Integer alive; /** - * Thread pool's queue length + * The length of the thread pool's queue. */ private Integer queues; - /** - * Thread pool exhausted listeners + * Listeners for exhausted thread pool. */ private String threadPoolExhaustedListeners; /** - * Max acceptable connections + * The maximum acceptable connections. */ private Integer accepts; /** - * Protocol codec + * The protocol codec. */ private String codec; /** - * Serialization + * The serialization method. */ private String serialization; /** - * If the parameter has a value, the consumer will read the parameter first. + * Specifies the preferred serialization method for the consumer. + * If specified, the consumer will use this parameter first. * If the Dubbo Sdk you are using contains the serialization type, the serialization method specified by the argument is used. *

* When this parameter is null or the serialization type specified by this parameter does not exist in the Dubbo SDK, the serialization type specified by serialization is used. * If the Dubbo SDK if still does not exist, the default type of the Dubbo SDK is used. * For Dubbo SDK >= 3.2, preferSerialization takes precedence over serialization *

- * The configuration supports multiple, which are separated by commas.Such as:fastjson2,fastjson,hessian2 + * Supports multiple values separated by commas, e.g., "fastjson2,fastjson,hessian2". */ private String preferSerialization; // default:fastjson2,hessian2 /** - * Charset + * The character set used for communication. */ private String charset; /** - * Payload max length + * The maximum payload length. */ private Integer payload; /** - * Buffer size + * The buffer size. */ private Integer buffer; /** - * Heartbeat interval + * The interval for sending heartbeats. */ private Integer heartbeat; /** - * Access log + * The access log configuration. */ private String accesslog; /** - * Transporter + * The transporter used for communication. */ private String transporter; /** - * How information is exchanged + * The method of information exchange. */ private String exchanger; /** - * Thread dispatch mode + * The thread dispatch mode. */ private String dispatcher; /** - * Networker + * The networker implementation. */ private String networker; /** - * Sever impl + * The server implementation. */ private String server; /** - * Client impl + * The client implementation. */ private String client; /** - * Supported telnet commands, separated with comma. + * Supported Telnet commands, separated by commas. */ private String telnet; /** - * Command line prompt + * The command line prompt. */ private String prompt; /** - * Status check + * The status check configuration. */ private String status; /** - * Whether to register + * Indicates whether the service should be registered. */ private Boolean register; + // TODO: Move this property to the provider configuration. /** - * whether it is a persistent connection + * Indicates whether it is a persistent connection. */ - //TODO add this to provider config private Boolean keepAlive; - // TODO add this to provider config + // TODO: Move this property to the provider configuration. + /** + * The optimizer used for dubbo protocol. + */ private String optimizer; /** - * The extension + * Additional extensions. */ private String extension; /** - * The customized parameters + * Custom parameters. */ private Map parameters; + /** + * Indicates whether SSL is enabled. + */ private Boolean sslEnabled; - /* - * Extra Protocol for this service, using Port Unification Server + /** + * Extra protocol for this service, using Port Unification Server. */ private String extProtocol; + /** + * JSON check level for serialization. + */ private String jsonCheckLevel; public ProtocolConfig() { @@ -326,14 +330,6 @@ public void setThreadpool(String threadpool) { this.threadpool = threadpool; } - public String getThreadname() { - return threadname; - } - - public void setThreadname(String threadname) { - this.threadname = threadname; - } - @Parameter(key = JSON_CHECK_LEVEL_KEY) public String getJsonCheckLevel() { return jsonCheckLevel; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ProviderConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ProviderConfig.java index 497e78b78c9c..1cbf3a5d014e 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/ProviderConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ProviderConfig.java @@ -26,7 +26,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.EXPORT_THREAD_NUM_KEY; /** - * The service provider default configuration + * Configuration for the service provider. * * @export * @see org.apache.dubbo.config.ProtocolConfig @@ -36,137 +36,137 @@ public class ProviderConfig extends AbstractServiceConfig { private static final long serialVersionUID = 6913423882496634749L; - // ======== protocol default values, it'll take effect when protocol's attributes are not set ======== + /* ======== Default values for protocols, which take effect when protocol attributes are not set ======== */ /** - * Service ip addresses (used when there are multiple network cards available) + * The IP addresses of the service (used when there are multiple network cards available). */ private String host; /** - * Service port + * The port of the service. */ private Integer port; /** - * Context path + * The context path of the service. */ private String contextpath; /** - * Thread pool + * The thread pool configuration. */ private String threadpool; /** - * Thread pool name + * The name of the thread pool. */ private String threadname; /** - * Thread pool size (fixed size) + * The size of the thread pool (fixed size). */ private Integer threads; /** - * IO thread pool size (fixed size) + * The size of the I/O thread pool (fixed size). */ private Integer iothreads; /** - * Thread pool keepAliveTime, default unit TimeUnit.MILLISECONDS + * The keep-alive time of the thread pool, default unit: TimeUnit.MILLISECONDS. */ private Integer alive; /** - * Thread pool queue length + * The length of the thread pool queue. */ private Integer queues; /** - * Max acceptable connections + * The maximum number of acceptable connections. */ private Integer accepts; /** - * Protocol codec + * The codec used by the protocol. */ private String codec; /** - * The serialization charset + * The charset used for serialization. */ private String charset; /** - * Payload max length + * The maximum payload length. */ private Integer payload; /** - * The network io buffer size + * The size of the network I/O buffer. */ private Integer buffer; /** - * Transporter + * The transporter used by the protocol. */ private String transporter; /** - * How information gets exchanged + * The method of information exchange. */ private String exchanger; /** - * Thread dispatching mode + * The mode of thread dispatching. */ private String dispatcher; /** - * Networker + * The networker used by the protocol. */ private String networker; /** - * The server-side implementation model of the protocol + * The server-side implementation model of the protocol. */ private String server; /** - * The client-side implementation model of the protocol + * The client-side implementation model of the protocol. */ private String client; /** - * Supported telnet commands, separated with comma. + * Supported telnet commands, separated by commas. */ private String telnet; /** - * Command line prompt + * The command line prompt. */ private String prompt; /** - * Status check + * The status check configuration. */ private String status; /** - * Wait time when stop + * The wait time when stopping the service. */ private Integer wait; /** - * Thread num for asynchronous export pool size + * The number of threads for the asynchronous export pool. */ private Integer exportThreadNum; /** - * Whether export should run in background or not. + * Whether the export should run in the background or not. * - * @deprecated replace with {@link ModuleConfig#setBackground(Boolean)} + * @deprecated Replace with {@link ModuleConfig#setBackground(Boolean)} * @see ModuleConfig#setBackground(Boolean) */ private Boolean exportBackground; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java index e2115e5cde69..bce814f80a36 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java @@ -44,7 +44,7 @@ import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION; /** - * ReferenceConfig + * Base configuration for the service reference. * * @export */ @@ -55,24 +55,23 @@ public abstract class ReferenceConfigBase extends AbstractReferenceConfig { private static final String ORIGIN_CONFIG = "ORIGIN_CONFIG"; /** - * The interface class of the reference service + * The interface class of the reference service. */ protected Class interfaceClass; - /** - * The url for peer-to-peer invocation + * The URL for peer-to-peer invocation. */ protected String url; /** - * The consumer config (default) + * The default consumer configuration. */ protected ConsumerConfig consumer; /** - * In the mesh mode, uninstall the directory, router and load balance related to the cluster in the currently invoked invoker. - * Delegate retry, load balancing, timeout and other traffic management capabilities to Sidecar. + * In mesh mode, this flag uninstalls the directory, router, and load balancing configurations related to the cluster in the currently invoked invoker. + * It delegates retry, load balancing, timeout, and other traffic management capabilities to Sidecar. */ protected Boolean unloadClusterRelated; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/RegistryConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/RegistryConfig.java index 91bc4b826eba..69886f1bd02f 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/RegistryConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/RegistryConfig.java @@ -33,7 +33,7 @@ import static org.apache.dubbo.common.utils.PojoUtils.updatePropertyIfAbsent; /** - * RegistryConfig + * Configuration for service registration and discovery. * * @export */ @@ -43,147 +43,166 @@ public class RegistryConfig extends AbstractConfig { private static final long serialVersionUID = 5508512956753757169L; /** - * Register center address + * Register center address. */ private String address; /** - * Username to login register center + * Username to login the register center. */ private String username; /** - * Password to login register center + * Password to login the register center. */ private String password; /** - * Default port for register center + * Default port for the register center. */ private Integer port; /** - * Protocol for register center + * Protocol used for the register center. */ private String protocol; /** - * Network transmission type + * Network transmission type. */ private String transporter; + /** + * Server implementation. + */ private String server; + /** + * Client implementation. + */ private String client; /** - * Affects how traffic distributes among registries, useful when subscribing multiple registries, available options: - * 1. zone-aware, a certain type of traffic always goes to one Registry according to where the traffic is originated. + * Affects how traffic distributes among registries, useful when subscribing to multiple registries. + * Available options: + * - "zone-aware": A certain type of traffic always goes to one Registry according to where the traffic is originated. */ private String cluster; /** - * The region where the registry belongs, usually used to isolate traffics + * The region where the registry belongs, usually used to isolate traffics. */ private String zone; /** - * The group that services registry in + * The group that services registry belongs to. */ private String group; + /** + * Version of the registry. + */ private String version; /** - * Connect timeout in milliseconds for register center + * Connect timeout in milliseconds for the register center. */ private Integer timeout; /** - * Session timeout in milliseconds for register center + * Session timeout in milliseconds for the register center. */ private Integer session; /** - * File for saving register center dynamic list + * File for saving the register center dynamic list. */ private String file; /** - * Wait time before stop + * Wait time before stopping. */ private Integer wait; /** - * Whether to check if register center is available when boot up + * Whether to check if the register center is available when booting up. */ private Boolean check; /** - * Whether to allow dynamic service to register on the register center + * Whether to allow dynamic service registration on the register center. */ private Boolean dynamic; /** - * Whether to allow exporting service on the register center + * Whether to allow exporting service on the register center. */ private Boolean register; /** - * Whether to allow subscribing service on the register center + * Whether to allow subscribing to services on the register center. */ private Boolean subscribe; /** - * The customized parameters + * Customized parameters. */ private Map parameters; /** - * Simple the registry. both useful for provider and consumer + * Simplify the registry, useful for both providers and consumers. * * @since 2.7.0 */ private Boolean simplified; + /** - * After simplify the registry, should add some parameter individually. just for provider. - *

- * such as: extra-keys = A,b,c,d + * After simplifying the registry, add some parameters individually, useful for providers. + * Example: extra-keys = "A, b, c, d". * * @since 2.7.0 */ private String extraKeys; /** - * the address work as config center or not + * Indicates whether the address works as a configuration center or not. */ private Boolean useAsConfigCenter; /** - * the address work as remote metadata center or not + * Indicates whether the address works as a remote metadata center or not. */ private Boolean useAsMetadataCenter; /** - * list of rpc protocols accepted by this registry, for example, "dubbo,rest" + * List of RPC protocols accepted by this registry, e.g., "dubbo,rest". */ private String accepts; /** - * Always use this registry first if set to true, useful when subscribe to multiple registries + * Always use this registry first if set to true, useful when subscribing to multiple registries. */ private Boolean preferred; /** - * Affects traffic distribution among registries, useful when subscribe to multiple registries - * Take effect only when no preferred registry is specified. + * Affects traffic distribution among registries, useful when subscribing to multiple registries. + * Takes effect only when no preferred registry is specified. */ private Integer weight; + /** + * Register mode. + */ private String registerMode; + /** + * Enable empty protection. + */ private Boolean enableEmptyProtection; + /** + * Security settings. + */ private String secure; public String getSecure() { diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java index 93279cf6571c..228944dde61c 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java @@ -43,7 +43,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.DUBBO; /** - * ServiceConfig + * Base configuration for service. * * @export */ @@ -51,38 +51,37 @@ public abstract class ServiceConfigBase extends AbstractServiceConfig { private static final long serialVersionUID = 3033787999037024738L; - /** - * The interface class of the exported service + * The interface class of the exported service. */ protected Class interfaceClass; /** - * The reference of the interface implementation + * The reference to the interface implementation. */ protected transient T ref; /** - * The service name + * The service name, which is used to uniquely identify the service. */ protected String path; /** - * The provider configuration + * The provider configuration for this service. */ protected ProviderConfig provider; /** - * The providerIds + * A comma-separated list of provider IDs. */ protected String providerIds; /** - * whether it is a GenericService + * Indicates whether the service is a GenericService. + * If set, this means that the service is a generic service that can handle multiple types. */ protected volatile String generic; - public ServiceConfigBase() { serviceMetadata = new ServiceMetadata(); serviceMetadata.addAttribute("ORIGIN_CONFIG", this); @@ -285,7 +284,6 @@ public void setInterfaceClass(Class interfaceClass) { setInterface(interfaceClass); } - public void setInterface(Class interfaceClass) { // rest protocol allow set impl class if (interfaceClass != null && !interfaceClass.isInterface() && !canSkipInterfaceCheck()) { diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/SslConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/SslConfig.java index 5bf5a57b0370..44a1cfe1dd05 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/SslConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/SslConfig.java @@ -16,8 +16,6 @@ */ package org.apache.dubbo.config; -import org.apache.dubbo.common.logger.Logger; -import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.IOUtils; import org.apache.dubbo.config.support.Parameter; import org.apache.dubbo.rpc.model.ApplicationModel; @@ -28,8 +26,6 @@ public class SslConfig extends AbstractConfig { - private static final Logger logger = LoggerFactory.getLogger(SslConfig.class); - public static final String SERVER_KEY_CERT_CHAIN_PATH = "server-key-cert-chain-path"; public static final String SERVER_PRIVATE_KEY_PATH = "server-private-key-path"; @@ -46,27 +42,94 @@ public class SslConfig extends AbstractConfig { public static final String CLIENT_TRUST_CERT_COLLECTION_PATH = "client-trust-cert-collection-path"; + /** + * Path to the server's key certificate chain file. + */ private String serverKeyCertChainPath; + + /** + * Path to the server's private key file. + */ private String serverPrivateKeyPath; + + /** + * Password for the server's private key (if applicable). + */ private String serverKeyPassword; + + /** + * Path to the server's trust certificate collection file. + */ private String serverTrustCertCollectionPath; + /** + * Path to the client's key certificate chain file. + */ private String clientKeyCertChainPath; + + /** + * Path to the client's private key file. + */ private String clientPrivateKeyPath; + + /** + * Password for the client's private key (if applicable). + */ private String clientKeyPassword; + + /** + * Path to the client's trust certificate collection file. + */ private String clientTrustCertCollectionPath; + /** + * Input stream for the server's key certificate chain (if provided). + */ private InputStream serverKeyCertChainPathStream; + + /** + * Input stream for the server's private key (if provided). + */ private InputStream serverPrivateKeyPathStream; + + /** + * Input stream for the server's trust certificate collection (if provided). + */ private InputStream serverTrustCertCollectionPathStream; + /** + * Input stream for the client's key certificate chain (if provided). + */ private InputStream clientKeyCertChainPathStream; + + /** + * Input stream for the client's private key (if provided). + */ private InputStream clientPrivateKeyPathStream; + + /** + * Input stream for the client's trust certificate collection (if provided). + */ private InputStream clientTrustCertCollectionPathStream; + /** + * Address for Certificate Authority (CA). + */ private String caAddress; + + /** + * Environment type for SSL configuration. + */ private String envType; + + /** + * Path to the CA certificate file. + */ private String caCertPath; + + /** + * Path to the OIDC (OpenID Connect) token file. + */ private String oidcTokenPath; public SslConfig() { diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/TracingConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/TracingConfig.java index 3a7e4e3b9178..ab3093b30760 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/TracingConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/TracingConfig.java @@ -31,28 +31,31 @@ public class TracingConfig extends AbstractConfig { private static final long serialVersionUID = -9089919311611546383L; + /** + * Indicates whether the feature is enabled (default is false). + */ private Boolean enabled = false; /** - * Sampling configuration. + * Configuration for sampling. */ @Nested private SamplingConfig sampling = new SamplingConfig(); /** - * Baggage configuration. + * Configuration for baggage. */ @Nested private BaggageConfig baggage = new BaggageConfig(); /** - * Propagation configuration. + * Configuration for propagation. */ @Nested private PropagationConfig propagation = new PropagationConfig(); /** - * Exporter configuration. + * Configuration for the tracing exporter. */ @Nested private ExporterConfig tracingExporter = new ExporterConfig(); diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/DubboService.java b/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/DubboService.java index d2d3cb69f001..a945909edfd4 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/DubboService.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/DubboService.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.config.annotation; - import org.apache.dubbo.common.constants.ClusterRules; import org.apache.dubbo.common.constants.LoadbalanceRules; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/ProvidedBy.java b/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/ProvidedBy.java index b8c0013bdadb..7c8e88f5931d 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/ProvidedBy.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/ProvidedBy.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.config.annotation; - import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/Service.java b/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/Service.java index e712e4ab2d7e..aba87ddc367e 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/Service.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/annotation/Service.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.config.annotation; - import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/context/AbstractConfigManager.java b/dubbo-common/src/main/java/org/apache/dubbo/config/context/AbstractConfigManager.java index 0f8a0e23d4bf..7ddbb732537e 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/context/AbstractConfigManager.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/context/AbstractConfigManager.java @@ -100,7 +100,6 @@ public abstract class AbstractConfigManager extends LifecycleAdapter { uniqueConfigTypes.add(ModuleConfig.class); } - public AbstractConfigManager(ScopeModel scopeModel, Collection> supportedConfigTypes) { this.scopeModel = scopeModel; this.applicationModel = ScopeModelUtil.getApplicationModel(scopeModel); @@ -567,7 +566,6 @@ private Set getConfigIdsFromProps(Class clazz) return ConfigurationUtils.getSubIds(environment.getConfigurationMaps(), prefix); } - protected void checkDefaultAndValidateConfigs(Class configType) { try { if (shouldAddDefaultConfig(configType)) { @@ -644,12 +642,10 @@ private boolean shouldAddDefaultConfig(Class clazz return this.getDefaultConfigs(clazz).isEmpty(); } - public void refreshAll() { } - /** * In some scenario, we may need to add and remove ServiceConfig or ReferenceConfig dynamically. * diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigManager.java b/dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigManager.java index e737e8971e8d..d8b0e58b20b9 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigManager.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigManager.java @@ -57,14 +57,12 @@ public class ConfigManager extends AbstractConfigManager implements ApplicationE public static final String BEAN_NAME = "dubboConfigManager"; public static final String DUBBO_CONFIG_MODE = ConfigKeys.DUBBO_CONFIG_MODE; - public ConfigManager(ApplicationModel applicationModel) { super(applicationModel, Arrays.asList(ApplicationConfig.class, MonitorConfig.class, MetricsConfig.class, SslConfig.class, ProtocolConfig.class, RegistryConfig.class, ConfigCenterConfig.class, MetadataReportConfig.class, TracingConfig.class)); } - // ApplicationConfig correlative methods /** @@ -201,7 +199,6 @@ public Collection getProtocols() { return getConfigs(getTagName(ProtocolConfig.class)); } - // RegistryConfig correlative methods public void addRegistry(RegistryConfig registryConfig) { @@ -226,7 +223,6 @@ public Collection getRegistries() { return getConfigs(getTagName(RegistryConfig.class)); } - @Override public void refreshAll() { // refresh all configs here diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/context/ModuleConfigManager.java b/dubbo-common/src/main/java/org/apache/dubbo/config/context/ModuleConfigManager.java index 0527fdaf1833..6bdb2b4d096b 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/context/ModuleConfigManager.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/context/ModuleConfigManager.java @@ -62,7 +62,6 @@ public class ModuleConfigManager extends AbstractConfigManager implements Module private final Map serviceConfigCache = new ConcurrentHashMap<>(); private final ConfigManager applicationConfigManager; - public ModuleConfigManager(ModuleModel moduleModel) { super(moduleModel, Arrays.asList(ModuleConfig.class, ServiceConfigBase.class, ReferenceConfigBase.class, ProviderConfig.class, ConsumerConfig.class)); applicationConfigManager = moduleModel.getApplicationModel().getApplicationConfigManager(); @@ -188,7 +187,6 @@ public void clear() { this.serviceConfigCache.clear(); } - @Override protected Optional findDuplicatedConfig(Map configsMap, C config) { // check duplicated configs @@ -295,7 +293,6 @@ public void loadConfigs() { checkDefaultAndValidateConfigs(ModuleConfig.class); } - // // Delegate read application configs // diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/AggregationConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/AggregationConfig.java index 1927d879168c..553d83435485 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/AggregationConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/AggregationConfig.java @@ -18,33 +18,48 @@ import java.io.Serializable; +/** + * Configuration for the metric aggregation. + */ public class AggregationConfig implements Serializable { /** - * Enable local aggregation or not + * Enable aggregation or not. */ private Boolean enabled; + /** + * Enable QPS (Queries Per Second) aggregation or not. + */ private Boolean enableQps; + /** + * Enable Response Time Percentile (Pxx) aggregation or not. + */ private Boolean enableRtPxx; + /** + * Enable Response Time aggregation or not. + */ private Boolean enableRt; + /** + * Enable Request aggregation or not. + */ private Boolean enableRequest; /** - * Bucket num for time window quantile + * The number of buckets for time window quantile. */ private Integer bucketNum; /** - * Time window seconds for time window quantile + * The time window in seconds for time window quantile. */ private Integer timeWindowSeconds; /** - * Time window mill seconds for qps + * The time window in milliseconds for QPS (Queries Per Second) aggregation. */ private Integer qpsTimeWindowMillSeconds; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/BaggageConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/BaggageConfig.java index b39f0ece30d0..cd6e1b9ccce5 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/BaggageConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/BaggageConfig.java @@ -22,8 +22,14 @@ import java.util.ArrayList; import java.util.List; +/** + * Configuration for the baggage. + */ public class BaggageConfig implements Serializable { + /** + * Whether baggage is enabled or not. + */ private Boolean enabled = true; /** diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/ExporterConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/ExporterConfig.java index 871a5afbab2b..7ad3aa5eb423 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/ExporterConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/ExporterConfig.java @@ -24,11 +24,20 @@ import java.util.HashMap; import java.util.Map; +/** + * Configuration for the exporter. + */ public class ExporterConfig implements Serializable { + /** + * Configuration for the Zipkin. + */ @Nested private ZipkinConfig zipkinConfig; + /** + * Configuration for the OTLP. + */ @Nested private OtlpConfig otlpConfig; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/HistogramConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/HistogramConfig.java index 53ef9ac9e450..a92ec109102a 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/HistogramConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/HistogramConfig.java @@ -19,20 +19,44 @@ import java.io.Serializable; +/** + * Configuration for the histogram. + */ public class HistogramConfig implements Serializable { + /** + * Whether histograms are enabled or not. Default is not enabled (false). + */ private Boolean enabled; + /** + * Buckets in milliseconds for the histograms. Defines the histogram bucket boundaries. + */ private Integer[] bucketsMs; + /** + * Minimum expected value in milliseconds for the histograms. Values lower than this will be considered outliers. + */ private Integer minExpectedMs; + /** + * Maximum expected value in milliseconds for the histograms. Values higher than this will be considered outliers. + */ private Integer maxExpectedMs; + /** + * Whether enabledPercentiles are enabled or not. Default is not enabled (false). + */ private Boolean enabledPercentiles; + /** + * Array of percentiles to be calculated for the histograms. Each percentile is a double value. + */ private double[] percentiles; + /** + * Expiry time in minutes for distribution statistics. After this time, the statistics are expired. + */ private Integer distributionStatisticExpiryMin; public Boolean getEnabled() { diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/PrometheusConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/PrometheusConfig.java index a35f779cce2c..a9b8ded5339f 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/PrometheusConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/PrometheusConfig.java @@ -20,6 +20,9 @@ import java.io.Serializable; +/** + * Configuration for the prometheus. + */ public class PrometheusConfig implements Serializable { /** @@ -29,7 +32,7 @@ public class PrometheusConfig implements Serializable { private Exporter exporter; /** - * Prometheus Pushgateway configuration + * Prometheus push gateway configuration */ @Nested private Pushgateway pushgateway; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/PropagationConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/PropagationConfig.java index c574bd0e6d5c..8d7dc391a4ff 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/PropagationConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/PropagationConfig.java @@ -18,6 +18,9 @@ import java.io.Serializable; +/** + * Configuration for the propagation. + */ public class PropagationConfig implements Serializable { public static final String B3 = "B3"; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/SamplingConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/SamplingConfig.java index 0e98a98b5f53..e4f5ea024f4b 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/nested/SamplingConfig.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/nested/SamplingConfig.java @@ -18,6 +18,9 @@ import java.io.Serializable; +/** + * Configuration for the sampling. + */ public class SamplingConfig implements Serializable { /** diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/support/Nested.java b/dubbo-common/src/main/java/org/apache/dubbo/config/support/Nested.java index 1cab41afc546..454e798c4cfe 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/config/support/Nested.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/config/support/Nested.java @@ -29,5 +29,4 @@ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) public @interface Nested { - } diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java index 343f8d0ac1c7..9d8280d312e1 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java @@ -66,7 +66,6 @@ import java.util.TreeSet; import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE; -import static org.apache.dubbo.common.constants.CommonConstants.CLUSTER_DOMAIN; import static org.apache.dubbo.common.constants.CommonConstants.CLUSTER_KEY; import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SEPARATOR; import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SEPARATOR_CHAR; @@ -78,7 +77,6 @@ import static org.apache.dubbo.common.constants.CommonConstants.MESH_ENABLE; import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY; import static org.apache.dubbo.common.constants.CommonConstants.MONITOR_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.POD_NAMESPACE; import static org.apache.dubbo.common.constants.CommonConstants.PROXY_CLASS_REF; import static org.apache.dubbo.common.constants.CommonConstants.REVISION_KEY; import static org.apache.dubbo.common.constants.CommonConstants.SEMICOLON_SPLIT_PATTERN; @@ -506,21 +504,21 @@ private void meshModeHandleUrl(Map referenceParameters) { // get pod namespace from env if annotation not present the provider namespace if (StringUtils.isEmpty(podNamespace)) { - if (StringUtils.isEmpty(System.getenv(POD_NAMESPACE))) { + if (StringUtils.isEmpty(System.getenv("POD_NAMESPACE"))) { if (logger.isWarnEnabled()) { logger.warn(CONFIG_FAILED_LOAD_ENV_VARIABLE, "", "", "Can not get env variable: POD_NAMESPACE, it may not be running in the K8S environment , " + "finally use 'default' replace."); } podNamespace = "default"; } else { - podNamespace = System.getenv(POD_NAMESPACE); + podNamespace = System.getenv("POD_NAMESPACE"); } } // In mesh mode, providedBy equals K8S Service name. String providedBy = referenceParameters.get(PROVIDED_BY); // cluster_domain default is 'cluster.local',generally unchanged. - String clusterDomain = Optional.ofNullable(System.getenv(CLUSTER_DOMAIN)).orElse(DEFAULT_CLUSTER_DOMAIN); + String clusterDomain = Optional.ofNullable(System.getenv("CLUSTER_DOMAIN")).orElse(DEFAULT_CLUSTER_DOMAIN); // By VirtualService and DestinationRule, envoy will generate a new route rule,such as 'demo.default.svc.cluster.local:80',the default port is 80. Integer meshPort = Optional.ofNullable(getProviderPort()).orElse(DEFAULT_MESH_PORT); // DubboReference default is -1, process it. diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/pom.xml b/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/pom.xml index 685b2516e95d..98c6f80fc3ae 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/pom.xml +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/pom.xml @@ -30,7 +30,6 @@ Apache Dubbo Spring Boot Compatible for Spring Boot 1.x Auto-Configure - org.springframework.boot @@ -50,13 +49,6 @@ true - - - org.springframework.boot - spring-boot-configuration-processor - true - - org.apache.dubbo dubbo-common @@ -77,12 +69,33 @@ ${project.version} + + org.apache.dubbo + dubbo-spring-boot-configuration-metadata-compatible + ${project.version} + provided + + org.springframework.boot spring-boot-starter-test test - + + + + + src/main/resources + + + META-INF + ../metadata/target/classes/META-INF + + spring-configuration-metadata.json + + + + diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfiguration.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfiguration.java index b4628c2a26c5..18e76e07ffde 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfiguration.java +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfiguration.java @@ -26,7 +26,6 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 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; @@ -50,7 +49,6 @@ @ConditionalOnProperty(prefix = DUBBO_PREFIX, name = "enabled", matchIfMissing = true) @Configuration @AutoConfigureAfter(DubboRelaxedBindingAutoConfiguration.class) -@EnableConfigurationProperties(DubboConfigurationProperties.class) @EnableDubboConfig public class DubboAutoConfiguration { @@ -63,8 +61,7 @@ public class DubboAutoConfiguration { @ConditionalOnProperty(prefix = DUBBO_SCAN_PREFIX, name = BASE_PACKAGES_PROPERTY_NAME) @ConditionalOnBean(name = BASE_PACKAGES_BEAN_NAME) @Bean - public ServiceAnnotationPostProcessor serviceAnnotationBeanProcessor(@Qualifier(BASE_PACKAGES_BEAN_NAME) - Set packagesToScan) { + public ServiceAnnotationPostProcessor serviceAnnotationBeanProcessor(@Qualifier(BASE_PACKAGES_BEAN_NAME) Set packagesToScan) { ServiceAnnotationPostProcessor serviceAnnotationPostProcessor; try { serviceAnnotationPostProcessor = (ServiceAnnotationPostProcessor) SpringCompatUtils.serviceAnnotationPostProcessor().getDeclaredConstructor(Collection.class).newInstance(packagesToScan); diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboConfigurationProperties.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboConfigurationProperties.java index ff8fdda5a852..fdad8c32867b 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboConfigurationProperties.java +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboConfigurationProperties.java @@ -17,6 +17,7 @@ package org.apache.dubbo.spring.boot.autoconfigure; import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.ConfigCenterConfig; import org.apache.dubbo.config.ConfigKeys; import org.apache.dubbo.config.ConsumerConfig; import org.apache.dubbo.config.MetadataReportConfig; @@ -26,110 +27,147 @@ import org.apache.dubbo.config.ProtocolConfig; import org.apache.dubbo.config.ProviderConfig; import org.apache.dubbo.config.RegistryConfig; +import org.apache.dubbo.config.SslConfig; import org.apache.dubbo.config.TracingConfig; -import org.apache.dubbo.config.context.ConfigMode; -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.DEFAULT_OVERRIDE_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) + * Dubbo {@link ConfigurationProperties Config Properties} only used to generate JSON metadata (non-public class) * * @see ConfigKeys * @since 2.7.1 */ -@ConfigurationProperties(DUBBO_PREFIX) +@ConfigurationProperties("dubbo") public class DubboConfigurationProperties { - @NestedConfigurationProperty - private Config config = new Config(); - - @NestedConfigurationProperty - private Scan scan = new Scan(); - - // Single Config Bindings + /** + * Configuration properties for the application. + */ @NestedConfigurationProperty private ApplicationConfig application = new ApplicationConfig(); + /** + * Configuration properties for the module. + */ @NestedConfigurationProperty private ModuleConfig module = new ModuleConfig(); + /** + * Configuration properties for the registry. + */ @NestedConfigurationProperty private RegistryConfig registry = new RegistryConfig(); + /** + * Configuration properties for the protocol. + */ @NestedConfigurationProperty private ProtocolConfig protocol = new ProtocolConfig(); + /** + * Configuration properties for the monitor. + */ @NestedConfigurationProperty private MonitorConfig monitor = new MonitorConfig(); + /** + * Configuration properties for the provider. + */ @NestedConfigurationProperty private ProviderConfig provider = new ProviderConfig(); + /** + * Configuration properties for the consumer. + */ @NestedConfigurationProperty private ConsumerConfig consumer = new ConsumerConfig(); + /** + * Configuration properties for the config center. + */ @NestedConfigurationProperty - private ConfigCenterBean configCenter = new ConfigCenterBean(); + private ConfigCenterConfig configCenter = new ConfigCenterConfig(); + /** + * Configuration properties for the metadata report. + */ @NestedConfigurationProperty private MetadataReportConfig metadataReport = new MetadataReportConfig(); + /** + * Configuration properties for metrics. + */ @NestedConfigurationProperty private MetricsConfig metrics = new MetricsConfig(); + /** + * Configuration properties for tracing. + */ @NestedConfigurationProperty private TracingConfig tracing = new TracingConfig(); + /** + * Configuration properties for ssl. + */ + @NestedConfigurationProperty + private SslConfig ssl = new SslConfig(); + // Multiple Config Bindings + /** + * Multiple configurations for Module. + */ private Map modules = new LinkedHashMap<>(); + /** + * Multiple configurations for Registry. + */ private Map registries = new LinkedHashMap<>(); + /** + * Multiple configurations for Protocol. + */ private Map protocols = new LinkedHashMap<>(); + /** + * Multiple configurations for Monitor. + */ private Map monitors = new LinkedHashMap<>(); + /** + * Multiple configurations for Provider. + */ private Map providers = new LinkedHashMap<>(); + /** + * Multiple configurations for Consumer. + */ private Map consumers = new LinkedHashMap<>(); - private Map configCenters = new LinkedHashMap<>(); + /** + * Multiple configurations for ConfigCenterBean. + */ + private Map configCenters = new LinkedHashMap<>(); + /** + * Multiple configurations for MetadataReportConfig. + */ private Map metadataReports = new LinkedHashMap<>(); + /** + * Multiple configurations for MetricsConfig. + */ private Map metricses = new LinkedHashMap<>(); + /** + * Multiple configurations for TracingConfig. + */ private Map tracings = 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; } @@ -186,11 +224,11 @@ public void setConsumer(ConsumerConfig consumer) { this.consumer = consumer; } - public ConfigCenterBean getConfigCenter() { + public ConfigCenterConfig getConfigCenter() { return configCenter; } - public void setConfigCenter(ConfigCenterBean configCenter) { + public void setConfigCenter(ConfigCenterConfig configCenter) { this.configCenter = configCenter; } @@ -218,6 +256,14 @@ public void setTracing(TracingConfig tracing) { this.tracing = tracing; } + public SslConfig getSsl() { + return ssl; + } + + public void setSsl(SslConfig ssl) { + this.ssl = ssl; + } + public Map getModules() { return modules; } @@ -266,11 +312,11 @@ public void setConsumers(Map consumers) { this.consumers = consumers; } - public Map getConfigCenters() { + public Map getConfigCenters() { return configCenters; } - public void setConfigCenters(Map configCenters) { + public void setConfigCenters(Map configCenters) { this.configCenters = configCenters; } @@ -297,65 +343,4 @@ public Map getTracings() { public void setTracings(Map tracings) { this.tracings = tracings; } - - static class Config { - - /** - * Config processing mode - * @see ConfigMode - */ - private ConfigMode mode = ConfigMode.STRICT; - - /** - * Indicates multiple properties binding from externalized configuration or not. - */ - private boolean multiple = DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE; - - /** - * The property name of override Dubbo config - */ - private boolean override = DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE; - - public boolean isOverride() { - return override; - } - - public void setOverride(boolean override) { - this.override = override; - } - - public boolean isMultiple() { - return multiple; - } - - public void setMultiple(boolean multiple) { - this.multiple = multiple; - } - - public ConfigMode getMode() { - return mode; - } - - public void setMode(ConfigMode mode) { - this.mode = mode; - } - } - - static class Scan { - - /** - * The basePackages to scan , the multiple-value is delimited by comma - * - * @see EnableDubbo#scanBasePackages() - */ - private Set basePackages = new LinkedHashSet<>(); - - public Set getBasePackages() { - return basePackages; - } - - public void setBasePackages(Set basePackages) { - this.basePackages = basePackages; - } - } } diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/README.md b/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/README.md new file mode 100644 index 000000000000..d2119d0d8c1c --- /dev/null +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/README.md @@ -0,0 +1,27 @@ +# About dubbo-spring-boot-configuration-metadata-compatible module + +## Why + +Configuration beans of dubbo are located in the `dubbo-common` module, and it's not suitable to add spring boot dependencies. +However, spring configuration metadata generation relies on read javadoc from the source code and cannot use the @NestedConfigurationProperty annotation. +This leads to missing comments and a lack of nested configuration options. Therefore, we use an independent module to copy the code and generate metadata. + +## Principles + +1. Copy classes under `org/apache/dubbo/config` from `dubbo-common` to the `generated-sources` directory. +2. Replace `@Nest` with `@NestedConfigurationProperty`. +3. Copy the class `DubboConfigurationProperties.java` from `autoconfigure` to the `generated-sources` directory. +4. Use an annotation-only option to compile and generate `spring-configuration-metadata.json`. +5. During `autoconfigure` module compilation, will read `spring-configuration-metadata.json` from this module. + +## How to add a new configuration option + +- For standard configuration options, add javadoc to the corresponding configuration classes in `dubbo-common`. +- For non-standard configuration options, there are unnecessary to add nested classes. add them directly to `additional-spring-configuration-metadata.json`. + +## Configuration Javadoc Guideline + +1. For noun-type configuration options, use "The xxx" format for comments. +2. For boolean-type configuration options, use "Whether to xxx" format and add ", default value is <code>true</code>" at the end. +3. For configuration options with longer comments, use multi-line comments, with a clear summary in the first line. +4. All comments should end with a period. diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/pom.xml b/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/pom.xml new file mode 100644 index 000000000000..12191efbda00 --- /dev/null +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/pom.xml @@ -0,0 +1,185 @@ + + + + + org.apache.dubbo + dubbo-spring-boot-compatible + ${revision} + ../pom.xml + + 4.0.0 + + dubbo-spring-boot-configuration-metadata-compatible + + + true + + + + + org.slf4j + slf4j-api + true + + + log4j + log4j + true + + + org.apache.logging.log4j + log4j-api + true + + + org.apache.logging.log4j + log4j-core + true + + + org.springframework.boot + spring-boot-autoconfigure + true + + + org.apache.dubbo + dubbo-common + ${project.version} + true + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + get-version-infos + none + + + copy-sources + generate-sources + + run + + + + + + + + + + + + + + + + + + + + + + + clean-sources + compile + + run + + + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/generated-sources/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + only + + + + maven-surefire-plugin + + true + + + + maven-javadoc-plugin + + true + + + + maven-jar-plugin + + + default-jar + none + + + + + maven-install-plugin + + true + + + + maven-source-plugin + + true + + + + + diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboMetadataGenerateAutoConfiguration.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboMetadataGenerateAutoConfiguration.java new file mode 100644 index 000000000000..2b4f208a00fd --- /dev/null +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboMetadataGenerateAutoConfiguration.java @@ -0,0 +1,25 @@ +/* + * 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.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableConfigurationProperties(DubboConfigurationProperties.class) +public class DubboMetadataGenerateAutoConfiguration { +} diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 000000000000..f095b721e47b --- /dev/null +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/metadata/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,44 @@ +{ + "properties": [ + { + "name": "dubbo.enabled", + "description": "Whether enable autoconfiguration of dubbo, default value is true.", + "type": "java.util.Set" + }, + { + "name": "dubbo.labels", + "description": "The labels for these service providers, enabling categorization and grouping, thereby enhancing their management and monitoring, the multiple-value is delimited by ';'.", + "type": "java.lang.String" + }, + { + "name": "dubbo.env.keys", + "description": "The keys for specify environment-specific keys, allowing for differentiation and utilization of various runtime environments (e.g., development, testing, production), the multiple-value is delimited by comma.", + "type": "java.lang.String" + }, + { + "name": "dubbo.config.override", + "description": " Whether to allow configuration override in Dubbo, default value is true.", + "type": "java.lang.Boolean" + }, + { + "name": "dubbo.config.multiple", + "description": "Whether to enable multiple configurations in Dubbo, allowing multiple configurations to be loaded and used, default value is true.", + "type": "java.lang.Boolean" + }, + { + "name": "dubbo.config.mode", + "description": "Config processing mode. See org.apache.dubbo.config.context.ConfigMode.", + "type": "org.apache.dubbo.config.context.ConfigMode" + }, + { + "name": "dubbo.config-center.include-spring-env", + "description": "Whether to include Spring Environment.", + "type": "java.lang.Boolean" + }, + { + "name": "dubbo.scan.base-packages", + "description": "The basePackages to scan, the multiple-value is delimited by comma @see EnableDubbo#scanBasePackages().", + "type": "java.util.Set" + } + ] +} diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/pom.xml b/dubbo-spring-boot/dubbo-spring-boot-compatible/pom.xml index 1526635a7f73..926e7b27b030 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/pom.xml +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/pom.xml @@ -37,6 +37,7 @@ autoconfigure actuator + metadata