diff --git a/NOTICE b/NOTICE index 97fefd076..62b278710 100644 --- a/NOTICE +++ b/NOTICE @@ -2,13 +2,4 @@ Apache Dubbo (incubating) Copyright 2018-2019 The Apache Software Foundation This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). - -This product contains code form the Netty Project: - -The Netty Project -================= -Please visit the Netty web site for more information: - * http://netty.io/ - -Copyright 2014 The Netty Project \ No newline at end of file +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/dubbo-spring-boot-actuator/pom.xml b/dubbo-spring-boot-actuator/pom.xml index 592bcd6ca..ef7eed38c 100644 --- a/dubbo-spring-boot-actuator/pom.xml +++ b/dubbo-spring-boot-actuator/pom.xml @@ -1,3 +1,4 @@ + org.springframework.boot spring-boot-starter-web diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointsAutoConfiguration.java b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfiguration.java similarity index 85% rename from dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointsAutoConfiguration.java rename to dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfiguration.java index fd5a7aad8..aa6536652 100644 --- a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointsAutoConfiguration.java +++ b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfiguration.java @@ -17,12 +17,11 @@ package org.apache.dubbo.spring.boot.actuate.autoconfigure; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboConfigsMetadataEndpoint; -import org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpoint; -import org.apache.dubbo.spring.boot.actuate.endpoint.DubboPropertiesEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboMetadataEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboPropertiesMetadataEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboReferencesMetadataEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboServicesMetadataEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboShutdownEndpoint; - import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -31,23 +30,23 @@ import org.springframework.context.annotation.PropertySource; /** - * Dubbo {@link Endpoint} Auto-{@link Configuration} + * Dubbo {@link Endpoint @Endpoint} Auto-{@link Configuration} for Spring Boot Actuator 2.0 * * @see Endpoint * @see Configuration - * @since 0.2.0 + * @since 2.7.0 */ @Configuration @PropertySource( name = "Dubbo Endpoints Default Properties", value = "classpath:/META-INF/dubbo-endpoins-default.properties") -public class DubboEndpointsAutoConfiguration { +public class DubboEndpointAnnotationAutoConfiguration { @Bean @ConditionalOnMissingBean @ConditionalOnEnabledEndpoint - public DubboEndpoint dubboEndpoint() { - return new DubboEndpoint(); + public DubboMetadataEndpoint dubboEndpoint() { + return new DubboMetadataEndpoint(); } @Bean @@ -60,8 +59,8 @@ public DubboConfigsMetadataEndpoint dubboConfigsMetadataEndpoint() { @Bean @ConditionalOnMissingBean @ConditionalOnEnabledEndpoint - public DubboPropertiesEndpoint dubboPropertiesEndpoint() { - return new DubboPropertiesEndpoint(); + public DubboPropertiesMetadataEndpoint dubboPropertiesEndpoint() { + return new DubboPropertiesMetadataEndpoint(); } @Bean diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboConfigsMetadataEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboConfigsMetadataEndpoint.java index 2cce5438a..0f57fa7bc 100644 --- a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboConfigsMetadataEndpoint.java +++ b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboConfigsMetadataEndpoint.java @@ -16,74 +16,27 @@ */ package org.apache.dubbo.spring.boot.actuate.endpoint; -import org.apache.dubbo.config.AbstractConfig; -import org.apache.dubbo.config.ApplicationConfig; -import org.apache.dubbo.config.ConsumerConfig; -import org.apache.dubbo.config.MethodConfig; -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.ReferenceConfig; -import org.apache.dubbo.config.RegistryConfig; -import org.apache.dubbo.config.ServiceConfig; - +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.AbstractDubboMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboConfigsMetadata; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; -import java.util.LinkedHashMap; import java.util.Map; -import java.util.TreeMap; - -import static org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors; /** * Dubbo Configs Metadata {@link Endpoint} * - * @since 0.2.0 + * @since 2.7.0 */ @Endpoint(id = "dubboconfigs") -public class DubboConfigsMetadataEndpoint extends AbstractDubboEndpoint { +public class DubboConfigsMetadataEndpoint extends AbstractDubboMetadata { + + @Autowired + private DubboConfigsMetadata dubboConfigsMetadata; @ReadOperation public Map>> configs() { - - Map>> configsMap = new LinkedHashMap<>(); - - addDubboConfigBeans(ApplicationConfig.class, configsMap); - addDubboConfigBeans(ConsumerConfig.class, configsMap); - addDubboConfigBeans(MethodConfig.class, configsMap); - addDubboConfigBeans(ModuleConfig.class, configsMap); - addDubboConfigBeans(MonitorConfig.class, configsMap); - addDubboConfigBeans(ProtocolConfig.class, configsMap); - addDubboConfigBeans(ProviderConfig.class, configsMap); - addDubboConfigBeans(ReferenceConfig.class, configsMap); - addDubboConfigBeans(RegistryConfig.class, configsMap); - addDubboConfigBeans(ServiceConfig.class, configsMap); - - return configsMap; - - } - - private void addDubboConfigBeans(Class dubboConfigClass, - Map>> configsMap) { - - Map dubboConfigBeans = beansOfTypeIncludingAncestors(applicationContext, dubboConfigClass); - - String name = dubboConfigClass.getSimpleName(); - - Map> beansMetadata = new TreeMap<>(); - - for (Map.Entry entry : dubboConfigBeans.entrySet()) { - - String beanName = entry.getKey(); - AbstractConfig configBean = entry.getValue(); - Map configBeanMeta = resolveBeanMetadata(configBean); - beansMetadata.put(beanName, configBeanMeta); - - } - - configsMap.put(name, beansMetadata); - + return dubboConfigsMetadata.configs(); } } diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboMetadataEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboMetadataEndpoint.java new file mode 100644 index 000000000..d7d4e586b --- /dev/null +++ b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboMetadataEndpoint.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.actuate.endpoint; + +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboMetadata; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.actuate.endpoint.annotation.Endpoint; +import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; + +import java.util.Map; + +/** + * Actuator {@link Endpoint} to expose Dubbo Meta Data + * + * @see Endpoint + * @since 2.7.0 + */ +@Endpoint(id = "dubbo") +public class DubboMetadataEndpoint { + + @Autowired + private DubboMetadata dubboMetadata; + + @ReadOperation + public Map invoke() { + return dubboMetadata.invoke(); + } + +} diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboPropertiesMetadataEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboPropertiesMetadataEndpoint.java new file mode 100644 index 000000000..6084d3f61 --- /dev/null +++ b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboPropertiesMetadataEndpoint.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.spring.boot.actuate.endpoint; + +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.AbstractDubboMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboPropertiesMetadata; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.actuate.endpoint.annotation.Endpoint; +import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; + +import java.util.SortedMap; + +/** + * Dubbo Properties {@link Endpoint} + * + * @since 2.7.0 + */ +@Endpoint(id = "dubboproperties") +public class DubboPropertiesMetadataEndpoint extends AbstractDubboMetadata { + + @Autowired + private DubboPropertiesMetadata dubboPropertiesMetadata; + + @ReadOperation + public SortedMap properties() { + return dubboPropertiesMetadata.properties(); + } +} diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboReferencesMetadataEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboReferencesMetadataEndpoint.java index b6aa6ff7d..54de83cc3 100644 --- a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboReferencesMetadataEndpoint.java +++ b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboReferencesMetadataEndpoint.java @@ -17,57 +17,27 @@ package org.apache.dubbo.spring.boot.actuate.endpoint; import org.apache.dubbo.config.annotation.Reference; -import org.apache.dubbo.config.spring.ReferenceBean; -import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; - -import org.springframework.beans.factory.annotation.InjectionMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.AbstractDubboMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboReferencesMetadata; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; -import java.util.LinkedHashMap; import java.util.Map; /** * Dubbo {@link Reference} Metadata {@link Endpoint} * - * @since 1.0.0 + * @since 2.7.0 */ @Endpoint(id = "dubboreferences") -public class DubboReferencesMetadataEndpoint extends AbstractDubboEndpoint { +public class DubboReferencesMetadataEndpoint extends AbstractDubboMetadata { + + @Autowired + private DubboReferencesMetadata dubboReferencesMetadata; @ReadOperation public Map> references() { - - Map> referencesMetadata = new LinkedHashMap<>(); - - ReferenceAnnotationBeanPostProcessor beanPostProcessor = getReferenceAnnotationBeanPostProcessor(); - - referencesMetadata.putAll(buildReferencesMetadata(beanPostProcessor.getInjectedFieldReferenceBeanMap())); - referencesMetadata.putAll(buildReferencesMetadata(beanPostProcessor.getInjectedMethodReferenceBeanMap())); - - return referencesMetadata; - + return dubboReferencesMetadata.references(); } - - private Map> buildReferencesMetadata( - Map> injectedElementReferenceBeanMap) { - Map> referencesMetadata = new LinkedHashMap<>(); - - for (Map.Entry> entry : - injectedElementReferenceBeanMap.entrySet()) { - - InjectionMetadata.InjectedElement injectedElement = entry.getKey(); - - ReferenceBean referenceBean = entry.getValue(); - - Map beanMetadata = resolveBeanMetadata(referenceBean); - beanMetadata.put("invoker", resolveBeanMetadata(referenceBean.get())); - - referencesMetadata.put(String.valueOf(injectedElement.getMember()), beanMetadata); - - } - - return referencesMetadata; - } - } diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboServicesMetadataEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboServicesMetadataEndpoint.java index dfef5a89d..e92f011f7 100644 --- a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboServicesMetadataEndpoint.java +++ b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboServicesMetadataEndpoint.java @@ -17,70 +17,27 @@ package org.apache.dubbo.spring.boot.actuate.endpoint; import org.apache.dubbo.config.annotation.Service; -import org.apache.dubbo.config.spring.ServiceBean; - +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.AbstractDubboMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboServicesMetadata; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; -import java.util.LinkedHashMap; import java.util.Map; /** * Dubbo {@link Service} Metadata {@link Endpoint} * - * @since 0.2.0 + * @since 2.7.0 */ @Endpoint(id = "dubboservices") -public class DubboServicesMetadataEndpoint extends AbstractDubboEndpoint { +public class DubboServicesMetadataEndpoint extends AbstractDubboMetadata { + + @Autowired + private DubboServicesMetadata dubboServicesMetadata; @ReadOperation public Map> services() { - - Map serviceBeansMap = getServiceBeansMap(); - - Map> servicesMetadata = new LinkedHashMap<>(serviceBeansMap.size()); - - for (Map.Entry entry : serviceBeansMap.entrySet()) { - - String serviceBeanName = entry.getKey(); - - ServiceBean serviceBean = entry.getValue(); - - Map serviceBeanMetadata = resolveBeanMetadata(serviceBean); - - Object service = resolveServiceBean(serviceBeanName, serviceBean); - - if (service != null) { - // Add Service implementation class - serviceBeanMetadata.put("serviceClass", service.getClass().getName()); - } - - servicesMetadata.put(serviceBeanName, serviceBeanMetadata); - - } - - return servicesMetadata; - - } - - private Object resolveServiceBean(String serviceBeanName, ServiceBean serviceBean) { - - int index = serviceBeanName.indexOf("#"); - - if (index > -1) { - - Class interfaceClass = serviceBean.getInterfaceClass(); - - String serviceName = serviceBeanName.substring(index + 1); - - if (applicationContext.containsBean(serviceName)) { - return applicationContext.getBean(serviceName, interfaceClass); - } - - } - - return null; - + return dubboServicesMetadata.services(); } - } diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboShutdownEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboShutdownEndpoint.java index a10f4d47a..b372472ca 100644 --- a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboShutdownEndpoint.java +++ b/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboShutdownEndpoint.java @@ -16,65 +16,28 @@ */ package org.apache.dubbo.spring.boot.actuate.endpoint; -import org.apache.dubbo.config.spring.ServiceBean; -import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; - +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.AbstractDubboMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboShutdownMetadata; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.WriteOperation; -import java.util.LinkedHashMap; import java.util.Map; -import java.util.TreeMap; - -import static org.apache.dubbo.registry.support.AbstractRegistryFactory.getRegistries; /** * Dubbo Shutdown * - * @since 0.2.0 + * @since 2.7.0 */ @Endpoint(id = "dubboshutdown") -public class DubboShutdownEndpoint extends AbstractDubboEndpoint { +public class DubboShutdownEndpoint extends AbstractDubboMetadata { + @Autowired + private DubboShutdownMetadata dubboShutdownMetadata; @WriteOperation public Map shutdown() throws Exception { - - Map shutdownCountData = new LinkedHashMap<>(); - - // registries - int registriesCount = getRegistries().size(); - - // protocols - int protocolsCount = getProtocolConfigsBeanMap().size(); - - shutdownCountData.put("registries", registriesCount); - shutdownCountData.put("protocols", protocolsCount); - - // Service Beans - Map serviceBeansMap = getServiceBeansMap(); - if (!serviceBeansMap.isEmpty()) { - for (ServiceBean serviceBean : serviceBeansMap.values()) { - serviceBean.destroy(); - } - } - shutdownCountData.put("services", serviceBeansMap.size()); - - // Reference Beans - ReferenceAnnotationBeanPostProcessor beanPostProcessor = getReferenceAnnotationBeanPostProcessor(); - - int referencesCount = beanPostProcessor.getReferenceBeans().size(); - - beanPostProcessor.destroy(); - - shutdownCountData.put("references", referencesCount); - - // Set Result to complete - Map shutdownData = new TreeMap<>(); - shutdownData.put("shutdown.count", shutdownCountData); - - - return shutdownData; + return dubboShutdownMetadata.shutdown(); } } diff --git a/dubbo-spring-boot-actuator/src/main/resources/META-INF/spring.factories b/dubbo-spring-boot-actuator/src/main/resources/META-INF/spring.factories index f80694c1f..53a1bb0d0 100644 --- a/dubbo-spring-boot-actuator/src/main/resources/META-INF/spring.factories +++ b/dubbo-spring-boot-actuator/src/main/resources/META-INF/spring.factories @@ -1,3 +1,2 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointsAutoConfiguration,\ -org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboHealthIndicatorAutoConfiguration \ No newline at end of file +org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointAnnotationAutoConfiguration \ No newline at end of file diff --git a/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointsAutoConfigurationTest.java b/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java similarity index 87% rename from dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointsAutoConfigurationTest.java rename to dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java index 39d06e737..d9747cc08 100644 --- a/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointsAutoConfigurationTest.java +++ b/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java @@ -14,13 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.spring.boot.actuate.endpoint; - -import org.apache.dubbo.config.annotation.Service; -import org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointsAutoConfiguration; +package org.apache.dubbo.spring.boot.actuate.autoconfigure; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.dubbo.config.annotation.Service; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboConfigsMetadataEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboMetadataEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboPropertiesMetadataEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboReferencesMetadataEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboServicesMetadataEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboShutdownEndpoint; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -36,15 +40,14 @@ import java.util.function.Supplier; /** - * {@link DubboEndpointsAutoConfiguration} Test + * {@link DubboEndpointAnnotationAutoConfiguration} Test * - * @since 0.2.0 + * @since 2.7.0 */ @RunWith(SpringRunner.class) @SpringBootTest( classes = { - DubboEndpointsAutoConfiguration.class, - DubboEndpointsAutoConfigurationTest.class + DubboEndpointAnnotationAutoConfigurationTest.class }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { @@ -60,7 +63,7 @@ "dubbo.protocol.port=20880", "dubbo.provider.id=my-provider", "dubbo.provider.host=127.0.0.1", - "dubbo.scan.basePackages= org.apache.dubbo.spring.boot.actuate.endpoint", + "dubbo.scan.basePackages = org.apache.dubbo.spring.boot.actuate.autoconfigure", "management.endpoint.dubbo.enabled = true", "management.endpoint.dubboshutdown.enabled = true", "management.endpoint.dubboconfigs.enabled = true", @@ -70,16 +73,16 @@ "management.endpoints.web.exposure.include = *", }) @EnableAutoConfiguration -public class DubboEndpointsAutoConfigurationTest { +public class DubboEndpointAnnotationAutoConfigurationTest { @Autowired - private DubboEndpoint dubboEndpoint; + private DubboMetadataEndpoint dubboEndpoint; @Autowired private DubboConfigsMetadataEndpoint dubboConfigsMetadataEndpoint; @Autowired - private DubboPropertiesEndpoint dubboPropertiesEndpoint; + private DubboPropertiesMetadataEndpoint dubboPropertiesEndpoint; @Autowired private DubboReferencesMetadataEndpoint dubboReferencesMetadataEndpoint; @@ -156,7 +159,7 @@ public void testServices() { Assert.assertEquals(1, services.size()); - Map demoServiceMeta = services.get("ServiceBean:org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpointsAutoConfigurationTest$DemoService:1.0.0"); + Map demoServiceMeta = services.get("ServiceBean:org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointAnnotationAutoConfigurationTest$DemoService:1.0.0"); Assert.assertEquals("1.0.0", demoServiceMeta.get("version")); @@ -187,7 +190,7 @@ public void testProperties() { Assert.assertEquals("20880", properties.get("dubbo.protocol.port")); Assert.assertEquals("my-provider", properties.get("dubbo.provider.id")); Assert.assertEquals("127.0.0.1", properties.get("dubbo.provider.host")); - Assert.assertEquals("org.apache.dubbo.spring.boot.actuate.endpoint", properties.get("dubbo.scan.basePackages")); + Assert.assertEquals("org.apache.dubbo.spring.boot.actuate.autoconfigure", properties.get("dubbo.scan.basePackages")); } @Test diff --git a/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java b/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java index 863489004..040ccf4ab 100644 --- a/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java +++ b/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java @@ -17,11 +17,11 @@ package org.apache.dubbo.spring.boot.actuate.endpoint; import org.apache.dubbo.spring.boot.util.DubboUtils; - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -30,22 +30,23 @@ import static org.apache.dubbo.common.Version.getVersion; /** - * {@link DubboEndpoint} Test + * {@link DubboMetadataEndpoint} Test * - * @see DubboEndpoint - * @since 1.0.0 + * @see DubboMetadataEndpoint + * @since 2.7.0 */ @RunWith(SpringRunner.class) @SpringBootTest( classes = { - DubboEndpoint.class + DubboMetadataEndpoint.class } ) +@EnableAutoConfiguration public class DubboEndpointTest { @Autowired - private DubboEndpoint dubboEndpoint; + private DubboMetadataEndpoint dubboEndpoint; @Test public void testInvoke() { diff --git a/dubbo-spring-boot-autoconfigure/pom.xml b/dubbo-spring-boot-autoconfigure/pom.xml index f50475ae4..83f1a4b29 100644 --- a/dubbo-spring-boot-autoconfigure/pom.xml +++ b/dubbo-spring-boot-autoconfigure/pom.xml @@ -1,3 +1,4 @@ + + + org.apache.dubbo + dubbo-spring-boot-autoconfigure-compatible + ${revision} + + org.springframework.boot diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinder.java b/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/BinderDubboConfigBinder.java similarity index 97% rename from dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinder.java rename to dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/BinderDubboConfigBinder.java index 7c1dc8729..b5d896248 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinder.java +++ b/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/BinderDubboConfigBinder.java @@ -19,7 +19,6 @@ import org.apache.dubbo.config.AbstractConfig; import org.apache.dubbo.config.spring.context.properties.AbstractDubboConfigBinder; import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; - import org.springframework.boot.context.properties.bind.BindHandler; import org.springframework.boot.context.properties.bind.Bindable; import org.springframework.boot.context.properties.bind.Binder; @@ -36,9 +35,9 @@ * 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 BinderDubboConfigBinder extends AbstractDubboConfigBinder { @Override public void bind(String prefix, C dubboConfig) { diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBinding2AutoConfiguration.java b/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBinding2AutoConfiguration.java new file mode 100644 index 000000000..97aa275f2 --- /dev/null +++ b/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBinding2AutoConfiguration.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.autoconfigure; + +import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; +import org.apache.dubbo.config.spring.util.PropertySourcesUtils; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +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.boot.util.DubboUtils.BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME; +import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_PREFIX; +import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_SCAN_PREFIX; +import static org.apache.dubbo.spring.boot.util.DubboUtils.RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME; +import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE; + +/** + * Dubbo Relaxed Binding Auto-{@link Configuration} for Spring Boot 2.0 + * + * @see DubboRelaxedBindingAutoConfiguration + * @since 2.7.0 + */ +@Configuration +@ConditionalOnProperty(prefix = DUBBO_PREFIX, name = "enabled", matchIfMissing = true) +@ConditionalOnClass(name = "org.springframework.boot.context.properties.bind.Binder") +@AutoConfigureBefore(DubboRelaxedBindingAutoConfiguration.class) +public class DubboRelaxedBinding2AutoConfiguration { + + @Bean(name = BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME) + public PropertyResolver dubboScanBasePackagesPropertyResolver(ConfigurableEnvironment environment) { + ConfigurableEnvironment propertyResolver = new AbstractEnvironment() { + protected void customizePropertySources(MutablePropertySources propertySources) { + Map dubboScanProperties = PropertySourcesUtils.getSubProperties(environment, DUBBO_SCAN_PREFIX); + propertySources.addLast(new MapPropertySource("dubboScanProperties", dubboScanProperties)); + } + }; + ConfigurationPropertySources.attach(propertyResolver); + return 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 BinderDubboConfigBinder(); + } + +} diff --git a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories b/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories index 1ef3d5b9c..c88a29b24 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories @@ -1,11 +1,2 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration - - -org.springframework.context.ApplicationListener=\ -org.apache.dubbo.spring.boot.context.event.OverrideDubboConfigApplicationListener,\ -org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListener,\ -org.apache.dubbo.spring.boot.context.event.AwaitingNonWebApplicationListener - -org.springframework.boot.env.EnvironmentPostProcessor=\ -org.apache.dubbo.spring.boot.env.DubboDefaultPropertiesEnvironmentPostProcessor \ No newline at end of file +org.apache.dubbo.spring.boot.autoconfigure.DubboRelaxedBinding2AutoConfiguration \ No newline at end of file diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/BinderDubboConfigBinderTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/BinderDubboConfigBinderTest.java new file mode 100644 index 000000000..80053020a --- /dev/null +++ b/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/BinderDubboConfigBinderTest.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.autoconfigure; + +import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.ProtocolConfig; +import org.apache.dubbo.config.RegistryConfig; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * {@link BinderDubboConfigBinder} Test + * + * @since 2.7.0 + */ +@RunWith(SpringRunner.class) +@TestPropertySource(locations = "classpath:/dubbo.properties") +@ContextConfiguration(classes = BinderDubboConfigBinder.class) +public class BinderDubboConfigBinderTest { + + @Autowired + private BinderDubboConfigBinder dubboConfigBinder; + + @Test + public void testBinder() { + + ApplicationConfig applicationConfig = new ApplicationConfig(); + dubboConfigBinder.bind("dubbo.application", applicationConfig); + Assert.assertEquals("hello", applicationConfig.getName()); + Assert.assertEquals("world", applicationConfig.getOwner()); + + RegistryConfig registryConfig = new RegistryConfig(); + dubboConfigBinder.bind("dubbo.registry", registryConfig); + Assert.assertEquals("10.20.153.17", registryConfig.getAddress()); + + ProtocolConfig protocolConfig = new ProtocolConfig(); + dubboConfigBinder.bind("dubbo.protocol", protocolConfig); + Assert.assertEquals(Integer.valueOf(20881), protocolConfig.getPort()); + + } +} diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBinding2AutoConfigurationTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBinding2AutoConfigurationTest.java new file mode 100644 index 000000000..4aee5a50d --- /dev/null +++ b/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBinding2AutoConfigurationTest.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.autoconfigure; + +import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; +import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor; +import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.core.env.PropertyResolver; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.util.ClassUtils; + +import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME; +import static org.apache.dubbo.spring.boot.util.DubboUtils.RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME; + +/** + * {@link DubboRelaxedBinding2AutoConfiguration} Test + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = DubboRelaxedBinding2AutoConfigurationTest.class, properties = { + "dubbo.scan.basePackages = org.apache.dubbo.spring.boot.autoconfigure" +}) +@EnableAutoConfiguration +public class DubboRelaxedBinding2AutoConfigurationTest { + + @Autowired + @Qualifier(BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME) + private PropertyResolver propertyResolver; + + @Autowired + @Qualifier(RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME) + private DubboConfigBinder dubboConfigBinder; + + @Autowired + private ObjectProvider serviceAnnotationBeanPostProcessor; + + @Autowired + private ObjectProvider referenceAnnotationBeanPostProcessor; + + @Test + public void testBeans() { + Assert.assertTrue(ClassUtils.isAssignableValue(BinderDubboConfigBinder.class, dubboConfigBinder)); + Assert.assertNotNull(serviceAnnotationBeanPostProcessor); + Assert.assertNotNull(serviceAnnotationBeanPostProcessor.getIfAvailable()); + Assert.assertNotNull(referenceAnnotationBeanPostProcessor); + Assert.assertNotNull(referenceAnnotationBeanPostProcessor.getIfAvailable()); + } + +} diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/EnvironmentUtilsTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/EnvironmentUtilsTest.java index 805b225f7..2ca3766c1 100644 --- a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/EnvironmentUtilsTest.java +++ b/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/EnvironmentUtilsTest.java @@ -30,7 +30,7 @@ * {@link EnvironmentUtils} Test * * @see EnvironmentUtils - * @since 1.0.0 + * @since 2.7.0 */ public class EnvironmentUtilsTest { diff --git a/dubbo-spring-boot-compatible/actuator/pom.xml b/dubbo-spring-boot-compatible/actuator/pom.xml new file mode 100644 index 000000000..60fbd2f9f --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/pom.xml @@ -0,0 +1,82 @@ + + + + + org.apache.dubbo + dubbo-spring-boot-compatible + ${revision} + ../pom.xml + + 4.0.0 + + dubbo-spring-boot-actuator-compatible + Apache Dubbo Spring Boot :: Compatible :: Actuator + Apache Dubbo Spring Boot Compatible for Spring Boot 1.x Actuator + + + + + org.springframework.boot + spring-boot-starter-web + true + + + + org.springframework.boot + spring-boot-starter-actuator + true + + + + org.springframework.boot + spring-boot-autoconfigure + true + + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + org.apache.dubbo + dubbo-spring-boot-autoconfigure-compatible + ${revision} + + + + + org.apache.dubbo + dubbo + true + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + \ No newline at end of file diff --git a/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAutoConfiguration.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAutoConfiguration.java new file mode 100644 index 000000000..a74cab1f0 --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAutoConfiguration.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.actuate.autoconfigure; + + +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpoint; +import org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration; +import org.apache.dubbo.spring.boot.autoconfigure.DubboRelaxedBindingAutoConfiguration; +import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint; +import org.springframework.boot.actuate.endpoint.Endpoint; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Dubbo {@link Endpoint} Auto Configuration is compatible with Spring Boot Actuator 1.x + * + * @since 2.7.0 + */ +@Configuration +@ConditionalOnClass(name = { + "org.springframework.boot.actuate.endpoint.Endpoint" // Spring Boot 1.x +}) +@AutoConfigureAfter(value = { + DubboAutoConfiguration.class, + DubboRelaxedBindingAutoConfiguration.class +}) +public class DubboEndpointAutoConfiguration { + + @Bean + @ConditionalOnMissingBean + @ConditionalOnEnabledEndpoint(value = "dubbo") + public DubboEndpoint dubboEndpoint() { + return new DubboEndpoint(); + } +} diff --git a/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointMetadataAutoConfiguration.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointMetadataAutoConfiguration.java new file mode 100644 index 000000000..d525e98b1 --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointMetadataAutoConfiguration.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.actuate.autoconfigure; + +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.AbstractDubboMetadata; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * Dubbo Endpoints Metadata Auto-{@link Configuration} + */ +@ConditionalOnClass(name = { + "org.springframework.boot.actuate.health.Health" // If spring-boot-actuator is present +}) +@Configuration +@AutoConfigureAfter(name = { + "org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration", + "org.apache.dubbo.spring.boot.autoconfigure.DubboRelaxedBindingAutoConfiguration" +}) +@ComponentScan(basePackageClasses = AbstractDubboMetadata.class) +public class DubboEndpointMetadataAutoConfiguration { +} diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboHealthIndicatorAutoConfiguration.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboHealthIndicatorAutoConfiguration.java similarity index 74% rename from dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboHealthIndicatorAutoConfiguration.java rename to dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboHealthIndicatorAutoConfiguration.java index 0422fea49..333954b43 100644 --- a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboHealthIndicatorAutoConfiguration.java +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboHealthIndicatorAutoConfiguration.java @@ -18,15 +18,10 @@ import org.apache.dubbo.spring.boot.actuate.health.DubboHealthIndicator; import org.apache.dubbo.spring.boot.actuate.health.DubboHealthIndicatorProperties; -import org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration; - -import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; import org.springframework.boot.actuate.health.HealthIndicator; -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; 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.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -35,13 +30,13 @@ * Dubbo {@link DubboHealthIndicator} Auto Configuration * * @see HealthIndicator - * @since 1.0.0 + * @since 2.7.0 */ @Configuration -@ConditionalOnClass({HealthIndicator.class}) -@AutoConfigureBefore({EndpointAutoConfiguration.class}) -@AutoConfigureAfter(DubboAutoConfiguration.class) -@ConditionalOnEnabledHealthIndicator("dubbo") +@ConditionalOnClass(name = { + "org.springframework.boot.actuate.health.Health" +}) +@ConditionalOnProperty(name = "management.health.dubbo.enabled", matchIfMissing = true, havingValue = "true") @EnableConfigurationProperties(DubboHealthIndicatorProperties.class) public class DubboHealthIndicatorAutoConfiguration { diff --git a/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboMvcEndpointManagementContextConfiguration.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboMvcEndpointManagementContextConfiguration.java new file mode 100644 index 000000000..cfe537c0f --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboMvcEndpointManagementContextConfiguration.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.actuate.autoconfigure; + + +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.mvc.DubboMvcEndpoint; +import org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration; +import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.context.annotation.Bean; + +/** + * Dubbo {@link MvcEndpoint} {@link ManagementContextConfiguration} for Spring Boot 1.x + * + * @since 2.7.0 + */ +@ManagementContextConfiguration +@ConditionalOnClass(name = { + "org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter" +}) +@ConditionalOnWebApplication +public class DubboMvcEndpointManagementContextConfiguration { + + @Bean + @ConditionalOnBean(DubboEndpoint.class) + @ConditionalOnMissingBean + public DubboMvcEndpoint dubboMvcEndpoint(DubboEndpoint dubboEndpoint) { + return new DubboMvcEndpoint(dubboEndpoint); + } +} diff --git a/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java new file mode 100644 index 000000000..0e0aa75c7 --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.actuate.endpoint; + + +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboMetadata; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.actuate.endpoint.AbstractEndpoint; +import org.springframework.boot.actuate.endpoint.Endpoint; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.Map; + +/** + * Actuator {@link Endpoint} to expose Dubbo Meta Data + * + * @see Endpoint + * @since 2.7.0 + */ +@ConfigurationProperties(prefix = "endpoints.dubbo", ignoreUnknownFields = false) +public class DubboEndpoint extends AbstractEndpoint> { + + @Autowired + private DubboMetadata dubboMetadata; + + public DubboEndpoint() { + super("dubbo", true, false); + } + + @Override + public Map invoke() { + return dubboMetadata.invoke(); + } +} diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/AbstractDubboEndpoint.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/AbstractDubboMetadata.java similarity index 94% rename from dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/AbstractDubboEndpoint.java rename to dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/AbstractDubboMetadata.java index eae99b4a7..fb4e01f2c 100644 --- a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/AbstractDubboEndpoint.java +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/AbstractDubboMetadata.java @@ -14,14 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.spring.boot.actuate.endpoint; +package org.apache.dubbo.spring.boot.actuate.endpoint.metadata; import org.apache.dubbo.config.ProtocolConfig; import org.apache.dubbo.config.spring.ServiceBean; import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; - import org.springframework.beans.BeansException; -import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.EnvironmentAware; @@ -44,11 +42,11 @@ import static org.springframework.util.ClassUtils.isPrimitiveOrWrapper; /** - * Abstract Dubbo {@link Endpoint @Endpoint} + * Abstract Dubbo Meatadata * - * @since 0.2.0 + * @since 2.7.0 */ -public abstract class AbstractDubboEndpoint implements ApplicationContextAware, EnvironmentAware { +public abstract class AbstractDubboMetadata implements ApplicationContextAware, EnvironmentAware { protected ApplicationContext applicationContext; diff --git a/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboConfigsMetadata.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboConfigsMetadata.java new file mode 100644 index 000000000..46de93e8f --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboConfigsMetadata.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.actuate.endpoint.metadata; + +import org.apache.dubbo.config.AbstractConfig; +import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.ConsumerConfig; +import org.apache.dubbo.config.MethodConfig; +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.ReferenceConfig; +import org.apache.dubbo.config.RegistryConfig; +import org.apache.dubbo.config.ServiceConfig; +import org.springframework.stereotype.Component; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.TreeMap; + +import static org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors; + +/** + * Dubbo Configs Metadata + * + * @since 2.7.0 + */ +@Component +public class DubboConfigsMetadata extends AbstractDubboMetadata { + + public Map>> configs() { + + Map>> configsMap = new LinkedHashMap<>(); + + addDubboConfigBeans(ApplicationConfig.class, configsMap); + addDubboConfigBeans(ConsumerConfig.class, configsMap); + addDubboConfigBeans(MethodConfig.class, configsMap); + addDubboConfigBeans(ModuleConfig.class, configsMap); + addDubboConfigBeans(MonitorConfig.class, configsMap); + addDubboConfigBeans(ProtocolConfig.class, configsMap); + addDubboConfigBeans(ProviderConfig.class, configsMap); + addDubboConfigBeans(ReferenceConfig.class, configsMap); + addDubboConfigBeans(RegistryConfig.class, configsMap); + addDubboConfigBeans(ServiceConfig.class, configsMap); + + return configsMap; + + } + + private void addDubboConfigBeans(Class dubboConfigClass, + Map>> configsMap) { + + Map dubboConfigBeans = beansOfTypeIncludingAncestors(applicationContext, dubboConfigClass); + + String name = dubboConfigClass.getSimpleName(); + + Map> beansMetadata = new TreeMap<>(); + + for (Map.Entry entry : dubboConfigBeans.entrySet()) { + + String beanName = entry.getKey(); + AbstractConfig configBean = entry.getValue(); + Map configBeanMeta = resolveBeanMetadata(configBean); + beansMetadata.put(beanName, configBeanMeta); + + } + + configsMap.put(name, beansMetadata); + + } +} diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboMetadata.java similarity index 85% rename from dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java rename to dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboMetadata.java index 34d2a9bc3..cf0818079 100644 --- a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboMetadata.java @@ -14,13 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.spring.boot.actuate.endpoint; +package org.apache.dubbo.spring.boot.actuate.endpoint.metadata; import org.apache.dubbo.common.Version; import org.apache.dubbo.spring.boot.util.DubboUtils; - -import org.springframework.boot.actuate.endpoint.annotation.Endpoint; -import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; +import org.springframework.stereotype.Component; import java.util.LinkedHashMap; import java.util.Map; @@ -32,15 +30,12 @@ import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_SPRING_BOOT_ISSUES_URL; /** - * Actuator {@link Endpoint} to expose Dubbo Meta Data - * - * @see Endpoint - * @since 1.0.0 + * Dubbo Metadata + * @since 2.7.0 */ -@Endpoint(id = "dubbo") -public class DubboEndpoint { +@Component +public class DubboMetadata { - @ReadOperation public Map invoke() { Map metaData = new LinkedHashMap<>(); @@ -63,5 +58,4 @@ public Map invoke() { return metaData; } - } diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboPropertiesEndpoint.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboPropertiesMetadata.java similarity index 73% rename from dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboPropertiesEndpoint.java rename to dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboPropertiesMetadata.java index 65de76dae..3749a0611 100644 --- a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboPropertiesEndpoint.java +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboPropertiesMetadata.java @@ -14,28 +14,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.spring.boot.actuate.endpoint; +package org.apache.dubbo.spring.boot.actuate.endpoint.metadata; -import org.springframework.boot.actuate.endpoint.annotation.Endpoint; -import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; +import org.springframework.stereotype.Component; import java.util.SortedMap; import static org.apache.dubbo.spring.boot.util.DubboUtils.filterDubboProperties; /** - * Dubbo Properties {@link Endpoint} + * Dubbo Properties Metadata * - * @since 1.0.0 + * @since 2.7.0 */ -@Endpoint(id = "dubboproperties") -public class DubboPropertiesEndpoint extends AbstractDubboEndpoint { +@Component +public class DubboPropertiesMetadata extends AbstractDubboMetadata { - @ReadOperation public SortedMap properties() { - return filterDubboProperties(environment); - } - -} +} \ No newline at end of file diff --git a/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboReferencesMetadata.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboReferencesMetadata.java new file mode 100644 index 000000000..e389a6a0a --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboReferencesMetadata.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.actuate.endpoint.metadata; + +import org.apache.dubbo.config.annotation.Reference; +import org.apache.dubbo.config.spring.ReferenceBean; +import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; +import org.springframework.beans.factory.annotation.InjectionMetadata; +import org.springframework.stereotype.Component; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Dubbo {@link Reference} Metadata + * + * @since 2.7.0 + */ +@Component +public class DubboReferencesMetadata extends AbstractDubboMetadata { + + public Map> references() { + + Map> referencesMetadata = new LinkedHashMap<>(); + + ReferenceAnnotationBeanPostProcessor beanPostProcessor = getReferenceAnnotationBeanPostProcessor(); + + referencesMetadata.putAll(buildReferencesMetadata(beanPostProcessor.getInjectedFieldReferenceBeanMap())); + referencesMetadata.putAll(buildReferencesMetadata(beanPostProcessor.getInjectedMethodReferenceBeanMap())); + + return referencesMetadata; + + } + + private Map> buildReferencesMetadata( + Map> injectedElementReferenceBeanMap) { + Map> referencesMetadata = new LinkedHashMap<>(); + + for (Map.Entry> entry : + injectedElementReferenceBeanMap.entrySet()) { + + InjectionMetadata.InjectedElement injectedElement = entry.getKey(); + + ReferenceBean referenceBean = entry.getValue(); + + Map beanMetadata = resolveBeanMetadata(referenceBean); + beanMetadata.put("invoker", resolveBeanMetadata(referenceBean.get())); + + referencesMetadata.put(String.valueOf(injectedElement.getMember()), beanMetadata); + + } + + return referencesMetadata; + } + +} diff --git a/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboServicesMetadata.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboServicesMetadata.java new file mode 100644 index 000000000..7122e365c --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboServicesMetadata.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.boot.actuate.endpoint.metadata; + +import org.apache.dubbo.config.annotation.Service; +import org.apache.dubbo.config.spring.ServiceBean; +import org.springframework.stereotype.Component; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Dubbo {@link Service} Metadata + * + * @since 2.7.0 + */ +@Component +public class DubboServicesMetadata extends AbstractDubboMetadata { + + public Map> services() { + + Map serviceBeansMap = getServiceBeansMap(); + + Map> servicesMetadata = new LinkedHashMap<>(serviceBeansMap.size()); + + for (Map.Entry entry : serviceBeansMap.entrySet()) { + + String serviceBeanName = entry.getKey(); + + ServiceBean serviceBean = entry.getValue(); + + Map serviceBeanMetadata = resolveBeanMetadata(serviceBean); + + Object service = resolveServiceBean(serviceBeanName, serviceBean); + + if (service != null) { + // Add Service implementation class + serviceBeanMetadata.put("serviceClass", service.getClass().getName()); + } + + servicesMetadata.put(serviceBeanName, serviceBeanMetadata); + + } + + return servicesMetadata; + + } + + private Object resolveServiceBean(String serviceBeanName, ServiceBean serviceBean) { + + int index = serviceBeanName.indexOf("#"); + + if (index > -1) { + + Class interfaceClass = serviceBean.getInterfaceClass(); + + String serviceName = serviceBeanName.substring(index + 1); + + if (applicationContext.containsBean(serviceName)) { + return applicationContext.getBean(serviceName, interfaceClass); + } + + } + + return null; + + } + +} diff --git a/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboShutdownMetadata.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboShutdownMetadata.java new file mode 100644 index 000000000..225c324e2 --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/metadata/DubboShutdownMetadata.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.actuate.endpoint.metadata; + +import org.apache.dubbo.config.spring.ServiceBean; +import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; +import org.springframework.stereotype.Component; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.TreeMap; + +import static org.apache.dubbo.registry.support.AbstractRegistryFactory.getRegistries; + +/** + * Dubbo Shutdown + * + * @since 2.7.0 + */ +@Component +public class DubboShutdownMetadata extends AbstractDubboMetadata { + + + public Map shutdown() throws Exception { + + Map shutdownCountData = new LinkedHashMap<>(); + + // registries + int registriesCount = getRegistries().size(); + + // protocols + int protocolsCount = getProtocolConfigsBeanMap().size(); + + shutdownCountData.put("registries", registriesCount); + shutdownCountData.put("protocols", protocolsCount); + + // Service Beans + Map serviceBeansMap = getServiceBeansMap(); + if (!serviceBeansMap.isEmpty()) { + for (ServiceBean serviceBean : serviceBeansMap.values()) { + serviceBean.destroy(); + } + } + shutdownCountData.put("services", serviceBeansMap.size()); + + // Reference Beans + ReferenceAnnotationBeanPostProcessor beanPostProcessor = getReferenceAnnotationBeanPostProcessor(); + + int referencesCount = beanPostProcessor.getReferenceBeans().size(); + + beanPostProcessor.destroy(); + + shutdownCountData.put("references", referencesCount); + + // Set Result to complete + Map shutdownData = new TreeMap<>(); + shutdownData.put("shutdown.count", shutdownCountData); + + + return shutdownData; + } + +} diff --git a/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/mvc/DubboMvcEndpoint.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/mvc/DubboMvcEndpoint.java new file mode 100644 index 000000000..fb23504b2 --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/mvc/DubboMvcEndpoint.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.actuate.endpoint.mvc; + +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboConfigsMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboPropertiesMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboReferencesMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboServicesMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboShutdownMetadata; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter; +import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.context.request.async.DeferredResult; + +import java.util.Map; +import java.util.SortedMap; + +/** + * {@link MvcEndpoint} to expose Dubbo Metadata + * + * @see MvcEndpoint + * @since 2.7.0 + */ +public class DubboMvcEndpoint extends EndpointMvcAdapter { + + public static final String DUBBO_SHUTDOWN_ENDPOINT_URI = "/shutdown"; + + public static final String DUBBO_CONFIGS_ENDPOINT_URI = "/configs"; + + public static final String DUBBO_SERVICES_ENDPOINT_URI = "/services"; + + public static final String DUBBO_REFERENCES_ENDPOINT_URI = "/references"; + + public static final String DUBBO_PROPERTIES_ENDPOINT_URI = "/properties"; + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private DubboShutdownMetadata dubboShutdownMetadata; + + @Autowired + private DubboConfigsMetadata dubboConfigsMetadata; + + @Autowired + private DubboServicesMetadata dubboServicesMetadata; + + @Autowired + private DubboReferencesMetadata dubboReferencesMetadata; + + @Autowired + private DubboPropertiesMetadata dubboPropertiesMetadata; + + public DubboMvcEndpoint(DubboEndpoint dubboEndpoint) { + super(dubboEndpoint); + } + + + @RequestMapping(value = DUBBO_SHUTDOWN_ENDPOINT_URI, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public DeferredResult shutdown() throws Exception { + Map shutdownCountData = dubboShutdownMetadata.shutdown(); + return new DeferredResult(null, shutdownCountData); + } + + @RequestMapping(value = DUBBO_CONFIGS_ENDPOINT_URI, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public Map>> configs() { + return dubboConfigsMetadata.configs(); + } + + + @RequestMapping(value = DUBBO_SERVICES_ENDPOINT_URI, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public Map> services() { + return dubboServicesMetadata.services(); + } + + @RequestMapping(value = DUBBO_REFERENCES_ENDPOINT_URI, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public Map> references() { + return dubboReferencesMetadata.references(); + } + + @RequestMapping(value = DUBBO_PROPERTIES_ENDPOINT_URI, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public SortedMap properties() { + return dubboPropertiesMetadata.properties(); + + } +} diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicator.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicator.java similarity index 99% rename from dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicator.java rename to dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicator.java index 2b2cf17da..c937dc6f1 100644 --- a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicator.java +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicator.java @@ -20,7 +20,6 @@ import org.apache.dubbo.common.status.StatusChecker; import org.apache.dubbo.config.ProtocolConfig; import org.apache.dubbo.config.ProviderConfig; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.health.AbstractHealthIndicator; import org.springframework.boot.actuate.health.Health; @@ -38,7 +37,7 @@ * Dubbo {@link HealthIndicator} * * @see HealthIndicator - * @since 1.0.0 + * @since 2.7.0 */ public class DubboHealthIndicator extends AbstractHealthIndicator { diff --git a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorProperties.java b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorProperties.java similarity index 99% rename from dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorProperties.java rename to dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorProperties.java index d931b19c5..769929325 100644 --- a/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorProperties.java +++ b/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorProperties.java @@ -17,7 +17,6 @@ package org.apache.dubbo.spring.boot.actuate.health; import org.apache.dubbo.common.status.StatusChecker; - import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -31,7 +30,7 @@ * Dubbo {@link HealthIndicator} Properties * * @see HealthIndicator - * @since 1.0.0 + * @since 2.7.0 */ @ConfigurationProperties(prefix = PREFIX, ignoreUnknownFields = false) public class DubboHealthIndicatorProperties { diff --git a/dubbo-spring-boot-compatible/actuator/src/main/resources/META-INF/spring.factories b/dubbo-spring-boot-compatible/actuator/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..bea4633af --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/src/main/resources/META-INF/spring.factories @@ -0,0 +1,6 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointAutoConfiguration,\ +org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboHealthIndicatorAutoConfiguration,\ +org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointMetadataAutoConfiguration +org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration=\ +org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboMvcEndpointManagementContextConfiguration \ No newline at end of file diff --git a/dubbo-spring-boot-compatible/actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAutoConfigurationTest.java b/dubbo-spring-boot-compatible/actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAutoConfigurationTest.java new file mode 100644 index 000000000..9f5f51ec5 --- /dev/null +++ b/dubbo-spring-boot-compatible/actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAutoConfigurationTest.java @@ -0,0 +1,235 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.actuate.autoconfigure; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.dubbo.config.annotation.Service; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboConfigsMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboPropertiesMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboReferencesMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboServicesMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboShutdownMetadata; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.client.RestTemplate; + +import java.util.Map; +import java.util.SortedMap; +import java.util.function.Supplier; + +/** + * {@link DubboEndpointAutoConfiguration} Test + * + * @since 2.7.0 + */ +@RunWith(SpringRunner.class) +@SpringBootTest( + classes = { + DubboEndpointAutoConfiguration.class, + DubboEndpointAutoConfigurationTest.class + }, + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { + "dubbo.service.version = 1.0.0", + "dubbo.application.id = my-application", + "dubbo.application.name = dubbo-demo-application", + "dubbo.module.id = my-module", + "dubbo.module.name = dubbo-demo-module", + "dubbo.registry.id = my-registry", + "dubbo.registry.address = N/A", + "dubbo.protocol.id=my-protocol", + "dubbo.protocol.name=dubbo", + "dubbo.protocol.port=20880", + "dubbo.provider.id=my-provider", + "dubbo.provider.host=127.0.0.1", + "dubbo.scan.basePackages=org.apache.dubbo.spring.boot.actuate.autoconfigure", + "endpoints.enabled = true", + "management.security.enabled = false", + "management.contextPath = /actuator", + "endpoints.dubbo.enabled = true", + "endpoints.dubbo.sensitive = false", + "endpoints.dubboshutdown.enabled = true", + "endpoints.dubboconfigs.enabled = true", + "endpoints.dubboservices.enabled = true", + "endpoints.dubboreferences.enabled = true", + "endpoints.dubboproperties.enabled = true", + }) +@EnableAutoConfiguration +public class DubboEndpointAutoConfigurationTest { + + @Autowired + private DubboEndpoint dubboEndpoint; + + @Autowired + private DubboConfigsMetadata dubboConfigsMetadata; + + @Autowired + private DubboPropertiesMetadata dubboProperties; + + @Autowired + private DubboReferencesMetadata dubboReferencesMetadata; + + @Autowired + private DubboServicesMetadata dubboServicesMetadata; + + @Autowired + private DubboShutdownMetadata dubboShutdownMetadata; + + private RestTemplate restTemplate = new RestTemplate(); + + @Autowired + private ObjectMapper objectMapper; + + @Value("http://127.0.0.1:${local.management.port}${management.contextPath:}") + private String actuatorBaseURL; + + @Test + public void testShutdown() throws Exception { + + Map value = dubboShutdownMetadata.shutdown(); + + Map shutdownCounts = (Map) value.get("shutdown.count"); + + Assert.assertEquals(0, shutdownCounts.get("registries")); + Assert.assertEquals(1, shutdownCounts.get("protocols")); + Assert.assertEquals(1, shutdownCounts.get("services")); + Assert.assertEquals(0, shutdownCounts.get("references")); + + } + + @Test + public void testConfigs() { + + Map>> configsMap = dubboConfigsMetadata.configs(); + + Map> beansMetadata = configsMap.get("ApplicationConfig"); + Assert.assertEquals("dubbo-demo-application", beansMetadata.get("my-application").get("name")); + + beansMetadata = configsMap.get("ConsumerConfig"); + Assert.assertTrue(beansMetadata.isEmpty()); + + beansMetadata = configsMap.get("MethodConfig"); + Assert.assertTrue(beansMetadata.isEmpty()); + + beansMetadata = configsMap.get("ModuleConfig"); + Assert.assertEquals("dubbo-demo-module", beansMetadata.get("my-module").get("name")); + + beansMetadata = configsMap.get("MonitorConfig"); + Assert.assertTrue(beansMetadata.isEmpty()); + + beansMetadata = configsMap.get("ProtocolConfig"); + Assert.assertEquals("dubbo", beansMetadata.get("my-protocol").get("name")); + + beansMetadata = configsMap.get("ProviderConfig"); + Assert.assertEquals("127.0.0.1", beansMetadata.get("my-provider").get("host")); + + beansMetadata = configsMap.get("ReferenceConfig"); + Assert.assertTrue(beansMetadata.isEmpty()); + + beansMetadata = configsMap.get("RegistryConfig"); + Assert.assertEquals("N/A", beansMetadata.get("my-registry").get("address")); + + beansMetadata = configsMap.get("ServiceConfig"); + Assert.assertFalse(beansMetadata.isEmpty()); + + } + + @Test + public void testServices() { + + Map> services = dubboServicesMetadata.services(); + + Assert.assertEquals(1, services.size()); + + Map demoServiceMeta = services.get("ServiceBean:org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointAutoConfigurationTest$DemoService:1.0.0"); + + Assert.assertEquals("1.0.0", demoServiceMeta.get("version")); + + } + + @Test + public void testReferences() { + + Map> references = dubboReferencesMetadata.references(); + + Assert.assertTrue(references.isEmpty()); + + } + + @Test + public void testProperties() { + + SortedMap properties = dubboProperties.properties(); + + Assert.assertEquals("my-application", properties.get("dubbo.application.id")); + Assert.assertEquals("dubbo-demo-application", properties.get("dubbo.application.name")); + Assert.assertEquals("my-module", properties.get("dubbo.module.id")); + Assert.assertEquals("dubbo-demo-module", properties.get("dubbo.module.name")); + Assert.assertEquals("my-registry", properties.get("dubbo.registry.id")); + Assert.assertEquals("N/A", properties.get("dubbo.registry.address")); + Assert.assertEquals("my-protocol", properties.get("dubbo.protocol.id")); + Assert.assertEquals("dubbo", properties.get("dubbo.protocol.name")); + Assert.assertEquals("20880", properties.get("dubbo.protocol.port")); + Assert.assertEquals("my-provider", properties.get("dubbo.provider.id")); + Assert.assertEquals("127.0.0.1", properties.get("dubbo.provider.host")); + Assert.assertEquals("org.apache.dubbo.spring.boot.actuate.autoconfigure", properties.get("dubbo.scan.basePackages")); + } + + @Test + public void testHttpEndpoints() throws JsonProcessingException { +// testHttpEndpoint("/dubbo", dubboEndpoint::invoke); + testHttpEndpoint("/dubbo/configs", dubboConfigsMetadata::configs); + testHttpEndpoint("/dubbo/services", dubboServicesMetadata::services); + testHttpEndpoint("/dubbo/references", dubboReferencesMetadata::references); + testHttpEndpoint("/dubbo/properties", dubboProperties::properties); + } + + private void testHttpEndpoint(String actuatorURI, Supplier resultsSupplier) throws JsonProcessingException { + String actuatorURL = actuatorBaseURL + actuatorURI; + String response = restTemplate.getForObject(actuatorURL, String.class); + Assert.assertEquals(objectMapper.writeValueAsString(resultsSupplier.get()), response); + } + + + interface DemoService { + String sayHello(String name); + } + + @Service( + version = "${dubbo.service.version}", + application = "${dubbo.application.id}", + protocol = "${dubbo.protocol.id}", + registry = "${dubbo.registry.id}" + ) + static class DefaultDemoService implements DemoService { + + public String sayHello(String name) { + return "Hello, " + name + " (from Spring Boot)"; + } + + } + + +} diff --git a/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorTest.java b/dubbo-spring-boot-compatible/actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorTest.java similarity index 96% rename from dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorTest.java rename to dubbo-spring-boot-compatible/actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorTest.java index 6a2efe373..a3ac06d0a 100644 --- a/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorTest.java +++ b/dubbo-spring-boot-compatible/actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/health/DubboHealthIndicatorTest.java @@ -17,7 +17,6 @@ package org.apache.dubbo.spring.boot.actuate.health; import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig; - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -27,7 +26,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import java.util.Map; @@ -35,9 +34,9 @@ * {@link DubboHealthIndicator} Test * * @see DubboHealthIndicator - * @since 1.0.0 + * @since 2.7.0 */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @TestPropertySource(properties = { "dubbo.protocol.id = dubbo-protocol", "dubbo.protocol.name = dubbo", diff --git a/dubbo-spring-boot-compatible/autoconfigure/pom.xml b/dubbo-spring-boot-compatible/autoconfigure/pom.xml new file mode 100644 index 000000000..f1b0e1275 --- /dev/null +++ b/dubbo-spring-boot-compatible/autoconfigure/pom.xml @@ -0,0 +1,72 @@ + + + + + org.apache.dubbo + dubbo-spring-boot-compatible + ${revision} + ../pom.xml + + 4.0.0 + + dubbo-spring-boot-autoconfigure-compatible + Apache Dubbo Spring Boot :: Compatible :: Auto-Configure + Apache Dubbo Spring Boot Compatible for Spring Boot 1.x Auto-Configure + + + + + + + org.springframework.boot + spring-boot-autoconfigure + true + + + + org.springframework.boot + spring-boot-starter-logging + true + + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + org.apache.dubbo + dubbo + true + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + \ No newline at end of file diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfiguration.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfiguration.java similarity index 70% rename from dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfiguration.java rename to dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfiguration.java index d90bd0d8b..f49e49e41 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfiguration.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfiguration.java @@ -16,72 +16,60 @@ */ package org.apache.dubbo.spring.boot.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.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Scope; -import org.springframework.core.env.Environment; +import org.springframework.core.env.PropertyResolver; import java.util.Set; import static java.util.Collections.emptySet; import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_PROPERTY_NAME; +import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME; +import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_CONFIG_PREFIX; import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_PREFIX; +import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_SCAN_PREFIX; import static org.apache.dubbo.spring.boot.util.DubboUtils.MULTIPLE_CONFIG_PROPERTY_NAME; -import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE; /** * 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) 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 * @@ -109,7 +97,7 @@ protected static class SingleDubboConfigConfiguration { * @see EnableDubboConfig * @see DubboConfigConfiguration.Multiple */ - @ConditionalOnProperty(name = MULTIPLE_CONFIG_PROPERTY_NAME, havingValue = "true") + @ConditionalOnProperty(prefix = DUBBO_CONFIG_PREFIX, name = MULTIPLE_CONFIG_PROPERTY_NAME, matchIfMissing = true) @EnableDubboConfig(multiple = true) protected static class MultipleDubboConfigConfiguration { } diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBindingAutoConfiguration.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBindingAutoConfiguration.java new file mode 100644 index 000000000..4de242eb1 --- /dev/null +++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBindingAutoConfiguration.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.autoconfigure; + +import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; +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.bind.RelaxedPropertyResolver; +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.core.env.PropertyResolver; + +import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME; +import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_PREFIX; +import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_SCAN_PREFIX; +import static org.apache.dubbo.spring.boot.util.DubboUtils.RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME; +import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE; + +/** + * Dubbo Relaxed Binding Auto-{@link Configuration} for Spring Boot 1.x + */ +@ConditionalOnProperty(prefix = DUBBO_PREFIX, name = "enabled", matchIfMissing = true) +@ConditionalOnClass(name = "org.springframework.boot.bind.RelaxedPropertyResolver") +@Configuration +public class DubboRelaxedBindingAutoConfiguration { + + @Bean(name = BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME) + public PropertyResolver dubboScanBasePackagesPropertyResolver(Environment environment) { + return new RelaxedPropertyResolver(environment, DUBBO_SCAN_PREFIX); + } + + @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(); + } +} diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinder.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinder.java new file mode 100644 index 000000000..b0e848078 --- /dev/null +++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinder.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.autoconfigure; + +import org.apache.dubbo.config.AbstractConfig; +import org.apache.dubbo.config.spring.context.properties.AbstractDubboConfigBinder; +import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; +import org.springframework.beans.MutablePropertyValues; +import org.springframework.boot.bind.RelaxedDataBinder; + +import java.util.Map; + +import static org.apache.dubbo.config.spring.util.PropertySourcesUtils.getSubProperties; + +/** + * Spring Boot Relaxed {@link DubboConfigBinder} implementation + * + * @since 2.7.0 + */ +class RelaxedDubboConfigBinder extends AbstractDubboConfigBinder { + + @Override + public void bind(String prefix, C dubboConfig) { + RelaxedDataBinder relaxedDataBinder = new RelaxedDataBinder(dubboConfig); + // Set ignored* + relaxedDataBinder.setIgnoreInvalidFields(isIgnoreInvalidFields()); + relaxedDataBinder.setIgnoreUnknownFields(isIgnoreUnknownFields()); + // Get properties under specified prefix from PropertySources + Map properties = getSubProperties(getPropertySources(), prefix); + // Convert Map to MutablePropertyValues + MutablePropertyValues propertyValues = new MutablePropertyValues(properties); + // Bind + relaxedDataBinder.bind(propertyValues); + } +} diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListener.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListener.java similarity index 80% rename from dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListener.java rename to dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListener.java index f4a94d2d2..738c2b105 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListener.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListener.java @@ -19,12 +19,13 @@ 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 @@ /** * 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 = @@ -90,12 +96,30 @@ protected void onApplicationReadyEvent(ApplicationReadyEvent event) { 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) { diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListener.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListener.java similarity index 95% rename from dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListener.java rename to dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListener.java index 319c1d9ee..6e6826be5 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListener.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListener.java @@ -18,7 +18,6 @@ import org.apache.dubbo.common.utils.ConfigUtils; import org.apache.dubbo.config.AbstractConfig; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; @@ -30,7 +29,7 @@ import java.util.SortedMap; import static org.apache.dubbo.spring.boot.util.DubboUtils.DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE; -import static org.apache.dubbo.spring.boot.util.DubboUtils.OVERRIDE_CONFIG_PROPERTY_NAME; +import static org.apache.dubbo.spring.boot.util.DubboUtils.OVERRIDE_CONFIG_FULL_PROPERTY_NAME; import static org.apache.dubbo.spring.boot.util.DubboUtils.filterDubboProperties; /** @@ -40,7 +39,7 @@ *

* * @see ConfigUtils - * @since 1.0.0 + * @since 2.7.0 */ @Order // LOWEST_PRECEDENCE Make sure last execution public class OverrideDubboConfigApplicationListener implements ApplicationListener { @@ -56,7 +55,7 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { 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) { @@ -66,19 +65,12 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { 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/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListener.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListener.java similarity index 95% rename from dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListener.java rename to dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListener.java index 1db2438e8..f053227ff 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListener.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListener.java @@ -17,12 +17,11 @@ package org.apache.dubbo.spring.boot.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; @@ -36,9 +35,9 @@ * 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); diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessor.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessor.java similarity index 99% rename from dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessor.java rename to dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessor.java index 3e406c73d..0efbc6b48 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessor.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessor.java @@ -19,7 +19,6 @@ import org.apache.dubbo.config.ApplicationConfig; import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig; import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfigBinding; - import org.springframework.boot.SpringApplication; import org.springframework.boot.context.ContextIdApplicationContextInitializer; import org.springframework.boot.env.EnvironmentPostProcessor; diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/DubboUtils.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/DubboUtils.java similarity index 78% rename from dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/DubboUtils.java rename to dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/DubboUtils.java index ba0e9c790..5b9fcd491 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/DubboUtils.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/DubboUtils.java @@ -16,7 +16,10 @@ */ package org.apache.dubbo.spring.boot.util; +import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor; +import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.PropertyResolver; import java.util.Collections; import java.util.Map; @@ -26,7 +29,7 @@ /** * The utilities class for Dubbo * - * @since 1.0.0 + * @since 2.7.0 */ public abstract class DubboUtils { @@ -49,38 +52,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 @@ -113,6 +116,16 @@ public abstract class DubboUtils { */ 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"; + /** * Filters Dubbo Properties from {@link ConfigurableEnvironment} * diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/EnvironmentUtils.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/EnvironmentUtils.java similarity index 99% rename from dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/EnvironmentUtils.java rename to dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/EnvironmentUtils.java index 1f0e1181c..943c1a40f 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/EnvironmentUtils.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/util/EnvironmentUtils.java @@ -32,7 +32,7 @@ * The utilities class for {@link Environment} * * @see Environment - * @since 1.0.0 + * @since 2.7.0 */ public abstract class EnvironmentUtils { diff --git a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json b/dubbo-spring-boot-compatible/autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json similarity index 58% rename from dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json rename to dubbo-spring-boot-compatible/autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json index 2b5200999..d8101217c 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json +++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json @@ -3,92 +3,92 @@ "groups": [], "properties": [ { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.architecture", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.compiler", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.default", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.dump-directory", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.environment", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.id", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.logger", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.monitor", - "type": "com.alibaba.dubbo.config.MonitorConfig" + "type": "org.apache.dubbo.config.MonitorConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.name", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.organization", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.owner", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.parameters", "type": "java.util.Map" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.qos-accept-foreign-ip", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.qos-enable", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.qos-port", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.registries", - "type": "java.util.List" + "type": "java.util.List" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.registry", - "type": "com.alibaba.dubbo.config.RegistryConfig" + "type": "org.apache.dubbo.config.RegistryConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "sourceType": "org.apache.dubbo.config.ApplicationConfig", "name": "dubbo.application.version", "type": "java.lang.String" }, @@ -96,7 +96,7 @@ "sourceType": "org.apache.dubbo.spring.boot.autoconfigure.MultipleDubboConfigBindingProperties", "name": "dubbo.applications", "description": "Multiple {@link ApplicationConfig} property", - "type": "java.util.Map" + "type": "java.util.Map" }, { "sourceType": "org.apache.dubbo.spring.boot.autoconfigure.DubboConfigProperties", @@ -111,211 +111,211 @@ "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.actives", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.application", - "type": "com.alibaba.dubbo.config.ApplicationConfig" + "type": "org.apache.dubbo.config.ApplicationConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.async", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.cache", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.callbacks", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.check", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.client", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.cluster", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.connections", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.default", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.filter", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.generic", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.group", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.id", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.init", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "deprecated": true, "name": "dubbo.consumer.injvm", "type": "java.lang.Boolean", "deprecation": {} }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.layer", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.lazy", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.listener", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.loadbalance", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "deprecated": true, "name": "dubbo.consumer.local", "type": "java.lang.String", "deprecation": {} }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.merger", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.mock", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.module", - "type": "com.alibaba.dubbo.config.ModuleConfig" + "type": "org.apache.dubbo.config.ModuleConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.monitor", - "type": "com.alibaba.dubbo.config.MonitorConfig" + "type": "org.apache.dubbo.config.MonitorConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.onconnect", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.ondisconnect", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.owner", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.parameters", "type": "java.util.Map" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.proxy", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.reconnect", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.registries", - "type": "java.util.List" + "type": "java.util.List" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.registry", - "type": "com.alibaba.dubbo.config.RegistryConfig" + "type": "org.apache.dubbo.config.RegistryConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.retries", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.scope", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.sent", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.sticky", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.stub", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.timeout", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.validation", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "sourceType": "org.apache.dubbo.config.ConsumerConfig", "name": "dubbo.consumer.version", "type": "java.lang.String" }, @@ -323,50 +323,50 @@ "sourceType": "org.apache.dubbo.spring.boot.autoconfigure.MultipleDubboConfigBindingProperties", "name": "dubbo.consumers", "description": "Multiple {@link ConsumerConfig} property", - "type": "java.util.Map" + "type": "java.util.Map" }, { - "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "sourceType": "org.apache.dubbo.config.ModuleConfig", "name": "dubbo.module.default", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "sourceType": "org.apache.dubbo.config.ModuleConfig", "name": "dubbo.module.id", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "sourceType": "org.apache.dubbo.config.ModuleConfig", "name": "dubbo.module.monitor", - "type": "com.alibaba.dubbo.config.MonitorConfig" + "type": "org.apache.dubbo.config.MonitorConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "sourceType": "org.apache.dubbo.config.ModuleConfig", "name": "dubbo.module.name", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "sourceType": "org.apache.dubbo.config.ModuleConfig", "name": "dubbo.module.organization", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "sourceType": "org.apache.dubbo.config.ModuleConfig", "name": "dubbo.module.owner", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "sourceType": "org.apache.dubbo.config.ModuleConfig", "name": "dubbo.module.registries", - "type": "java.util.List" + "type": "java.util.List" }, { - "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "sourceType": "org.apache.dubbo.config.ModuleConfig", "name": "dubbo.module.registry", - "type": "com.alibaba.dubbo.config.RegistryConfig" + "type": "org.apache.dubbo.config.RegistryConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "sourceType": "org.apache.dubbo.config.ModuleConfig", "name": "dubbo.module.version", "type": "java.lang.String" }, @@ -374,50 +374,50 @@ "sourceType": "org.apache.dubbo.spring.boot.autoconfigure.MultipleDubboConfigBindingProperties", "name": "dubbo.modules", "description": "Multiple {@link ModuleConfig} property", - "type": "java.util.Map" + "type": "java.util.Map" }, { - "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "sourceType": "org.apache.dubbo.config.MonitorConfig", "name": "dubbo.monitor.address", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "sourceType": "org.apache.dubbo.config.MonitorConfig", "name": "dubbo.monitor.default", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "sourceType": "org.apache.dubbo.config.MonitorConfig", "name": "dubbo.monitor.group", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "sourceType": "org.apache.dubbo.config.MonitorConfig", "name": "dubbo.monitor.id", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "sourceType": "org.apache.dubbo.config.MonitorConfig", "name": "dubbo.monitor.parameters", "type": "java.util.Map" }, { - "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "sourceType": "org.apache.dubbo.config.MonitorConfig", "name": "dubbo.monitor.password", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "sourceType": "org.apache.dubbo.config.MonitorConfig", "name": "dubbo.monitor.protocol", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "sourceType": "org.apache.dubbo.config.MonitorConfig", "name": "dubbo.monitor.username", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "sourceType": "org.apache.dubbo.config.MonitorConfig", "name": "dubbo.monitor.version", "type": "java.lang.String" }, @@ -425,164 +425,164 @@ "sourceType": "org.apache.dubbo.spring.boot.autoconfigure.MultipleDubboConfigBindingProperties", "name": "dubbo.monitors", "description": "Multiple {@link MonitorConfig} property", - "type": "java.util.Map" + "type": "java.util.Map" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.accepts", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.accesslog", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.buffer", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.charset", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.client", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.codec", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.contextpath", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.default", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.dispatcher", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "deprecated": true, "name": "dubbo.protocol.dispather", "type": "java.lang.String", "deprecation": {} }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.exchanger", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.heartbeat", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.host", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.id", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.iothreads", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.name", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.networker", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.parameters", "type": "java.util.Map" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "deprecated": true, "name": "dubbo.protocol.path", "type": "java.lang.String", "deprecation": {} }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.payload", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.port", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.prompt", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.queues", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.register", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.serialization", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.server", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.status", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.telnet", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.threadpool", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.threads", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "sourceType": "org.apache.dubbo.config.ProtocolConfig", "name": "dubbo.protocol.transporter", "type": "java.lang.String" }, @@ -590,370 +590,370 @@ "sourceType": "org.apache.dubbo.spring.boot.autoconfigure.MultipleDubboConfigBindingProperties", "name": "dubbo.protocols", "description": "Multiple {@link ProtocolConfig} property", - "type": "java.util.Map" + "type": "java.util.Map" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.accepts", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.accesslog", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.actives", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.application", - "type": "com.alibaba.dubbo.config.ApplicationConfig" + "type": "org.apache.dubbo.config.ApplicationConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.async", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.buffer", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.cache", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.callbacks", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.charset", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.client", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.cluster", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.codec", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.connections", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.contextpath", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "deprecated": true, "name": "dubbo.provider.default", "type": "java.lang.Boolean", "deprecation": {} }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.delay", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.deprecated", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.dispatcher", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "deprecated": true, "name": "dubbo.provider.dispather", "type": "java.lang.String", "deprecation": {} }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.document", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.dynamic", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.exchanger", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.executes", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.export", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.filter", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.group", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.host", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.id", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.iothreads", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.layer", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.listener", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.loadbalance", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "deprecated": true, "name": "dubbo.provider.local", "type": "java.lang.String", "deprecation": {} }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.merger", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.mock", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.module", - "type": "com.alibaba.dubbo.config.ModuleConfig" + "type": "org.apache.dubbo.config.ModuleConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.monitor", - "type": "com.alibaba.dubbo.config.MonitorConfig" + "type": "org.apache.dubbo.config.MonitorConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.networker", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.onconnect", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.ondisconnect", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.owner", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.parameters", "type": "java.util.Map" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "deprecated": true, "name": "dubbo.provider.path", "type": "java.lang.String", "deprecation": {} }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.payload", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "deprecated": true, "name": "dubbo.provider.port", "type": "java.lang.Integer", "deprecation": {} }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.prompt", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.protocol", - "type": "com.alibaba.dubbo.config.ProtocolConfig" + "type": "org.apache.dubbo.config.ProtocolConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.protocols", - "type": "java.util.List" + "type": "java.util.List" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.proxy", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.queues", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.register", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.registries", - "type": "java.util.List" + "type": "java.util.List" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.registry", - "type": "com.alibaba.dubbo.config.RegistryConfig" + "type": "org.apache.dubbo.config.RegistryConfig" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.retries", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.scope", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.sent", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.serialization", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.server", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.status", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.stub", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.telnet", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.threadpool", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.threads", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.timeout", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.token", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.transporter", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.validation", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.version", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.wait", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.warmup", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "sourceType": "org.apache.dubbo.config.ProviderConfig", "name": "dubbo.provider.weight", "type": "java.lang.Integer" }, @@ -961,128 +961,128 @@ "sourceType": "org.apache.dubbo.spring.boot.autoconfigure.MultipleDubboConfigBindingProperties", "name": "dubbo.providers", "description": "Multiple {@link ProviderConfig} property", - "type": "java.util.Map" + "type": "java.util.Map" }, { "sourceType": "org.apache.dubbo.spring.boot.autoconfigure.MultipleDubboConfigBindingProperties", "name": "dubbo.registries", "description": "Multiple {@link RegistryConfig} property", - "type": "java.util.Map" + "type": "java.util.Map" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.address", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.check", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.client", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.cluster", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.default", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.dynamic", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.file", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.group", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.id", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.parameters", "type": "java.util.Map" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.password", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.port", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.protocol", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.register", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.server", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.session", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.subscribe", "type": "java.lang.Boolean" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.timeout", "type": "java.lang.Integer" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "deprecated": true, "name": "dubbo.registry.transport", "type": "java.lang.String", "deprecation": {} }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.transporter", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.username", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "name": "dubbo.registry.version", "type": "java.lang.String" }, { - "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "sourceType": "org.apache.dubbo.config.RegistryConfig", "deprecated": true, "name": "dubbo.registry.wait", "type": "java.lang.Integer", diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/main/resources/META-INF/spring.factories b/dubbo-spring-boot-compatible/autoconfigure/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..08db894ac --- /dev/null +++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/resources/META-INF/spring.factories @@ -0,0 +1,9 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration,\ +org.apache.dubbo.spring.boot.autoconfigure.DubboRelaxedBindingAutoConfiguration +org.springframework.context.ApplicationListener=\ +org.apache.dubbo.spring.boot.context.event.OverrideDubboConfigApplicationListener,\ +org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListener,\ +org.apache.dubbo.spring.boot.context.event.AwaitingNonWebApplicationListener +org.springframework.boot.env.EnvironmentPostProcessor=\ +org.apache.dubbo.spring.boot.env.DubboDefaultPropertiesEnvironmentPostProcessor \ No newline at end of file diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTest.java new file mode 100644 index 000000000..cd574e029 --- /dev/null +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.autoconfigure; + +import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; +import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * {@link DubboAutoConfiguration} Test + * + * @see DubboAutoConfiguration + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = { + CompatibleDubboAutoConfigurationTest.class +}, properties = { + "dubbo.scan.base-packages = org.apache.dubbo.spring.boot.autoconfigure" +}) +@EnableAutoConfiguration +public class CompatibleDubboAutoConfigurationTest { + + @Autowired + private ObjectProvider serviceAnnotationBeanPostProcessor; + + @Autowired + private ObjectProvider referenceAnnotationBeanPostProcessor; + + @Test + public void testBeans() { + Assert.assertNotNull(serviceAnnotationBeanPostProcessor); + Assert.assertNotNull(serviceAnnotationBeanPostProcessor.getIfAvailable()); + Assert.assertNotNull(referenceAnnotationBeanPostProcessor); + Assert.assertNotNull(referenceAnnotationBeanPostProcessor.getIfAvailable()); + } +} diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTestWithoutProperties.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTestWithoutProperties.java new file mode 100644 index 000000000..06a21d881 --- /dev/null +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTestWithoutProperties.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.autoconfigure; + +import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; +import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * {@link DubboAutoConfiguration} Test + * + * @see DubboAutoConfiguration + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = CompatibleDubboAutoConfigurationTestWithoutProperties.class) +@EnableAutoConfiguration +public class CompatibleDubboAutoConfigurationTestWithoutProperties { + + @Autowired(required = false) + private ServiceAnnotationBeanPostProcessor serviceAnnotationBeanPostProcessor; + + @Autowired + private ReferenceAnnotationBeanPostProcessor referenceAnnotationBeanPostProcessor; + + @Test + public void testBeans() { + Assert.assertNull(serviceAnnotationBeanPostProcessor); + Assert.assertNotNull(referenceAnnotationBeanPostProcessor); + } +} diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java similarity index 96% rename from dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java rename to dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java index 5a6d737b1..1addb5e78 100644 --- a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java @@ -23,17 +23,17 @@ import org.apache.dubbo.config.ProtocolConfig; import org.apache.dubbo.config.ProviderConfig; import org.apache.dubbo.config.RegistryConfig; - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.core.env.Environment; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import java.util.LinkedHashMap; import java.util.Map; @@ -43,9 +43,9 @@ /** * {@link DubboAutoConfiguration} Test On multiple Dubbo Configuration * - * @since 1.0.0 + * @since 2.7.0 */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @TestPropertySource( properties = { "dubbo.applications.application1.NAME = dubbo-demo-application", @@ -62,8 +62,11 @@ } ) @SpringBootTest( - classes = {DubboAutoConfiguration.class} + classes = { + DubboAutoConfigurationOnMultipleConfigTest.class + } ) +@EnableAutoConfiguration public class DubboAutoConfigurationOnMultipleConfigTest { @Autowired diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java similarity index 88% rename from dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java rename to dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java index 6f93ad0c8..28d1e6d06 100644 --- a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java @@ -23,25 +23,23 @@ import org.apache.dubbo.config.ProtocolConfig; import org.apache.dubbo.config.ProviderConfig; import org.apache.dubbo.config.RegistryConfig; -import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; -import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor; - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.core.env.Environment; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; /** * {@link DubboAutoConfiguration} Test On single Dubbo Configuration * - * @since 1.0.0 + * @since 2.7.0 */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @TestPropertySource( properties = { "dubbo.application.name = dubbo-demo-application", @@ -55,8 +53,9 @@ } ) @SpringBootTest( - classes = {DubboAutoConfiguration.class} + classes = {DubboAutoConfigurationOnSingleConfigTest.class} ) +@EnableAutoConfiguration public class DubboAutoConfigurationOnSingleConfigTest { @Autowired @@ -92,12 +91,6 @@ public class DubboAutoConfigurationOnSingleConfigTest { @Autowired private ApplicationContext applicationContext; - @Autowired(required = false) - private ServiceAnnotationBeanPostProcessor serviceAnnotationBeanPostProcessor; - - @Autowired - private ReferenceAnnotationBeanPostProcessor referenceAnnotationBeanPostProcessor; - @Test public void testApplicationConfig() { diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinderTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinderTest.java similarity index 85% rename from dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinderTest.java rename to dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinderTest.java index fa91c09fb..817f03550 100644 --- a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinderTest.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/RelaxedDubboConfigBinderTest.java @@ -19,7 +19,7 @@ import org.apache.dubbo.config.ApplicationConfig; import org.apache.dubbo.config.ProtocolConfig; import org.apache.dubbo.config.RegistryConfig; - +import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -30,16 +30,20 @@ /** * {@link RelaxedDubboConfigBinder} Test - * - * @since 0.1.1 */ @RunWith(SpringRunner.class) -@TestPropertySource(locations = "classpath:/dubbo.properties") +@TestPropertySource(properties = { + "dubbo.application.NAME=hello", + "dubbo.application.owneR=world", + "dubbo.registry.Address=10.20.153.17", + "dubbo.protocol.pORt=20881", + "dubbo.service.invoke.timeout=2000", +}) @ContextConfiguration(classes = RelaxedDubboConfigBinder.class) public class RelaxedDubboConfigBinderTest { @Autowired - private RelaxedDubboConfigBinder dubboConfigBinder; + private DubboConfigBinder dubboConfigBinder; @Test public void testBinder() { diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListenerTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListenerTest.java new file mode 100644 index 000000000..8de2caece --- /dev/null +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListenerTest.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.context.event; + +import org.junit.Assert; +import org.junit.Test; +import org.springframework.boot.builder.SpringApplicationBuilder; + +import java.util.concurrent.atomic.AtomicBoolean; + +/** + * {@link AwaitingNonWebApplicationListener} Test + */ +public class AwaitingNonWebApplicationListenerTest { + + @Test + public void init() { + AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited(); + awaited.set(false); + + } + + @Test + public void testSingleContextNonWebApplication() { + new SpringApplicationBuilder(Object.class) + .web(false) + .run().close(); + AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited(); + Assert.assertTrue(awaited.get()); + } + + @Test + public void testMultipleContextNonWebApplication() { + new SpringApplicationBuilder(Object.class) + .parent(Object.class) + .web(false) + .run().close(); + AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited(); + Assert.assertTrue(awaited.get()); + } + +} diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerDisableTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerDisableTest.java similarity index 94% rename from dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerDisableTest.java rename to dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerDisableTest.java index 3fff62140..4bea84cad 100644 --- a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerDisableTest.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerDisableTest.java @@ -17,14 +17,13 @@ package org.apache.dubbo.spring.boot.context.event; import org.apache.dubbo.common.utils.ConfigUtils; - import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import java.util.Properties; @@ -32,9 +31,9 @@ * {@link OverrideDubboConfigApplicationListener} Test * * @see OverrideDubboConfigApplicationListener - * @since 1.0.0 + * @since 2.7.0 */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @TestPropertySource( properties = { "dubbo.config.override = false", diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerTest.java similarity index 94% rename from dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerTest.java rename to dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerTest.java index 8e8116171..5e42561c5 100644 --- a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerTest.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/OverrideDubboConfigApplicationListenerTest.java @@ -17,14 +17,13 @@ package org.apache.dubbo.spring.boot.context.event; import org.apache.dubbo.common.utils.ConfigUtils; - import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import java.util.Properties; @@ -32,9 +31,9 @@ * {@link OverrideDubboConfigApplicationListener} Test * * @see OverrideDubboConfigApplicationListener - * @since 1.0.0 + * @since 2.7.0 */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @TestPropertySource( properties = { "dubbo.application.name = dubbo-demo-application", diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListenerTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListenerTest.java similarity index 92% rename from dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListenerTest.java rename to dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListenerTest.java index be9d2a3d8..c006a7553 100644 --- a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListenerTest.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListenerTest.java @@ -21,15 +21,15 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; /** * {@link WelcomeLogoApplicationListener} Test * * @see WelcomeLogoApplicationListener - * @since 1.0.0 + * @since 2.7.0 */ -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @SpringBootTest( classes = {WelcomeLogoApplicationListener.class} ) diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java new file mode 100644 index 000000000..2fbb6aa1b --- /dev/null +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.env; + +import org.junit.Assert; +import org.junit.Test; +import org.springframework.boot.SpringApplication; +import org.springframework.core.Ordered; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.MutablePropertySources; +import org.springframework.core.env.PropertySource; +import org.springframework.mock.env.MockEnvironment; + +import java.util.HashMap; + +/** + * {@link DubboDefaultPropertiesEnvironmentPostProcessor} Test + */ +public class DubboDefaultPropertiesEnvironmentPostProcessorTest { + + private DubboDefaultPropertiesEnvironmentPostProcessor instance = + new DubboDefaultPropertiesEnvironmentPostProcessor(); + + private SpringApplication springApplication = new SpringApplication(); + + @Test + public void testOrder() { + Assert.assertEquals(Ordered.LOWEST_PRECEDENCE, instance.getOrder()); + } + + @Test + public void testPostProcessEnvironment() { + MockEnvironment environment = new MockEnvironment(); + // Case 1 : Not Any property + instance.postProcessEnvironment(environment, springApplication); + // Get PropertySources + MutablePropertySources propertySources = environment.getPropertySources(); + // Nothing to change + PropertySource defaultPropertySource = propertySources.get("defaultProperties"); + Assert.assertNotNull(defaultPropertySource); + Assert.assertEquals("true", defaultPropertySource.getProperty("dubbo.config.multiple")); + Assert.assertEquals("false", defaultPropertySource.getProperty("dubbo.application.qos-enable")); + + // Case 2 : Only set property "spring.application.name" + environment.setProperty("spring.application.name", "demo-dubbo-application"); + instance.postProcessEnvironment(environment, springApplication); + defaultPropertySource = propertySources.get("defaultProperties"); + Object dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name"); + Assert.assertEquals("demo-dubbo-application", dubboApplicationName); + + // Case 3 : Only set property "dubbo.application.name" + // Rest environment + environment = new MockEnvironment(); + propertySources = environment.getPropertySources(); + environment.setProperty("dubbo.application.name", "demo-dubbo-application"); + instance.postProcessEnvironment(environment, springApplication); + defaultPropertySource = propertySources.get("defaultProperties"); + Assert.assertNotNull(defaultPropertySource); + dubboApplicationName = environment.getProperty("dubbo.application.name"); + Assert.assertEquals("demo-dubbo-application", dubboApplicationName); + + // Case 4 : If "defaultProperties" PropertySource is present in PropertySources + // Rest environment + environment = new MockEnvironment(); + propertySources = environment.getPropertySources(); + propertySources.addLast(new MapPropertySource("defaultProperties", new HashMap())); + environment.setProperty("spring.application.name", "demo-dubbo-application"); + instance.postProcessEnvironment(environment, springApplication); + defaultPropertySource = propertySources.get("defaultProperties"); + dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name"); + Assert.assertEquals("demo-dubbo-application", dubboApplicationName); + + // Case 5 : Rest dubbo.config.multiple and dubbo.application.qos-enable + environment = new MockEnvironment(); + propertySources = environment.getPropertySources(); + propertySources.addLast(new MapPropertySource("defaultProperties", new HashMap())); + environment.setProperty("dubbo.config.multiple", "false"); + environment.setProperty("dubbo.application.qos-enable", "true"); + instance.postProcessEnvironment(environment, springApplication); + Assert.assertEquals("false", environment.getProperty("dubbo.config.multiple")); + Assert.assertEquals("true", environment.getProperty("dubbo.application.qos-enable")); + } +} \ No newline at end of file diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/DubboUtilsTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/DubboUtilsTest.java similarity index 82% rename from dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/DubboUtilsTest.java rename to dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/DubboUtilsTest.java index 910cb7c43..7242b58af 100644 --- a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/DubboUtilsTest.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/DubboUtilsTest.java @@ -34,14 +34,14 @@ import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_SPRING_BOOT_GIT_URL; import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_SPRING_BOOT_ISSUES_URL; import static org.apache.dubbo.spring.boot.util.DubboUtils.MULTIPLE_CONFIG_PROPERTY_NAME; -import static org.apache.dubbo.spring.boot.util.DubboUtils.OVERRIDE_CONFIG_PROPERTY_NAME; +import static org.apache.dubbo.spring.boot.util.DubboUtils.OVERRIDE_CONFIG_FULL_PROPERTY_NAME; import static org.apache.dubbo.spring.boot.util.DubboUtils.filterDubboProperties; /** * {@link DubboUtils} Test * * @see DubboUtils - * @since 1.0.0 + * @since 2.7.0 */ public class DubboUtilsTest { @@ -50,15 +50,15 @@ public void testConstants() { Assert.assertEquals("dubbo", DUBBO_PREFIX); - Assert.assertEquals("dubbo.scan", DUBBO_SCAN_PREFIX); + Assert.assertEquals("dubbo.scan.", DUBBO_SCAN_PREFIX); - Assert.assertEquals("dubbo.scan.base-packages", BASE_PACKAGES_PROPERTY_NAME); + Assert.assertEquals("base-packages", BASE_PACKAGES_PROPERTY_NAME); - Assert.assertEquals("dubbo.config", DUBBO_CONFIG_PREFIX); + Assert.assertEquals("dubbo.config.", DUBBO_CONFIG_PREFIX); - Assert.assertEquals("dubbo.config.multiple", MULTIPLE_CONFIG_PROPERTY_NAME); + Assert.assertEquals("multiple", MULTIPLE_CONFIG_PROPERTY_NAME); - Assert.assertEquals("dubbo.config.override", OVERRIDE_CONFIG_PROPERTY_NAME); + Assert.assertEquals("dubbo.config.override", OVERRIDE_CONFIG_FULL_PROPERTY_NAME); Assert.assertEquals("https://github.com/apache/incubator-dubbo-spring-boot-project", DUBBO_SPRING_BOOT_GITHUB_URL); Assert.assertEquals("https://github.com/apache/incubator-dubbo-spring-boot-project.git", DUBBO_SPRING_BOOT_GIT_URL); @@ -68,7 +68,7 @@ public void testConstants() { Assert.assertEquals("dev@dubbo.apache.org", DUBBO_MAILING_LIST); - Assert.assertFalse(DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE); + Assert.assertTrue(DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE); Assert.assertTrue(DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE); @@ -80,13 +80,13 @@ public void testFilterDubboProperties() { MockEnvironment environment = new MockEnvironment(); environment.setProperty("message", "Hello,World"); - environment.setProperty(MULTIPLE_CONFIG_PROPERTY_NAME, "true"); - environment.setProperty(OVERRIDE_CONFIG_PROPERTY_NAME, "true"); + environment.setProperty(DUBBO_CONFIG_PREFIX + MULTIPLE_CONFIG_PROPERTY_NAME, "true"); + environment.setProperty(OVERRIDE_CONFIG_FULL_PROPERTY_NAME, "true"); SortedMap dubboProperties = filterDubboProperties(environment); - Assert.assertEquals("true", dubboProperties.get(MULTIPLE_CONFIG_PROPERTY_NAME)); - Assert.assertEquals("true", dubboProperties.get(OVERRIDE_CONFIG_PROPERTY_NAME)); + Assert.assertEquals("true", dubboProperties.get(DUBBO_CONFIG_PREFIX + MULTIPLE_CONFIG_PROPERTY_NAME)); + Assert.assertEquals("true", dubboProperties.get(OVERRIDE_CONFIG_FULL_PROPERTY_NAME)); } diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/EnvironmentUtilsTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/EnvironmentUtilsTest.java new file mode 100644 index 000000000..2ca3766c1 --- /dev/null +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/util/EnvironmentUtilsTest.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.spring.boot.util; + +import org.junit.Assert; +import org.junit.Test; +import org.springframework.core.env.CompositePropertySource; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.MutablePropertySources; +import org.springframework.core.env.StandardEnvironment; + +import java.util.HashMap; +import java.util.Map; + +/** + * {@link EnvironmentUtils} Test + * + * @see EnvironmentUtils + * @since 2.7.0 + */ +public class EnvironmentUtilsTest { + + @Test + public void testExtraProperties() { + + System.setProperty("user.name", "mercyblitz"); + + StandardEnvironment environment = new StandardEnvironment(); + + Map map = new HashMap<>(); + + map.put("user.name", "Mercy"); + + MapPropertySource propertySource = new MapPropertySource("first", map); + + CompositePropertySource compositePropertySource = new CompositePropertySource("comp"); + + compositePropertySource.addFirstPropertySource(propertySource); + + MutablePropertySources propertySources = environment.getPropertySources(); + + propertySources.addFirst(compositePropertySource); + + Map properties = EnvironmentUtils.extractProperties(environment); + + Assert.assertEquals("Mercy", properties.get("user.name")); + + } +} diff --git a/dubbo-spring-boot-compatible/pom.xml b/dubbo-spring-boot-compatible/pom.xml new file mode 100644 index 000000000..8af787e8a --- /dev/null +++ b/dubbo-spring-boot-compatible/pom.xml @@ -0,0 +1,43 @@ + + + + + org.apache.dubbo + dubbo-spring-boot-parent + ${revision} + ../dubbo-spring-boot-parent/pom.xml + + 4.0.0 + + dubbo-spring-boot-compatible + pom + Apache Dubbo Spring Boot :: Compatible + Apache Dubbo Spring Boot Compatible for Spring Boot 1.x + + + 1.5.19.RELEASE + + + + autoconfigure + actuator + + + \ No newline at end of file diff --git a/dubbo-spring-boot-distribution/pom.xml b/dubbo-spring-boot-distribution/pom.xml index 38f4a19a9..181ba4412 100644 --- a/dubbo-spring-boot-distribution/pom.xml +++ b/dubbo-spring-boot-distribution/pom.xml @@ -1,3 +1,4 @@ + + --> @@ -27,7 +28,7 @@ dubbo-spring-boot-distribution pom - Apache Dubbo Spring Boot Distribution + Apache Dubbo Spring Boot :: Distribution Apache Dubbo Spring Boot Distribution diff --git a/dubbo-spring-boot-parent/pom.xml b/dubbo-spring-boot-parent/pom.xml index e1db10f6b..9d7b1e8a9 100644 --- a/dubbo-spring-boot-parent/pom.xml +++ b/dubbo-spring-boot-parent/pom.xml @@ -1,3 +1,4 @@ + diff --git a/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/java/org/apache/dubbo/spring/boot/demo/consumer/bootstrap/DubboAutoConfigurationConsumerBootstrap.java b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/java/org/apache/dubbo/spring/boot/demo/consumer/bootstrap/DubboAutoConfigurationConsumerBootstrap.java index a76da3d45..5b2ac82eb 100644 --- a/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/java/org/apache/dubbo/spring/boot/demo/consumer/bootstrap/DubboAutoConfigurationConsumerBootstrap.java +++ b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/java/org/apache/dubbo/spring/boot/demo/consumer/bootstrap/DubboAutoConfigurationConsumerBootstrap.java @@ -18,7 +18,6 @@ import org.apache.dubbo.config.annotation.Reference; import org.apache.dubbo.spring.boot.demo.consumer.DemoService; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.ApplicationRunner; @@ -29,7 +28,7 @@ /** * Dubbo Auto Configuration Consumer Bootstrap * - * @since 1.0.0 + * @since 2.7.0 */ @EnableAutoConfiguration public class DubboAutoConfigurationConsumerBootstrap { diff --git a/dubbo-spring-boot-samples/auto-configure-samples/pom.xml b/dubbo-spring-boot-samples/auto-configure-samples/pom.xml index 51d86611f..3df5bf58a 100644 --- a/dubbo-spring-boot-samples/auto-configure-samples/pom.xml +++ b/dubbo-spring-boot-samples/auto-configure-samples/pom.xml @@ -1,3 +1,4 @@ + diff --git a/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/pom.xml index b0b46fe77..741dce9bf 100644 --- a/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/pom.xml +++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/pom.xml @@ -1,3 +1,4 @@ + org.springframework.boot - spring-boot-starter + spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-actuator + + + org.apache.dubbo dubbo-spring-boot-starter ${revision} + + org.apache.dubbo + dubbo-spring-boot-actuator + ${revision} + + org.apache.dubbo dubbo diff --git a/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/java/org/apache/dubbo/spring/boot/demo/consumer/bootstrap/DubboExternalizedConfigurationConsumerBootstrap.java b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/java/org/apache/dubbo/spring/boot/demo/consumer/bootstrap/DubboExternalizedConfigurationConsumerBootstrap.java index 835bfac46..f36ec2b6c 100644 --- a/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/java/org/apache/dubbo/spring/boot/demo/consumer/bootstrap/DubboExternalizedConfigurationConsumerBootstrap.java +++ b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/java/org/apache/dubbo/spring/boot/demo/consumer/bootstrap/DubboExternalizedConfigurationConsumerBootstrap.java @@ -18,18 +18,21 @@ import org.apache.dubbo.config.annotation.Reference; import org.apache.dubbo.spring.boot.demo.consumer.DemoService; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.ApplicationRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; /** * Dubbo Externalized Configuration Consumer Bootstrap */ @EnableAutoConfiguration +@RestController public class DubboExternalizedConfigurationConsumerBootstrap { private final Logger logger = LoggerFactory.getLogger(getClass()); @@ -38,7 +41,12 @@ public class DubboExternalizedConfigurationConsumerBootstrap { private DemoService demoService; public static void main(String[] args) { - SpringApplication.run(DubboExternalizedConfigurationConsumerBootstrap.class).close(); + SpringApplication.run(DubboExternalizedConfigurationConsumerBootstrap.class); + } + + @GetMapping("/say-hello") + public String sayHello(@RequestParam String name) { + return demoService.sayHello(name); } @Bean diff --git a/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/resources/application.yml b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/resources/application.yml index e3aef4286..3f98bc1e6 100644 --- a/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/resources/application.yml +++ b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/resources/application.yml @@ -2,6 +2,44 @@ spring: application: name: dubbo-externalized-configuration-consumer-sample +management: + endpoints: + web: + exposure: + include: '*' + endpoint: + dubbo: + enabled: true + dubboshutdown: + enabled: true + dubboconfigs: + enabled: true + dubboservices: + enabled: true + dubboreferences: + enabled: true + dubboproperties: + enabled: true + security: + ## Deprecated 2.x + enabled: false + +## For Spring Boot 1.x demo +endpoints: + dubbo: + enabled: true + sensitive: false + dubboshutdown: + enabled: true + dubboconfigs: + enabled: true + dubboservices: + enabled: true + dubboreferences: + enabled: true + dubboproperties: + enabled: true + demo: service: version: 1.0.0 diff --git a/dubbo-spring-boot-samples/externalized-configuration-samples/pom.xml b/dubbo-spring-boot-samples/externalized-configuration-samples/pom.xml index 75a4810b4..86e26ad86 100644 --- a/dubbo-spring-boot-samples/externalized-configuration-samples/pom.xml +++ b/dubbo-spring-boot-samples/externalized-configuration-samples/pom.xml @@ -1,3 +1,4 @@ + - - org.apache.zookeeper - zookeeper - true - - - - org.apache.curator - curator-framework - true - - org.apache.dubbo dubbo-spring-boot-autoconfigure diff --git a/pom.xml b/pom.xml index 9b52dd133..ffefee6a9 100644 --- a/pom.xml +++ b/pom.xml @@ -1,3 +1,4 @@ +