From b82e34a58872c9df5dd655f367439608fb57839e Mon Sep 17 00:00:00 2001 From: javahongxi Date: Sat, 8 Jun 2019 16:28:45 +0800 Subject: [PATCH] upgrade dubbo to 2.7.2 --- README.md | 2 +- pom.xml | 2 +- .../DelegatingPropertyResolver.java | 83 ++ .../autoconfigure/DubboAutoConfiguration.java | 58 +- .../DubboConfigurationProperties.java | 300 +++++ .../DubboRelaxedBindingAutoConfiguration.java | 53 + .../RelaxedDubboConfigBinder.java | 6 +- ...ConfigBeanDefinitionConflictProcessor.java | 120 ++ .../DubboApplicationContextInitializer.java | 46 + .../AwaitingNonWebApplicationListener.java | 46 +- ...verrideDubboConfigApplicationListener.java | 17 +- .../event/WelcomeLogoApplicationListener.java | 9 +- ...ultPropertiesEnvironmentPostProcessor.java | 52 +- .../dubbo/spring/starter/util/DubboUtils.java | 83 +- .../spring/starter/util/EnvironmentUtils.java | 2 +- .../spring-configuration-metadata.json | 1098 ----------------- .../main/resources/META-INF/spring.factories | 6 +- .../demo/consumer/ConsumerApplication.java | 7 +- .../dubbo/demo/consumer/rpc/DemoRpc.java | 4 +- .../dubbo/demo/consumer/AsyncConsumer2.java | 14 +- .../demo/provider/ProviderApplication.java | 2 +- 21 files changed, 787 insertions(+), 1223 deletions(-) create mode 100644 whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DelegatingPropertyResolver.java create mode 100644 whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboConfigurationProperties.java create mode 100644 whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboRelaxedBindingAutoConfiguration.java create mode 100644 whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/beans/factory/config/DubboConfigBeanDefinitionConflictProcessor.java create mode 100644 whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/DubboApplicationContextInitializer.java delete mode 100644 whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring-configuration-metadata.json diff --git a/README.md b/README.md index 586dd738..53a52021 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ whatsmars-spring-cloud | Spring Cloud 微服务生态 whatsmars-zk | zookeeper remoting 封装 ### Rocket Stack -- [x] [*Dubbo*](https://github.com/alibaba/dubbo) +- [x] [*Dubbo*](https://github.com/apache/dubbo) - [x] [*ZooKeeper*](https://github.com/apache/zookeeper) - [x] [*RocketMQ*](https://github.com/apache/rocketmq) - [x] [*Kafka*](https://github.com/apache/kafka) diff --git a/pom.xml b/pom.xml index 176bce3c..c363d0ff 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ 2.6 1.2 2.12.0 - 2.7.0 + 2.7.2 1.2.44 20.0 4.0.7 diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DelegatingPropertyResolver.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DelegatingPropertyResolver.java new file mode 100644 index 00000000..f48f1624 --- /dev/null +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DelegatingPropertyResolver.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.spring.starter.autoconfigure; + +import org.apache.dubbo.common.utils.Assert; +import org.springframework.core.env.PropertyResolver; +import org.springframework.lang.Nullable; + +/** + * Delegating {@link PropertyResolver} + * + * @since 2.7.1 + */ +class DelegatingPropertyResolver implements PropertyResolver { + + private final PropertyResolver delegate; + + DelegatingPropertyResolver(PropertyResolver delegate) { + Assert.notNull(delegate, "The delegate of PropertyResolver must not be null"); + this.delegate = delegate; + } + + @Override + public boolean containsProperty(String key) { + return delegate.containsProperty(key); + } + + @Override + @Nullable + public String getProperty(String key) { + return delegate.getProperty(key); + } + + @Override + public String getProperty(String key, String defaultValue) { + return delegate.getProperty(key, defaultValue); + } + + @Override + @Nullable + public T getProperty(String key, Class targetType) { + return delegate.getProperty(key, targetType); + } + + @Override + public T getProperty(String key, Class targetType, T defaultValue) { + return delegate.getProperty(key, targetType, defaultValue); + } + + @Override + public String getRequiredProperty(String key) throws IllegalStateException { + return delegate.getRequiredProperty(key); + } + + @Override + public T getRequiredProperty(String key, Class targetType) throws IllegalStateException { + return delegate.getRequiredProperty(key, targetType); + } + + @Override + public String resolvePlaceholders(String text) { + return delegate.resolvePlaceholders(text); + } + + @Override + public String resolveRequiredPlaceholders(String text) throws IllegalArgumentException { + return delegate.resolveRequiredPlaceholders(text); + } +} \ No newline at end of file diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboAutoConfiguration.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboAutoConfiguration.java index 4745d9db..df46a806 100644 --- a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboAutoConfiguration.java +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboAutoConfiguration.java @@ -16,69 +16,59 @@ */ package org.apache.dubbo.spring.starter.autoconfigure; -import org.apache.dubbo.config.AbstractConfig; -import org.apache.dubbo.config.ApplicationConfig; import org.apache.dubbo.config.annotation.Reference; import org.apache.dubbo.config.annotation.Service; import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor; -import org.apache.dubbo.config.spring.context.annotation.DubboComponentScan; import org.apache.dubbo.config.spring.context.annotation.DubboConfigConfiguration; -import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.bind.Binder; -import org.springframework.boot.context.properties.source.ConfigurationPropertySources; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Scope; -import org.springframework.core.env.Environment; +import org.springframework.context.annotation.Import; +import org.springframework.core.env.PropertyResolver; import java.util.Set; -import static org.apache.dubbo.spring.starter.util.DubboUtils.*; import static java.util.Collections.emptySet; -import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE; +import static org.apache.dubbo.spring.starter.util.DubboUtils.*; /** * Dubbo Auto {@link Configuration} * - * @see ApplicationConfig - * @see Service * @see Reference - * @see DubboComponentScan - * @see EnableDubboConfig - * @see EnableDubbo - * @since 1.0.0 + * @see Service + * @see ServiceAnnotationBeanPostProcessor + * @see ReferenceAnnotationBeanPostProcessor + * @since 2.7.0 */ +@ConditionalOnProperty(prefix = DUBBO_PREFIX, name = "enabled", matchIfMissing = true) @Configuration -@ConditionalOnProperty(prefix = DUBBO_PREFIX, name = "enabled", matchIfMissing = true, havingValue = "true") -@ConditionalOnClass(AbstractConfig.class) +@AutoConfigureAfter(DubboRelaxedBindingAutoConfiguration.class) +@EnableConfigurationProperties(DubboConfigurationProperties.class) public class DubboAutoConfiguration { /** * Creates {@link ServiceAnnotationBeanPostProcessor} Bean * - * @param environment {@link Environment} Bean + * @param propertyResolver {@link PropertyResolver} Bean * @return {@link ServiceAnnotationBeanPostProcessor} */ - @ConditionalOnProperty(name = BASE_PACKAGES_PROPERTY_NAME) - @ConditionalOnClass(ConfigurationPropertySources.class) + @ConditionalOnProperty(prefix = DUBBO_SCAN_PREFIX, name = BASE_PACKAGES_PROPERTY_NAME) + @ConditionalOnBean(name = BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME) @Bean - public ServiceAnnotationBeanPostProcessor serviceAnnotationBeanPostProcessor(Environment environment) { - Set packagesToScan = environment.getProperty(BASE_PACKAGES_PROPERTY_NAME, Set.class, emptySet()); + public ServiceAnnotationBeanPostProcessor serviceAnnotationBeanPostProcessor( + @Qualifier(BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME) PropertyResolver propertyResolver) { + Set packagesToScan = propertyResolver.getProperty(BASE_PACKAGES_PROPERTY_NAME, Set.class, emptySet()); return new ServiceAnnotationBeanPostProcessor(packagesToScan); } - @ConditionalOnClass(Binder.class) - @Bean - @Scope(scopeName = SCOPE_PROTOTYPE) - public RelaxedDubboConfigBinder relaxedDubboConfigBinder() { - return new RelaxedDubboConfigBinder(); - } - /** * Creates {@link ReferenceAnnotationBeanPostProcessor} Bean if Absent * @@ -96,7 +86,7 @@ public class DubboAutoConfiguration { * @see EnableDubboConfig * @see DubboConfigConfiguration.Single */ - @EnableDubboConfig + @Import(DubboConfigConfiguration.Single.class) protected static class SingleDubboConfigConfiguration { } @@ -106,8 +96,8 @@ public class DubboAutoConfiguration { * @see EnableDubboConfig * @see DubboConfigConfiguration.Multiple */ - @ConditionalOnProperty(name = MULTIPLE_CONFIG_PROPERTY_NAME, havingValue = "true") - @EnableDubboConfig(multiple = true) + @ConditionalOnProperty(prefix = DUBBO_CONFIG_PREFIX, name = MULTIPLE_CONFIG_PROPERTY_NAME, matchIfMissing = true) + @Import(DubboConfigConfiguration.Multiple.class) protected static class MultipleDubboConfigConfiguration { } diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboConfigurationProperties.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboConfigurationProperties.java new file mode 100644 index 00000000..731eaa15 --- /dev/null +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboConfigurationProperties.java @@ -0,0 +1,300 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.starter.autoconfigure; + +import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.ConsumerConfig; +import org.apache.dubbo.config.MetadataReportConfig; +import org.apache.dubbo.config.ModuleConfig; +import org.apache.dubbo.config.MonitorConfig; +import org.apache.dubbo.config.ProtocolConfig; +import org.apache.dubbo.config.ProviderConfig; +import org.apache.dubbo.config.RegistryConfig; +import org.apache.dubbo.config.spring.ConfigCenterBean; +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import static org.apache.dubbo.spring.starter.util.DubboUtils.DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE; +import static org.apache.dubbo.spring.starter.util.DubboUtils.DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE; +import static org.apache.dubbo.spring.starter.util.DubboUtils.DUBBO_PREFIX; + +/** + * Dubbo {@link ConfigurationProperties Config Properties} only used to generate JSON metadata(non-public class) + * + * @since 2.7.1 + */ +@ConfigurationProperties(DUBBO_PREFIX) +class DubboConfigurationProperties { + + @NestedConfigurationProperty + private Config config = new Config(); + + @NestedConfigurationProperty + private Scan scan = new Scan(); + + // Single Config Bindings + @NestedConfigurationProperty + private ApplicationConfig application = new ApplicationConfig(); + + @NestedConfigurationProperty + private ModuleConfig module = new ModuleConfig(); + + @NestedConfigurationProperty + private RegistryConfig registry = new RegistryConfig(); + + @NestedConfigurationProperty + private ProtocolConfig protocol = new ProtocolConfig(); + + @NestedConfigurationProperty + private MonitorConfig monitor = new MonitorConfig(); + + @NestedConfigurationProperty + private ProviderConfig provider = new ProviderConfig(); + + @NestedConfigurationProperty + private ConsumerConfig consumer = new ConsumerConfig(); + + @NestedConfigurationProperty + private ConfigCenterBean configCenter = new ConfigCenterBean(); + + @NestedConfigurationProperty + private MetadataReportConfig metadataReport = new MetadataReportConfig(); + + // Multiple Config Bindings + + private Map modules = new LinkedHashMap<>(); + + private Map registrys = new LinkedHashMap<>(); + + private Map protocols = new LinkedHashMap<>(); + + private Map monitors = new LinkedHashMap<>(); + + private Map providers = new LinkedHashMap<>(); + + private Map consumers = new LinkedHashMap<>(); + + private Map configCenters = new LinkedHashMap<>(); + + private Map metadataReports = new LinkedHashMap<>(); + + public Config getConfig() { + return config; + } + + public void setConfig(Config config) { + this.config = config; + } + + public Scan getScan() { + return scan; + } + + public void setScan(Scan scan) { + this.scan = scan; + } + + public ApplicationConfig getApplication() { + return application; + } + + public void setApplication(ApplicationConfig application) { + this.application = application; + } + + public ModuleConfig getModule() { + return module; + } + + public void setModule(ModuleConfig module) { + this.module = module; + } + + public RegistryConfig getRegistry() { + return registry; + } + + public void setRegistry(RegistryConfig registry) { + this.registry = registry; + } + + public ProtocolConfig getProtocol() { + return protocol; + } + + public void setProtocol(ProtocolConfig protocol) { + this.protocol = protocol; + } + + public MonitorConfig getMonitor() { + return monitor; + } + + public void setMonitor(MonitorConfig monitor) { + this.monitor = monitor; + } + + public ProviderConfig getProvider() { + return provider; + } + + public void setProvider(ProviderConfig provider) { + this.provider = provider; + } + + public ConsumerConfig getConsumer() { + return consumer; + } + + public void setConsumer(ConsumerConfig consumer) { + this.consumer = consumer; + } + + public ConfigCenterBean getConfigCenter() { + return configCenter; + } + + public void setConfigCenter(ConfigCenterBean configCenter) { + this.configCenter = configCenter; + } + + public MetadataReportConfig getMetadataReport() { + return metadataReport; + } + + public void setMetadataReport(MetadataReportConfig metadataReport) { + this.metadataReport = metadataReport; + } + + public Map getModules() { + return modules; + } + + public void setModules(Map modules) { + this.modules = modules; + } + + public Map getRegistrys() { + return registrys; + } + + public void setRegistrys(Map registrys) { + this.registrys = registrys; + } + + public Map getProtocols() { + return protocols; + } + + public void setProtocols(Map protocols) { + this.protocols = protocols; + } + + public Map getMonitors() { + return monitors; + } + + public void setMonitors(Map monitors) { + this.monitors = monitors; + } + + public Map getProviders() { + return providers; + } + + public void setProviders(Map providers) { + this.providers = providers; + } + + public Map getConsumers() { + return consumers; + } + + public void setConsumers(Map consumers) { + this.consumers = consumers; + } + + public Map getConfigCenters() { + return configCenters; + } + + public void setConfigCenters(Map configCenters) { + this.configCenters = configCenters; + } + + public Map getMetadataReports() { + return metadataReports; + } + + public void setMetadataReports(Map metadataReports) { + this.metadataReports = metadataReports; + } + + static class Config { + + /** + * Indicates multiple properties binding from externalized configuration or not. + */ + private boolean multiple = DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE; + + /** + * The property name of override Dubbo config + */ + private boolean override = DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE; + + public boolean isOverride() { + return override; + } + + public void setOverride(boolean override) { + this.override = override; + } + + public boolean isMultiple() { + return multiple; + } + + public void setMultiple(boolean multiple) { + this.multiple = multiple; + } + } + + static class Scan { + + /** + * The basePackages to scan , the multiple-value is delimited by comma + * + * @see EnableDubbo#scanBasePackages() + */ + private Set basePackages = new LinkedHashSet<>(); + + public Set getBasePackages() { + return basePackages; + } + + public void setBasePackages(Set basePackages) { + this.basePackages = basePackages; + } + } +} \ No newline at end of file diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboRelaxedBindingAutoConfiguration.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboRelaxedBindingAutoConfiguration.java new file mode 100644 index 00000000..d8cd7216 --- /dev/null +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboRelaxedBindingAutoConfiguration.java @@ -0,0 +1,53 @@ +package org.apache.dubbo.spring.starter.autoconfigure; + +import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; +import org.apache.dubbo.config.spring.util.PropertySourcesUtils; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.source.ConfigurationPropertySources; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; +import org.springframework.core.env.AbstractEnvironment; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.MutablePropertySources; +import org.springframework.core.env.PropertyResolver; + +import java.util.Map; + +import static org.apache.dubbo.spring.starter.util.DubboUtils.*; +import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE; + +/** + * Dubbo Relaxed Binding Auto-{@link Configuration} for Spring Boot 2.0 + * + * @since 2.7.0 + */ +@Configuration +@ConditionalOnProperty(prefix = DUBBO_PREFIX, name = "enabled", matchIfMissing = true) +@ConditionalOnClass(name = "org.springframework.boot.context.properties.bind.Binder") +public class DubboRelaxedBindingAutoConfiguration { + + @Bean(name = BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME) + public PropertyResolver dubboScanBasePackagesPropertyResolver(ConfigurableEnvironment environment) { + ConfigurableEnvironment propertyResolver = new AbstractEnvironment() { + @Override + protected void customizePropertySources(MutablePropertySources propertySources) { + Map dubboScanProperties = PropertySourcesUtils.getSubProperties(environment, DUBBO_SCAN_PREFIX); + propertySources.addLast(new MapPropertySource("dubboScanProperties", dubboScanProperties)); + } + }; + ConfigurationPropertySources.attach(propertyResolver); + return new DelegatingPropertyResolver(propertyResolver); + } + + @ConditionalOnMissingBean(name = RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME, value = DubboConfigBinder.class) + @Bean(RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME) + @Scope(scopeName = SCOPE_PROTOTYPE) + public DubboConfigBinder relaxedDubboConfigBinder() { + return new RelaxedDubboConfigBinder(); + } + +} \ No newline at end of file diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/RelaxedDubboConfigBinder.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/RelaxedDubboConfigBinder.java index f31c157b..43965f14 100644 --- a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/RelaxedDubboConfigBinder.java +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/RelaxedDubboConfigBinder.java @@ -35,9 +35,9 @@ import static org.springframework.boot.context.properties.source.ConfigurationPr * Spring Boot Relaxed {@link DubboConfigBinder} implementation * see org.springframework.boot.context.properties.ConfigurationPropertiesBinder * - * @since 0.1.1 + * @since 2.7.0 */ -public class RelaxedDubboConfigBinder extends AbstractDubboConfigBinder { +class RelaxedDubboConfigBinder extends AbstractDubboConfigBinder { @Override public void bind(String prefix, C dubboConfig) { @@ -71,4 +71,4 @@ public class RelaxedDubboConfigBinder extends AbstractDubboConfigBinder { } return handler; } -} +} \ No newline at end of file diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/beans/factory/config/DubboConfigBeanDefinitionConflictProcessor.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/beans/factory/config/DubboConfigBeanDefinitionConflictProcessor.java new file mode 100644 index 00000000..a13020e5 --- /dev/null +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/beans/factory/config/DubboConfigBeanDefinitionConflictProcessor.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.starter.beans.factory.config; + +import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.BeanFactoryUtils; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; +import org.springframework.core.Ordered; +import org.springframework.core.env.Environment; + +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors; +import static org.springframework.context.ConfigurableApplicationContext.ENVIRONMENT_BEAN_NAME; + +/** + * Dubbo Config {@link BeanDefinition Bean Definition} {@link BeanDefinitionRegistryPostProcessor processor} + * to resolve conflict + * + * @see BeanDefinition + * @see BeanDefinitionRegistryPostProcessor + * @since 2.7.1 + */ +public class DubboConfigBeanDefinitionConflictProcessor implements BeanDefinitionRegistryPostProcessor, Ordered { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private BeanDefinitionRegistry registry; + + private Environment environment; + + @Override + public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { + this.registry = registry; + } + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { + resolveUniqueApplicationConfigBean(registry, beanFactory); + } + + /** + * Resolve the unique {@link ApplicationConfig} Bean + * + * @param registry {@link BeanDefinitionRegistry} instance + * @param beanFactory {@link ConfigurableListableBeanFactory} instance + * @see EnableDubboConfig + */ + private void resolveUniqueApplicationConfigBean(BeanDefinitionRegistry registry, + ConfigurableListableBeanFactory beanFactory) { + + this.environment = beanFactory.getBean(ENVIRONMENT_BEAN_NAME, Environment.class); + + String[] beansNames = beanNamesForTypeIncludingAncestors(beanFactory, ApplicationConfig.class); + + if (beansNames.length < 2) { // If the number of ApplicationConfig beans is less than two, return immediately. + return; + } + + // Remove ApplicationConfig Beans that are configured by "dubbo.application.*" + Stream.of(beansNames) + .filter(this::isConfiguredApplicationConfigBeanName) + .forEach(registry::removeBeanDefinition); + + beansNames = beanNamesForTypeIncludingAncestors(beanFactory, ApplicationConfig.class); + + if (beansNames.length > 1) { + throw new IllegalStateException(String.format("There are more than one instances of %s, whose bean definitions : %s", + ApplicationConfig.class.getSimpleName(), + Stream.of(beansNames) + .map(registry::getBeanDefinition) + .collect(Collectors.toList())) + ); + } + } + + private boolean isConfiguredApplicationConfigBeanName(String beanName) { + boolean removed = BeanFactoryUtils.isGeneratedBeanName(beanName) + // Dubbo ApplicationConfig id as bean name + || Objects.equals(beanName, environment.getProperty("dubbo.application.id")); + + if (removed) { + if (logger.isWarnEnabled()) { + logger.warn("The {} bean [ name : {} ] has been removed!", ApplicationConfig.class.getSimpleName(), beanName); + } + } + + return removed; + } + + + @Override + public int getOrder() { + return LOWEST_PRECEDENCE; + } +} \ No newline at end of file diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/DubboApplicationContextInitializer.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/DubboApplicationContextInitializer.java new file mode 100644 index 00000000..0eb57771 --- /dev/null +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/DubboApplicationContextInitializer.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.spring.starter.context; + +import org.apache.dubbo.spring.starter.beans.factory.config.DubboConfigBeanDefinitionConflictProcessor; +import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.Ordered; + +/** + * Dubbo {@link ApplicationContextInitializer} implementation + * + * @see ApplicationContextInitializer + * @since 2.7.1 + */ +public class DubboApplicationContextInitializer implements ApplicationContextInitializer, Ordered { + + @Override + public void initialize(ConfigurableApplicationContext applicationContext) { + overrideBeanDefinitions(applicationContext); + } + + private void overrideBeanDefinitions(ConfigurableApplicationContext applicationContext) { + applicationContext.addBeanFactoryPostProcessor(new DubboConfigBeanDefinitionConflictProcessor()); + } + + @Override + public int getOrder() { + return HIGHEST_PRECEDENCE; + } + +} \ No newline at end of file diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/AwaitingNonWebApplicationListener.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/AwaitingNonWebApplicationListener.java index bd1726af..a68c741f 100644 --- a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/AwaitingNonWebApplicationListener.java +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/AwaitingNonWebApplicationListener.java @@ -19,12 +19,13 @@ package org.apache.dubbo.spring.starter.context.event; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; -import org.springframework.boot.WebApplicationType; import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextClosedEvent; import org.springframework.context.event.SmartApplicationListener; +import org.springframework.util.ClassUtils; import org.springframework.util.ObjectUtils; import java.util.concurrent.ExecutorService; @@ -37,10 +38,15 @@ import java.util.concurrent.locks.ReentrantLock; /** * Awaiting Non-Web Spring Boot {@link ApplicationListener} * - * @since 0.1.1 + * @since 2.7.0 */ public class AwaitingNonWebApplicationListener implements SmartApplicationListener { + private static final String[] WEB_APPLICATION_CONTEXT_CLASSES = new String[]{ + "org.springframework.web.context.WebApplicationContext", + "org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext" + }; + private static final Logger logger = LoggerFactory.getLogger(AwaitingNonWebApplicationListener.class); private static final Class[] SUPPORTED_APPLICATION_EVENTS = @@ -54,6 +60,14 @@ public class AwaitingNonWebApplicationListener implements SmartApplicationListen private final ExecutorService executorService = Executors.newSingleThreadExecutor(); + private static T[] of(T... values) { + return values; + } + + static AtomicBoolean getAwaited() { + return awaited; + } + @Override public boolean supportsEventType(Class eventType) { return ObjectUtils.containsElement(SUPPORTED_APPLICATION_EVENTS, eventType); @@ -64,10 +78,6 @@ public class AwaitingNonWebApplicationListener implements SmartApplicationListen return true; } - private static T[] of(T... values) { - return values; - } - @Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ApplicationReadyEvent) { @@ -86,12 +96,30 @@ public class AwaitingNonWebApplicationListener implements SmartApplicationListen final SpringApplication springApplication = event.getSpringApplication(); - if (!WebApplicationType.NONE.equals(springApplication.getWebApplicationType())) { + if (isWebApplication(event.getApplicationContext(), springApplication.getClassLoader())) { return; } await(); + } + + private static boolean isWebApplication(ApplicationContext applicationContext, ClassLoader classLoader) { + boolean webApplication = false; + for (String contextClass : WEB_APPLICATION_CONTEXT_CLASSES) { + if (isAssignable(contextClass, applicationContext.getClass(), classLoader)) { + webApplication = true; + break; + } + } + return webApplication; + } + private static boolean isAssignable(String target, Class type, ClassLoader classLoader) { + try { + return ClassUtils.resolveClassName(target, classLoader).isAssignableFrom(type); + } catch (Throwable ex) { + return false; + } } protected void onContextClosedEvent(ContextClosedEvent event) { @@ -146,8 +174,4 @@ public class AwaitingNonWebApplicationListener implements SmartApplicationListen lock.unlock(); } } - - static AtomicBoolean getAwaited() { - return awaited; - } } diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/OverrideDubboConfigApplicationListener.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/OverrideDubboConfigApplicationListener.java index 9f25d255..35fd3fec 100644 --- a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/OverrideDubboConfigApplicationListener.java +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/OverrideDubboConfigApplicationListener.java @@ -28,7 +28,9 @@ import org.springframework.core.env.Environment; import java.util.SortedMap; -import static org.apache.dubbo.spring.starter.util.DubboUtils.*; +import static org.apache.dubbo.spring.starter.util.DubboUtils.DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE; +import static org.apache.dubbo.spring.starter.util.DubboUtils.OVERRIDE_CONFIG_FULL_PROPERTY_NAME; +import static org.apache.dubbo.spring.starter.util.DubboUtils.filterDubboProperties; /** * {@link ApplicationListener} to override the dubbo properties from {@link Environment}into @@ -37,7 +39,7 @@ import static org.apache.dubbo.spring.starter.util.DubboUtils.*; *

* * @see ConfigUtils - * @since 1.0.0 + * @since 2.7.0 */ @Order // LOWEST_PRECEDENCE Make sure last execution public class OverrideDubboConfigApplicationListener implements ApplicationListener { @@ -53,7 +55,7 @@ public class OverrideDubboConfigApplicationListener implements ApplicationListen ConfigurableEnvironment environment = event.getEnvironment(); - boolean override = environment.getProperty(OVERRIDE_CONFIG_PROPERTY_NAME, boolean.class, + boolean override = environment.getProperty(OVERRIDE_CONFIG_FULL_PROPERTY_NAME, boolean.class, DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE); if (override) { @@ -63,19 +65,12 @@ public class OverrideDubboConfigApplicationListener implements ApplicationListen ConfigUtils.getProperties().putAll(dubboProperties); if (logger.isInfoEnabled()) { - logger.info("Dubbo Config was overridden by externalized configuration {}", dubboProperties); - } - } else { - if (logger.isInfoEnabled()) { - - logger.info("Disable override Dubbo Config caused by property {} = {}", OVERRIDE_CONFIG_PROPERTY_NAME, override); - + logger.info("Disable override Dubbo Config caused by property {} = {}", OVERRIDE_CONFIG_FULL_PROPERTY_NAME, override); } - } } diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/WelcomeLogoApplicationListener.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/WelcomeLogoApplicationListener.java index af70328f..a17ced23 100644 --- a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/WelcomeLogoApplicationListener.java +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/WelcomeLogoApplicationListener.java @@ -17,11 +17,12 @@ package org.apache.dubbo.spring.starter.context.event; import org.apache.dubbo.common.Version; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; -import org.springframework.boot.context.logging.LoggingApplicationListener; import org.springframework.context.ApplicationListener; +import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import java.util.concurrent.atomic.AtomicBoolean; @@ -32,9 +33,9 @@ import static org.apache.dubbo.spring.starter.util.DubboUtils.*; * Dubbo Welcome Logo {@link ApplicationListener} * * @see ApplicationListener - * @since 1.0.0 + * @since 2.7.0 */ -@Order(LoggingApplicationListener.DEFAULT_ORDER + 1) +@Order(Ordered.HIGHEST_PRECEDENCE + 20 + 1) // After LoggingApplicationListener#DEFAULT_ORDER public class WelcomeLogoApplicationListener implements ApplicationListener { private static AtomicBoolean processed = new AtomicBoolean(false); @@ -72,7 +73,7 @@ public class WelcomeLogoApplicationListener implements ApplicationListenertrue as default. + * + * @param defaultProperties the default {@link Properties properties} + * @see #ALLOW_BEAN_DEFINITION_OVERRIDING_PROPERTY + * @since 2.7.1 + */ + private void setAllowBeanDefinitionOverriding(Map defaultProperties) { + defaultProperties.put(ALLOW_BEAN_DEFINITION_OVERRIDING_PROPERTY, Boolean.TRUE.toString()); + } + /** * Copy from BusEnvironmentPostProcessor#addOrReplace(MutablePropertySources, Map) * diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/DubboUtils.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/DubboUtils.java index 178e54aa..0c7b81e2 100644 --- a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/DubboUtils.java +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/DubboUtils.java @@ -16,7 +16,15 @@ */ package org.apache.dubbo.spring.starter.util; +import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor; +import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig; +import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfigBinding; +import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; + +import org.springframework.boot.context.ContextIdApplicationContextInitializer; import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.PropertyResolver; import java.util.Collections; import java.util.Map; @@ -26,7 +34,7 @@ import java.util.TreeMap; /** * The utilities class for Dubbo * - * @since 1.0.0 + * @since 2.7.0 */ public abstract class DubboUtils { @@ -49,38 +57,38 @@ public abstract class DubboUtils { /** * The prefix of property name for Dubbo scan */ - public static final String DUBBO_SCAN_PREFIX = DUBBO_PREFIX + PROPERTY_NAME_SEPARATOR + "scan"; + public static final String DUBBO_SCAN_PREFIX = DUBBO_PREFIX + PROPERTY_NAME_SEPARATOR + "scan" + PROPERTY_NAME_SEPARATOR; /** - * The prefix of property name for Dubbo Config.ØØ + * The prefix of property name for Dubbo Config */ - public static final String DUBBO_CONFIG_PREFIX = DUBBO_PREFIX + PROPERTY_NAME_SEPARATOR + "config"; + public static final String DUBBO_CONFIG_PREFIX = DUBBO_PREFIX + PROPERTY_NAME_SEPARATOR + "config" + PROPERTY_NAME_SEPARATOR; /** * The property name of base packages to scan *

* The default value is empty set. */ - public static final String BASE_PACKAGES_PROPERTY_NAME = DUBBO_SCAN_PREFIX + PROPERTY_NAME_SEPARATOR + "base-packages"; + public static final String BASE_PACKAGES_PROPERTY_NAME = "base-packages"; /** * The property name of multiple properties binding from externalized configuration *

* The default value is {@link #DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE} */ - public static final String MULTIPLE_CONFIG_PROPERTY_NAME = DUBBO_CONFIG_PREFIX + PROPERTY_NAME_SEPARATOR + "multiple"; + public static final String MULTIPLE_CONFIG_PROPERTY_NAME = "multiple"; /** * The default value of multiple properties binding from externalized configuration */ - public static final boolean DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE = false; + public static final boolean DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE = true; /** * The property name of override Dubbo config *

* The default value is {@link #DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE} */ - public static final String OVERRIDE_CONFIG_PROPERTY_NAME = DUBBO_CONFIG_PREFIX + PROPERTY_NAME_SEPARATOR + "override"; + public static final String OVERRIDE_CONFIG_FULL_PROPERTY_NAME = DUBBO_CONFIG_PREFIX + "override"; /** * The default property value of override Dubbo config @@ -91,28 +99,79 @@ public abstract class DubboUtils { /** * The github URL of Dubbo Spring Boot */ - public static final String DUBBO_SPRING_BOOT_GITHUB_URL = "https://github.com/apache/incubator-dubbo-spring-boot-project"; + public static final String DUBBO_SPRING_BOOT_GITHUB_URL = "https://github.com/apache/dubbo-spring-boot-project"; /** * The git URL of Dubbo Spring Boot */ - public static final String DUBBO_SPRING_BOOT_GIT_URL = "https://github.com/apache/incubator-dubbo-spring-boot-project.git"; + public static final String DUBBO_SPRING_BOOT_GIT_URL = "https://github.com/apache/dubbo-spring-boot-project.git"; /** * The issues of Dubbo Spring Boot */ - public static final String DUBBO_SPRING_BOOT_ISSUES_URL = "https://github.com/apache/incubator-dubbo-spring-boot-project/issues"; + public static final String DUBBO_SPRING_BOOT_ISSUES_URL = "https://github.com/apache/dubbo-spring-boot-project/issues"; /** * The github URL of Dubbo */ - public static final String DUBBO_GITHUB_URL = "https://github.com/apache/incubator-dubbo"; + public static final String DUBBO_GITHUB_URL = "https://github.com/apache/dubbo"; /** * The google group URL of Dubbo */ public static final String DUBBO_MAILING_LIST = "dev@dubbo.apache.org"; + /** + * The bean name of Relaxed-binding {@link DubboConfigBinder} + */ + public static final String RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME = "relaxedDubboConfigBinder"; + + /** + * The bean name of {@link PropertyResolver} for {@link ServiceAnnotationBeanPostProcessor}'s base-packages + */ + public static final String BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME = "dubboScanBasePackagesPropertyResolver"; + + /** + * The property name of Spring Application + * + * @see ContextIdApplicationContextInitializer + * @since 2.7.1 + */ + public static final String SPRING_APPLICATION_NAME_PROPERTY = "spring.application.name"; + + /** + * The property id of {@link ApplicationConfig} Bean + * + * @see EnableDubboConfig + * @see EnableDubboConfigBinding + * @since 2.7.1 + */ + public static final String DUBBO_APPLICATION_ID_PROPERTY = "dubbo.application.id"; + + /** + * The property name of {@link ApplicationConfig} + * + * @see EnableDubboConfig + * @see EnableDubboConfigBinding + * @since 2.7.1 + */ + public static final String DUBBO_APPLICATION_NAME_PROPERTY = "dubbo.application.name"; + + /** + * The property name of {@link ApplicationConfig#getQosEnable() application's QOS enable} + * + * @since 2.7.1 + */ + public static final String DUBBO_APPLICATION_QOS_ENABLE_PROPERTY = "dubbo.application.qos-enable"; + + /** + * The property name of {@link EnableDubboConfig#multiple() @EnableDubboConfig.multiple()} + * + * @since 2.7.1 + */ + public static final String DUBBO_CONFIG_MULTIPLE_PROPERTY = "dubbo.config.multiple"; + + /** * Filters Dubbo Properties from {@link ConfigurableEnvironment} * diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/EnvironmentUtils.java b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/EnvironmentUtils.java index 30d6964c..f722624f 100644 --- a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/EnvironmentUtils.java +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/EnvironmentUtils.java @@ -27,7 +27,7 @@ import java.util.Map; * The utilities class for {@link Environment} * * @see Environment - * @since 1.0.0 + * @since 2.7.0 */ public abstract class EnvironmentUtils { diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring-configuration-metadata.json b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring-configuration-metadata.json deleted file mode 100644 index 2ccf1847..00000000 --- a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring-configuration-metadata.json +++ /dev/null @@ -1,1098 +0,0 @@ -{ - "hints": [], - "groups": [], - "properties": [ - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.architecture", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.compiler", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.default", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.dump-directory", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.environment", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.id", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.logger", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.monitor", - "type": "org.apache.dubbo.config.MonitorConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.name", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.organization", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.owner", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.parameters", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.qos-accept-foreign-ip", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.qos-enable", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.qos-port", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.registries", - "type": "java.util.List" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.registry", - "type": "org.apache.dubbo.config.RegistryConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ApplicationConfig", - "name": "dubbo.application.version", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.spring.starter.autoconfigure.MultipleDubboConfigBindingProperties", - "name": "dubbo.applications", - "description": "Multiple {@link ApplicationConfig} property", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.spring.starter.autoconfigure.DubboConfigProperties", - "name": "dubbo.config.multiple", - "description": "Indicates multiple properties binding from externalized configuration or not.", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.spring.starter.autoconfigure.DubboConfigProperties", - "name": "dubbo.config.override", - "description": "Indicates override {@link ConfigUtils#getProperties() Dubbo config properties} from externalized configuration\n or not.", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.actives", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.application", - "type": "org.apache.dubbo.config.ApplicationConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.async", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.cache", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.callbacks", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.check", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.client", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.cluster", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.connections", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.default", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.filter", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.generic", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.group", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.id", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.init", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "deprecated": true, - "name": "dubbo.consumer.injvm", - "type": "java.lang.Boolean", - "deprecation": {} - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.layer", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.lazy", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.listener", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.loadbalance", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "deprecated": true, - "name": "dubbo.consumer.local", - "type": "java.lang.String", - "deprecation": {} - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.merger", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.mock", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.module", - "type": "org.apache.dubbo.config.ModuleConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.monitor", - "type": "org.apache.dubbo.config.MonitorConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.onconnect", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.ondisconnect", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.owner", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.parameters", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.proxy", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.reconnect", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.registries", - "type": "java.util.List" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.registry", - "type": "org.apache.dubbo.config.RegistryConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.retries", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.scope", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.sent", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.sticky", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.stub", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.timeout", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.validation", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ConsumerConfig", - "name": "dubbo.consumer.version", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.spring.starter.autoconfigure.MultipleDubboConfigBindingProperties", - "name": "dubbo.consumers", - "description": "Multiple {@link ConsumerConfig} property", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.config.ModuleConfig", - "name": "dubbo.module.default", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ModuleConfig", - "name": "dubbo.module.id", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ModuleConfig", - "name": "dubbo.module.monitor", - "type": "org.apache.dubbo.config.MonitorConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ModuleConfig", - "name": "dubbo.module.name", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ModuleConfig", - "name": "dubbo.module.organization", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ModuleConfig", - "name": "dubbo.module.owner", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ModuleConfig", - "name": "dubbo.module.registries", - "type": "java.util.List" - }, - { - "sourceType": "org.apache.dubbo.config.ModuleConfig", - "name": "dubbo.module.registry", - "type": "org.apache.dubbo.config.RegistryConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ModuleConfig", - "name": "dubbo.module.version", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.spring.starter.autoconfigure.MultipleDubboConfigBindingProperties", - "name": "dubbo.modules", - "description": "Multiple {@link ModuleConfig} property", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.config.MonitorConfig", - "name": "dubbo.monitor.address", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.MonitorConfig", - "name": "dubbo.monitor.default", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.MonitorConfig", - "name": "dubbo.monitor.group", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.MonitorConfig", - "name": "dubbo.monitor.id", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.MonitorConfig", - "name": "dubbo.monitor.parameters", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.config.MonitorConfig", - "name": "dubbo.monitor.password", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.MonitorConfig", - "name": "dubbo.monitor.protocol", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.MonitorConfig", - "name": "dubbo.monitor.username", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.MonitorConfig", - "name": "dubbo.monitor.version", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.spring.starter.autoconfigure.MultipleDubboConfigBindingProperties", - "name": "dubbo.monitors", - "description": "Multiple {@link MonitorConfig} property", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.accepts", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.accesslog", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.buffer", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.charset", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.client", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.codec", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.contextpath", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.default", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.dispatcher", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "deprecated": true, - "name": "dubbo.protocol.dispather", - "type": "java.lang.String", - "deprecation": {} - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.exchanger", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.heartbeat", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.host", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.id", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.iothreads", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.name", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.networker", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.parameters", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "deprecated": true, - "name": "dubbo.protocol.path", - "type": "java.lang.String", - "deprecation": {} - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.payload", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.port", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.prompt", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.queues", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.register", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.serialization", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.server", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.status", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.telnet", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.threadpool", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.threads", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProtocolConfig", - "name": "dubbo.protocol.transporter", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.spring.starter.autoconfigure.MultipleDubboConfigBindingProperties", - "name": "dubbo.protocols", - "description": "Multiple {@link ProtocolConfig} property", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.accepts", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.accesslog", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.actives", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.application", - "type": "org.apache.dubbo.config.ApplicationConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.async", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.buffer", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.cache", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.callbacks", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.charset", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.client", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.cluster", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.codec", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.connections", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.contextpath", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "deprecated": true, - "name": "dubbo.provider.default", - "type": "java.lang.Boolean", - "deprecation": {} - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.delay", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.deprecated", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.dispatcher", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "deprecated": true, - "name": "dubbo.provider.dispather", - "type": "java.lang.String", - "deprecation": {} - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.document", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.dynamic", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.exchanger", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.executes", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.export", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.filter", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.group", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.host", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.id", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.iothreads", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.layer", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.listener", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.loadbalance", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "deprecated": true, - "name": "dubbo.provider.local", - "type": "java.lang.String", - "deprecation": {} - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.merger", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.mock", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.module", - "type": "org.apache.dubbo.config.ModuleConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.monitor", - "type": "org.apache.dubbo.config.MonitorConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.networker", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.onconnect", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.ondisconnect", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.owner", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.parameters", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "deprecated": true, - "name": "dubbo.provider.path", - "type": "java.lang.String", - "deprecation": {} - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.payload", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "deprecated": true, - "name": "dubbo.provider.port", - "type": "java.lang.Integer", - "deprecation": {} - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.prompt", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.protocol", - "type": "org.apache.dubbo.config.ProtocolConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.protocols", - "type": "java.util.List" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.proxy", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.queues", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.register", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.registries", - "type": "java.util.List" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.registry", - "type": "org.apache.dubbo.config.RegistryConfig" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.retries", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.scope", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.sent", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.serialization", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.server", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.status", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.stub", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.telnet", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.threadpool", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.threads", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.timeout", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.token", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.transporter", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.validation", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.version", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.wait", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.warmup", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.ProviderConfig", - "name": "dubbo.provider.weight", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.spring.starter.autoconfigure.MultipleDubboConfigBindingProperties", - "name": "dubbo.providers", - "description": "Multiple {@link ProviderConfig} property", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.spring.starter.autoconfigure.MultipleDubboConfigBindingProperties", - "name": "dubbo.registries", - "description": "Multiple {@link RegistryConfig} property", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.address", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.check", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.client", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.cluster", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.default", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.dynamic", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.file", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.group", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.id", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.parameters", - "type": "java.util.Map" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.password", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.port", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.protocol", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.register", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.server", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.session", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.subscribe", - "type": "java.lang.Boolean" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.timeout", - "type": "java.lang.Integer" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "deprecated": true, - "name": "dubbo.registry.transport", - "type": "java.lang.String", - "deprecation": {} - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.transporter", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.username", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "name": "dubbo.registry.version", - "type": "java.lang.String" - }, - { - "sourceType": "org.apache.dubbo.config.RegistryConfig", - "deprecated": true, - "name": "dubbo.registry.wait", - "type": "java.lang.Integer", - "deprecation": {} - }, - { - "sourceType": "org.apache.dubbo.spring.starter.autoconfigure.DubboScanProperties", - "name": "dubbo.scan.base-packages", - "description": "The base-packages to scan , the multiple-value is delimited by comma\n\n @see EnableDubbo#scanBasePackages()", - "type": "java.util.Set" - } - ] -} \ No newline at end of file diff --git a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring.factories b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring.factories index 6051d370..da4e2289 100644 --- a/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring.factories +++ b/whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -1,4 +1,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.apache.dubbo.spring.starter.autoconfigure.DubboRelaxedBindingAutoConfiguration,\ org.apache.dubbo.spring.starter.autoconfigure.DubboAutoConfiguration @@ -8,4 +9,7 @@ org.apache.dubbo.spring.starter.context.event.WelcomeLogoApplicationListener,\ org.apache.dubbo.spring.starter.context.event.AwaitingNonWebApplicationListener org.springframework.boot.env.EnvironmentPostProcessor=\ -org.apache.dubbo.spring.starter.env.DubboDefaultPropertiesEnvironmentPostProcessor \ No newline at end of file +org.apache.dubbo.spring.starter.env.DubboDefaultPropertiesEnvironmentPostProcessor + +org.springframework.context.ApplicationContextInitializer=\ +org.apache.dubbo.spring.starter.context.DubboApplicationContextInitializer \ No newline at end of file diff --git a/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/ConsumerApplication.java b/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/ConsumerApplication.java index baade11e..8c2b3eba 100644 --- a/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/ConsumerApplication.java +++ b/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/ConsumerApplication.java @@ -1,9 +1,7 @@ package org.hongxi.whatsmars.dubbo.demo.consumer; -import org.hongxi.whatsmars.dubbo.demo.consumer.rpc.DemoRpc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.ConfigurableApplicationContext; /** * Created by javahongxi on 2017/12/4. @@ -11,9 +9,6 @@ import org.springframework.context.ConfigurableApplicationContext; @SpringBootApplication public class ConsumerApplication { public static void main(String[] args) { - ConfigurableApplicationContext context = SpringApplication.run(ConsumerApplication.class, args); -// DemoRpc demoRpc = context.getBean(DemoRpc.class); -// System.out.println(demoRpc.sayHello("Lily")); -// System.out.println(demoRpc.sayHello2("Lily")); + SpringApplication.run(ConsumerApplication.class, args); } } diff --git a/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java b/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java index 8e2af395..41e7cb21 100644 --- a/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java +++ b/whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java @@ -15,10 +15,10 @@ public class DemoRpc { /** * 当不指定registry时,Reference会从所有含有该service的registry里选择一个registry */ - @Reference(registry = "defaultRegistry", check = false) + @Reference(registry = "defaultRegistry") private DemoService demoService; - @Reference(registry = "otherRegistry", check = false) + @Reference(registry = "otherRegistry") private OtherService otherService; public String sayHello(String name) { diff --git a/whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/AsyncConsumer2.java b/whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/AsyncConsumer2.java index 7bf07ec1..e74d21b1 100644 --- a/whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/AsyncConsumer2.java +++ b/whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/AsyncConsumer2.java @@ -22,19 +22,15 @@ public class AsyncConsumer2 { final DemoService demoService = (DemoService) context.getBean("demoService"); - Future f = RpcContext.getContext().asyncCall(new Callable() { - public String call() throws Exception { - return demoService.sayHello("async call request"); - } + Future f = RpcContext.getContext().asyncCall(() -> { + return demoService.sayHello("async call request"); }); System.out.println("async call ret :" + f.get()); - RpcContext.getContext().asyncCall(new Runnable() { - public void run() { - demoService.sayHello("oneway call request1"); - demoService.sayHello("oneway call request2"); - } + RpcContext.getContext().asyncCall(() -> { + demoService.sayHello("oneway call request1"); + demoService.sayHello("oneway call request2"); }); System.in.read(); diff --git a/whatsmars-dubbo/whatsmars-dubbo-provider-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/provider/ProviderApplication.java b/whatsmars-dubbo/whatsmars-dubbo-provider-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/provider/ProviderApplication.java index 02a6bfab..1ae92b43 100644 --- a/whatsmars-dubbo/whatsmars-dubbo-provider-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/provider/ProviderApplication.java +++ b/whatsmars-dubbo/whatsmars-dubbo-provider-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/provider/ProviderApplication.java @@ -8,7 +8,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; */ @SpringBootApplication public class ProviderApplication { - public static void main(String[] args) throws Exception { + public static void main(String[] args) { SpringApplication.run(ProviderApplication.class, args); } } -- GitLab