diff --git a/CHANGES.md b/CHANGES.md index 78711ebbb4..e49e66636c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,86 @@ # Release Notes +## 2.7.1 + +### Notice + +'zkclient' extension for 'org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter' is removed from Dubbo 2.7.1, and 'curator' extension becomes the default extension. If you happen to config your application to use 'zkclient' explicitly, pls. switch to use 'curator' instead. + +### New Features + +- service register support on nacos [#3582](https://github.com/apache/incubator-dubbo/issues/3582) +- support consul as registry center, config center and metadata center [#983](https://github.com/apache/incubator-dubbo/issues/983) +- service registry support/config center support on etcd [#808](https://github.com/apache/incubator-dubbo/issues/808) +- metrics support in dubbo 2.7.1 [#3598](https://github.com/apache/incubator-dubbo/issues/3598) +- @Argument @Method support [#2405](https://github.com/apache/incubator-dubbo/issues/2045) + +### Enhancement + +- [Enhancement] @EnableDubboConfigBinding annotates @Repeatable [#1770](https://github.com/apache/incubator-dubbo/issues/1770) +- [Enhancement] Change the default behavior of @EnableDubboConfig.multiple() [#3193](https://github.com/apache/incubator-dubbo/issues/3193) +- Should make annotation easier to use in multiple items circumstance [#3039](https://github.com/apache/incubator-dubbo/issues/3039) +- NoSuchMethodError are thrown when add custom Filter using dubbo2.6.5 and JDK1.6 and upgrade to dubbo2.7.0 [#3570](https://github.com/apache/incubator-dubbo/issues/3570) +- introduce dubbo-dependencies-zookeeper [#3607](https://github.com/apache/incubator-dubbo/pull/3607) +- Zookeeper ConfigCenter reuse the client abstraction and connection session [#3288](https://github.com/apache/incubator-dubbo/issues/3288) +- [Survey] Is it necessary to continue to maintain zkclient in dubbo project? [#3569](https://github.com/apache/incubator-dubbo/issues/3569) +- Start to use IdleStateHandler in Netty4 [#3341](https://github.com/apache/incubator-dubbo/pull/3341) +- Support multiple shared links [#2457](https://github.com/apache/incubator-dubbo/pull/2457) +- Optimize heartbeat [#3299](https://github.com/apache/incubator-dubbo/pull/3299) +- AccessLogFilter simple date format reduce instance creation [#3026](https://github.com/apache/incubator-dubbo/issues/3026) +- Support wildcard ip for tag router rule. [#3289](https://github.com/apache/incubator-dubbo/issues/3289) +- ScriptRouter should cache CompiledScript [#390](https://github.com/apache/incubator-dubbo/issues/390) +- Optimize compareTo in Router to guarantee consistent behaviour. [#3302](https://github.com/apache/incubator-dubbo/issues/3302) +- RMI protocol doesn't support generic invocation [#2779](https://github.com/apache/incubator-dubbo/issues/2779) +- a more elegant way to enhance HashedWheelTimer [#3567](https://github.com/apache/incubator-dubbo/pull/3567) +- obtain local address incorrectly sometimes in dubbo [#538](https://github.com/apache/incubator-dubbo/issues/538) +- implement pull request #3412 on master branch [#3418](https://github.com/apache/incubator-dubbo/pull/3418) +- enhancement for event of response (follow up for pull request #3043) [#3244](https://github.com/apache/incubator-dubbo/issues/3244) +- bump up hessian-lite version #3423 [#3513](https://github.com/apache/incubator-dubbo/pull/3513) +- [Dubbo-3610]make snakeyaml transitive, should we do this? [#3659](https://github.com/apache/incubator-dubbo/pull/3659) + +### Bugfixes + +- cannot register REST service in 2.7 due to the changes in RestProtoco#getContextPath [#3445](https://github.com/apache/incubator-dubbo/issues/3445) +- Conflict between curator client and dubbo [#3574](https://github.com/apache/incubator-dubbo/issues/3574) +- is there a problem in NettyBackedChannelBuffer.setBytes(...)? [#2619](https://github.com/apache/incubator-dubbo/issues/2619) +- [Dubbo - client always reconnect offline provider] Dubbo client bug [#3158](https://github.com/apache/incubator-dubbo/issues/3158) +- fix heartbeat internal [#3579](https://github.com/apache/incubator-dubbo/pull/3579) +- logic issue in RedisRegistry leads to services cannot be discovered. [#3291](https://github.com/apache/incubator-dubbo/pull/3291) +- Multicast demo fails with message "Can't assign requested address" [#2423](https://github.com/apache/incubator-dubbo/issues/2423) +- Fix thrift protocol, use path to locate exporter. [#3331](https://github.com/apache/incubator-dubbo/pull/3331) +- cannot use override to modify provider's configuration when hessian protocol is used [#900](https://github.com/apache/incubator-dubbo/issues/900) +- Condition is not properly used ? [#1917](https://github.com/apache/incubator-dubbo/issues/1917) +- connectionMonitor in RestProtocol seems not work [#3237](https://github.com/apache/incubator-dubbo/issues/3237) +- fail to parse config text with white space [#3367](https://github.com/apache/incubator-dubbo/issues/3367) +- @Reference check=false doesn't take effect [#195](https://github.com/apache/incubator-dubbo/issues/195) +- [Issue] SpringStatusChecker execute errors on non-XML Spring configuration [#3615](https://github.com/apache/incubator-dubbo/issues/3615) +- monitor's cluster config is set to failsafe and set to failsafe only [#274](https://github.com/apache/incubator-dubbo/issues/274) +- A question for ReferenceConfigCache. [#1293](https://github.com/apache/incubator-dubbo/issues/1293) +- referenceconfig#destroy never invoke unregister [#3294](https://github.com/apache/incubator-dubbo/issues/3294) +- Fix when qos is disable,log will print every time [#3397](https://github.com/apache/incubator-dubbo/pull/3397) +- service group is not supported in generic direct invocation [#3555](https://github.com/apache/incubator-dubbo/issues/3555) +- setOnreturn doesn't take effect in async generic invocation [#208](https://github.com/apache/incubator-dubbo/issues/208) +- Fix timeout filter not work in async way [#3174](https://github.com/apache/incubator-dubbo/pull/3174) +- java.lang.NumberFormatException: For input string: "" [#3069](https://github.com/apache/incubator-dubbo/issues/3069) +- NPE occurred when the configuration was deleted [#3533](https://github.com/apache/incubator-dubbo/issues/3533) +- NPE when package of interface is empty [#3556](https://github.com/apache/incubator-dubbo/issues/3556) +- NPE when exporting rest service using a given path. [#3477](https://github.com/apache/incubator-dubbo/issues/3477) +- NullPointerException happened when using SpringContainer.getContext() [#3476](https://github.com/apache/incubator-dubbo/issues/3476) +- Why does not tomcat throw an exception when `server.start` failed with a socket binding error. [#3236](https://github.com/apache/incubator-dubbo/issues/3236) +- No such extension org.apache.dubbo.metadata.store.MetadataReportFactory by name redis [#3514](https://github.com/apache/incubator-dubbo/issues/3514) +- dubbo 2.7.1-SNAPSHOT NoClassDefFoundError when use springboot [#3426](https://github.com/apache/incubator-dubbo/issues/3426) +- NPE occurs when use @Reference in junit in spring boot application [#3429](https://github.com/apache/incubator-dubbo/issues/3429) +- When refer the same service with more than one @References(with different configs) on consumer side, only one take effect [#1306](https://github.com/apache/incubator-dubbo/issues/1306) +- consumer always catch java.lang.reflect.UndeclaredThrowableException for the exception thrown from provider [#3386](https://github.com/apache/incubator-dubbo/issues/3386) +- dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated [#3342](https://github.com/apache/incubator-dubbo/issues/3342) +- Close Resources Properly [#3473](https://github.com/apache/incubator-dubbo/issues/3473) +- SPI entires dup by 3 times. [#2842](https://github.com/apache/incubator-dubbo/issues/2842) +- provider gets wrong interface name from attachment when use generic invocation in 2.6.3 [#2981](https://github.com/apache/incubator-dubbo/issues/2981) +- HashedWheelTimer's queue gets full [#3449](https://github.com/apache/incubator-dubbo/issues/3449) +- Modify MetadataReportRetry ThreadName [#3550](https://github.com/apache/incubator-dubbo/pull/3550) +- Keep interface key in the URL in simplify mode when it's different from path. [#3478](https://github.com/apache/incubator-dubbo/issues/3478) +- nc is not stable in dubbo's bootstrap script [#936](https://github.com/apache/incubator-dubbo/issues/936) + ## 2.7.0 Requirements: **Java 8+** required @@ -64,6 +145,32 @@ We have always keep compatibility in mind during the whole process of 2.7.0. We 5. Configuration +## 2.6.6 + +Enhancement / New feature: + +* tag route. #3065 +* Use Netty4 as default Netty version. #3029 +* upporting Java 8 Date/Time type when serializing with Kryo #3519 +* supoort config telnet #3511 +* add annotation driven in MethodConfig and ArgumentConfig #2603 +* add nacos-registry module #3296 +* add `protocol` attribute in `@Rerefence` #3555 +*support the hierarchical interface in @Service #3251 +* change the default behavior in `@EnableDubboConfig.multiple()` #3193 +* inline source code of `spring-context-support` #3192 +* Simplify externalized configuration of Dubbo Protocol name #3189 + +BugFix: + +* update hessian-lite to 2.3.5, fix unnecessary class load #3538 +* Fix unregister when client destroyed(referenceconfig#destroy) #3502 +* SPI entires dup by 3 times #3315 +* fix Consumer throws RpcException after RegistryDirectory notify in high QPS #2016 +* fix NPE in @Reference when using Junit to test dubbo service #3429 +* fix consuer always catch java.lang.reflect.UndeclaredThrowableException for any exception throws in provider #3386 +* fix the priority of `DubboConfigConfigurationSelector ` #2897 +* fix `@Rerefence#parameters()` not work #2301 ## 2.6.5 diff --git a/README.md b/README.md index 09c12ffa97..3f19e548a9 100644 --- a/README.md +++ b/README.md @@ -42,21 +42,9 @@ There's a [README](https://github.com/apache/incubator-dubbo-samples/tree/master ```xml - 2.7.0 + 2.7.1 - - - - org.apache.dubbo - dubbo-dependencies-bom - ${dubbo.version} - pom - import - - - - org.apache.dubbo @@ -64,20 +52,9 @@ There's a [README](https://github.com/apache/incubator-dubbo-samples/tree/master ${dubbo.version} - io.netty - netty-all - - - org.apache.curator - curator-framework - - - org.apache.curator - curator-recipes - - - org.apache.zookeeper - zookeeper + org.apache.dubbo + dubbo-dependencies-zookeeper + ${dubbo.version} ``` diff --git a/dubbo-all/pom.xml b/dubbo-all/pom.xml index a4a0b5cc3c..e0e6e11ccc 100644 --- a/dubbo-all/pom.xml +++ b/dubbo-all/pom.xml @@ -19,11 +19,11 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT ../pom.xml dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT jar dubbo-all The all in one project of dubbo diff --git a/dubbo-bom/pom.xml b/dubbo-bom/pom.xml index 47875b83ff..85fcbae576 100644 --- a/dubbo-bom/pom.xml +++ b/dubbo-bom/pom.xml @@ -6,12 +6,12 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT org.apache.dubbo dubbo-bom - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT pom dubbo-bom diff --git a/dubbo-cluster/pom.xml b/dubbo-cluster/pom.xml index 58d0367d87..7b8860a149 100644 --- a/dubbo-cluster/pom.xml +++ b/dubbo-cluster/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-cluster jar diff --git a/dubbo-common/pom.xml b/dubbo-common/pom.xml index bd3347f524..3477f9b859 100644 --- a/dubbo-common/pom.xml +++ b/dubbo-common/pom.xml @@ -20,7 +20,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-common jar diff --git a/dubbo-compatible/pom.xml b/dubbo-compatible/pom.xml index 43d14f9510..2fd3d2e6f2 100644 --- a/dubbo-compatible/pom.xml +++ b/dubbo-compatible/pom.xml @@ -20,7 +20,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-compatible jar diff --git a/dubbo-config/dubbo-config-api/pom.xml b/dubbo-config/dubbo-config-api/pom.xml index 19c7aca7bb..0ff700d657 100644 --- a/dubbo-config/dubbo-config-api/pom.xml +++ b/dubbo-config/dubbo-config-api/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-config - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-config-api jar diff --git a/dubbo-config/dubbo-config-spring/pom.xml b/dubbo-config/dubbo-config-spring/pom.xml index 988715baf4..dc51d4e979 100644 --- a/dubbo-config/dubbo-config-spring/pom.xml +++ b/dubbo-config/dubbo-config-spring/pom.xml @@ -1,132 +1,132 @@ - - - 4.0.0 - - org.apache.dubbo - dubbo-config - 2.7.1-SNAPSHOT - - dubbo-config-spring - jar - ${project.artifactId} - The spring config module of dubbo project - - false - - - - org.apache.dubbo - dubbo-config-api - ${project.parent.version} - - - org.springframework - spring-beans - - - org.springframework - spring-web - - - org.springframework - spring-context - - - javax.servlet - javax.servlet-api - provided - - - org.apache.dubbo - dubbo-registry-default - ${project.parent.version} - test - - - org.apache.dubbo - dubbo-monitor-default - ${project.parent.version} - test - - - org.apache.dubbo - dubbo-rpc-dubbo - ${project.parent.version} - test - - - org.apache.dubbo - dubbo-rpc-rmi - ${project.parent.version} - test - - - org.apache.dubbo - dubbo-rpc-injvm - ${project.parent.version} - - - org.apache.dubbo - dubbo-remoting-netty4 - ${project.parent.version} - test - - - org.apache.dubbo - dubbo-serialization-hessian2 - ${project.parent.version} - test - - - javax.validation - validation-api - test - - - org.hibernate - hibernate-validator - test - - - org.glassfish - javax.el - test - - - org.springframework - spring-tx - test - - - org.springframework - spring-test - test - - - junit - junit - 4.12 - test - - - org.apache.tomcat.embed - tomcat-embed-core - test - - - + + + 4.0.0 + + org.apache.dubbo + dubbo-config + 2.7.2-SNAPSHOT + + dubbo-config-spring + jar + ${project.artifactId} + The spring config module of dubbo project + + false + + + + org.apache.dubbo + dubbo-config-api + ${project.parent.version} + + + org.springframework + spring-beans + + + org.springframework + spring-web + + + org.springframework + spring-context + + + javax.servlet + javax.servlet-api + provided + + + org.apache.dubbo + dubbo-registry-default + ${project.parent.version} + test + + + org.apache.dubbo + dubbo-monitor-default + ${project.parent.version} + test + + + org.apache.dubbo + dubbo-rpc-dubbo + ${project.parent.version} + test + + + org.apache.dubbo + dubbo-rpc-rmi + ${project.parent.version} + test + + + org.apache.dubbo + dubbo-rpc-injvm + ${project.parent.version} + + + org.apache.dubbo + dubbo-remoting-netty4 + ${project.parent.version} + test + + + org.apache.dubbo + dubbo-serialization-hessian2 + ${project.parent.version} + test + + + javax.validation + validation-api + test + + + org.hibernate + hibernate-validator + test + + + org.glassfish + javax.el + test + + + org.springframework + spring-tx + test + + + org.springframework + spring-test + test + + + junit + junit + 4.12 + test + + + org.apache.tomcat.embed + tomcat-embed-core + test + + + diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationBeanNameBuilder.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationBeanNameBuilder.java new file mode 100644 index 0000000000..610058acd7 --- /dev/null +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationBeanNameBuilder.java @@ -0,0 +1,142 @@ +/* + * 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.config.spring.beans.factory.annotation; + +import org.apache.dubbo.common.Constants; +import org.apache.dubbo.config.annotation.Reference; +import org.apache.dubbo.config.annotation.Service; +import org.apache.dubbo.registry.Registry; + +import org.springframework.core.env.Environment; + +import static org.apache.dubbo.common.Constants.CONSUMERS_CATEGORY; +import static org.apache.dubbo.common.Constants.DEFAULT_PROTOCOL; +import static org.apache.dubbo.common.Constants.PROVIDERS_CATEGORY; +import static org.apache.dubbo.config.spring.util.AnnotationUtils.resolveInterfaceName; +import static org.springframework.util.StringUtils.arrayToCommaDelimitedString; +import static org.springframework.util.StringUtils.hasText; + +/** + * The Bean Name Builder for the annotations {@link Service} and {@link Reference} + *

+ * The naming rule is consistent with the the implementation {@link Registry} that is based on the service-name aware + * infrastructure, e.g Spring Cloud, Cloud Native and so on. + *

+ * The pattern of bean name : ${category}:${protocol}:${serviceInterface}:${version}:${group}. + *

+ * ${version} and ${group} are optional. + * + * @since 2.6.6 + */ +class AnnotationBeanNameBuilder { + + private static final String SEPARATOR = ":"; + + // Required properties + + private final String category; + + private final String protocol; + + private final String interfaceClassName; + + // Optional properties + + private String version; + + private String group; + + private Environment environment; + + private AnnotationBeanNameBuilder(String category, String protocol, String interfaceClassName) { + this.category = category; + this.protocol = protocol; + this.interfaceClassName = interfaceClassName; + } + + private AnnotationBeanNameBuilder(Service service, Class interfaceClass) { + this(PROVIDERS_CATEGORY, resolveProtocol(service.protocol()), resolveInterfaceName(service, interfaceClass)); + this.group(service.group()); + this.version(service.version()); + } + + private AnnotationBeanNameBuilder(Reference reference, Class interfaceClass) { + this(CONSUMERS_CATEGORY, resolveProtocol(reference.protocol()), resolveInterfaceName(reference, interfaceClass)); + this.group(reference.group()); + this.version(reference.version()); + } + + public static AnnotationBeanNameBuilder create(Service service, Class interfaceClass) { + return new AnnotationBeanNameBuilder(service, interfaceClass); + } + + public static AnnotationBeanNameBuilder create(Reference reference, Class interfaceClass) { + return new AnnotationBeanNameBuilder(reference, interfaceClass); + } + + private static void append(StringBuilder builder, String value) { + if (hasText(value)) { + builder.append(SEPARATOR).append(value); + } + } + + public AnnotationBeanNameBuilder group(String group) { + this.group = group; + return this; + } + + public AnnotationBeanNameBuilder version(String version) { + this.version = version; + return this; + } + + public AnnotationBeanNameBuilder environment(Environment environment) { + this.environment = environment; + return this; + } + + /** + * Resolve the protocol + * + * @param protocols one or more protocols + * @return if protocols == null, it will return + * {@link Constants#DEFAULT_PROTOCOL "dubbo"} as the default protocol + * @see Constants#DEFAULT_PROTOCOL + */ + private static String resolveProtocol(String... protocols) { + String protocol = arrayToCommaDelimitedString(protocols); + return hasText(protocol) ? protocol : DEFAULT_PROTOCOL; + } + + /** + * Build bean name while resolve the placeholders if possible. + * + * @return pattern : ${category}:${protocol}:${serviceInterface}:${version}:${group} + */ + public String build() { + // Append the required properties + StringBuilder beanNameBuilder = new StringBuilder(category); + append(beanNameBuilder, protocol); + append(beanNameBuilder, interfaceClassName); + // Append the optional properties + append(beanNameBuilder, version); + append(beanNameBuilder, group); + String beanName = beanNameBuilder.toString(); + // Resolve placeholders + return environment != null ? environment.resolvePlaceholders(beanName) : beanName; + } +} diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java index 96c4d3885b..4430c9fcd4 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java @@ -20,6 +20,7 @@ import org.apache.dubbo.common.utils.Assert; import org.apache.dubbo.config.AbstractConfig; import org.apache.dubbo.config.spring.context.annotation.DubboConfigBindingRegistrar; import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfigBinding; +import org.apache.dubbo.config.spring.context.config.DubboConfigBeanCustomizer; import org.apache.dubbo.config.spring.context.properties.DefaultDubboConfigBinder; import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; @@ -30,8 +31,16 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; +import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.env.Environment; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import static org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors; + /** * Dubbo Config Binding {@link BeanPostProcessor} * @@ -62,6 +71,8 @@ public class DubboConfigBindingBeanPostProcessor implements BeanPostProcessor, A private boolean ignoreInvalidFields = true; + private List configBeanCustomizers = Collections.emptyList(); + /** * @param prefix the prefix of Configuration Properties * @param beanName the binding Bean Name @@ -80,18 +91,34 @@ public class DubboConfigBindingBeanPostProcessor implements BeanPostProcessor, A AbstractConfig dubboConfig = (AbstractConfig) bean; - dubboConfigBinder.bind(prefix, dubboConfig); + bind(prefix, dubboConfig); + + customize(beanName, dubboConfig); - if (log.isInfoEnabled()) { - log.info("The properties of bean [name : " + beanName + "] have been binding by prefix of " + - "configuration properties : " + prefix); - } } return bean; } + private void bind(String prefix, AbstractConfig dubboConfig) { + + dubboConfigBinder.bind(prefix, dubboConfig); + + if (log.isInfoEnabled()) { + log.info("The properties of bean [name : " + beanName + "] have been binding by prefix of " + + "configuration properties : " + prefix); + } + } + + private void customize(String beanName, AbstractConfig dubboConfig) { + + for (DubboConfigBeanCustomizer customizer : configBeanCustomizers) { + customizer.customize(beanName, dubboConfig); + } + + } + public boolean isIgnoreUnknownFields() { return ignoreUnknownFields; } @@ -129,6 +156,14 @@ public class DubboConfigBindingBeanPostProcessor implements BeanPostProcessor, A @Override public void afterPropertiesSet() throws Exception { + initDubboConfigBinder(); + + initConfigBeanCustomizers(); + + } + + private void initDubboConfigBinder() { + if (dubboConfigBinder == null) { try { dubboConfigBinder = applicationContext.getBean(DubboConfigBinder.class); @@ -146,6 +181,16 @@ public class DubboConfigBindingBeanPostProcessor implements BeanPostProcessor, A } + private void initConfigBeanCustomizers() { + + Collection configBeanCustomizers = + beansOfTypeIncludingAncestors(applicationContext, DubboConfigBeanCustomizer.class).values(); + + this.configBeanCustomizers = new ArrayList(configBeanCustomizers); + + AnnotationAwareOrderComparator.sort(this.configBeanCustomizers); + } + /** * Create {@link DubboConfigBinder} instance. * @@ -158,4 +203,4 @@ public class DubboConfigBindingBeanPostProcessor implements BeanPostProcessor, A return defaultDubboConfigBinder; } -} +} \ No newline at end of file diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java index 82fb9b25eb..94bf9e800f 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java @@ -32,6 +32,7 @@ import org.springframework.context.event.ContextRefreshedEvent; import java.lang.reflect.Field; import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Collection; @@ -155,7 +156,18 @@ public class ReferenceAnnotationBeanPostProcessor extends AnnotationInjectedBean @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - return method.invoke(bean, args); + Object result = null; + try { + if (bean == null) { // If the bean is not initialized, invoke init() + // issue: https://github.com/apache/incubator-dubbo/issues/3429 + init(); + } + result = method.invoke(bean, args); + } catch (InvocationTargetException e) { + // re-throws the actual Exception. + throw e.getTargetException(); + } + return result; } private void init() { @@ -176,7 +188,9 @@ public class ReferenceAnnotationBeanPostProcessor extends AnnotationInjectedBean private String buildReferencedBeanName(Reference reference, Class injectedType) { - ServiceBeanNameBuilder builder = ServiceBeanNameBuilder.create(reference, injectedType, getEnvironment()); + AnnotationBeanNameBuilder builder = AnnotationBeanNameBuilder.create(reference, injectedType); + + builder.environment(getEnvironment()); return getEnvironment().resolvePlaceholders(builder.build()); } @@ -249,4 +263,4 @@ public class ReferenceAnnotationBeanPostProcessor extends AnnotationInjectedBean this.injectedFieldReferenceBeanCache.clear(); this.injectedMethodReferenceBeanCache.clear(); } -} +} \ No newline at end of file diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java index 22fa70422d..532026de3d 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java @@ -18,7 +18,6 @@ package org.apache.dubbo.config.spring.beans.factory.annotation; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.config.MethodConfig; import org.apache.dubbo.config.annotation.Service; import org.apache.dubbo.config.spring.ServiceBean; import org.apache.dubbo.config.spring.context.annotation.DubboClassPathBeanDefinitionScanner; @@ -290,8 +289,9 @@ public class ServiceAnnotationBeanPostProcessor implements BeanDefinitionRegistr */ private String generateServiceBeanName(Service service, Class interfaceClass, String annotatedServiceBeanName) { - ServiceBeanNameBuilder builder = ServiceBeanNameBuilder.create(service, interfaceClass, environment); + AnnotationBeanNameBuilder builder = AnnotationBeanNameBuilder.create(service, interfaceClass); + builder.environment(environment); return builder.build(); @@ -316,8 +316,9 @@ public class ServiceAnnotationBeanPostProcessor implements BeanDefinitionRegistr } if (interfaceClass == null) { - - Class[] allInterfaces = annotatedServiceBeanClass.getInterfaces(); + // Find all interfaces from the annotated class + // To resolve an issue : https://github.com/apache/incubator-dubbo/issues/3251 + Class[] allInterfaces = ClassUtils.getAllInterfacesForClass(annotatedServiceBeanClass); if (allInterfaces.length > 0) { interfaceClass = allInterfaces[0]; @@ -435,11 +436,6 @@ public class ServiceAnnotationBeanPostProcessor implements BeanDefinitionRegistr builder.addPropertyValue("protocols", protocolRuntimeBeanReferences); } - List methodConfigs = MethodConfig.constructMethodConfig(service.methods()); - if (!methodConfigs.isEmpty()) { - builder.addPropertyValue("methods", methodConfigs); - } - return builder.getBeanDefinition(); } @@ -490,4 +486,4 @@ public class ServiceAnnotationBeanPostProcessor implements BeanDefinitionRegistr this.classLoader = classLoader; } -} +} \ No newline at end of file diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceBeanNameBuilder.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceBeanNameBuilder.java deleted file mode 100644 index 6cd712408b..0000000000 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceBeanNameBuilder.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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.config.spring.beans.factory.annotation; - -import org.apache.dubbo.config.annotation.Reference; -import org.apache.dubbo.config.annotation.Service; -import org.apache.dubbo.config.spring.ReferenceBean; -import org.apache.dubbo.config.spring.ServiceBean; - -import org.springframework.core.env.Environment; -import org.springframework.util.StringUtils; - -import static org.apache.dubbo.config.spring.util.AnnotationUtils.resolveInterfaceName; - - -/** - * Dubbo {@link Service @Service} Bean Builder - * - * @see Service - * @see Reference - * @see ServiceBean - * @see ReferenceBean - * @since 2.6.5 - */ -class ServiceBeanNameBuilder { - - private static final String SEPARATOR = ":"; - - private final String interfaceClassName; - - private final Environment environment; - - // Optional - private String version; - - private String group; - - private ServiceBeanNameBuilder(String interfaceClassName, Environment environment) { - this.interfaceClassName = interfaceClassName; - this.environment = environment; - } - - private ServiceBeanNameBuilder(Class interfaceClass, Environment environment) { - this(interfaceClass.getName(), environment); - } - - private ServiceBeanNameBuilder(Service service, Class interfaceClass, Environment environment) { - this(resolveInterfaceName(service, interfaceClass), environment); - this.group(service.group()); - this.version(service.version()); - } - - private ServiceBeanNameBuilder(Reference reference, Class interfaceClass, Environment environment) { - this(resolveInterfaceName(reference, interfaceClass), environment); - this.group(reference.group()); - this.version(reference.version()); - } - - public static ServiceBeanNameBuilder create(Class interfaceClass, Environment environment) { - return new ServiceBeanNameBuilder(interfaceClass, environment); - } - - public static ServiceBeanNameBuilder create(Service service, Class interfaceClass, Environment environment) { - return new ServiceBeanNameBuilder(service, interfaceClass, environment); - } - - public static ServiceBeanNameBuilder create(Reference reference, Class interfaceClass, Environment environment) { - return new ServiceBeanNameBuilder(reference, interfaceClass, environment); - } - - private static void append(StringBuilder builder, String value) { - if (StringUtils.hasText(value)) { - builder.append(SEPARATOR).append(value); - } - } - - public ServiceBeanNameBuilder group(String group) { - this.group = group; - return this; - } - - public ServiceBeanNameBuilder version(String version) { - this.version = version; - return this; - } - - public String build() { - StringBuilder beanNameBuilder = new StringBuilder("ServiceBean"); - // Required - append(beanNameBuilder, interfaceClassName); - // Optional - append(beanNameBuilder, version); - append(beanNameBuilder, group); - // Build - String rawBeanName = beanNameBuilder.toString(); - // Resolve placeholders - return environment.resolvePlaceholders(rawBeanName); - } -} \ No newline at end of file diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrar.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrar.java index e797e5585e..f604a3ffe6 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrar.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrar.java @@ -18,6 +18,7 @@ package org.apache.dubbo.config.spring.context.annotation; import org.apache.dubbo.config.AbstractConfig; import org.apache.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor; +import org.apache.dubbo.config.spring.context.config.NamePropertyDefaultValueDubboConfigBeanCustomizer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -41,6 +42,8 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import static org.apache.dubbo.config.spring.context.config.NamePropertyDefaultValueDubboConfigBeanCustomizer.BEAN_NAME; +import static org.apache.dubbo.config.spring.util.BeanRegistrar.registerInfrastructureBean; import static org.apache.dubbo.config.spring.util.PropertySourcesUtils.getSubProperties; import static org.apache.dubbo.config.spring.util.PropertySourcesUtils.normalizePrefix; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition; @@ -107,6 +110,8 @@ public class DubboConfigBindingRegistrar implements ImportBeanDefinitionRegistra } + registerDubboConfigBeanCustomizers(registry); + } private void registerDubboConfigBean(String beanName, Class configClass, @@ -149,6 +154,10 @@ public class DubboConfigBindingRegistrar implements ImportBeanDefinitionRegistra } + private void registerDubboConfigBeanCustomizers(BeanDefinitionRegistry registry) { + registerInfrastructureBean(registry, BEAN_NAME, NamePropertyDefaultValueDubboConfigBeanCustomizer.class); + } + @Override public void setEnvironment(Environment environment) { @@ -193,4 +202,4 @@ public class DubboConfigBindingRegistrar implements ImportBeanDefinitionRegistra } -} +} \ No newline at end of file diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigConfigurationRegistrar.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigConfigurationRegistrar.java index cc5f4f8c72..d01dd398ee 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigConfigurationRegistrar.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigConfigurationRegistrar.java @@ -44,10 +44,11 @@ public class DubboConfigConfigurationRegistrar implements ImportBeanDefinitionRe boolean multiple = attributes.getBoolean("multiple"); - if (multiple) { + // Single Config Bindings + registerBeans(registry, DubboConfigConfiguration.Single.class); + + if (multiple) { // Since 2.6.6 https://github.com/apache/incubator-dubbo/issues/3193 registerBeans(registry, DubboConfigConfiguration.Multiple.class); - } else { - registerBeans(registry, DubboConfigConfiguration.Single.class); } } diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubbo.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubbo.java index 4535f188e4..706e288597 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubbo.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubbo.java @@ -76,6 +76,6 @@ public @interface EnableDubbo { * @see EnableDubboConfig#multiple() */ @AliasFor(annotation = EnableDubboConfig.class, attribute = "multiple") - boolean multipleConfig() default false; + boolean multipleConfig() default true; } diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfig.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfig.java index 47bafa53b5..314f2e93d6 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfig.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfig.java @@ -59,7 +59,7 @@ import java.lang.annotation.Target; * * @see EnableDubboConfigBinding * @see DubboConfigConfiguration - * @see DubboConfigConfigurationSelector + * @see DubboConfigConfigurationRegistrar * @since 2.5.8 */ @Target({ElementType.TYPE}) @@ -75,6 +75,6 @@ public @interface EnableDubboConfig { * @return the default value is false * @revised 2.5.9 */ - boolean multiple() default false; + boolean multiple() default true; } diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/DubboConfigBeanCustomizer.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/DubboConfigBeanCustomizer.java new file mode 100644 index 0000000000..75bf0dd2eb --- /dev/null +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/DubboConfigBeanCustomizer.java @@ -0,0 +1,47 @@ +/* + * 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.config.spring.context.config; + +import org.apache.dubbo.config.AbstractConfig; +import org.apache.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor; +import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; + +import org.springframework.context.ApplicationContext; +import org.springframework.core.Ordered; + +/** + * The Bean customizer for {@link AbstractConfig Dubbo Config}. Generally, The subclass will be registered as a Spring + * Bean that is used to {@link #customize(String, AbstractConfig) customize} {@link AbstractConfig Dubbo Config} bean + * after {@link DubboConfigBinder#bind(String, AbstractConfig) its binding}. + *

+ * If There are multiple {@link DubboConfigBeanCustomizer} beans in the Spring {@link ApplicationContext context}, they + * are executed orderly, thus the subclass should be aware to implement the {@link #getOrder()} method. + * + * @see DubboConfigBinder#bind(String, AbstractConfig) + * @see DubboConfigBindingBeanPostProcessor + * @since 2.6.6 + */ +public interface DubboConfigBeanCustomizer extends Ordered { + + /** + * Customize {@link AbstractConfig Dubbo Config Bean} + * + * @param beanName the name of {@link AbstractConfig Dubbo Config Bean} + * @param dubboConfigBean the instance of {@link AbstractConfig Dubbo Config Bean} + */ + void customize(String beanName, AbstractConfig dubboConfigBean); +} diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/NamePropertyDefaultValueDubboConfigBeanCustomizer.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/NamePropertyDefaultValueDubboConfigBeanCustomizer.java new file mode 100644 index 0000000000..fcd053d503 --- /dev/null +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/NamePropertyDefaultValueDubboConfigBeanCustomizer.java @@ -0,0 +1,83 @@ +/* + * 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.config.spring.context.config; + +import org.apache.dubbo.config.AbstractConfig; + +import org.springframework.util.ReflectionUtils; + +import java.beans.PropertyDescriptor; +import java.lang.reflect.Method; +import java.util.Arrays; + +import static org.apache.dubbo.config.spring.util.ObjectUtils.of; +import static org.springframework.beans.BeanUtils.getPropertyDescriptor; + +/** + * {@link DubboConfigBeanCustomizer} for the default value for the "name" property that will be taken bean name + * if absent. + * + * @since 2.6.6 + */ +public class NamePropertyDefaultValueDubboConfigBeanCustomizer implements DubboConfigBeanCustomizer { + + /** + * The bean name of {@link NamePropertyDefaultValueDubboConfigBeanCustomizer} + * + * @since 2.7.1 + */ + public static final String BEAN_NAME = "namePropertyDefaultValueDubboConfigBeanCustomizer"; + + /** + * The name of property that is "name" maybe is absent in target class + */ + private static final String PROPERTY_NAME = "name"; + + @Override + public void customize(String beanName, AbstractConfig dubboConfigBean) { + + PropertyDescriptor propertyDescriptor = getPropertyDescriptor(dubboConfigBean.getClass(), PROPERTY_NAME); + + if (propertyDescriptor != null) { // "name" property is present + + Method getNameMethod = propertyDescriptor.getReadMethod(); + + if (getNameMethod == null) { // if "getName" method is absent + return; + } + + Object propertyValue = ReflectionUtils.invokeMethod(getNameMethod, dubboConfigBean); + + if (propertyValue != null) { // If The return value of "getName" method is not null + return; + } + + Method setNameMethod = propertyDescriptor.getWriteMethod(); + if (setNameMethod != null && getNameMethod != null) { // "setName" and "getName" methods are present + if (Arrays.equals(of(String.class), setNameMethod.getParameterTypes())) { // the param type is String + // set bean name to the value of the "name" property + ReflectionUtils.invokeMethod(setNameMethod, dubboConfigBean, beanName); + } + } + } + } + + @Override + public int getOrder() { + return HIGHEST_PRECEDENCE; + } +} diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/status/SpringStatusChecker.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/status/SpringStatusChecker.java index 9a99ec138f..63517c6e52 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/status/SpringStatusChecker.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/status/SpringStatusChecker.java @@ -1,94 +1,101 @@ -/* - * 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.config.spring.status; - -import org.apache.dubbo.common.extension.Activate; -import org.apache.dubbo.common.logger.Logger; -import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.common.status.Status; -import org.apache.dubbo.common.status.StatusChecker; -import org.apache.dubbo.config.spring.extension.SpringExtensionFactory; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.Lifecycle; - -import java.lang.reflect.Method; - -/** - * SpringStatusChecker - */ -@Activate -public class SpringStatusChecker implements StatusChecker { - - private static final Logger logger = LoggerFactory.getLogger(SpringStatusChecker.class); - - @Override - public Status check() { - ApplicationContext context = null; - for (ApplicationContext c : SpringExtensionFactory.getContexts()) { - if (c != null) { - context = c; - break; - } - } - - if (context == null) { - return new Status(Status.Level.UNKNOWN); - } - - Status.Level level = Status.Level.OK; - if (context instanceof Lifecycle) { - if (((Lifecycle) context).isRunning()) { - level = Status.Level.OK; - } else { - level = Status.Level.ERROR; - } - } else { - level = Status.Level.UNKNOWN; - } - StringBuilder buf = new StringBuilder(); - try { - Class cls = context.getClass(); - Method method = null; - while (cls != null && method == null) { - try { - method = cls.getDeclaredMethod("getConfigLocations", new Class[0]); - } catch (NoSuchMethodException t) { - cls = cls.getSuperclass(); - } - } - if (method != null) { - if (!method.isAccessible()) { - method.setAccessible(true); - } - String[] configs = (String[]) method.invoke(context, new Object[0]); - if (configs != null && configs.length > 0) { - for (String config : configs) { - if (buf.length() > 0) { - buf.append(","); - } - buf.append(config); - } - } - } - } catch (Throwable t) { - logger.warn(t.getMessage(), t); - } - return new Status(level, buf.toString()); - } - -} +/* + * 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.config.spring.status; + +import org.apache.dubbo.common.extension.Activate; +import org.apache.dubbo.common.logger.Logger; +import org.apache.dubbo.common.logger.LoggerFactory; +import org.apache.dubbo.common.status.Status; +import org.apache.dubbo.common.status.StatusChecker; +import org.apache.dubbo.config.spring.extension.SpringExtensionFactory; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.Lifecycle; +import org.springframework.web.context.support.GenericWebApplicationContext; + +import java.lang.reflect.Method; + +/** + * SpringStatusChecker + */ +@Activate +public class SpringStatusChecker implements StatusChecker { + + private static final Logger logger = LoggerFactory.getLogger(SpringStatusChecker.class); + + @Override + public Status check() { + ApplicationContext context = null; + for (ApplicationContext c : SpringExtensionFactory.getContexts()) { + // [Issue] SpringStatusChecker execute errors on non-XML Spring configuration + // issue : https://github.com/apache/incubator-dubbo/issues/3615 + if(c instanceof GenericWebApplicationContext) { // ignore GenericXmlApplicationContext + continue; + } + + if (c != null) { + context = c; + break; + } + } + + if (context == null) { + return new Status(Status.Level.UNKNOWN); + } + + Status.Level level = Status.Level.OK; + if (context instanceof Lifecycle) { + if (((Lifecycle) context).isRunning()) { + level = Status.Level.OK; + } else { + level = Status.Level.ERROR; + } + } else { + level = Status.Level.UNKNOWN; + } + StringBuilder buf = new StringBuilder(); + try { + Class cls = context.getClass(); + Method method = null; + while (cls != null && method == null) { + try { + method = cls.getDeclaredMethod("getConfigLocations", new Class[0]); + } catch (NoSuchMethodException t) { + cls = cls.getSuperclass(); + } + } + if (method != null) { + if (!method.isAccessible()) { + method.setAccessible(true); + } + String[] configs = (String[]) method.invoke(context, new Object[0]); + if (configs != null && configs.length > 0) { + for (String config : configs) { + if (buf.length() > 0) { + buf.append(","); + } + buf.append(config); + } + } + } + } catch (Throwable t) { + logger.warn(t.getMessage(), t); + } + return new Status(level, buf.toString()); + } + +} diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceBeanNameBuilderTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationBeanNameBuilderTest.java similarity index 51% rename from dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceBeanNameBuilderTest.java rename to dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationBeanNameBuilderTest.java index b3616cd58a..2e79109ab3 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceBeanNameBuilderTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationBeanNameBuilderTest.java @@ -16,29 +16,31 @@ */ package org.apache.dubbo.config.spring.beans.factory.annotation; - import org.apache.dubbo.config.annotation.Reference; import org.apache.dubbo.config.annotation.Service; import org.apache.dubbo.config.spring.api.DemoService; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.mock.env.MockEnvironment; import org.springframework.util.ReflectionUtils; +import static org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationBeanNameBuilderTest.GROUP; +import static org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationBeanNameBuilderTest.VERSION; /** - * {@link ServiceBeanNameBuilder} Test + * {@link AnnotationBeanNameBuilder} Test * - * @see ServiceBeanNameBuilder - * @since 2.6.5 + * @see AnnotationBeanNameBuilder + * @since 2.6.6 */ -@Service(interfaceClass = DemoService.class, group = ServiceBeanNameBuilderTest.GROUP, version = ServiceBeanNameBuilderTest.VERSION, +@Service(interfaceClass = DemoService.class, group = GROUP, version = VERSION, application = "application", module = "module", registry = {"1", "2", "3"}) -public class ServiceBeanNameBuilderTest { +public class AnnotationBeanNameBuilderTest { - @Reference(interfaceClass = DemoService.class, group = "DUBBO", version = "1.0.0", + @Reference(interfaceClass = DemoService.class, group = "DUBBO", version = "${dubbo.version}", application = "application", module = "module", registry = {"1", "2", "3"}) static final Class INTERFACE_CLASS = DemoService.class; @@ -46,30 +48,36 @@ public class ServiceBeanNameBuilderTest { static final String VERSION = "1.0.0"; - static final String BEAN_NAME = "ServiceBean:org.apache.dubbo.config.spring.api.DemoService:1.0.0:DUBBO"; + private MockEnvironment environment; - private MockEnvironment environment = new MockEnvironment(); - - @Test - public void testRequiredAttributes() { - ServiceBeanNameBuilder builder = ServiceBeanNameBuilder.create(INTERFACE_CLASS, environment); - Assertions.assertEquals("ServiceBean:org.apache.dubbo.config.spring.api.DemoService", builder.build()); + @Before + public void prepare() { + environment = new MockEnvironment(); + environment.setProperty("dubbo.version", "1.0.0"); } @Test public void testServiceAnnotation() { - Service service = AnnotationUtils.getAnnotation(ServiceBeanNameBuilderTest.class, Service.class); - ServiceBeanNameBuilder builder = ServiceBeanNameBuilder.create(service, INTERFACE_CLASS, environment); - Assertions.assertEquals(BEAN_NAME, + Service service = AnnotationUtils.getAnnotation(AnnotationBeanNameBuilderTest.class, Service.class); + AnnotationBeanNameBuilder builder = AnnotationBeanNameBuilder.create(service, INTERFACE_CLASS); + Assert.assertEquals("providers:dubbo:org.apache.dubbo.config.spring.api.DemoService:1.0.0:DUBBO", + builder.build()); + + builder.environment(environment); + Assert.assertEquals("providers:dubbo:org.apache.dubbo.config.spring.api.DemoService:1.0.0:DUBBO", builder.build()); } @Test public void testReferenceAnnotation() { - Reference reference = AnnotationUtils.getAnnotation(ReflectionUtils.findField(ServiceBeanNameBuilderTest.class, "INTERFACE_CLASS"), Reference.class); - ServiceBeanNameBuilder builder = ServiceBeanNameBuilder.create(reference, INTERFACE_CLASS, environment); - Assertions.assertEquals(BEAN_NAME, + Reference reference = AnnotationUtils.getAnnotation(ReflectionUtils.findField(AnnotationBeanNameBuilderTest.class, "INTERFACE_CLASS"), Reference.class); + AnnotationBeanNameBuilder builder = AnnotationBeanNameBuilder.create(reference, INTERFACE_CLASS); + Assert.assertEquals("consumers:dubbo:org.apache.dubbo.config.spring.api.DemoService:${dubbo.version}:DUBBO", + builder.build()); + + builder.environment(environment); + Assert.assertEquals("consumers:dubbo:org.apache.dubbo.config.spring.api.DemoService:1.0.0:DUBBO", builder.build()); } -} +} \ No newline at end of file diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java index 0baa7bbe45..5c0570e4ff 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java @@ -96,7 +96,7 @@ public class AnnotationPropertyValuesAdapterTest { Assert.assertEquals("dubbo://localhost:12345", referenceBean.getUrl()); Assert.assertEquals("client", referenceBean.getClient()); Assert.assertEquals(true, referenceBean.isGeneric()); - Assert.assertEquals(true, referenceBean.isInjvm()); + Assert.assertNull(referenceBean.isInjvm()); Assert.assertEquals(false, referenceBean.isCheck()); Assert.assertEquals(true, referenceBean.isInit()); Assert.assertEquals(true, referenceBean.getLazy()); diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessorTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessorTest.java index 7811c7371f..62a9a26643 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessorTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessorTest.java @@ -17,50 +17,56 @@ package org.apache.dubbo.config.spring.beans.factory.annotation; import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.spring.context.config.NamePropertyDefaultValueDubboConfigBeanCustomizer; import org.apache.dubbo.config.spring.context.properties.DefaultDubboConfigBinder; -import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; /** * {@link DubboConfigBindingBeanPostProcessor} */ -@PropertySource({"classpath:/META-INF/config.properties"}) -@Configuration +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = { + DefaultDubboConfigBinder.class, + NamePropertyDefaultValueDubboConfigBeanCustomizer.class, + DubboConfigBindingBeanPostProcessorTest.class +}) +@TestPropertySource(properties = { + "dubbo.application.id = dubbo-demo-application", + "dubbo.application.owner = mercyblitz", + "dubbo.application.organization = Apache", + +}) public class DubboConfigBindingBeanPostProcessorTest { - @Bean("applicationBean") + @Bean("dubbo-demo-application") public ApplicationConfig applicationConfig() { return new ApplicationConfig(); } @Bean - public DubboConfigBinder dubboConfigBinder() { - return new DefaultDubboConfigBinder(); + public DubboConfigBindingBeanPostProcessor bindingBeanPostProcessor() { + return new DubboConfigBindingBeanPostProcessor("dubbo.application", "dubbo-demo-application"); } + @Autowired + private ApplicationContext applicationContext; + @Test public void test() { - final AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); - - applicationContext.register(getClass()); - - Class processorClass = DubboConfigBindingBeanPostProcessor.class; - - applicationContext.registerBeanDefinition("DubboConfigBindingBeanPostProcessor", rootBeanDefinition(processorClass).addConstructorArgValue("dubbo.application").addConstructorArgValue("applicationBean").getBeanDefinition()); - - applicationContext.refresh(); - ApplicationConfig applicationConfig = applicationContext.getBean(ApplicationConfig.class); - Assertions.assertEquals("dubbo-demo-application", applicationConfig.getName()); - + Assert.assertEquals("dubbo-demo-application", applicationConfig.getName()); + Assert.assertEquals("mercyblitz", applicationConfig.getOwner()); + Assert.assertEquals("Apache", applicationConfig.getOrganization()); } -} +} \ No newline at end of file diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceBeanBuilderTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceBeanBuilderTest.java index 27f6c9663e..7dd12663d8 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceBeanBuilderTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceBeanBuilderTest.java @@ -81,7 +81,7 @@ public class ReferenceBeanBuilderTest { Assert.assertEquals("dubbo://localhost:12345", referenceBean.getUrl()); Assert.assertEquals("client", referenceBean.getClient()); Assert.assertEquals(true, referenceBean.isGeneric()); - Assert.assertEquals(true, referenceBean.isInjvm()); + Assert.assertNull(referenceBean.isInjvm()); Assert.assertEquals(false, referenceBean.isCheck()); Assert.assertEquals(null, referenceBean.isInit()); Assert.assertEquals(true, referenceBean.getLazy()); diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigTest.java index 5f52a3e0ec..b611c06019 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigTest.java @@ -26,7 +26,6 @@ import org.apache.dubbo.config.RegistryConfig; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; - import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.PropertySource; @@ -95,15 +94,15 @@ public class EnableDubboConfigTest { } - @EnableDubboConfig(multiple = true) + @EnableDubboConfig @PropertySource("META-INF/config.properties") private static class TestMultipleConfig { } - @EnableDubboConfig + @EnableDubboConfig(multiple = false) @PropertySource("META-INF/config.properties") private static class TestConfig { } -} +} \ No newline at end of file diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/provider/DemoServiceImpl.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/provider/DemoServiceImpl.java index eb12225588..3aa1e86f4e 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/provider/DemoServiceImpl.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/provider/DemoServiceImpl.java @@ -45,11 +45,6 @@ public class DemoServiceImpl implements DemoService { @Override public Box getBox() { - return new Box() { - @Override - public String getName() { - return "MyBox"; - } - }; + throw new UnsupportedOperationException("For Purposes!"); } } diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/context/annotation/EnableDubboConfigTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/context/annotation/EnableDubboConfigTest.java index fba874332b..691f251dac 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/context/annotation/EnableDubboConfigTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/context/annotation/EnableDubboConfigTest.java @@ -25,11 +25,14 @@ import org.apache.dubbo.config.ProviderConfig; import org.apache.dubbo.config.RegistryConfig; import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig; +import org.junit.Assert; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.PropertySource; +import java.util.Map; + /** * {@link EnableDubboConfig} Test * @@ -93,16 +96,24 @@ public class EnableDubboConfigTest { ApplicationConfig applicationBean3 = context.getBean("applicationBean3", ApplicationConfig.class); Assertions.assertEquals("dubbo-demo-application3", applicationBean3.getName()); - } + Map protocolConfigs = context.getBeansOfType(ProtocolConfig.class); - @EnableDubboConfig(multiple = true) - @PropertySource("META-INF/config.properties") - private static class TestMultipleConfig { + for (Map.Entry entry : protocolConfigs.entrySet()) { + String beanName = entry.getKey(); + ProtocolConfig protocol = entry.getValue(); + Assert.assertEquals(beanName, protocol.getName()); + } } @EnableDubboConfig @PropertySource("META-INF/config.properties") + private static class TestMultipleConfig { + + } + + @EnableDubboConfig(multiple = false) + @PropertySource("META-INF/config.properties") private static class TestConfig { } diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/status/SpringStatusCheckerTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/status/SpringStatusCheckerTest.java index f3be445103..e3386e2588 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/status/SpringStatusCheckerTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/status/SpringStatusCheckerTest.java @@ -20,14 +20,15 @@ import org.apache.dubbo.common.status.Status; import org.apache.dubbo.config.spring.ServiceBean; import org.apache.dubbo.config.spring.extension.SpringExtensionFactory; +import org.junit.Assert; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - import org.mockito.Mock; import org.mockito.Mockito; import org.springframework.context.ApplicationContext; import org.springframework.context.Lifecycle; +import org.springframework.web.context.support.GenericWebApplicationContext; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -90,4 +91,14 @@ public class SpringStatusCheckerTest { interface ApplicationLifeCycle extends Lifecycle, ApplicationContext { String[] getConfigLocations(); } + + @Test + public void testGenericWebApplicationContext() { + SpringExtensionFactory.clearContexts(); + GenericWebApplicationContext context = new GenericWebApplicationContext(); + SpringExtensionFactory.addApplicationContext(context); + SpringStatusChecker checker = new SpringStatusChecker(); + Status status = checker.check(); + Assert.assertEquals(Status.Level.UNKNOWN, status.getLevel()); + } } diff --git a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/config.properties b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/config.properties index 6e728ccb20..aa79925d4e 100644 --- a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/config.properties +++ b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/config.properties @@ -14,9 +14,13 @@ dubbo.module.name = dubbo-demo-module dubbo.registry.address = zookeeper://192.168.99.100:32770 ## protocol +dubbo.protocol.id = dubbo dubbo.protocol.name = dubbo dubbo.protocol.port = 20880 +dubbo.protocols.rest.port=8080 +dubbo.protocols.thrift.port=9090 + ## monitor dubbo.monitor.address = zookeeper://127.0.0.1:32770 diff --git a/dubbo-config/pom.xml b/dubbo-config/pom.xml index d1f16c146d..dc8c043da9 100644 --- a/dubbo-config/pom.xml +++ b/dubbo-config/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-config pom diff --git a/dubbo-configcenter/dubbo-configcenter-api/pom.xml b/dubbo-configcenter/dubbo-configcenter-api/pom.xml index 7f2715e5b6..2e8a000b8d 100644 --- a/dubbo-configcenter/dubbo-configcenter-api/pom.xml +++ b/dubbo-configcenter/dubbo-configcenter-api/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-configcenter - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-configcenter-api jar diff --git a/dubbo-configcenter/dubbo-configcenter-apollo/pom.xml b/dubbo-configcenter/dubbo-configcenter-apollo/pom.xml index 040b0eb33a..4a502141b6 100644 --- a/dubbo-configcenter/dubbo-configcenter-apollo/pom.xml +++ b/dubbo-configcenter/dubbo-configcenter-apollo/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-configcenter - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-configcenter-apollo jar diff --git a/dubbo-configcenter/dubbo-configcenter-consul/pom.xml b/dubbo-configcenter/dubbo-configcenter-consul/pom.xml index 2a7580e837..03dc3d19d2 100644 --- a/dubbo-configcenter/dubbo-configcenter-consul/pom.xml +++ b/dubbo-configcenter/dubbo-configcenter-consul/pom.xml @@ -16,13 +16,11 @@ ~ limitations under the License. --> - + dubbo-configcenter org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-configcenter/dubbo-configcenter-consul/src/main/java/org/apache/dubbo/configcenter/consul/ConsulDynamicConfiguration.java b/dubbo-configcenter/dubbo-configcenter-consul/src/main/java/org/apache/dubbo/configcenter/consul/ConsulDynamicConfiguration.java index 5ef1985e96..0168fd1294 100644 --- a/dubbo-configcenter/dubbo-configcenter-consul/src/main/java/org/apache/dubbo/configcenter/consul/ConsulDynamicConfiguration.java +++ b/dubbo-configcenter/dubbo-configcenter-consul/src/main/java/org/apache/dubbo/configcenter/consul/ConsulDynamicConfiguration.java @@ -23,6 +23,7 @@ import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.NamedThreadFactory; import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.configcenter.ConfigChangeEvent; +import org.apache.dubbo.configcenter.ConfigChangeType; import org.apache.dubbo.configcenter.ConfigurationListener; import org.apache.dubbo.configcenter.DynamicConfiguration; @@ -40,6 +41,7 @@ import java.util.concurrent.ExecutorService; import static java.util.concurrent.Executors.newCachedThreadPool; import static org.apache.dubbo.common.Constants.CONFIG_NAMESPACE_KEY; import static org.apache.dubbo.common.Constants.PATH_SEPARATOR; +import static org.apache.dubbo.configcenter.ConfigChangeType.ADDED; /** * config center implementation for consul @@ -104,11 +106,23 @@ public class ConsulDynamicConfiguration implements DynamicConfiguration { @Override public Object getInternalProperty(String key) { logger.info("get config from: " + key); - Long currentIndex = consulIndexes.computeIfAbsent(key, k -> -1L); - Response response = client.getKVValue(key, new QueryParams(watchTimeout, currentIndex)); - GetValue value = response.getValue(); - consulIndexes.put(key, response.getConsulIndex()); - return value != null ? value.getDecodedValue() : null; + Response response = getValue(key); + if (response != null) { + GetValue value = response.getValue(); + consulIndexes.put(key, response.getConsulIndex()); + return value != null ? value.getDecodedValue() : null; + } + return null; + } + + private Response getValue(String key) { + try { + Long currentIndex = consulIndexes.computeIfAbsent(key, k -> -1L); + return client.getKVValue(key, new QueryParams(watchTimeout, currentIndex)); + } catch (Throwable t) { + logger.warn("fail to get value for key: " + key); + } + return null; } private int buildWatchTimeout(URL url) { @@ -119,6 +133,7 @@ public class ConsulDynamicConfiguration implements DynamicConfiguration { private String key; private Set listeners; private boolean running = true; + private boolean existing = false; public ConsulKVWatcher(String key) { this.key = convertKey(key); @@ -129,19 +144,45 @@ public class ConsulDynamicConfiguration implements DynamicConfiguration { public void run() { while (running) { Long lastIndex = consulIndexes.computeIfAbsent(key, k -> -1L); - Response response = client.getKVValue(key, new QueryParams(watchTimeout, lastIndex)); + Response response = getValue(key); + if (response == null) { + try { + Thread.sleep(watchTimeout); + } catch (InterruptedException e) { + // ignore + } + continue; + } + GetValue getValue = response.getValue(); Long currentIndex = response.getConsulIndex(); if (currentIndex == null || currentIndex <= lastIndex) { continue; } consulIndexes.put(key, currentIndex); - String value = response.getValue().getDecodedValue(); - logger.info("notify change for key: " + key + ", the value is: " + value); - ConfigChangeEvent event = new ConfigChangeEvent(key, value); - for (ConfigurationListener listener : listeners) { - listener.process(event); + ConfigChangeEvent event = null; + if (getValue != null) { + String value = getValue.getDecodedValue(); + if (existing) { + logger.info("notify change for key: " + key + ", the changed value is: " + value); + event = new ConfigChangeEvent(key, value); + } else { + logger.info("notify change for key: " + key + ", the added value is: " + value); + event = new ConfigChangeEvent(key, value, ADDED); + } + } else { + if (existing) { + logger.info("notify change for key: " + key + ", the value is deleted"); + event = new ConfigChangeEvent(key, null, ConfigChangeType.DELETED); + } + } + + existing = getValue != null; + if (event != null) { + for (ConfigurationListener listener : listeners) { + listener.process(event); + } } } } diff --git a/dubbo-configcenter/dubbo-configcenter-etcd/pom.xml b/dubbo-configcenter/dubbo-configcenter-etcd/pom.xml index 60efc8e4bb..868c686846 100644 --- a/dubbo-configcenter/dubbo-configcenter-etcd/pom.xml +++ b/dubbo-configcenter/dubbo-configcenter-etcd/pom.xml @@ -18,11 +18,11 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> dubbo-configcenter org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 @@ -43,4 +43,4 @@ ${project.parent.version} - \ No newline at end of file + diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml b/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml index 5c84f6515a..c4bccaf453 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-configcenter - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-configcenter-zookeeper jar diff --git a/dubbo-configcenter/pom.xml b/dubbo-configcenter/pom.xml index 92f727d232..206293f639 100644 --- a/dubbo-configcenter/pom.xml +++ b/dubbo-configcenter/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-configcenter pom diff --git a/dubbo-container/dubbo-container-api/pom.xml b/dubbo-container/dubbo-container-api/pom.xml index 2c1e9100af..1ace802bc8 100644 --- a/dubbo-container/dubbo-container-api/pom.xml +++ b/dubbo-container/dubbo-container-api/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-container - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-container-api jar diff --git a/dubbo-container/dubbo-container-log4j/pom.xml b/dubbo-container/dubbo-container-log4j/pom.xml index be5a1733a3..46655f6181 100644 --- a/dubbo-container/dubbo-container-log4j/pom.xml +++ b/dubbo-container/dubbo-container-log4j/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-container - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-container-log4j jar diff --git a/dubbo-container/dubbo-container-logback/pom.xml b/dubbo-container/dubbo-container-logback/pom.xml index 9a1aa47eda..8e3d4150ca 100644 --- a/dubbo-container/dubbo-container-logback/pom.xml +++ b/dubbo-container/dubbo-container-logback/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-container - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-container-logback jar diff --git a/dubbo-container/dubbo-container-spring/pom.xml b/dubbo-container/dubbo-container-spring/pom.xml index 83298634f2..cb06217c6c 100644 --- a/dubbo-container/dubbo-container-spring/pom.xml +++ b/dubbo-container/dubbo-container-spring/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-container - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-container-spring jar diff --git a/dubbo-container/pom.xml b/dubbo-container/pom.xml index 932899488e..7e17a60175 100644 --- a/dubbo-container/pom.xml +++ b/dubbo-container/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-container pom diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml index 58e260ed59..78027b0882 100644 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml +++ b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml @@ -22,7 +22,7 @@ dubbo-demo-annotation org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml index bf6bc8fd9d..7b02888b66 100644 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml +++ b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml @@ -22,7 +22,7 @@ dubbo-demo-annotation org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-demo/dubbo-demo-annotation/pom.xml b/dubbo-demo/dubbo-demo-annotation/pom.xml index f94870dc56..8109804d4b 100644 --- a/dubbo-demo/dubbo-demo-annotation/pom.xml +++ b/dubbo-demo/dubbo-demo-annotation/pom.xml @@ -22,7 +22,7 @@ dubbo-demo org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 pom diff --git a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/pom.xml b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/pom.xml index 947537667b..25cb23e950 100644 --- a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/pom.xml +++ b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/pom.xml @@ -22,7 +22,7 @@ dubbo-demo-api org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/pom.xml b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/pom.xml index d2dd9af1c8..c30139cacb 100644 --- a/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/pom.xml +++ b/dubbo-demo/dubbo-demo-api/dubbo-demo-api-provider/pom.xml @@ -22,7 +22,7 @@ dubbo-demo-api org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-demo/dubbo-demo-api/pom.xml b/dubbo-demo/dubbo-demo-api/pom.xml index b9088fc4d3..c1a2eee320 100644 --- a/dubbo-demo/dubbo-demo-api/pom.xml +++ b/dubbo-demo/dubbo-demo-api/pom.xml @@ -22,7 +22,7 @@ dubbo-demo org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 pom diff --git a/dubbo-demo/dubbo-demo-interface/pom.xml b/dubbo-demo/dubbo-demo-interface/pom.xml index f6376c9157..5488d9824d 100644 --- a/dubbo-demo/dubbo-demo-interface/pom.xml +++ b/dubbo-demo/dubbo-demo-interface/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-demo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-demo-interface jar diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml index 8487459153..35f357039b 100644 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml +++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-demo-xml - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-demo-xml-consumer jar diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml index fbd0f04149..9c9b18c9f5 100644 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml +++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-demo-xml - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-demo-xml-provider jar diff --git a/dubbo-demo/dubbo-demo-xml/pom.xml b/dubbo-demo/dubbo-demo-xml/pom.xml index fbbcae942b..80339b1031 100644 --- a/dubbo-demo/dubbo-demo-xml/pom.xml +++ b/dubbo-demo/dubbo-demo-xml/pom.xml @@ -22,7 +22,7 @@ dubbo-demo org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 pom diff --git a/dubbo-demo/pom.xml b/dubbo-demo/pom.xml index 77d59aebcd..9894cd95ab 100644 --- a/dubbo-demo/pom.xml +++ b/dubbo-demo/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-demo pom diff --git a/dubbo-dependencies-bom/pom.xml b/dubbo-dependencies-bom/pom.xml index 245b6ff61f..d2e604dad2 100644 --- a/dubbo-dependencies-bom/pom.xml +++ b/dubbo-dependencies-bom/pom.xml @@ -16,20 +16,19 @@ ~ limitations under the License. --> - + 4.0.0 org.apache apache 21 - + org.apache.dubbo dubbo-dependencies-bom - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT pom dubbo-dependencies-bom diff --git a/dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml b/dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml index 18a3f2abcc..9a94a7b50b 100644 --- a/dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml +++ b/dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml @@ -16,21 +16,19 @@ ~ limitations under the License. --> - + 4.0.0 org.apache apache 21 - + org.apache.dubbo dubbo-dependencies-zookeeper - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT pom @@ -38,7 +36,7 @@ org.apache.dubbo dubbo-dependencies-bom - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT pom import @@ -77,5 +75,4 @@ - diff --git a/dubbo-dependencies/pom.xml b/dubbo-dependencies/pom.xml index 6d144449d5..a1a4f73d69 100644 --- a/dubbo-dependencies/pom.xml +++ b/dubbo-dependencies/pom.xml @@ -16,13 +16,11 @@ ~ limitations under the License. --> - + dubbo-parent org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-distribution/pom.xml b/dubbo-distribution/pom.xml index b018cec4e5..d60548d3b1 100644 --- a/dubbo-distribution/pom.xml +++ b/dubbo-distribution/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-distribution pom @@ -267,7 +267,7 @@ 3.1.0 - bin-release + bin package single @@ -279,7 +279,7 @@ - source-release + src package single diff --git a/dubbo-distribution/src/assembly/bin-release.xml b/dubbo-distribution/src/assembly/bin-release.xml index e055929602..e0aef5cbca 100644 --- a/dubbo-distribution/src/assembly/bin-release.xml +++ b/dubbo-distribution/src/assembly/bin-release.xml @@ -16,12 +16,12 @@ --> - bin-release + bin zip true - ${project.build.finalName}-bin-release + ${project.build.finalName}-bin ../ diff --git a/dubbo-distribution/src/assembly/source-release.xml b/dubbo-distribution/src/assembly/source-release.xml index 434377bdd3..2a802a5401 100644 --- a/dubbo-distribution/src/assembly/source-release.xml +++ b/dubbo-distribution/src/assembly/source-release.xml @@ -16,12 +16,12 @@ --> - source-release + src zip true - ${project.build.finalName}-source-release + ${project.build.finalName}-src diff --git a/dubbo-filter/dubbo-filter-cache/pom.xml b/dubbo-filter/dubbo-filter-cache/pom.xml index bec6067478..3128aea3d9 100644 --- a/dubbo-filter/dubbo-filter-cache/pom.xml +++ b/dubbo-filter/dubbo-filter-cache/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-filter - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-filter-cache jar diff --git a/dubbo-filter/dubbo-filter-validation/pom.xml b/dubbo-filter/dubbo-filter-validation/pom.xml index 9ce481061d..0d23e59bb1 100644 --- a/dubbo-filter/dubbo-filter-validation/pom.xml +++ b/dubbo-filter/dubbo-filter-validation/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-filter - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-filter-validation jar diff --git a/dubbo-filter/pom.xml b/dubbo-filter/pom.xml index f985141229..958a1830bd 100644 --- a/dubbo-filter/pom.xml +++ b/dubbo-filter/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-filter pom diff --git a/dubbo-metadata-report/dubbo-metadata-definition/pom.xml b/dubbo-metadata-report/dubbo-metadata-definition/pom.xml index 09dc860fb6..2aca021bba 100644 --- a/dubbo-metadata-report/dubbo-metadata-definition/pom.xml +++ b/dubbo-metadata-report/dubbo-metadata-definition/pom.xml @@ -18,7 +18,7 @@ dubbo-metadata-report org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-metadata-report/dubbo-metadata-report-api/pom.xml b/dubbo-metadata-report/dubbo-metadata-report-api/pom.xml index 6244d0407f..d9bc0c3d9f 100644 --- a/dubbo-metadata-report/dubbo-metadata-report-api/pom.xml +++ b/dubbo-metadata-report/dubbo-metadata-report-api/pom.xml @@ -18,7 +18,7 @@ dubbo-metadata-report org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-metadata-report/dubbo-metadata-report-consul/pom.xml b/dubbo-metadata-report/dubbo-metadata-report-consul/pom.xml index ad02eaedda..4630f58c49 100644 --- a/dubbo-metadata-report/dubbo-metadata-report-consul/pom.xml +++ b/dubbo-metadata-report/dubbo-metadata-report-consul/pom.xml @@ -16,13 +16,11 @@ ~ limitations under the License. --> - + dubbo-metadata-report org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-metadata-report/dubbo-metadata-report-redis/pom.xml b/dubbo-metadata-report/dubbo-metadata-report-redis/pom.xml index 6f5d418e28..9fd1479299 100644 --- a/dubbo-metadata-report/dubbo-metadata-report-redis/pom.xml +++ b/dubbo-metadata-report/dubbo-metadata-report-redis/pom.xml @@ -18,7 +18,7 @@ dubbo-metadata-report org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-metadata-report/dubbo-metadata-report-zookeeper/pom.xml b/dubbo-metadata-report/dubbo-metadata-report-zookeeper/pom.xml index 4f7feb1b22..dd7afdcda7 100644 --- a/dubbo-metadata-report/dubbo-metadata-report-zookeeper/pom.xml +++ b/dubbo-metadata-report/dubbo-metadata-report-zookeeper/pom.xml @@ -18,7 +18,7 @@ dubbo-metadata-report org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-metadata-report/pom.xml b/dubbo-metadata-report/pom.xml index aa14d56122..2aa17954da 100644 --- a/dubbo-metadata-report/pom.xml +++ b/dubbo-metadata-report/pom.xml @@ -18,7 +18,7 @@ dubbo-parent org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-monitor/dubbo-monitor-api/pom.xml b/dubbo-monitor/dubbo-monitor-api/pom.xml index 5d649dc1fa..ec69d4e39b 100644 --- a/dubbo-monitor/dubbo-monitor-api/pom.xml +++ b/dubbo-monitor/dubbo-monitor-api/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-monitor - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-monitor-api jar diff --git a/dubbo-monitor/dubbo-monitor-default/pom.xml b/dubbo-monitor/dubbo-monitor-default/pom.xml index a7ae0ecd00..0b84690a52 100644 --- a/dubbo-monitor/dubbo-monitor-default/pom.xml +++ b/dubbo-monitor/dubbo-monitor-default/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-monitor - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-monitor-default jar diff --git a/dubbo-monitor/pom.xml b/dubbo-monitor/pom.xml index 6e0171d303..35eca044fe 100644 --- a/dubbo-monitor/pom.xml +++ b/dubbo-monitor/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-monitor pom diff --git a/dubbo-plugin/dubbo-qos/pom.xml b/dubbo-plugin/dubbo-qos/pom.xml index 717c20ceac..4fee097f61 100644 --- a/dubbo-plugin/dubbo-qos/pom.xml +++ b/dubbo-plugin/dubbo-qos/pom.xml @@ -18,7 +18,7 @@ org.apache.dubbo dubbo-plugin - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-plugin/pom.xml b/dubbo-plugin/pom.xml index e542776024..91ea5b7d37 100644 --- a/dubbo-plugin/pom.xml +++ b/dubbo-plugin/pom.xml @@ -18,7 +18,7 @@ dubbo-parent org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-registry/dubbo-registry-api/pom.xml b/dubbo-registry/dubbo-registry-api/pom.xml index d96df68084..bb32665a07 100644 --- a/dubbo-registry/dubbo-registry-api/pom.xml +++ b/dubbo-registry/dubbo-registry-api/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-registry - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-registry-api jar diff --git a/dubbo-registry/dubbo-registry-consul/pom.xml b/dubbo-registry/dubbo-registry-consul/pom.xml index 38647f259a..70bb1a3fac 100644 --- a/dubbo-registry/dubbo-registry-consul/pom.xml +++ b/dubbo-registry/dubbo-registry-consul/pom.xml @@ -16,13 +16,11 @@ ~ limitations under the License. --> - + dubbo-registry org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-registry/dubbo-registry-default/pom.xml b/dubbo-registry/dubbo-registry-default/pom.xml index 73bda5ceab..792ec4b5f4 100644 --- a/dubbo-registry/dubbo-registry-default/pom.xml +++ b/dubbo-registry/dubbo-registry-default/pom.xml @@ -20,7 +20,7 @@ org.apache.dubbo dubbo-registry - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-registry-default jar diff --git a/dubbo-registry/dubbo-registry-etcd3/pom.xml b/dubbo-registry/dubbo-registry-etcd3/pom.xml index 00b0ae5390..a77861a703 100644 --- a/dubbo-registry/dubbo-registry-etcd3/pom.xml +++ b/dubbo-registry/dubbo-registry-etcd3/pom.xml @@ -16,14 +16,12 @@ ~ limitations under the License. --> - + 4.0.0 dubbo-registry org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-registry-etcd3 diff --git a/dubbo-registry/dubbo-registry-multicast/pom.xml b/dubbo-registry/dubbo-registry-multicast/pom.xml index 61a8669e8f..586f1aa917 100644 --- a/dubbo-registry/dubbo-registry-multicast/pom.xml +++ b/dubbo-registry/dubbo-registry-multicast/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-registry - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-registry-multicast jar diff --git a/dubbo-registry/dubbo-registry-nacos/pom.xml b/dubbo-registry/dubbo-registry-nacos/pom.xml new file mode 100644 index 0000000000..15e27e21a0 --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/pom.xml @@ -0,0 +1,151 @@ + + + + org.apache.dubbo + dubbo-registry + 2.7.2-SNAPSHOT + ../pom.xml + + 4.0.0 + + org.apache.dubbo + dubbo-registry-nacos + ${project.artifactId} + The Nacos registry module of Dubbo project + + + 0.9.0 + + + + + + org.apache.dubbo + dubbo-registry-api + ${project.version} + true + + + + org.apache.dubbo + dubbo-common + ${project.version} + true + + + + com.alibaba.nacos + nacos-client + ${nacos.version} + true + + + + + org.apache.dubbo + dubbo-config-api + ${project.version} + test + + + + org.apache.dubbo + dubbo-serialization-hessian2 + ${project.version} + test + + + + org.apache.dubbo + dubbo-config-spring + ${project.version} + test + + + + org.apache.dubbo + dubbo-rpc-dubbo + ${project.version} + test + + + + org.apache.dubbo + dubbo-remoting-netty4 + ${project.version} + test + + + + ch.qos.logback + logback-classic + test + + + + + org.apache.dubbo + dubbo-rpc-rest + ${project.version} + test + + + + org.jboss.resteasy + resteasy-jaxrs + test + + + + org.jboss.resteasy + resteasy-client + test + + + + org.jboss.resteasy + resteasy-netty4 + test + + + + javax.validation + validation-api + test + + + + org.jboss.resteasy + resteasy-jackson-provider + test + + + + org.jboss.resteasy + resteasy-jaxb-provider + test + + + + org.springframework + spring-test + test + + + + \ No newline at end of file diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java new file mode 100644 index 0000000000..31ca2a83ca --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java @@ -0,0 +1,530 @@ +/* + * 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.registry.nacos; + +import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.logger.Logger; +import org.apache.dubbo.common.logger.LoggerFactory; +import org.apache.dubbo.common.utils.UrlUtils; +import org.apache.dubbo.registry.NotifyListener; +import org.apache.dubbo.registry.Registry; +import org.apache.dubbo.registry.support.FailbackRegistry; + +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.naming.NamingService; +import com.alibaba.nacos.api.naming.listener.Event; +import com.alibaba.nacos.api.naming.listener.EventListener; +import com.alibaba.nacos.api.naming.listener.NamingEvent; +import com.alibaba.nacos.api.naming.pojo.Instance; +import com.alibaba.nacos.api.naming.pojo.ListView; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import static org.apache.dubbo.common.Constants.ADMIN_PROTOCOL; +import static org.apache.dubbo.common.Constants.CATEGORY_KEY; +import static org.apache.dubbo.common.Constants.CONFIGURATORS_CATEGORY; +import static org.apache.dubbo.common.Constants.CONSUMERS_CATEGORY; +import static org.apache.dubbo.common.Constants.DEFAULT_CATEGORY; +import static org.apache.dubbo.common.Constants.GROUP_KEY; +import static org.apache.dubbo.common.Constants.INTERFACE_KEY; +import static org.apache.dubbo.common.Constants.PROVIDERS_CATEGORY; +import static org.apache.dubbo.common.Constants.ROUTERS_CATEGORY; +import static org.apache.dubbo.common.Constants.VERSION_KEY; + +/** + * Nacos {@link Registry} + * + * @see #SERVICE_NAME_SEPARATOR + * @see #PAGINATION_SIZE + * @see #LOOKUP_INTERVAL + * @since 2.6.5 + */ +public class NacosRegistry extends FailbackRegistry { + + /** + * All supported categories + */ + private static final String[] ALL_SUPPORTED_CATEGORIES = of( + PROVIDERS_CATEGORY, + CONSUMERS_CATEGORY, + ROUTERS_CATEGORY, + CONFIGURATORS_CATEGORY + ); + + private static final int CATEGORY_INDEX = 0; + + private static final int SERVICE_INTERFACE_INDEX = 1; + + private static final int SERVICE_VERSION_INDEX = 2; + + private static final int SERVICE_GROUP_INDEX = 3; + + private static final String WILDCARD = "*"; + + /** + * The separator for service name + * + * @revert change a constant to be configurable, it's designed for Windows file name that is compatible with old + * Nacos binary release(< 0.6.1) + */ + private static final String SERVICE_NAME_SEPARATOR = System.getProperty("nacos.service.name.separator", ":"); + + /** + * The pagination size of query for Nacos service names(only for Dubbo-OPS) + */ + private static final int PAGINATION_SIZE = Integer.getInteger("nacos.service.names.pagination.size", 100); + + /** + * The interval in second of lookup Nacos service names(only for Dubbo-OPS) + */ + private static final long LOOKUP_INTERVAL = Long.getLong("nacos.service.names.lookup.interval", 30); + + /** + * {@link ScheduledExecutorService} lookup Nacos service names(only for Dubbo-OPS) + */ + private volatile ScheduledExecutorService scheduledExecutorService; + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private final NamingService namingService; + + private final ConcurrentMap nacosListeners; + + public NacosRegistry(URL url, NamingService namingService) { + super(url); + this.namingService = namingService; + this.nacosListeners = new ConcurrentHashMap(); + } + + @Override + public boolean isAvailable() { + return "UP".equals(namingService.getServerStatus()); + } + + @Override + public List lookup(final URL url) { + final List urls = new LinkedList(); + execute(new NamingServiceCallback() { + @Override + public void callback(NamingService namingService) throws NacosException { + List serviceNames = getServiceNames(url, null); + for (String serviceName : serviceNames) { + List instances = namingService.getAllInstances(serviceName); + urls.addAll(buildURLs(url, instances)); + } + } + }); + return urls; + } + + @Override + public void doRegister(URL url) { + final String serviceName = getServiceName(url); + final Instance instance = createInstance(url); + execute(new NamingServiceCallback() { + public void callback(NamingService namingService) throws NacosException { + namingService.registerInstance(serviceName, instance); + } + }); + } + + @Override + public void doUnregister(final URL url) { + execute(new NamingServiceCallback() { + public void callback(NamingService namingService) throws NacosException { + String serviceName = getServiceName(url); + Instance instance = createInstance(url); + namingService.deregisterInstance(serviceName, instance.getIp(), instance.getPort()); + } + }); + } + + @Override + public void doSubscribe(final URL url, final NotifyListener listener) { + List serviceNames = getServiceNames(url, listener); + doSubscribe(url, listener, serviceNames); + } + + private void doSubscribe(final URL url, final NotifyListener listener, final List serviceNames) { + execute(new NamingServiceCallback() { + @Override + public void callback(NamingService namingService) throws NacosException { + for (String serviceName : serviceNames) { + List instances = namingService.getAllInstances(serviceName); + notifySubscriber(url, listener, instances); + subscribeEventListener(serviceName, url, listener); + } + } + }); + } + + @Override + public void doUnsubscribe(URL url, NotifyListener listener) { + if (isAdminProtocol(url)) { + shutdownServiceNamesLookup(); + } + } + + private void shutdownServiceNamesLookup() { + if (scheduledExecutorService != null) { + scheduledExecutorService.shutdown(); + } + } + + /** + * Get the service names from the specified {@link URL url} + * + * @param url {@link URL} + * @param listener {@link NotifyListener} + * @return non-null + */ + private List getServiceNames(URL url, NotifyListener listener) { + if (isAdminProtocol(url)) { + scheduleServiceNamesLookup(url, listener); + return getServiceNamesForOps(url); + } else { + return doGetServiceNames(url); + } + } + + private boolean isAdminProtocol(URL url) { + return ADMIN_PROTOCOL.equals(url.getProtocol()); + } + + private void scheduleServiceNamesLookup(final URL url, final NotifyListener listener) { + if (scheduledExecutorService == null) { + scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); + scheduledExecutorService.scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + List serviceNames = getAllServiceNames(); + filterData(serviceNames, new NacosDataFilter() { + @Override + public boolean accept(String serviceName) { + boolean accepted = false; + for (String category : ALL_SUPPORTED_CATEGORIES) { + String prefix = category + SERVICE_NAME_SEPARATOR; + if (StringUtils.startsWith(serviceName, prefix)) { + accepted = true; + break; + } + } + return accepted; + } + }); + doSubscribe(url, listener, serviceNames); + } + }, LOOKUP_INTERVAL, LOOKUP_INTERVAL, TimeUnit.SECONDS); + } + } + + /** + * Get the service names for Dubbo OPS + * + * @param url {@link URL} + * @return non-null + */ + private List getServiceNamesForOps(URL url) { + List serviceNames = getAllServiceNames(); + filterServiceNames(serviceNames, url); + return serviceNames; + } + + private List getAllServiceNames() { + + final List serviceNames = new LinkedList(); + + execute(new NamingServiceCallback() { + @Override + public void callback(NamingService namingService) throws NacosException { + + int pageIndex = 1; + ListView listView = namingService.getServicesOfServer(pageIndex, PAGINATION_SIZE); + // First page data + List firstPageData = listView.getData(); + // Append first page into list + serviceNames.addAll(firstPageData); + // the total count + int count = listView.getCount(); + // the number of pages + int pageNumbers = count / PAGINATION_SIZE; + int remainder = count % PAGINATION_SIZE; + // remain + if (remainder > 0) { + pageNumbers += 1; + } + // If more than 1 page + while (pageIndex < pageNumbers) { + listView = namingService.getServicesOfServer(++pageIndex, PAGINATION_SIZE); + serviceNames.addAll(listView.getData()); + } + + } + }); + + return serviceNames; + } + + private void filterServiceNames(List serviceNames, URL url) { + + final String[] categories = getCategories(url); + + final String targetServiceInterface = url.getServiceInterface(); + + final String targetVersion = url.getParameter(VERSION_KEY); + + final String targetGroup = url.getParameter(GROUP_KEY); + + filterData(serviceNames, new NacosDataFilter() { + @Override + public boolean accept(String serviceName) { + // split service name to segments + // (required) segments[0] = category + // (required) segments[1] = serviceInterface + // (required) segments[2] = version + // (optional) segments[3] = group + String[] segments = StringUtils.split(serviceName, SERVICE_NAME_SEPARATOR); + int length = segments.length; + if (length < 3) { // must present 3 segments or more + return false; + } + + String category = segments[CATEGORY_INDEX]; + if (!ArrayUtils.contains(categories, category)) { // no match category + return false; + } + + String serviceInterface = segments[SERVICE_INTERFACE_INDEX]; + if (!WILDCARD.equals(targetServiceInterface) && + !StringUtils.equals(targetServiceInterface, serviceInterface)) { // no match service interface + return false; + } + + String version = segments[SERVICE_VERSION_INDEX]; + if (!WILDCARD.equals(targetVersion) && + !StringUtils.equals(targetVersion, version)) { // no match service version + return false; + } + + String group = length > 3 ? segments[SERVICE_GROUP_INDEX] : null; + if (group != null && !WILDCARD.equals(targetGroup) + && !StringUtils.equals(targetGroup, group)) { // no match service group + return false; + } + + return true; + } + }); + } + + private void filterData(Collection collection, NacosDataFilter filter) { + Iterator iterator = collection.iterator(); + while (iterator.hasNext()) { + T data = iterator.next(); + if (!filter.accept(data)) { // remove if not accept + iterator.remove(); + } + } + } + + private List doGetServiceNames(URL url) { + String[] categories = getCategories(url); + List serviceNames = new ArrayList(categories.length); + for (String category : categories) { + final String serviceName = getServiceName(url, category); + serviceNames.add(serviceName); + } + return serviceNames; + } + + private List buildURLs(URL consumerURL, Collection instances) { + if (instances.isEmpty()) { + return Collections.emptyList(); + } + List urls = new LinkedList(); + for (Instance instance : instances) { + URL url = buildURL(instance); + if (UrlUtils.isMatch(consumerURL, url)) { + urls.add(url); + } + } + return urls; + } + + private void subscribeEventListener(String serviceName, final URL url, final NotifyListener listener) + throws NacosException { + if (!nacosListeners.containsKey(serviceName)) { + EventListener eventListener = new EventListener() { + public void onEvent(Event event) { + if (event instanceof NamingEvent) { + NamingEvent e = (NamingEvent) event; + notifySubscriber(url, listener, e.getInstances()); + } + } + }; + namingService.subscribe(serviceName, eventListener); + nacosListeners.put(serviceName, eventListener); + } + } + + /** + * Notify the Healthy {@link Instance instances} to subscriber. + * + * @param url {@link URL} + * @param listener {@link NotifyListener} + * @param instances all {@link Instance instances} + */ + private void notifySubscriber(URL url, NotifyListener listener, Collection instances) { + List healthyInstances = new LinkedList(instances); + // Healthy Instances + filterHealthyInstances(healthyInstances); + List urls = buildURLs(url, healthyInstances); + NacosRegistry.this.notify(url, listener, urls); + } + + /** + * Get the categories from {@link URL} + * + * @param url {@link URL} + * @return non-null array + */ + private String[] getCategories(URL url) { + return Constants.ANY_VALUE.equals(url.getServiceInterface()) ? + ALL_SUPPORTED_CATEGORIES : of(Constants.DEFAULT_CATEGORY); + } + + private URL buildURL(Instance instance) { + Map metadata = instance.getMetadata(); + String protocol = metadata.get(Constants.PROTOCOL_KEY); + String path = metadata.get(Constants.PATH_KEY); + URL url = new URL(protocol, + instance.getIp(), + instance.getPort(), + path, + instance.getMetadata()); + return url; + } + + private Instance createInstance(URL url) { + // Append default category if absent + String category = url.getParameter(Constants.CATEGORY_KEY, Constants.DEFAULT_CATEGORY); + URL newURL = url.addParameter(Constants.CATEGORY_KEY, category); + newURL = newURL.addParameter(Constants.PROTOCOL_KEY, url.getProtocol()); + newURL = newURL.addParameter(Constants.PATH_KEY, url.getPath()); + String ip = url.getHost(); + int port = url.getPort(); + Instance instance = new Instance(); + instance.setIp(ip); + instance.setPort(port); + instance.setMetadata(new HashMap(newURL.getParameters())); + return instance; + } + + private String getServiceName(URL url) { + String category = url.getParameter(CATEGORY_KEY, DEFAULT_CATEGORY); + return getServiceName(url, category); + } + + private String getServiceName(URL url, String category) { + StringBuilder serviceNameBuilder = new StringBuilder(category); + appendIfPresent(serviceNameBuilder, url, INTERFACE_KEY); + appendIfPresent(serviceNameBuilder, url, VERSION_KEY); + appendIfPresent(serviceNameBuilder, url, GROUP_KEY); + return serviceNameBuilder.toString(); + } + + private void appendIfPresent(StringBuilder target, URL url, String parameterName) { + String parameterValue = url.getParameter(parameterName); + if (!StringUtils.isBlank(parameterValue)) { + target.append(SERVICE_NAME_SEPARATOR).append(parameterValue); + } + } + + private void execute(NamingServiceCallback callback) { + try { + callback.callback(namingService); + } catch (NacosException e) { + if (logger.isErrorEnabled()) { + logger.error(e.getErrMsg(), e); + } + } + } + + private void filterHealthyInstances(Collection instances) { + filterData(instances, new NacosDataFilter() { + @Override + public boolean accept(Instance data) { + return data.isEnabled(); + } + }); + } + + private static T[] of(T... values) { + return values; + } + + + /** + * A filter for Nacos data + * + * @since 2.6.5 + */ + private interface NacosDataFilter { + + /** + * Tests whether or not the specified data should be accepted. + * + * @param data The data to be tested + * @return true if and only if data + * should be accepted + */ + boolean accept(T data); + + } + + /** + * {@link NamingService} Callback + * + * @since 2.6.5 + */ + interface NamingServiceCallback { + + /** + * Callback + * + * @param namingService {@link NamingService} + * @throws NacosException + */ + void callback(NamingService namingService) throws NacosException; + + } +} diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java new file mode 100644 index 0000000000..1470c19893 --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java @@ -0,0 +1,108 @@ +/* + * 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.registry.nacos; + +import org.apache.dubbo.common.URL; +import org.apache.dubbo.registry.Registry; +import org.apache.dubbo.registry.RegistryFactory; +import org.apache.dubbo.registry.support.AbstractRegistryFactory; + +import com.alibaba.nacos.api.NacosFactory; +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.naming.NamingService; +import com.alibaba.nacos.client.naming.utils.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Properties; + +import static com.alibaba.nacos.api.PropertyKeyConst.ACCESS_KEY; +import static com.alibaba.nacos.api.PropertyKeyConst.CLUSTER_NAME; +import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT; +import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE; +import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY; +import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR; +import static com.alibaba.nacos.client.naming.utils.UtilAndComs.NACOS_NAMING_LOG_NAME; +import static org.apache.dubbo.common.Constants.BACKUP_KEY; + +/** + * Nacos {@link RegistryFactory} + * + * @since 2.6.5 + */ +public class NacosRegistryFactory extends AbstractRegistryFactory { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + protected Registry createRegistry(URL url) { + return new NacosRegistry(url, buildNamingService(url)); + } + + private NamingService buildNamingService(URL url) { + Properties nacosProperties = buildNacosProperties(url); + NamingService namingService = null; + try { + namingService = NacosFactory.createNamingService(nacosProperties); + } catch (NacosException e) { + if (logger.isErrorEnabled()) { + logger.error(e.getErrMsg(), e); + } + throw new IllegalStateException(e); + } + return namingService; + } + + private Properties buildNacosProperties(URL url) { + Properties properties = new Properties(); + setServerAddr(url, properties); + setProperties(url, properties); + return properties; + } + + private void setServerAddr(URL url, Properties properties) { + StringBuilder serverAddrBuilder = + new StringBuilder(url.getHost()) // Host + .append(":") + .append(url.getPort()); // Port + + // Append backup parameter as other servers + String backup = url.getParameter(BACKUP_KEY); + if (backup != null) { + serverAddrBuilder.append(",").append(backup); + } + + String serverAddr = serverAddrBuilder.toString(); + properties.put(SERVER_ADDR, serverAddr); + } + + private void setProperties(URL url, Properties properties) { + putPropertyIfAbsent(url, properties, NAMESPACE); + putPropertyIfAbsent(url, properties, NACOS_NAMING_LOG_NAME); + putPropertyIfAbsent(url, properties, ENDPOINT); + putPropertyIfAbsent(url, properties, NAMESPACE); + putPropertyIfAbsent(url, properties, ACCESS_KEY); + putPropertyIfAbsent(url, properties, SECRET_KEY); + putPropertyIfAbsent(url, properties, CLUSTER_NAME); + } + + private void putPropertyIfAbsent(URL url, Properties properties, String propertyName) { + String propertyValue = url.getParameter(propertyName); + if (StringUtils.isNotEmpty(propertyValue)) { + properties.setProperty(propertyName, propertyValue); + } + } +} diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.RegistryFactory b/dubbo-registry/dubbo-registry-nacos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.RegistryFactory new file mode 100644 index 0000000000..bb75467497 --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.RegistryFactory @@ -0,0 +1 @@ +nacos=org.apache.dubbo.registry.nacos.NacosRegistryFactory \ No newline at end of file diff --git a/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/consumer/DemoServiceConsumerBootstrap.java b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/consumer/DemoServiceConsumerBootstrap.java new file mode 100644 index 0000000000..b411d4a80f --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/consumer/DemoServiceConsumerBootstrap.java @@ -0,0 +1,59 @@ +/* + * 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.demo.consumer; + +import org.apache.dubbo.config.annotation.Reference; +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; +import org.apache.dubbo.demo.service.DemoService; + +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.PropertySource; + +import javax.annotation.PostConstruct; +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +/** + * {@link DemoService} consumer demo + */ +@EnableDubbo +@PropertySource(value = "classpath:/consumer-config.properties") +public class DemoServiceConsumerBootstrap { + + @Reference(version = "${demo.service.version}") + private DemoService demoService; + + @Reference(version = "${demo.service.version}", protocol = "rest") + private DemoService restDemoService; + + @PostConstruct + public void init() throws InterruptedException { + for (int j = 0; j < 10; j++) { + System.out.println(demoService.sayName("小马哥(mercyblitz)")); + System.out.println(restDemoService.sayName("小马哥(mercyblitz)")); + } + Thread.sleep(TimeUnit.SECONDS.toMillis(5)); + } + + public static void main(String[] args) throws IOException { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); + context.register(DemoServiceConsumerBootstrap.class); + context.refresh(); + System.in.read(); + context.close(); + } +} diff --git a/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/consumer/DemoServiceConsumerXmlBootstrap.java b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/consumer/DemoServiceConsumerXmlBootstrap.java new file mode 100644 index 0000000000..cc25f8c135 --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/consumer/DemoServiceConsumerXmlBootstrap.java @@ -0,0 +1,42 @@ +/* + * 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.demo.consumer; + +import org.apache.dubbo.demo.service.DemoService; + +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import java.io.IOException; + +/** + * {@link DemoService} consumer demo XML bootstrap + */ +public class DemoServiceConsumerXmlBootstrap { + + public static void main(String[] args) throws IOException { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); + context.setConfigLocation("/META-INF/spring/dubbo-consumer-context.xml"); + context.refresh(); + System.out.println("DemoService consumer (XML) is starting..."); + DemoService demoService = context.getBean("demoService", DemoService.class); + for (int i = 0; i < 10; i++) { + System.out.println(demoService.sayName("小马哥(mercyblitz)")); + } + System.in.read(); + context.close(); + } +} diff --git a/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/provider/DemoServiceProviderBootstrap.java b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/provider/DemoServiceProviderBootstrap.java new file mode 100644 index 0000000000..c1d2ec4f0f --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/provider/DemoServiceProviderBootstrap.java @@ -0,0 +1,41 @@ +/* + * 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.demo.provider; + +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; +import org.apache.dubbo.demo.service.DemoService; + +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.PropertySource; + +import java.io.IOException; + +/** + * {@link DemoService} provider demo + */ +@EnableDubbo(scanBasePackages = "org.apache.dubbo.demo.service") +@PropertySource(value = "classpath:/provider-config.properties") +public class DemoServiceProviderBootstrap { + + public static void main(String[] args) throws IOException { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); + context.register(DemoServiceProviderBootstrap.class); + context.refresh(); + System.out.println("DemoService provider is starting..."); + System.in.read(); + } +} diff --git a/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/provider/DemoServiceProviderXmlBootstrap.java b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/provider/DemoServiceProviderXmlBootstrap.java new file mode 100644 index 0000000000..0a37f3fabe --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/provider/DemoServiceProviderXmlBootstrap.java @@ -0,0 +1,37 @@ +/* + * 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.demo.provider; + +import org.apache.dubbo.demo.service.DemoService; + +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import java.io.IOException; + +/** + * {@link DemoService} provider demo XML bootstrap + */ +public class DemoServiceProviderXmlBootstrap { + + public static void main(String[] args) throws IOException { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); + context.setConfigLocation("/META-INF/spring/dubbo-provider-context.xml"); + context.refresh(); + System.out.println("DemoService provider (XML) is starting..."); + System.in.read(); + } +} diff --git a/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/service/DefaultService.java b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/service/DefaultService.java new file mode 100644 index 0000000000..56393ef396 --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/service/DefaultService.java @@ -0,0 +1,46 @@ +/* + * 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.demo.service; + +import org.apache.dubbo.config.annotation.Service; +import org.apache.dubbo.rpc.RpcContext; + +import org.springframework.beans.factory.annotation.Value; + + +/** + * Default {@link DemoService} + * + * @since 2.6.5 + */ +@Service(version = "${demo.service.version}") +public class DefaultService implements DemoService { + + @Value("${demo.service.name}") + private String serviceName; + + public String sayName(String name) { + RpcContext rpcContext = RpcContext.getContext(); + return String.format("Service [name :%s , protocol: %s , port : %d] %s(\"%s\") : Hello,%s", + serviceName, + rpcContext.getUrl().getProtocol(), + rpcContext.getLocalPort(), + rpcContext.getMethodName(), + name, + name); + } +} diff --git a/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/service/DemoService.java b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/service/DemoService.java new file mode 100644 index 0000000000..0c80877931 --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/test/java/org/apache/dubbo/demo/service/DemoService.java @@ -0,0 +1,34 @@ +/* + * 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.demo.service; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +/** + * DemoService + * + * @since 2.6.5 + */ +@Path("/demo-service") +public interface DemoService { + + @GET + String sayName(@QueryParam("name") String name); + +} \ No newline at end of file diff --git a/dubbo-registry/dubbo-registry-nacos/src/test/resources/META-INF/spring/dubbo-consumer-context.xml b/dubbo-registry/dubbo-registry-nacos/src/test/resources/META-INF/spring/dubbo-consumer-context.xml new file mode 100644 index 0000000000..3fa32d77b5 --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/test/resources/META-INF/spring/dubbo-consumer-context.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/dubbo-registry/dubbo-registry-nacos/src/test/resources/META-INF/spring/dubbo-provider-context.xml b/dubbo-registry/dubbo-registry-nacos/src/test/resources/META-INF/spring/dubbo-provider-context.xml new file mode 100644 index 0000000000..36b1267ddb --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/test/resources/META-INF/spring/dubbo-provider-context.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dubbo-registry/dubbo-registry-nacos/src/test/resources/consumer-config.properties b/dubbo-registry/dubbo-registry-nacos/src/test/resources/consumer-config.properties new file mode 100644 index 0000000000..d32e6e8a64 --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/test/resources/consumer-config.properties @@ -0,0 +1,6 @@ +## Dubbo Application info +dubbo.application.name=dubbo-consumer-demo +## Nacos registry address +dubbo.registry.address=nacos://127.0.0.1:8848 +# @Reference version +demo.service.version=1.0.0 \ No newline at end of file diff --git a/dubbo-registry/dubbo-registry-nacos/src/test/resources/provider-config.properties b/dubbo-registry/dubbo-registry-nacos/src/test/resources/provider-config.properties new file mode 100644 index 0000000000..e2dd335b0e --- /dev/null +++ b/dubbo-registry/dubbo-registry-nacos/src/test/resources/provider-config.properties @@ -0,0 +1,14 @@ +## Dubbo Application info +dubbo.application.name=dubbo-provider-demo +## Nacos registry address +dubbo.registry.protocol=nacos +dubbo.registry.address=127.0.0.1:8848 +## Exports multiple protocols +### Dubbo Protocol using random port +dubbo.protocols.dubbo.port=-1 +### REST protocol +dubbo.protocols.rest.port=9090 +dubbo.protocols.rest.server=netty +# Provider @Service info +demo.service.version=1.0.0 +demo.service.name=demoService \ No newline at end of file diff --git a/dubbo-registry/dubbo-registry-redis/pom.xml b/dubbo-registry/dubbo-registry-redis/pom.xml index 7644e1ca85..816083f255 100644 --- a/dubbo-registry/dubbo-registry-redis/pom.xml +++ b/dubbo-registry/dubbo-registry-redis/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-registry - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-registry-redis jar diff --git a/dubbo-registry/dubbo-registry-zookeeper/pom.xml b/dubbo-registry/dubbo-registry-zookeeper/pom.xml index 2c565d8b1a..b6bc23710f 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/pom.xml +++ b/dubbo-registry/dubbo-registry-zookeeper/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-registry - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-registry-zookeeper jar diff --git a/dubbo-registry/pom.xml b/dubbo-registry/pom.xml index 33a329bb0f..f9161c64bf 100644 --- a/dubbo-registry/pom.xml +++ b/dubbo-registry/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-registry pom @@ -36,5 +36,6 @@ dubbo-registry-redis dubbo-registry-consul dubbo-registry-etcd3 + dubbo-registry-nacos diff --git a/dubbo-remoting/dubbo-remoting-api/pom.xml b/dubbo-remoting/dubbo-remoting-api/pom.xml index ec278e96e0..9f96912163 100644 --- a/dubbo-remoting/dubbo-remoting-api/pom.xml +++ b/dubbo-remoting/dubbo-remoting-api/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-remoting - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-remoting-api jar diff --git a/dubbo-remoting/dubbo-remoting-etcd3/pom.xml b/dubbo-remoting/dubbo-remoting-etcd3/pom.xml index 768052f6b1..eb133a1178 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/pom.xml +++ b/dubbo-remoting/dubbo-remoting-etcd3/pom.xml @@ -16,14 +16,12 @@ ~ limitations under the License. --> - + 4.0.0 dubbo-remoting org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-remoting-etcd3 jar diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java index b122f53b12..c7f472d401 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java @@ -550,7 +550,7 @@ public class JEtcdClientWrapper { try { cancelKeepAlive = true; - if (globalLeaseId != 0) { + if (globalLeaseId > 0) { revokeLease(this.globalLeaseId); } } catch (Exception e) { diff --git a/dubbo-remoting/dubbo-remoting-grizzly/pom.xml b/dubbo-remoting/dubbo-remoting-grizzly/pom.xml index f740422a7a..5e01ff37ed 100644 --- a/dubbo-remoting/dubbo-remoting-grizzly/pom.xml +++ b/dubbo-remoting/dubbo-remoting-grizzly/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-remoting - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-remoting-grizzly jar diff --git a/dubbo-remoting/dubbo-remoting-http/pom.xml b/dubbo-remoting/dubbo-remoting-http/pom.xml index 85ea81dff1..ecfb55e034 100644 --- a/dubbo-remoting/dubbo-remoting-http/pom.xml +++ b/dubbo-remoting/dubbo-remoting-http/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-remoting - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-remoting-http jar diff --git a/dubbo-remoting/dubbo-remoting-mina/pom.xml b/dubbo-remoting/dubbo-remoting-mina/pom.xml index a10aacc52d..2d7b2da175 100644 --- a/dubbo-remoting/dubbo-remoting-mina/pom.xml +++ b/dubbo-remoting/dubbo-remoting-mina/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-remoting - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-remoting-mina jar diff --git a/dubbo-remoting/dubbo-remoting-netty/pom.xml b/dubbo-remoting/dubbo-remoting-netty/pom.xml index cfa826279e..44ecba5e10 100644 --- a/dubbo-remoting/dubbo-remoting-netty/pom.xml +++ b/dubbo-remoting/dubbo-remoting-netty/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-remoting - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-remoting-netty jar diff --git a/dubbo-remoting/dubbo-remoting-netty4/pom.xml b/dubbo-remoting/dubbo-remoting-netty4/pom.xml index e17cfe185f..e565c28e3e 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/pom.xml +++ b/dubbo-remoting/dubbo-remoting-netty4/pom.xml @@ -18,7 +18,7 @@ dubbo-remoting org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-remoting/dubbo-remoting-p2p/pom.xml b/dubbo-remoting/dubbo-remoting-p2p/pom.xml index 238398e4a1..7f5d4f55b1 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/pom.xml +++ b/dubbo-remoting/dubbo-remoting-p2p/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-remoting - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-remoting-p2p jar diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml b/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml index 24b14e9bd7..864e88bc31 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml +++ b/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-remoting - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-remoting-zookeeper jar @@ -35,10 +35,12 @@ ${project.parent.version} - org.apache.dubbo - dubbo-dependencies-zookeeper - ${project.parent.version} - pom + org.apache.curator + curator-recipes + + + org.apache.zookeeper + zookeeper org.apache.curator diff --git a/dubbo-remoting/pom.xml b/dubbo-remoting/pom.xml index fd17dbf0cd..efa3a14f7b 100644 --- a/dubbo-remoting/pom.xml +++ b/dubbo-remoting/pom.xml @@ -20,7 +20,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-remoting pom diff --git a/dubbo-rpc/dubbo-rpc-api/pom.xml b/dubbo-rpc/dubbo-rpc-api/pom.xml index 06d17aec9e..91a6aa4a32 100644 --- a/dubbo-rpc/dubbo-rpc-api/pom.xml +++ b/dubbo-rpc/dubbo-rpc-api/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-rpc - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-rpc-api jar diff --git a/dubbo-rpc/dubbo-rpc-dubbo/pom.xml b/dubbo-rpc/dubbo-rpc-dubbo/pom.xml index 290f627b36..d93ad0942a 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/pom.xml +++ b/dubbo-rpc/dubbo-rpc-dubbo/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-rpc - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-rpc-dubbo jar diff --git a/dubbo-rpc/dubbo-rpc-hessian/pom.xml b/dubbo-rpc/dubbo-rpc-hessian/pom.xml index 0eed79d254..582c01aae0 100644 --- a/dubbo-rpc/dubbo-rpc-hessian/pom.xml +++ b/dubbo-rpc/dubbo-rpc-hessian/pom.xml @@ -1,62 +1,62 @@ - - - 4.0.0 - - org.apache.dubbo - dubbo-rpc - 2.7.1-SNAPSHOT - - dubbo-rpc-hessian - jar - ${project.artifactId} - The hessian rpc module of dubbo project - - false - - - - org.apache.dubbo - dubbo-rpc-api - ${project.parent.version} - - - org.apache.dubbo - dubbo-remoting-http - ${project.parent.version} - - - com.caucho - hessian - - - org.apache.httpcomponents - httpclient - - - org.apache.dubbo - dubbo-serialization-jdk - ${project.parent.version} - test - - - org.springframework - spring-test - test - - + + + 4.0.0 + + org.apache.dubbo + dubbo-rpc + 2.7.2-SNAPSHOT + + dubbo-rpc-hessian + jar + ${project.artifactId} + The hessian rpc module of dubbo project + + false + + + + org.apache.dubbo + dubbo-rpc-api + ${project.parent.version} + + + org.apache.dubbo + dubbo-remoting-http + ${project.parent.version} + + + com.caucho + hessian + + + org.apache.httpcomponents + httpclient + + + org.apache.dubbo + dubbo-serialization-jdk + ${project.parent.version} + test + + + org.springframework + spring-test + test + + \ No newline at end of file diff --git a/dubbo-rpc/dubbo-rpc-http/pom.xml b/dubbo-rpc/dubbo-rpc-http/pom.xml index 5ab4d25d15..1cff7cf084 100644 --- a/dubbo-rpc/dubbo-rpc-http/pom.xml +++ b/dubbo-rpc/dubbo-rpc-http/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-rpc - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-rpc-http jar diff --git a/dubbo-rpc/dubbo-rpc-injvm/pom.xml b/dubbo-rpc/dubbo-rpc-injvm/pom.xml index 9a3de8e080..3e266f5f4f 100644 --- a/dubbo-rpc/dubbo-rpc-injvm/pom.xml +++ b/dubbo-rpc/dubbo-rpc-injvm/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-rpc - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-rpc-injvm jar diff --git a/dubbo-rpc/dubbo-rpc-memcached/pom.xml b/dubbo-rpc/dubbo-rpc-memcached/pom.xml index 6544e9c9a1..156f48d5fc 100644 --- a/dubbo-rpc/dubbo-rpc-memcached/pom.xml +++ b/dubbo-rpc/dubbo-rpc-memcached/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-rpc - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-rpc-memcached jar diff --git a/dubbo-rpc/dubbo-rpc-redis/pom.xml b/dubbo-rpc/dubbo-rpc-redis/pom.xml index 056b901397..4fe00c0be3 100644 --- a/dubbo-rpc/dubbo-rpc-redis/pom.xml +++ b/dubbo-rpc/dubbo-rpc-redis/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-rpc - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-rpc-redis jar diff --git a/dubbo-rpc/dubbo-rpc-rest/pom.xml b/dubbo-rpc/dubbo-rpc-rest/pom.xml index 126b26d3a0..ab2c758faf 100644 --- a/dubbo-rpc/dubbo-rpc-rest/pom.xml +++ b/dubbo-rpc/dubbo-rpc-rest/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-rpc - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-rpc-rest jar diff --git a/dubbo-rpc/dubbo-rpc-rmi/pom.xml b/dubbo-rpc/dubbo-rpc-rmi/pom.xml index bb5efb4ed3..6a096a3c58 100644 --- a/dubbo-rpc/dubbo-rpc-rmi/pom.xml +++ b/dubbo-rpc/dubbo-rpc-rmi/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-rpc - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-rpc-rmi jar diff --git a/dubbo-rpc/dubbo-rpc-thrift/pom.xml b/dubbo-rpc/dubbo-rpc-thrift/pom.xml index 5e106b2ba3..49633e2d56 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/pom.xml +++ b/dubbo-rpc/dubbo-rpc-thrift/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-rpc - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-rpc-thrift jar diff --git a/dubbo-rpc/dubbo-rpc-webservice/pom.xml b/dubbo-rpc/dubbo-rpc-webservice/pom.xml index a859b58546..96986ddd13 100644 --- a/dubbo-rpc/dubbo-rpc-webservice/pom.xml +++ b/dubbo-rpc/dubbo-rpc-webservice/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-rpc - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-rpc-webservice jar diff --git a/dubbo-rpc/pom.xml b/dubbo-rpc/pom.xml index 03e5b9abf4..dfd9be38c8 100644 --- a/dubbo-rpc/pom.xml +++ b/dubbo-rpc/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-rpc pom diff --git a/dubbo-serialization/dubbo-serialization-api/pom.xml b/dubbo-serialization/dubbo-serialization-api/pom.xml index cd1ff42939..ec217323e4 100644 --- a/dubbo-serialization/dubbo-serialization-api/pom.xml +++ b/dubbo-serialization/dubbo-serialization-api/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.apache.dubbo dubbo-serialization - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-serialization-api jar diff --git a/dubbo-serialization/dubbo-serialization-fastjson/pom.xml b/dubbo-serialization/dubbo-serialization-fastjson/pom.xml index 92dbbec882..cb9435c06e 100644 --- a/dubbo-serialization/dubbo-serialization-fastjson/pom.xml +++ b/dubbo-serialization/dubbo-serialization-fastjson/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.apache.dubbo dubbo-serialization - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-serialization-fastjson jar diff --git a/dubbo-serialization/dubbo-serialization-fst/pom.xml b/dubbo-serialization/dubbo-serialization-fst/pom.xml index 4332453a90..781d79c0d4 100644 --- a/dubbo-serialization/dubbo-serialization-fst/pom.xml +++ b/dubbo-serialization/dubbo-serialization-fst/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-serialization - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-serialization-fst jar diff --git a/dubbo-serialization/dubbo-serialization-hessian2/pom.xml b/dubbo-serialization/dubbo-serialization-hessian2/pom.xml index b5ba85a295..88ee9b9365 100644 --- a/dubbo-serialization/dubbo-serialization-hessian2/pom.xml +++ b/dubbo-serialization/dubbo-serialization-hessian2/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.apache.dubbo dubbo-serialization - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-serialization-hessian2 jar diff --git a/dubbo-serialization/dubbo-serialization-jdk/pom.xml b/dubbo-serialization/dubbo-serialization-jdk/pom.xml index 1f78b9a9c1..51bc49484a 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/pom.xml +++ b/dubbo-serialization/dubbo-serialization-jdk/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.apache.dubbo dubbo-serialization - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-serialization-jdk jar diff --git a/dubbo-serialization/dubbo-serialization-kryo/pom.xml b/dubbo-serialization/dubbo-serialization-kryo/pom.xml index 4ebf59bea3..3d5b022ce5 100644 --- a/dubbo-serialization/dubbo-serialization-kryo/pom.xml +++ b/dubbo-serialization/dubbo-serialization-kryo/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.apache.dubbo dubbo-serialization - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-serialization-kryo jar diff --git a/dubbo-serialization/dubbo-serialization-protostuff/pom.xml b/dubbo-serialization/dubbo-serialization-protostuff/pom.xml index ab3a2a5f39..37d2d55ef3 100644 --- a/dubbo-serialization/dubbo-serialization-protostuff/pom.xml +++ b/dubbo-serialization/dubbo-serialization-protostuff/pom.xml @@ -20,7 +20,7 @@ limitations under the License. dubbo-serialization org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-serialization-protostuff diff --git a/dubbo-serialization/dubbo-serialization-test/pom.xml b/dubbo-serialization/dubbo-serialization-test/pom.xml index 392dc335d7..32e98196aa 100644 --- a/dubbo-serialization/dubbo-serialization-test/pom.xml +++ b/dubbo-serialization/dubbo-serialization-test/pom.xml @@ -19,7 +19,7 @@ dubbo-serialization org.apache.dubbo - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT 4.0.0 diff --git a/dubbo-serialization/pom.xml b/dubbo-serialization/pom.xml index 9cfb7d72da..e6fcd52a61 100644 --- a/dubbo-serialization/pom.xml +++ b/dubbo-serialization/pom.xml @@ -19,7 +19,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT dubbo-serialization pom diff --git a/pom.xml b/pom.xml index 6220d015df..eff466e8fe 100644 --- a/pom.xml +++ b/pom.xml @@ -14,8 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 @@ -27,7 +26,7 @@ org.apache.dubbo dubbo-parent - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT pom ${project.artifactId} @@ -121,7 +120,7 @@ 3.0.0 0.8.2 0.12 - + true true @@ -154,7 +153,7 @@ org.apache.dubbo dubbo-dependencies-bom - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT pom import