2.7.9 Release (#741)
* Polish apache/dubbo-spring-boot-project#718 : [Samples] Introducing the samples deployed the external Servlet container
* Polish apache/dubbo-spring-boot-project#718 : [Samples] Introducing the samples deployed the external Servlet container
* Polish apache/dubbo-spring-boot-project#718 : [Samples] Introducing the samples deployed the external Servlet container
* Polish apache/dubbo-spring-boot-project#685 : Dubbo2.7.5: Duplicate ServiceBean found
* To fix the declaration of years
* Polish apache/dubbo-spring-boot-project#733 : Upgrading the dependencies
* Polish apache/dubbo-spring-boot-project#734 : [Samples] Upgrading the latest Service-Introspection features
* Polish apache/dubbo-spring-boot-project#736 : Duplicate RegistryConfig found, there already has one default RegistryConfig or more than two RegistryConfigs have the same id
* Polish apache/dubbo-spring-boot-project#734 : [Samples] Upgrading the latest Service-Introspection features
* Revert "Polish apache/dubbo-spring-boot-project#734 : [Samples] Upgrading the latest Service-Introspection features"
This reverts commit 3e57fbe9ee87bbcd0de6c39d1f9e0b5ab4fc6f1f.
* Polish apache/dubbo-spring-boot-project#736 : Duplicate RegistryConfig found, there already has one default RegistryConfig or more than two RegistryConfigs have the same id
* Polish apache/dubbo-spring-boot-project#728 : When openfeign and dubbo coexist, DubboAutoConfiguration.primaryPropertyResolver configuration causes openfeign call to fail
* Polish apache/dubbo-spring-boot-project#728 : Refactor
* Bugfix test-cases
* Bugfix build errors
* Bugfix test-cases
* Bugfix test-cases
diff --git a/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java b/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java
index 51f4e03..44e8b4a 100644
--- a/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java
+++ b/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.spring.boot.actuate.autoconfigure;
import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.dubbo.rpc.model.ApplicationModel;
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;
@@ -26,7 +27,9 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -102,6 +105,16 @@
@Value("http://127.0.0.1:${local.management.port}${management.endpoints.web.base-path:/actuator}")
private String actuatorBaseURL;
+ @Before
+ public void init() {
+ ApplicationModel.reset();
+ }
+
+ @After
+ public void destroy() {
+ ApplicationModel.reset();
+ }
+
@Test
public void testShutdown() throws Exception {
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 6347a2e..3d32586 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
@@ -16,9 +16,12 @@
*/
package org.apache.dubbo.spring.boot.actuate.endpoint;
+import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.spring.boot.util.DubboUtils;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -40,6 +43,9 @@
@SpringBootTest(
classes = {
DubboMetadataEndpoint.class
+ },
+ properties = {
+ "dubbo.application.name = dubbo-demo-application"
}
)
@EnableAutoConfiguration
@@ -49,6 +55,16 @@
@Autowired
private DubboMetadataEndpoint dubboEndpoint;
+ @Before
+ public void init() {
+ ApplicationModel.reset();
+ }
+
+ @After
+ public void destroy() {
+ ApplicationModel.reset();
+ }
+
@Test
public void testInvoke() {
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DelegatingPropertyResolver.java b/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DelegatingPropertyResolver.java
deleted file mode 100644
index b36d921..0000000
--- a/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DelegatingPropertyResolver.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.spring.boot.autoconfigure;
-
-import org.apache.dubbo.common.utils.Assert;
-import org.springframework.core.env.PropertyResolver;
-import org.springframework.lang.Nullable;
-
-/**
- * Delegating {@link PropertyResolver}
- *
- * @since 2.7.1
- */
-class DelegatingPropertyResolver implements PropertyResolver {
-
- private final PropertyResolver delegate;
-
- DelegatingPropertyResolver(PropertyResolver delegate) {
- Assert.notNull(delegate, "The delegate of PropertyResolver must not be null");
- this.delegate = delegate;
- }
-
- @Override
- public boolean containsProperty(String key) {
- return delegate.containsProperty(key);
- }
-
- @Override
- @Nullable
- public String getProperty(String key) {
- return delegate.getProperty(key);
- }
-
- @Override
- public String getProperty(String key, String defaultValue) {
- return delegate.getProperty(key, defaultValue);
- }
-
- @Override
- @Nullable
- public <T> T getProperty(String key, Class<T> targetType) {
- return delegate.getProperty(key, targetType);
- }
-
- @Override
- public <T> T getProperty(String key, Class<T> targetType, T defaultValue) {
- return delegate.getProperty(key, targetType, defaultValue);
- }
-
- @Override
- public String getRequiredProperty(String key) throws IllegalStateException {
- return delegate.getRequiredProperty(key);
- }
-
- @Override
- public <T> T getRequiredProperty(String key, Class<T> targetType) throws IllegalStateException {
- return delegate.getRequiredProperty(key, targetType);
- }
-
- @Override
- public String resolvePlaceholders(String text) {
- return delegate.resolvePlaceholders(text);
- }
-
- @Override
- public String resolveRequiredPlaceholders(String text) throws IllegalArgumentException {
- return delegate.resolveRequiredPlaceholders(text);
- }
-}
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
index 9c10278..0b858f8 100644
--- 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
@@ -27,14 +27,18 @@
import org.springframework.context.annotation.Scope;
import org.springframework.core.env.AbstractEnvironment;
import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertyResolver;
import java.util.Map;
+import java.util.Set;
import static com.alibaba.spring.util.PropertySourcesUtils.getSubProperties;
-import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME;
+import static java.util.Collections.emptySet;
+import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_BEAN_NAME;
+import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_PROPERTY_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;
@@ -52,7 +56,6 @@
@AutoConfigureBefore(DubboRelaxedBindingAutoConfiguration.class)
public class DubboRelaxedBinding2AutoConfiguration {
- @Bean(name = BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME)
public PropertyResolver dubboScanBasePackagesPropertyResolver(ConfigurableEnvironment environment) {
ConfigurableEnvironment propertyResolver = new AbstractEnvironment() {
@Override
@@ -62,7 +65,21 @@
}
};
ConfigurationPropertySources.attach(propertyResolver);
- return new DelegatingPropertyResolver(propertyResolver);
+ return propertyResolver;
+ }
+
+ /**
+ * The bean is used to scan the packages of Dubbo Service classes
+ *
+ * @param environment {@link Environment} instance
+ * @return non-null {@link Set}
+ * @since 2.7.8
+ */
+ @ConditionalOnMissingBean(name = BASE_PACKAGES_BEAN_NAME)
+ @Bean(name = BASE_PACKAGES_BEAN_NAME)
+ public Set<String> dubboBasePackages(ConfigurableEnvironment environment) {
+ PropertyResolver propertyResolver = dubboScanBasePackagesPropertyResolver(environment);
+ return propertyResolver.getProperty(BASE_PACKAGES_PROPERTY_NAME, Set.class, emptySet());
}
@ConditionalOnMissingBean(name = RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME, value = ConfigurationBeanBinder.class)
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
index 9787666..aaa74c7 100644
--- 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
@@ -17,7 +17,7 @@
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.beans.factory.annotation.ServiceClassPostProcessor;
import com.alibaba.spring.context.config.ConfigurationBeanBinder;
import org.junit.Test;
@@ -34,7 +34,9 @@
import org.springframework.util.ClassUtils;
import java.util.Map;
+import java.util.Set;
+import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_BEAN_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.RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME;
import static org.junit.Assert.assertEquals;
@@ -53,15 +55,15 @@
public class DubboRelaxedBinding2AutoConfigurationTest {
@Autowired
- @Qualifier(BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME)
- private PropertyResolver propertyResolver;
+ @Qualifier(BASE_PACKAGES_BEAN_NAME)
+ private Set<String> packagesToScan;
@Autowired
@Qualifier(RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME)
private ConfigurationBeanBinder dubboConfigBinder;
@Autowired
- private ObjectProvider<ServiceAnnotationBeanPostProcessor> serviceAnnotationBeanPostProcessor;
+ private ObjectProvider<ServiceClassPostProcessor> serviceClassPostProcessor;
@Autowired
private ObjectProvider<ReferenceAnnotationBeanPostProcessor> referenceAnnotationBeanPostProcessor;
@@ -70,9 +72,6 @@
private Environment environment;
@Autowired
- private PropertyResolver primaryPropertyResolver;
-
- @Autowired
private Map<String, Environment> environments;
@Test
@@ -80,17 +79,16 @@
assertTrue(ClassUtils.isAssignableValue(BinderDubboConfigBinder.class, dubboConfigBinder));
- assertNotNull(serviceAnnotationBeanPostProcessor);
- assertNotNull(serviceAnnotationBeanPostProcessor.getIfAvailable());
+ assertNotNull(serviceClassPostProcessor);
+ assertNotNull(serviceClassPostProcessor.getIfAvailable());
assertNotNull(referenceAnnotationBeanPostProcessor);
assertNotNull(referenceAnnotationBeanPostProcessor.getIfAvailable());
assertNotNull(environment);
- assertNotNull(primaryPropertyResolver);
assertNotNull(environments);
- assertEquals(primaryPropertyResolver, environment);
- assertEquals(2, environments.size());
+
+ assertEquals(1, environments.size());
assertTrue(environments.containsValue(environment));
}
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListenerTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListenerTest.java
deleted file mode 100644
index e4064b9..0000000
--- a/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListenerTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.spring.boot.context.event;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.boot.WebApplicationType;
-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(WebApplicationType.NONE)
- .run().close();
- AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited();
- Assert.assertTrue(awaited.get());
- }
-
- @Test
- public void testMultipleContextNonWebApplication() {
- new SpringApplicationBuilder(Object.class)
- .parent(Object.class)
- .web(WebApplicationType.NONE)
- .run().close();
- AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited();
- Assert.assertTrue(awaited.get());
- }
-
-}
diff --git a/dubbo-spring-boot-compatible/autoconfigure/pom.xml b/dubbo-spring-boot-compatible/autoconfigure/pom.xml
index c867723..a5a56a3 100644
--- a/dubbo-spring-boot-compatible/autoconfigure/pom.xml
+++ b/dubbo-spring-boot-compatible/autoconfigure/pom.xml
@@ -42,6 +42,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<optional>true</optional>
</dependency>
@@ -66,6 +72,7 @@
<scope>test</scope>
</dependency>
+
</dependencies>
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-compatible/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
index 6f130e8..360bbfc 100644
--- a/dubbo-spring-boot-compatible/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
@@ -19,35 +19,32 @@
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
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.beans.factory.annotation.ServiceClassPostProcessor;
-import org.apache.dubbo.config.spring.context.annotation.DubboConfigConfiguration;
+import org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener;
+import org.apache.dubbo.config.spring.context.DubboLifecycleComponentApplicationListener;
import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig;
-import org.apache.dubbo.spring.boot.beans.factory.config.ServiceBeanIdConflictProcessor;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import org.springframework.context.annotation.Primary;
-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_BEAN_NAME;
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;
/**
* Dubbo Auto {@link Configuration}
@@ -62,66 +59,54 @@
@Configuration
@AutoConfigureAfter(DubboRelaxedBindingAutoConfiguration.class)
@EnableConfigurationProperties(DubboConfigurationProperties.class)
-@Import(ServiceBeanIdConflictProcessor.class)
-public class DubboAutoConfiguration {
+@EnableDubboConfig
+public class DubboAutoConfiguration implements ApplicationContextAware, BeanDefinitionRegistryPostProcessor {
/**
- * Creates {@link ServiceAnnotationBeanPostProcessor} Bean
+ * Creates {@link ServiceClassPostProcessor} Bean
*
- * @param propertyResolver {@link PropertyResolver} Bean
- * @return {@link ServiceAnnotationBeanPostProcessor}
+ * @param packagesToScan the packages to scan
+ * @return {@link ServiceClassPostProcessor}
*/
@ConditionalOnProperty(prefix = DUBBO_SCAN_PREFIX, name = BASE_PACKAGES_PROPERTY_NAME)
- @ConditionalOnBean(name = BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME)
+ @ConditionalOnBean(name = BASE_PACKAGES_BEAN_NAME)
@Bean
- public ServiceAnnotationBeanPostProcessor serviceAnnotationBeanPostProcessor(
- @Qualifier(BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME) PropertyResolver propertyResolver) {
- Set<String> packagesToScan = propertyResolver.getProperty(BASE_PACKAGES_PROPERTY_NAME, Set.class, emptySet());
- return new ServiceAnnotationBeanPostProcessor(packagesToScan);
+ public ServiceClassPostProcessor serviceClassPostProcessor(@Qualifier(BASE_PACKAGES_BEAN_NAME)
+ Set<String> packagesToScan) {
+ return new ServiceClassPostProcessor(packagesToScan);
}
- /**
- * Creates {@link ReferenceAnnotationBeanPostProcessor} Bean if Absent
- *
- * @return {@link ReferenceAnnotationBeanPostProcessor}
- */
- @ConditionalOnMissingBean
- @Bean(name = ReferenceAnnotationBeanPostProcessor.BEAN_NAME)
- public ReferenceAnnotationBeanPostProcessor referenceAnnotationBeanPostProcessor() {
- return new ReferenceAnnotationBeanPostProcessor();
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ if (applicationContext instanceof ConfigurableApplicationContext) {
+ ConfigurableApplicationContext context = (ConfigurableApplicationContext) applicationContext;
+ DubboLifecycleComponentApplicationListener dubboLifecycleComponentApplicationListener
+ = new DubboLifecycleComponentApplicationListener();
+ dubboLifecycleComponentApplicationListener.setApplicationContext(applicationContext);
+ context.addApplicationListener(dubboLifecycleComponentApplicationListener);
+
+ DubboBootstrapApplicationListener dubboBootstrapApplicationListener = new DubboBootstrapApplicationListener();
+ dubboBootstrapApplicationListener.setApplicationContext(applicationContext);
+ context.addApplicationListener(dubboBootstrapApplicationListener);
+ }
}
- /**
- * Single Dubbo Config Configuration
- *
- * @see EnableDubboConfig
- * @see DubboConfigConfiguration.Single
- */
- @Import(DubboConfigConfiguration.Single.class)
- protected static class SingleDubboConfigConfiguration {
+ @Override
+ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
+ // Remove the BeanDefinitions of ApplicationListener from DubboBeanUtils#registerCommonBeans(BeanDefinitionRegistry)
+ // TODO Refactoring in Dubbo 2.7.9
+ removeBeanDefinition(registry, DubboLifecycleComponentApplicationListener.BEAN_NAME);
+ removeBeanDefinition(registry, DubboBootstrapApplicationListener.BEAN_NAME);
}
- /**
- * Multiple Dubbo Config Configuration , equals @EnableDubboConfig.multiple() == <code>true</code>
- *
- * @see EnableDubboConfig
- * @see DubboConfigConfiguration.Multiple
- */
- @ConditionalOnProperty(prefix = DUBBO_CONFIG_PREFIX, name = MULTIPLE_CONFIG_PROPERTY_NAME, matchIfMissing = true)
- @Import(DubboConfigConfiguration.Multiple.class)
- protected static class MultipleDubboConfigConfiguration {
+ private void removeBeanDefinition(BeanDefinitionRegistry registry, String beanName) {
+ if (registry.containsBeanDefinition(beanName)) {
+ registry.removeBeanDefinition(beanName);
+ }
}
- /**
- * Build a primary {@link PropertyResolver} bean to {@link Autowired @Autowired}
- *
- * @param environment {@link Environment}
- * @return alias bean for {@link Environment}
- * @since 2.7.3
- */
- @Bean
- @Primary
- public PropertyResolver primaryPropertyResolver(Environment environment) {
- return environment;
+ @Override
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
+ // DO NOTHING
}
}
diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboConfigurationProperties.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboConfigurationProperties.java
index 6274f67..e5c72ba 100644
--- a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboConfigurationProperties.java
+++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboConfigurationProperties.java
@@ -45,7 +45,7 @@
* @since 2.7.1
*/
@ConfigurationProperties(DUBBO_PREFIX)
-class DubboConfigurationProperties {
+public class DubboConfigurationProperties {
@NestedConfigurationProperty
private Config config = new Config();
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
index 0536783..fdd3209 100644
--- 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
@@ -27,7 +27,11 @@
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 java.util.Set;
+
+import static java.util.Collections.emptySet;
+import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_BEAN_NAME;
+import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_PROPERTY_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;
@@ -41,11 +45,24 @@
@Configuration
public class DubboRelaxedBindingAutoConfiguration {
- @Bean(name = BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME)
public PropertyResolver dubboScanBasePackagesPropertyResolver(Environment environment) {
return new RelaxedPropertyResolver(environment, DUBBO_SCAN_PREFIX);
}
+ /**
+ * The bean is used to scan the packages of Dubbo Service classes
+ *
+ * @param environment {@link Environment} instance
+ * @return non-null {@link Set}
+ * @since 2.7.8
+ */
+ @ConditionalOnMissingBean(name = BASE_PACKAGES_BEAN_NAME)
+ @Bean(name = BASE_PACKAGES_BEAN_NAME)
+ public Set<String> dubboBasePackages(Environment environment) {
+ PropertyResolver propertyResolver = dubboScanBasePackagesPropertyResolver(environment);
+ return propertyResolver.getProperty(BASE_PACKAGES_PROPERTY_NAME, Set.class, emptySet());
+ }
+
@ConditionalOnMissingBean(name = RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME, value = ConfigurationBeanBinder.class)
@Bean(RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME)
@Scope(scopeName = SCOPE_PROTOTYPE)
diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/DubboConfigBeanCustomizer.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/DubboConfigBeanCustomizer.java
deleted file mode 100644
index 96be9fd..0000000
--- a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/DubboConfigBeanCustomizer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.spring.boot.beans.factory.config;
-
-import org.apache.dubbo.config.AbstractConfig;
-import org.apache.dubbo.config.spring.context.config.NamePropertyDefaultValueDubboConfigBeanCustomizer;
-
-import org.springframework.beans.BeanUtils;
-
-import java.lang.reflect.Method;
-
-import static org.springframework.util.ReflectionUtils.findMethod;
-import static org.springframework.util.ReflectionUtils.invokeMethod;
-
-
-/**
- * Current implementation will be replaced {@link NamePropertyDefaultValueDubboConfigBeanCustomizer} in Dubbo 2.7.2
- *
- * @since 2.7.1
- * @deprecated
- */
-@Deprecated
-class DubboConfigBeanCustomizer extends NamePropertyDefaultValueDubboConfigBeanCustomizer {
-
- @Override
- public void customize(String beanName, AbstractConfig dubboConfigBean) {
- boolean valid = isValidPropertyName(dubboConfigBean, beanName);
- if (valid) {
- super.customize(beanName, dubboConfigBean);
- }
- }
-
- private boolean isValidPropertyName(AbstractConfig dubboConfigBean, String propertyValue) {
- boolean valid = true;
- String propertyName = "name";
- // AbstractConfig.checkName(String,String)
- Method method = findMethod(AbstractConfig.class, "checkName", String.class, String.class);
- try {
- if (method != null) {
- if (!method.isAccessible()) {
- method.setAccessible(true);
- }
- if (BeanUtils.getPropertyDescriptor(dubboConfigBean.getClass(), propertyName) != null) {
- invokeMethod(method, null, propertyName, propertyValue);
- }
- }
- } catch (IllegalStateException e) {
- valid = false;
- }
-
- return valid;
- }
-}
diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/DubboConfigBeanDefinitionConflictProcessor.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/DubboConfigBeanDefinitionConflictProcessor.java
deleted file mode 100644
index 61697a6..0000000
--- a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/DubboConfigBeanDefinitionConflictProcessor.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.spring.boot.beans.factory.config;
-
-import org.apache.dubbo.config.ApplicationConfig;
-import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig;
-import org.apache.dubbo.spring.boot.context.event.DubboConfigBeanDefinitionConflictApplicationListener;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanFactoryUtils;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
-import org.springframework.core.Ordered;
-import org.springframework.core.env.Environment;
-
-import java.util.Objects;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors;
-import static org.springframework.context.ConfigurableApplicationContext.ENVIRONMENT_BEAN_NAME;
-
-/**
- * Dubbo Config {@link BeanDefinition Bean Definition} {@link BeanDefinitionRegistryPostProcessor processor}
- * to resolve conflict
- *
- * @see BeanDefinition
- * @see BeanDefinitionRegistryPostProcessor
- * @see DubboConfigBeanDefinitionConflictApplicationListener
- * @since 2.7.1
- * @deprecated Since 2.7.5, {@link DubboConfigBeanDefinitionConflictApplicationListener} will be a substituted
- * implementation
- */
-@Deprecated
-public class DubboConfigBeanDefinitionConflictProcessor implements BeanDefinitionRegistryPostProcessor, Ordered {
-
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
- private BeanDefinitionRegistry registry;
-
- private Environment environment;
-
- @Override
- public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
- this.registry = registry;
- }
-
- @Override
- public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
- resolveUniqueApplicationConfigBean(registry, beanFactory);
- }
-
- /**
- * Resolve the unique {@link ApplicationConfig} Bean
- *
- * @param registry {@link BeanDefinitionRegistry} instance
- * @param beanFactory {@link ConfigurableListableBeanFactory} instance
- * @see EnableDubboConfig
- */
- private void resolveUniqueApplicationConfigBean(BeanDefinitionRegistry registry,
- ConfigurableListableBeanFactory beanFactory) {
-
- this.environment = beanFactory.getBean(ENVIRONMENT_BEAN_NAME, Environment.class);
-
- String[] beansNames = beanNamesForTypeIncludingAncestors(beanFactory, ApplicationConfig.class);
-
- if (beansNames.length < 2) { // If the number of ApplicationConfig beans is less than two, return immediately.
- return;
- }
-
- // Remove ApplicationConfig Beans that are configured by "dubbo.application.*"
- Stream.of(beansNames)
- .filter(this::isConfiguredApplicationConfigBeanName)
- .forEach(registry::removeBeanDefinition);
-
- beansNames = beanNamesForTypeIncludingAncestors(beanFactory, ApplicationConfig.class);
-
- if (beansNames.length > 1) {
- throw new IllegalStateException(String.format("There are more than one instances of %s, whose bean definitions : %s",
- ApplicationConfig.class.getSimpleName(),
- Stream.of(beansNames)
- .map(registry::getBeanDefinition)
- .collect(Collectors.toList()))
- );
- }
- }
-
- private boolean isConfiguredApplicationConfigBeanName(String beanName) {
- boolean removed = BeanFactoryUtils.isGeneratedBeanName(beanName)
- // Dubbo ApplicationConfig id as bean name
- || Objects.equals(beanName, environment.getProperty("dubbo.application.id"));
-
- if (removed) {
- if (logger.isWarnEnabled()) {
- logger.warn("The {} bean [ name : {} ] has been removed!", ApplicationConfig.class.getSimpleName(), beanName);
- }
- }
-
- return removed;
- }
-
-
- @Override
- public int getOrder() {
- return LOWEST_PRECEDENCE;
- }
-}
diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/OverrideBeanDefinitionRegistryPostProcessor.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/OverrideBeanDefinitionRegistryPostProcessor.java
deleted file mode 100644
index 0c15f0e..0000000
--- a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/OverrideBeanDefinitionRegistryPostProcessor.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.spring.boot.beans.factory.config;
-
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
-
-import static com.alibaba.spring.util.BeanRegistrar.registerInfrastructureBean;
-import static org.apache.dubbo.config.spring.context.config.NamePropertyDefaultValueDubboConfigBeanCustomizer.BEAN_NAME;
-
-/**
- * Override {@link BeanDefinitionRegistryPostProcessor}
- *
- * @since 2.7.1
- */
-public class OverrideBeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor {
-
- @Override
- public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
- registerInfrastructureBean(registry, BEAN_NAME, DubboConfigBeanCustomizer.class);
- }
-
- @Override
- public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
- }
-}
-
diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/ServiceBeanIdConflictProcessor.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/ServiceBeanIdConflictProcessor.java
deleted file mode 100644
index b6bf04b..0000000
--- a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/beans/factory/config/ServiceBeanIdConflictProcessor.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.spring.boot.beans.factory.config;
-
-import org.apache.dubbo.config.ServiceConfig;
-import org.apache.dubbo.config.spring.ServiceBean;
-
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor;
-import org.springframework.core.Ordered;
-import org.springframework.core.PriorityOrdered;
-
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import static org.springframework.util.ClassUtils.getUserClass;
-import static org.springframework.util.ClassUtils.isAssignable;
-
-/**
- * The post-processor for resolving the id conflict of {@link ServiceBean} when an interface is
- * implemented by multiple services with different groups or versions that are exported on one provider
- * <p>
- * Current implementation is a temporary resolution, and will be removed in the future.
- *
- * @see CommonAnnotationBeanPostProcessor
- * @since 2.7.7
- * @deprecated
- */
-public class ServiceBeanIdConflictProcessor implements MergedBeanDefinitionPostProcessor, DisposableBean, PriorityOrdered {
-
- /**
- * The key is the class names of interfaces that were exported by {@link ServiceBean}
- * The value is bean names of {@link ServiceBean} or {@link ServiceConfig}.
- */
- private Map<String, String> interfaceNamesToBeanNames = new HashMap<>();
-
- /**
- * Holds the bean names of {@link ServiceBean} or {@link ServiceConfig}.
- */
- private Set<String> conflictedBeanNames = new LinkedHashSet<>();
-
- @Override
- public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
- // Get raw bean type
- Class<?> rawBeanType = getUserClass(beanType);
- if (isAssignable(ServiceConfig.class, rawBeanType)) { // ServiceConfig type or sub-type
- String interfaceName = (String) beanDefinition.getPropertyValues().get("interface");
- String mappedBeanName = interfaceNamesToBeanNames.putIfAbsent(interfaceName, beanName);
- // If mapped bean name exists and does not equal current bean name
- if (mappedBeanName != null && !mappedBeanName.equals(beanName)) {
- // conflictedBeanNames will record current bean name.
- conflictedBeanNames.add(beanName);
- }
- }
- }
-
- @Override
- public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
- if (conflictedBeanNames.contains(beanName) && bean instanceof ServiceConfig) {
- ServiceConfig serviceConfig = (ServiceConfig) bean;
- if (isConflictedServiceConfig(serviceConfig)) {
- // Set id as the bean name
- serviceConfig.setId(beanName);
- }
-
- }
- return bean;
- }
-
- private boolean isConflictedServiceConfig(ServiceConfig serviceConfig) {
- return Objects.equals(serviceConfig.getId(), serviceConfig.getInterface());
- }
-
- @Override
- public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
- return bean;
- }
-
- /**
- * Keep the order being higher than {@link CommonAnnotationBeanPostProcessor#getOrder()} that is
- * {@link Ordered#LOWEST_PRECEDENCE}
- *
- * @return {@link Ordered#LOWEST_PRECEDENCE} +1
- */
- @Override
- public int getOrder() {
- return LOWEST_PRECEDENCE + 1;
- }
-
- @Override
- public void destroy() throws Exception {
- interfaceNamesToBeanNames.clear();
- conflictedBeanNames.clear();
- }
-}
diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/DubboApplicationContextInitializer.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/DubboApplicationContextInitializer.java
index e90dd8c..56f78b9 100644
--- a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/DubboApplicationContextInitializer.java
+++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/context/DubboApplicationContextInitializer.java
@@ -16,8 +16,6 @@
*/
package org.apache.dubbo.spring.boot.context;
-import org.apache.dubbo.spring.boot.beans.factory.config.OverrideBeanDefinitionRegistryPostProcessor;
-
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.Ordered;
@@ -36,10 +34,12 @@
}
private void overrideBeanDefinitions(ConfigurableApplicationContext applicationContext) {
- applicationContext.addBeanFactoryPostProcessor(new OverrideBeanDefinitionRegistryPostProcessor());
+ // @since 2.7.8 OverrideBeanDefinitionRegistryPostProcessor has been removed
+ // applicationContext.addBeanFactoryPostProcessor(new OverrideBeanDefinitionRegistryPostProcessor());
// @since 2.7.5 DubboConfigBeanDefinitionConflictProcessor has been removed
// @see {@link DubboConfigBeanDefinitionConflictApplicationListener}
// applicationContext.addBeanFactoryPostProcessor(new DubboConfigBeanDefinitionConflictProcessor());
+ // TODO Add some components in the future ( after 2.7.8 )
}
@Override
diff --git a/dubbo-spring-boot-compatible/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
index 4669d86..8c0d59d 100644
--- a/dubbo-spring-boot-compatible/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
@@ -16,6 +16,8 @@
*/
package org.apache.dubbo.spring.boot.context.event;
+import org.apache.dubbo.common.lang.ShutdownHookCallbacks;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationReadyEvent;
@@ -29,6 +31,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -55,6 +58,13 @@
private static final AtomicBoolean awaited = new AtomicBoolean(false);
+ private static final Integer UNDEFINED_ID = Integer.valueOf(-1);
+
+ /**
+ * Target the application id
+ */
+ private static final AtomicInteger applicationContextId = new AtomicInteger(UNDEFINED_ID);
+
private static final Lock lock = new ReentrantLock();
private static final Condition condition = lock.newCondition();
@@ -83,8 +93,6 @@
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ApplicationReadyEvent) {
onApplicationReadyEvent((ApplicationReadyEvent) event);
- } else if (event instanceof ContextClosedEvent) {
- onContextClosedEvent((ContextClosedEvent) event);
}
}
@@ -101,7 +109,17 @@
return;
}
- await();
+ if (applicationContextId.compareAndSet(UNDEFINED_ID, applicationContext.hashCode())) {
+ await();
+ releaseOnExit();
+ }
+ }
+
+ /**
+ * @since 2.7.8
+ */
+ private void releaseOnExit() {
+ ShutdownHookCallbacks.INSTANCE.addCallback(this::release);
}
private boolean isRootApplicationContext(ApplicationContext applicationContext) {
@@ -127,11 +145,6 @@
}
}
- protected void onContextClosedEvent(ContextClosedEvent event) {
- release();
- shutdown();
- }
-
protected void await() {
// has been waited, return immediately
@@ -162,6 +175,8 @@
logger.info(" [Dubbo] Current Spring Boot Application is about to shutdown...");
}
condition.signalAll();
+ // @since 2.7.8 method shutdown() is combined into the method release()
+ shutdown();
}
});
}
diff --git a/dubbo-spring-boot-compatible/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
index e9381ac..4e6505c 100644
--- a/dubbo-spring-boot-compatible/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
@@ -18,6 +18,7 @@
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor;
+import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceClassPostProcessor;
import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig;
import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder;
@@ -27,6 +28,7 @@
import java.util.Collections;
import java.util.Map;
+import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
@@ -74,12 +76,18 @@
* The property name of multiple properties binding from externalized configuration
* <p>
* The default value is {@link #DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE}
+ *
+ * @deprecated 2.7.8 It will be remove in the future, {@link EnableDubboConfig} instead
*/
+ @Deprecated
public static final String MULTIPLE_CONFIG_PROPERTY_NAME = "multiple";
/**
* The default value of multiple properties binding from externalized configuration
+ *
+ * @deprecated 2.7.8 It will be remove in the future
*/
+ @Deprecated
public static final boolean DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE = true;
/**
@@ -127,10 +135,20 @@
/**
* The bean name of {@link PropertyResolver} for {@link ServiceAnnotationBeanPostProcessor}'s base-packages
+ *
+ * @deprecated 2.7.8 It will be remove in the future, please use {@link #BASE_PACKAGES_BEAN_NAME}
*/
+ @Deprecated
public static final String BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME = "dubboScanBasePackagesPropertyResolver";
/**
+ * The bean name of {@link Set} presenting {@link ServiceClassPostProcessor}'s base-packages
+ *
+ * @since 2.7.8
+ */
+ public static final String BASE_PACKAGES_BEAN_NAME = "dubbo-service-class-base-packages";
+
+ /**
* The property name of Spring Application
*
* @see ContextIdApplicationContextInitializer
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
index b0d8681..17dfe93 100644
--- 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
@@ -17,7 +17,7 @@
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.beans.factory.annotation.ServiceClassPostProcessor;
import org.junit.Assert;
import org.junit.Test;
@@ -44,15 +44,15 @@
public class CompatibleDubboAutoConfigurationTest {
@Autowired
- private ObjectProvider<ServiceAnnotationBeanPostProcessor> serviceAnnotationBeanPostProcessor;
+ private ObjectProvider<ServiceClassPostProcessor> serviceClassPostProcessor;
@Autowired
private ObjectProvider<ReferenceAnnotationBeanPostProcessor> referenceAnnotationBeanPostProcessor;
@Test
public void testBeans() {
- Assert.assertNotNull(serviceAnnotationBeanPostProcessor);
- Assert.assertNotNull(serviceAnnotationBeanPostProcessor.getIfAvailable());
+ Assert.assertNotNull(serviceClassPostProcessor);
+ Assert.assertNotNull(serviceClassPostProcessor.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
index 06a21d8..0b3a063 100644
--- 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
@@ -18,7 +18,11 @@
import org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor;
import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +46,16 @@
@Autowired
private ReferenceAnnotationBeanPostProcessor referenceAnnotationBeanPostProcessor;
+ @Before
+ public void init() {
+ ApplicationModel.reset();
+ }
+
+ @After
+ public void destroy() {
+ ApplicationModel.reset();
+ }
+
@Test
public void testBeans() {
Assert.assertNull(serviceAnnotationBeanPostProcessor);
diff --git a/dubbo-spring-boot-compatible/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
index ba4e0a4..c7a67c0 100644
--- a/dubbo-spring-boot-compatible/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,8 +23,11 @@
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ProviderConfig;
import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -70,12 +73,6 @@
public class DubboAutoConfigurationOnMultipleConfigTest {
@Autowired
- private DubboAutoConfiguration.MultipleDubboConfigConfiguration multipleDubboConfigConfiguration;
-
- @Autowired(required = false)
- private DubboAutoConfiguration.SingleDubboConfigConfiguration singleDubboConfigConfiguration;
-
- @Autowired
private Environment environment;
@Autowired
@@ -130,6 +127,16 @@
@Qualifier("consumer1")
private ConsumerConfig consumer;
+ @Before
+ public void init() {
+ ApplicationModel.reset();
+ }
+
+ @After
+ public void destroy() {
+ ApplicationModel.reset();
+ }
+
@Autowired
private Map<String, ApplicationConfig> applications = new LinkedHashMap<>();
@@ -267,16 +274,4 @@
Assert.assertEquals("netty", consumer.getClient());
}
-
- @Test
- public void testMultipleDubboConfigConfiguration() {
- Assert.assertNotNull(multipleDubboConfigConfiguration);
- }
-
- @Test
- public void testSingleDubboConfigConfiguration() {
- Assert.assertNotNull(singleDubboConfigConfiguration);
- }
-
-
}
diff --git a/dubbo-spring-boot-compatible/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
index 28d1e6d..26fb6bd 100644
--- a/dubbo-spring-boot-compatible/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,7 +23,11 @@
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ProviderConfig;
import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -79,18 +83,22 @@
@Autowired
private ProtocolConfig protocolConfig;
- @Autowired(required = false)
- private DubboAutoConfiguration.MultipleDubboConfigConfiguration multipleDubboConfigConfiguration;
-
- @Autowired
- private DubboAutoConfiguration.SingleDubboConfigConfiguration singleDubboConfigConfiguration;
-
@Autowired
private Environment environment;
@Autowired
private ApplicationContext applicationContext;
+ @Before
+ public void init() {
+ ApplicationModel.reset();
+ }
+
+ @After
+ public void destroy() {
+ ApplicationModel.reset();
+ }
+
@Test
public void testApplicationConfig() {
@@ -140,20 +148,4 @@
Assert.assertEquals("netty", consumerConfig.getClient());
}
-
- @Test
- public void testMultipleDubboConfigConfiguration() {
- Assert.assertNotNull(multipleDubboConfigConfiguration);
- }
-
- @Test
- public void testSingleDubboConfigConfiguration() {
- Assert.assertNotNull(singleDubboConfigConfiguration);
- }
-
- @Test
- public void testServiceAnnotationBeanPostProcessor() {
- Assert.assertNotNull(multipleDubboConfigConfiguration);
- }
-
}
diff --git a/dubbo-spring-boot-compatible/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
index 40f596e..cb93b69 100644
--- a/dubbo-spring-boot-compatible/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,9 +19,12 @@
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.rpc.model.ApplicationModel;
import com.alibaba.spring.context.config.ConfigurationBeanBinder;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -54,6 +57,16 @@
@Autowired
private ConfigurableEnvironment environment;
+ @Before
+ public void init() {
+ ApplicationModel.reset();
+ }
+
+ @After
+ public void destroy() {
+ ApplicationModel.reset();
+ }
+
@Test
public void testBinder() {
diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/beans/factory/config/DubboConfigBeanDefinitionConflictProcessorTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/beans/factory/config/DubboConfigBeanDefinitionConflictProcessorTest.java
deleted file mode 100644
index a24ca14..0000000
--- a/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/beans/factory/config/DubboConfigBeanDefinitionConflictProcessorTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.spring.boot.beans.factory.config;
-
-import org.apache.dubbo.config.ApplicationConfig;
-import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.springframework.context.annotation.ImportResource;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.core.Ordered;
-
-import java.util.Map;
-
-
-/**
- * {@link DubboConfigBeanDefinitionConflictProcessor} Test
- *
- * @since 2.7.1
- */
-public class DubboConfigBeanDefinitionConflictProcessorTest {
-
- private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
-
- @Before
- public void init() {
- context.addBeanFactoryPostProcessor(new DubboConfigBeanDefinitionConflictProcessor());
- }
-
- @After
- public void destroy() {
- context.close();
- }
-
- @Test
- public void testOrder() {
- Assert.assertEquals(Ordered.LOWEST_PRECEDENCE, new DubboConfigBeanDefinitionConflictProcessor().getOrder());
- }
-
- @Test
- public void testNormalCase() {
-
- System.setProperty("dubbo.application.name", "test-dubbo-application");
-
- context.register(DubboConfig.class);
-
- context.refresh();
-
- ApplicationConfig applicationConfig = context.getBean(ApplicationConfig.class);
-
- Assert.assertEquals("test-dubbo-application", applicationConfig.getName());
- }
-
- @Test
- public void testDuplicatedConfigsCase() {
-
- context.register(PropertySourceConfig.class, DubboConfig.class);
-
- context.register(XmlConfig.class);
-
- context.refresh();
-
- Map<String, ApplicationConfig> beansMap = context.getBeansOfType(ApplicationConfig.class);
-
- ApplicationConfig applicationConfig = beansMap.get("dubbo-consumer-2.7.x");
-
- Assert.assertEquals(1, beansMap.size());
-
- Assert.assertEquals("dubbo-consumer-2.7.x", applicationConfig.getName());
- }
-
- @Test(expected = IllegalStateException.class)
- public void testFailedCase() {
- context.register(ApplicationConfig.class);
- testDuplicatedConfigsCase();
- }
-
- @EnableDubboConfig
- static class DubboConfig {
-
- }
-
- @PropertySource("classpath:/META-INF/dubbo.properties")
- static class PropertySourceConfig {
-
- }
-
- @ImportResource("classpath:/META-INF/spring/dubbo-context.xml")
- static class XmlConfig {
- }
-}
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
index 8de2cae..e002607 100644
--- 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
@@ -16,7 +16,12 @@
*/
package org.apache.dubbo.spring.boot.context.event;
+import org.apache.dubbo.common.lang.ShutdownHookCallbacks;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.builder.SpringApplicationBuilder;
@@ -27,30 +32,44 @@
*/
public class AwaitingNonWebApplicationListenerTest {
+ @Before
+ public void before() {
+ ApplicationModel.reset();
+ }
+
+ @After
+ public void after() {
+ ApplicationModel.reset();
+ }
+
@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());
- }
+ .run()
+ .close();
- @Test
- public void testMultipleContextNonWebApplication() {
- new SpringApplicationBuilder(Object.class)
- .parent(Object.class)
- .web(false)
- .run().close();
- AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited();
- Assert.assertTrue(awaited.get());
+ ShutdownHookCallbacks.INSTANCE.addCallback(() -> {
+ AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited();
+ Assert.assertTrue(awaited.get());
+ System.out.println("Callback...");
+ });
}
+//
+// @Test
+// public void testMultipleContextNonWebApplication() {
+// new SpringApplicationBuilder(Object.class)
+// .parent(Object.class)
+// .web(false)
+// .run().close();
+// AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited();
+// Assert.assertFalse(awaited.get());
+// }
}
diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/DubboConfigBeanDefinitionConflictApplicationListenerTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/DubboConfigBeanDefinitionConflictApplicationListenerTest.java
index ce87523..462ce1d 100644
--- a/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/DubboConfigBeanDefinitionConflictApplicationListenerTest.java
+++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/context/event/DubboConfigBeanDefinitionConflictApplicationListenerTest.java
@@ -18,7 +18,7 @@
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig;
-import org.apache.dubbo.spring.boot.beans.factory.config.DubboConfigBeanDefinitionConflictProcessor;
+import org.apache.dubbo.rpc.model.ApplicationModel;
import org.junit.After;
import org.junit.Assert;
@@ -27,13 +27,13 @@
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
-import org.springframework.core.Ordered;
import java.util.Map;
/**
* {@link DubboConfigBeanDefinitionConflictApplicationListener} Test
+ *
* @since 2.7.5
*/
public class DubboConfigBeanDefinitionConflictApplicationListenerTest {
@@ -42,17 +42,15 @@
@Before
public void init() {
+ ApplicationModel.reset();
context.addApplicationListener(new DubboConfigBeanDefinitionConflictApplicationListener());
}
@After
public void destroy() {
context.close();
- }
+ ApplicationModel.reset();
- @Test
- public void testOrder() {
- Assert.assertEquals(Ordered.LOWEST_PRECEDENCE, new DubboConfigBeanDefinitionConflictProcessor().getOrder());
}
@Test
diff --git a/dubbo-spring-boot-compatible/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
index 4bea84c..c193c60 100644
--- a/dubbo-spring-boot-compatible/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,8 +17,11 @@
package org.apache.dubbo.spring.boot.context.event;
import org.apache.dubbo.common.utils.ConfigUtils;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
+import org.junit.After;
import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
@@ -46,9 +49,15 @@
)
public class OverrideDubboConfigApplicationListenerDisableTest {
- @BeforeClass
- public static void init() {
+ @Before
+ public void init() {
ConfigUtils.getProperties().clear();
+ ApplicationModel.reset();
+ }
+
+ @After
+ public void destroy() {
+ ApplicationModel.reset();
}
@Test
diff --git a/dubbo-spring-boot-compatible/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
index 5e42561..87ee1c3 100644
--- a/dubbo-spring-boot-compatible/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,6 +17,9 @@
package org.apache.dubbo.spring.boot.context.event;
import org.apache.dubbo.common.utils.ConfigUtils;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
+import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -48,9 +51,15 @@
@BeforeClass
public static void init() {
+ ApplicationModel.reset();
ConfigUtils.getProperties().clear();
}
+ @AfterClass
+ public static void destroy() {
+ ApplicationModel.reset();
+ }
+
@Test
public void testOnApplicationEvent() {
diff --git a/dubbo-spring-boot-parent/pom.xml b/dubbo-spring-boot-parent/pom.xml
index 836b470..81ae9ec 100644
--- a/dubbo-spring-boot-parent/pom.xml
+++ b/dubbo-spring-boot-parent/pom.xml
@@ -38,7 +38,7 @@
<java.target.version>1.8</java.target.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <spring-boot.version>2.3.0.RELEASE</spring-boot.version>
+ <spring-boot.version>2.3.1.RELEASE</spring-boot.version>
<dubbo.version>${revision}</dubbo.version>
<!-- Build args -->
<argline>-server -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true
@@ -443,7 +443,7 @@
<!-- Spring Boot 2.1 -->
<id>spring-boot-2.1</id>
<properties>
- <spring-boot.version>2.1.13.RELEASE</spring-boot.version>
+ <spring-boot.version>2.1.15.RELEASE</spring-boot.version>
</properties>
</profile>
@@ -451,7 +451,7 @@
<!-- Spring Boot 2.2 -->
<id>spring-boot-2.2</id>
<properties>
- <spring-boot.version>2.2.7.RELEASE</spring-boot.version>
+ <spring-boot.version>2.2.8.RELEASE</spring-boot.version>
</properties>
</profile>
</profiles>
diff --git a/dubbo-spring-boot-samples/service-introspection-samples/nacos-samples/consumer-sample/pom.xml b/dubbo-spring-boot-samples/service-introspection-samples/nacos-samples/consumer-sample/pom.xml
index 0fb6c5f..44b0093 100644
--- a/dubbo-spring-boot-samples/service-introspection-samples/nacos-samples/consumer-sample/pom.xml
+++ b/dubbo-spring-boot-samples/service-introspection-samples/nacos-samples/consumer-sample/pom.xml
@@ -50,12 +50,6 @@
<!-- Dubbo Registry Nacos -->
<dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo-registry-nacos</artifactId>
- <version>${revision}</version>
- </dependency>
-
- <dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos.version}</version>
diff --git a/dubbo-spring-boot-samples/service-introspection-samples/nacos-samples/provider-sample/pom.xml b/dubbo-spring-boot-samples/service-introspection-samples/nacos-samples/provider-sample/pom.xml
index 6b709fd..eaf50d5 100644
--- a/dubbo-spring-boot-samples/service-introspection-samples/nacos-samples/provider-sample/pom.xml
+++ b/dubbo-spring-boot-samples/service-introspection-samples/nacos-samples/provider-sample/pom.xml
@@ -50,12 +50,6 @@
<!-- Dubbo Registry Nacos -->
<dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo-registry-nacos</artifactId>
- <version>${revision}</version>
- </dependency>
-
- <dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos.version}</version>
diff --git a/dubbo-spring-boot-samples/service-introspection-samples/zookeeper-samples/consumer-sample/src/main/resources/application.yml b/dubbo-spring-boot-samples/service-introspection-samples/zookeeper-samples/consumer-sample/src/main/resources/application.yml
index fdabf9f..61d3b7a 100644
--- a/dubbo-spring-boot-samples/service-introspection-samples/zookeeper-samples/consumer-sample/src/main/resources/application.yml
+++ b/dubbo-spring-boot-samples/service-introspection-samples/zookeeper-samples/consumer-sample/src/main/resources/application.yml
@@ -11,6 +11,10 @@
port: 2181
dubbo:
+ application:
+ metadata-type: composite
registry:
address: zookeeper://127.0.0.1:${embedded.zookeeper.port}/?registry-type=service
- file: ${user.home}/dubbo-cache/${spring.application.name}/dubbo.cache
\ No newline at end of file
+ file: ${user.home}/dubbo-cache/${spring.application.name}/dubbo.cache
+ use-as-config-center: true
+ use-as-metadata-center: true
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/service-introspection-samples/zookeeper-samples/provider-sample/src/main/resources/application.properties b/dubbo-spring-boot-samples/service-introspection-samples/zookeeper-samples/provider-sample/src/main/resources/application.properties
index 844cd82..ce99686 100644
--- a/dubbo-spring-boot-samples/service-introspection-samples/zookeeper-samples/provider-sample/src/main/resources/application.properties
+++ b/dubbo-spring-boot-samples/service-introspection-samples/zookeeper-samples/provider-sample/src/main/resources/application.properties
@@ -6,6 +6,9 @@
zookeeper.server.port = 2181
# Dubbo Spring Boot Externalization Configuration
+## "composite" is a new metadata type introduced since 2.7.8
+dubbo.application.metadata-type=composite
+
## Base packages to scan Dubbo Component: @org.apache.dubbo.config.annotation.Service
dubbo.scan.base-packages=org.apache.dubbo.spring.boot.sample.provider.service
@@ -19,6 +22,9 @@
## Dubbo Registry
dubbo.registry.address=zookeeper://${zookeeper.server.host}:${zookeeper.server.port}?registry-type=service
+dubbo.registry.use-as-config-center=true
+dubbo.registry.use-as-metadata-center=true
+
## DemoService version
demo.service.version=1.0.0
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/servlet-container-samples/pom.xml b/dubbo-spring-boot-samples/servlet-container-samples/pom.xml
index 3bc24d4..99c3a78 100644
--- a/dubbo-spring-boot-samples/servlet-container-samples/pom.xml
+++ b/dubbo-spring-boot-samples/servlet-container-samples/pom.xml
@@ -48,4 +48,29 @@
</pluginRepository>
</pluginRepositories>
+ <profiles>
+ <!-- Spring Boot 1.5 - 1.3 -->
+ <profile>
+ <id>spring-boot-1.5</id>
+ <properties>
+ <spring-boot.version>2.0.0.RELEASE</spring-boot.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <!-- Spring Boot 1.4 -->
+ <id>spring-boot-1.4</id>
+ <properties>
+ <spring-boot.version>2.0.0.RELEASE</spring-boot.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <!-- Spring Boot 1.3 -->
+ <id>spring-boot-1.3</id>
+ <properties>
+ <spring-boot.version>2.0.0.RELEASE</spring-boot.version>
+ </properties>
+ </profile>
+ </profiles>
</project>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 9d9ad3c..79a6498 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,7 +38,7 @@
<properties>
<maven_javadoc_version>3.0.1</maven_javadoc_version>
<maven_surefire_version>2.19.1</maven_surefire_version>
- <revision>2.7.7</revision>
+ <revision>2.7.8</revision>
</properties>
<modules>