You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by me...@apache.org on 2020/02/11 05:12:19 UTC
[dubbo] branch master updated: [Optimization] To remove
EnableDubboConfigBinding and EnableDubboConfigBindings (#5730)
This is an automated email from the ASF dual-hosted git repository.
mercyblitz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new b99b383 [Optimization] To remove EnableDubboConfigBinding and EnableDubboConfigBindings (#5730)
b99b383 is described below
commit b99b3837186b7fb7f68ae106b67cc42deeed18b9
Author: Mercy Ma <me...@gmail.com>
AuthorDate: Tue Feb 11 13:12:03 2020 +0800
[Optimization] To remove EnableDubboConfigBinding and EnableDubboConfigBindings (#5730)
* Polish /apache/dubbo#5721 : [Enhancement] Setting the default IDs for Dubbo's Config Beans
* Polish /apache/dubbo#5729 : [Optimization] To remove EnableDubboConfigBinding and EnableDubboConfigBindings
---
.../DubboConfigBindingBeanPostProcessor.java | 234 ---------------------
.../annotation/DubboConfigBindingRegistrar.java | 215 -------------------
.../annotation/DubboConfigBindingsRegistrar.java | 71 -------
.../annotation/EnableDubboConfigBinding.java | 83 --------
.../annotation/EnableDubboConfigBindings.java | 50 -----
.../context/config/DubboConfigBeanCustomizer.java | 2 -
...pertyDefaultValueDubboConfigBeanCustomizer.java | 86 --------
.../DubboConfigBindingBeanPostProcessorTest.java | 88 --------
.../DubboConfigBindingRegistrarTest.java | 86 --------
.../DubboConfigBindingsRegistrarTest.java | 60 ------
.../java/org/apache/dubbo/rpc/RpcContextTest.java | 1 +
11 files changed, 1 insertion(+), 975 deletions(-)
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java
deleted file mode 100644
index 9b181cb..0000000
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.beans.factory.annotation;
-
-import org.apache.dubbo.common.utils.Assert;
-import org.apache.dubbo.common.utils.StringUtils;
-import org.apache.dubbo.config.AbstractConfig;
-import org.apache.dubbo.config.spring.context.annotation.DubboConfigBindingRegistrar;
-import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfigBinding;
-import org.apache.dubbo.config.spring.context.config.DubboConfigBeanCustomizer;
-import org.apache.dubbo.config.spring.context.properties.DefaultDubboConfigBinder;
-import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.core.annotation.AnnotationAwareOrderComparator;
-import org.springframework.core.env.Environment;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import static org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors;
-
-/**
- * Dubbo Config Binding {@link BeanPostProcessor}
- *
- * @see EnableDubboConfigBinding
- * @see DubboConfigBindingRegistrar
- * @since 2.5.8
- */
-
-public class DubboConfigBindingBeanPostProcessor implements BeanPostProcessor, ApplicationContextAware, InitializingBean
- , BeanDefinitionRegistryPostProcessor {
-
- private final Log log = LogFactory.getLog(getClass());
-
- /**
- * The prefix of Configuration Properties
- */
- private final String prefix;
-
- /**
- * Binding Bean Name
- */
- private final String beanName;
-
- private DubboConfigBinder dubboConfigBinder;
-
- private ApplicationContext applicationContext;
-
- private BeanDefinitionRegistry beanDefinitionRegistry;
-
- private boolean ignoreUnknownFields = true;
-
- private boolean ignoreInvalidFields = true;
-
- private List<DubboConfigBeanCustomizer> configBeanCustomizers = Collections.emptyList();
-
- /**
- * @param prefix the prefix of Configuration Properties
- * @param beanName the binding Bean Name
- */
- public DubboConfigBindingBeanPostProcessor(String prefix, String beanName) {
- Assert.notNull(prefix, "The prefix of Configuration Properties must not be null");
- Assert.notNull(beanName, "The name of bean must not be null");
- this.prefix = prefix;
- this.beanName = beanName;
- }
-
- @Override
- public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
-
- if (this.beanName.equals(beanName) && bean instanceof AbstractConfig) {
-
- AbstractConfig dubboConfig = (AbstractConfig) bean;
-
- bind(prefix, dubboConfig);
-
- customize(beanName, dubboConfig);
-
- }
-
- return bean;
-
- }
-
- private void bind(String prefix, AbstractConfig dubboConfig) {
-
- dubboConfigBinder.bind(prefix, dubboConfig);
-
- if (log.isInfoEnabled()) {
- log.info("The properties of bean [name : " + beanName + "] have been binding by prefix of " +
- "configuration properties : " + prefix);
- }
- }
-
- private void customize(String beanName, AbstractConfig dubboConfig) {
-
- for (DubboConfigBeanCustomizer customizer : configBeanCustomizers) {
- customizer.customize(beanName, dubboConfig);
- }
-
- }
-
- public boolean isIgnoreUnknownFields() {
- return ignoreUnknownFields;
- }
-
- public void setIgnoreUnknownFields(boolean ignoreUnknownFields) {
- this.ignoreUnknownFields = ignoreUnknownFields;
- }
-
- public boolean isIgnoreInvalidFields() {
- return ignoreInvalidFields;
- }
-
- public void setIgnoreInvalidFields(boolean ignoreInvalidFields) {
- this.ignoreInvalidFields = ignoreInvalidFields;
- }
-
- public DubboConfigBinder getDubboConfigBinder() {
- return dubboConfigBinder;
- }
-
- public void setDubboConfigBinder(DubboConfigBinder dubboConfigBinder) {
- this.dubboConfigBinder = dubboConfigBinder;
- }
-
- @Override
- public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
- if (bean instanceof AbstractConfig) {
- String id = ((AbstractConfig) bean).getId();
- if (beanDefinitionRegistry != null && beanDefinitionRegistry instanceof DefaultListableBeanFactory) {
- DefaultListableBeanFactory factory = (DefaultListableBeanFactory) beanDefinitionRegistry;
- if (!StringUtils.isBlank(id) && !factory.hasAlias(beanName, id)) {
- beanDefinitionRegistry.registerAlias(beanName, id);
- }
- }
- }
- return bean;
- }
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- this.applicationContext = applicationContext;
- }
-
- @Override
- public void afterPropertiesSet() throws Exception {
-
- initDubboConfigBinder();
-
- initConfigBeanCustomizers();
-
- }
-
- private void initDubboConfigBinder() {
-
- if (dubboConfigBinder == null) {
- try {
- dubboConfigBinder = applicationContext.getBean(DubboConfigBinder.class);
- } catch (BeansException ignored) {
- if (log.isDebugEnabled()) {
- log.debug("DubboConfigBinder Bean can't be found in ApplicationContext.");
- }
- // Use Default implementation
- dubboConfigBinder = createDubboConfigBinder(applicationContext.getEnvironment());
- }
- }
-
- dubboConfigBinder.setIgnoreUnknownFields(ignoreUnknownFields);
- dubboConfigBinder.setIgnoreInvalidFields(ignoreInvalidFields);
-
- }
-
- private void initConfigBeanCustomizers() {
-
- Collection<DubboConfigBeanCustomizer> configBeanCustomizers =
- beansOfTypeIncludingAncestors(applicationContext, DubboConfigBeanCustomizer.class).values();
-
- this.configBeanCustomizers = new ArrayList<>(configBeanCustomizers);
-
- AnnotationAwareOrderComparator.sort(this.configBeanCustomizers);
- }
-
- /**
- * Create {@link DubboConfigBinder} instance.
- *
- * @param environment
- * @return {@link DefaultDubboConfigBinder}
- */
- protected DubboConfigBinder createDubboConfigBinder(Environment environment) {
- DefaultDubboConfigBinder defaultDubboConfigBinder = new DefaultDubboConfigBinder();
- defaultDubboConfigBinder.setEnvironment(environment);
- return defaultDubboConfigBinder;
- }
-
- @Override
- public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
- if (this.beanDefinitionRegistry == null) {
- this.beanDefinitionRegistry = registry;
- }
- }
-
- @Override
- public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
- //do nothing here
- }
-}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrar.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrar.java
deleted file mode 100644
index 62f5b69..0000000
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrar.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.context.annotation;
-
-import org.apache.dubbo.config.AbstractConfig;
-import org.apache.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor;
-import org.apache.dubbo.config.spring.beans.factory.config.ConfigurableSourceBeanMetadataElement;
-import org.apache.dubbo.config.spring.context.config.NamePropertyDefaultValueDubboConfigBeanCustomizer;
-
-import com.alibaba.spring.beans.factory.annotation.ConfigurationBeanBindingRegistrar;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.context.EnvironmentAware;
-import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
-import org.springframework.core.annotation.AnnotationAttributes;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.core.env.Environment;
-import org.springframework.core.type.AnnotationMetadata;
-import org.springframework.util.Assert;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
-
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static com.alibaba.spring.util.BeanRegistrar.registerInfrastructureBean;
-import static com.alibaba.spring.util.PropertySourcesUtils.getSubProperties;
-import static com.alibaba.spring.util.PropertySourcesUtils.normalizePrefix;
-import static org.apache.dubbo.config.spring.context.config.NamePropertyDefaultValueDubboConfigBeanCustomizer.BEAN_NAME;
-import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition;
-import static org.springframework.beans.factory.support.BeanDefinitionReaderUtils.registerWithGeneratedName;
-import static org.springframework.core.annotation.AnnotationAttributes.fromMap;
-
-/**
- * {@link AbstractConfig Dubbo Config} binding Bean registrar
- *
- * @see EnableDubboConfigBinding
- * @see DubboConfigBindingBeanPostProcessor
- * @since 2.5.8
- * @deprecated it will be removed in future, please use {@link ConfigurationBeanBindingRegistrar} for replacement
- */
-@Deprecated
-public class DubboConfigBindingRegistrar implements ImportBeanDefinitionRegistrar, EnvironmentAware,
- ConfigurableSourceBeanMetadataElement {
-
- private final Log log = LogFactory.getLog(getClass());
-
- private ConfigurableEnvironment environment;
-
- @Override
- public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
-
- AnnotationAttributes attributes = fromMap(importingClassMetadata.getAnnotationAttributes(EnableDubboConfigBinding.class.getName()));
-
- registerBeanDefinitions(attributes, registry);
-
- }
-
- protected void registerBeanDefinitions(AnnotationAttributes attributes, BeanDefinitionRegistry registry) {
-
- String prefix = environment.resolvePlaceholders(attributes.getString("prefix"));
-
- Class<? extends AbstractConfig> configClass = attributes.getClass("type");
-
- boolean multiple = attributes.getBoolean("multiple");
-
- registerDubboConfigBeans(prefix, configClass, multiple, registry);
-
- }
-
- private void registerDubboConfigBeans(String prefix,
- Class<? extends AbstractConfig> configClass,
- boolean multiple,
- BeanDefinitionRegistry registry) {
-
- Map<String, Object> properties = getSubProperties(environment.getPropertySources(), prefix);
-
- if (CollectionUtils.isEmpty(properties)) {
- if (log.isDebugEnabled()) {
- log.debug("There is no property for binding to dubbo config class [" + configClass.getName()
- + "] within prefix [" + prefix + "]");
- }
- return;
- }
-
- Set<String> beanNames = multiple ? resolveMultipleBeanNames(properties) :
- Collections.singleton(resolveSingleBeanName(properties, configClass, registry));
-
- for (String beanName : beanNames) {
-
- registerDubboConfigBean(beanName, configClass, registry);
-
- registerDubboConfigBindingBeanPostProcessor(prefix, beanName, multiple, registry);
-
- }
-
- registerDubboConfigBeanCustomizers(registry);
-
- }
-
- private void registerDubboConfigBean(String beanName, Class<? extends AbstractConfig> configClass,
- BeanDefinitionRegistry registry) {
-
- BeanDefinitionBuilder builder = rootBeanDefinition(configClass);
-
- AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
-
- /**
- * @since 2.7.5
- */
- setSource(beanDefinition);
-
- registry.registerBeanDefinition(beanName, beanDefinition);
-
- if (log.isInfoEnabled()) {
- log.info("The dubbo config bean definition [name : " + beanName + ", class : " + configClass.getName() +
- "] has been registered.");
- }
-
- }
-
- private void registerDubboConfigBindingBeanPostProcessor(String prefix, String beanName, boolean multiple,
- BeanDefinitionRegistry registry) {
-
- Class<?> processorClass = DubboConfigBindingBeanPostProcessor.class;
-
- BeanDefinitionBuilder builder = rootBeanDefinition(processorClass);
-
- String actualPrefix = multiple ? normalizePrefix(prefix) + beanName : prefix;
-
- builder.addConstructorArgValue(actualPrefix).addConstructorArgValue(beanName);
-
- AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
-
- beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
-
- registerWithGeneratedName(beanDefinition, registry);
-
- if (log.isInfoEnabled()) {
- log.info("The BeanPostProcessor bean definition [" + processorClass.getName()
- + "] for dubbo config bean [name : " + beanName + "] has been registered.");
- }
-
- }
-
- private void registerDubboConfigBeanCustomizers(BeanDefinitionRegistry registry) {
- registerInfrastructureBean(registry, BEAN_NAME, NamePropertyDefaultValueDubboConfigBeanCustomizer.class);
- }
-
- @Override
- public void setEnvironment(Environment environment) {
-
- Assert.isInstanceOf(ConfigurableEnvironment.class, environment);
-
- this.environment = (ConfigurableEnvironment) environment;
-
- }
-
- private Set<String> resolveMultipleBeanNames(Map<String, Object> properties) {
-
- Set<String> beanNames = new LinkedHashSet<String>();
-
- for (String propertyName : properties.keySet()) {
-
- int index = propertyName.indexOf(".");
-
- if (index > 0) {
-
- String beanName = propertyName.substring(0, index);
-
- beanNames.add(beanName);
- }
-
- }
-
- return beanNames;
-
- }
-
- private String resolveSingleBeanName(Map<String, Object> properties, Class<? extends AbstractConfig> configClass,
- BeanDefinitionRegistry registry) {
-
- String beanName = (String) properties.get("id");
-
- if (!StringUtils.hasText(beanName)) {
- BeanDefinitionBuilder builder = rootBeanDefinition(configClass);
- beanName = BeanDefinitionReaderUtils.generateBeanName(builder.getRawBeanDefinition(), registry);
- }
-
- return beanName;
-
- }
-
-}
\ No newline at end of file
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingsRegistrar.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingsRegistrar.java
deleted file mode 100644
index d1ff887..0000000
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingsRegistrar.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.context.annotation;
-
-import org.apache.dubbo.config.AbstractConfig;
-
-import com.alibaba.spring.beans.factory.annotation.ConfigurationBeanBindingsRegister;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.context.EnvironmentAware;
-import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
-import org.springframework.core.annotation.AnnotationAttributes;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.core.env.Environment;
-import org.springframework.core.type.AnnotationMetadata;
-import org.springframework.util.Assert;
-
-/**
- * {@link AbstractConfig Dubbo Config} binding Bean registrar for {@link EnableDubboConfigBindings}
- *
- * @see EnableDubboConfigBindings
- * @see DubboConfigBindingRegistrar
- * @since 2.5.8
- * @deprecated it will be removed in future, please use {@link ConfigurationBeanBindingsRegister} for replacement
- */
-@Deprecated
-public class DubboConfigBindingsRegistrar implements ImportBeanDefinitionRegistrar, EnvironmentAware {
-
- private ConfigurableEnvironment environment;
-
- @Override
- public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
-
- AnnotationAttributes attributes = AnnotationAttributes.fromMap(
- importingClassMetadata.getAnnotationAttributes(EnableDubboConfigBindings.class.getName()));
-
- AnnotationAttributes[] annotationAttributes = attributes.getAnnotationArray("value");
-
- DubboConfigBindingRegistrar registrar = new DubboConfigBindingRegistrar();
- registrar.setEnvironment(environment);
-
- for (AnnotationAttributes element : annotationAttributes) {
-
- registrar.registerBeanDefinitions(element, registry);
-
- }
- }
-
- @Override
- public void setEnvironment(Environment environment) {
-
- Assert.isInstanceOf(ConfigurableEnvironment.class, environment);
-
- this.environment = (ConfigurableEnvironment) environment;
-
- }
-
-}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigBinding.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigBinding.java
deleted file mode 100644
index 14fabf9..0000000
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigBinding.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.config.spring.context.annotation;
-
-import org.apache.dubbo.config.AbstractConfig;
-import org.apache.dubbo.config.ApplicationConfig;
-import org.apache.dubbo.config.ModuleConfig;
-import org.apache.dubbo.config.RegistryConfig;
-import org.apache.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor;
-
-import com.alibaba.spring.beans.factory.annotation.EnableConfigurationBeanBinding;
-import org.springframework.context.annotation.Import;
-import org.springframework.core.env.PropertySources;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Enables Spring's annotation-driven {@link AbstractConfig Dubbo Config} from {@link PropertySources properties}.
- * <p>
- * Default , {@link #prefix()} associates with a prefix of {@link PropertySources properties}, e,g. "dubbo.application."
- * or "dubbo.application"
- * <pre class="code">
- * <p>
- * </pre>
- *
- * @see DubboConfigBindingRegistrar
- * @see DubboConfigBindingBeanPostProcessor
- * @see EnableDubboConfigBindings
- * @see EnableConfigurationBeanBinding
- * @since 2.5.8
- * @deprecated it will be removed in future, please use {@link EnableConfigurationBeanBinding} for replacement
- */
-@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-@Repeatable(EnableDubboConfigBindings.class)
-@Import(DubboConfigBindingRegistrar.class)
-@Deprecated
-public @interface EnableDubboConfigBinding {
-
- /**
- * The name prefix of the properties that are valid to bind to {@link AbstractConfig Dubbo Config}.
- *
- * @return the name prefix of the properties to bind
- */
- String prefix();
-
- /**
- * @return The binding type of {@link AbstractConfig Dubbo Config}.
- * @see AbstractConfig
- * @see ApplicationConfig
- * @see ModuleConfig
- * @see RegistryConfig
- */
- Class<? extends AbstractConfig> type();
-
- /**
- * It indicates whether {@link #prefix()} binding to multiple Spring Beans.
- *
- * @return the default value is <code>false</code>
- */
- boolean multiple() default false;
-
-}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigBindings.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigBindings.java
deleted file mode 100644
index 5fde1a4..0000000
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigBindings.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.context.annotation;
-
-import com.alibaba.spring.beans.factory.annotation.EnableConfigurationBeanBindings;
-import org.springframework.context.annotation.Import;
-
-import java.lang.annotation.Annotation;
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Multiple {@link EnableDubboConfigBinding} {@link Annotation}
- *
- * @see EnableDubboConfigBinding
- * @since 2.5.8
- * @deprecated it will be removed in future, please use {@link EnableConfigurationBeanBindings} for replacement
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-@Import(DubboConfigBindingsRegistrar.class)
-@Deprecated
-public @interface EnableDubboConfigBindings {
-
- /**
- * The value of {@link EnableDubboConfigBindings}
- *
- * @return non-null
- */
- EnableDubboConfigBinding[] value();
-
-}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/DubboConfigBeanCustomizer.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/DubboConfigBeanCustomizer.java
index 5588a33..b473cfe 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/DubboConfigBeanCustomizer.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/DubboConfigBeanCustomizer.java
@@ -17,7 +17,6 @@
package org.apache.dubbo.config.spring.context.config;
import org.apache.dubbo.config.AbstractConfig;
-import org.apache.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor;
import org.apache.dubbo.config.spring.context.properties.DubboConfigBinder;
import com.alibaba.spring.context.config.ConfigurationBeanCustomizer;
@@ -33,7 +32,6 @@ import org.springframework.core.Ordered;
* are executed orderly, thus the subclass should be aware to implement the {@link #getOrder()} method.
*
* @see DubboConfigBinder#bind(String, AbstractConfig)
- * @see DubboConfigBindingBeanPostProcessor
* @since 2.6.6
*/
public interface DubboConfigBeanCustomizer extends ConfigurationBeanCustomizer, Ordered {
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/NamePropertyDefaultValueDubboConfigBeanCustomizer.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/NamePropertyDefaultValueDubboConfigBeanCustomizer.java
deleted file mode 100644
index 175ba33..0000000
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/NamePropertyDefaultValueDubboConfigBeanCustomizer.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.context.config;
-
-import org.apache.dubbo.config.AbstractConfig;
-import org.apache.dubbo.config.spring.beans.factory.config.DubboConfigDefaultPropertyValueBeanPostProcessor;
-
-import org.springframework.util.ReflectionUtils;
-
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-import static com.alibaba.spring.util.ObjectUtils.of;
-import static org.springframework.beans.BeanUtils.getPropertyDescriptor;
-
-/**
- * {@link DubboConfigBeanCustomizer} for the default value for the "name" property that will be taken bean name
- * if absent.
- *
- * @since 2.6.6
- * @deprecated As 2.7.6, use {@link DubboConfigDefaultPropertyValueBeanPostProcessor}
- */
-@Deprecated
-public class NamePropertyDefaultValueDubboConfigBeanCustomizer implements DubboConfigBeanCustomizer {
-
- /**
- * The bean name of {@link NamePropertyDefaultValueDubboConfigBeanCustomizer}
- *
- * @since 2.7.1
- */
- public static final String BEAN_NAME = "namePropertyDefaultValueDubboConfigBeanCustomizer";
-
- /**
- * The name of property that is "name" maybe is absent in target class
- */
- private static final String PROPERTY_NAME = "name";
-
- @Override
- public void customize(String beanName, AbstractConfig dubboConfigBean) {
-
- PropertyDescriptor propertyDescriptor = getPropertyDescriptor(dubboConfigBean.getClass(), PROPERTY_NAME);
-
- if (propertyDescriptor != null) { // "name" property is present
-
- Method getNameMethod = propertyDescriptor.getReadMethod();
-
- if (getNameMethod == null) { // if "getName" method is absent
- return;
- }
-
- Object propertyValue = ReflectionUtils.invokeMethod(getNameMethod, dubboConfigBean);
-
- if (propertyValue != null) { // If The return value of "getName" method is not null
- return;
- }
-
- Method setNameMethod = propertyDescriptor.getWriteMethod();
- if (setNameMethod != null) { // "setName" and "getName" methods are present
- if (Arrays.equals(of(String.class), setNameMethod.getParameterTypes())) { // the param type is String
- // set bean name to the value of the "name" property
- ReflectionUtils.invokeMethod(setNameMethod, dubboConfigBean, beanName);
- }
- }
- }
- }
-
- @Override
- public int getOrder() {
- return HIGHEST_PRECEDENCE;
- }
-}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessorTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessorTest.java
deleted file mode 100644
index 301c1d9..0000000
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessorTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.beans.factory.annotation;
-
-import org.apache.dubbo.config.ApplicationConfig;
-import org.apache.dubbo.config.ProtocolConfig;
-import org.apache.dubbo.config.spring.context.config.NamePropertyDefaultValueDubboConfigBeanCustomizer;
-import org.apache.dubbo.config.spring.context.properties.DefaultDubboConfigBinder;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * {@link DubboConfigBindingBeanPostProcessor}
- */
-@RunWith(SpringRunner.class)
-@ContextConfiguration(classes = {
- DefaultDubboConfigBinder.class,
- NamePropertyDefaultValueDubboConfigBeanCustomizer.class,
- DubboConfigBindingBeanPostProcessorTest.class
-})
-@TestPropertySource(properties = {
- "dubbo.application.id = dubbo-demo-application",
- "dubbo.application.owner = mercyblitz",
- "dubbo.application.organization = Apache",
-
-})
-public class DubboConfigBindingBeanPostProcessorTest {
-
- @Bean("dubbo-demo-application")
- public ApplicationConfig applicationConfig() {
- return new ApplicationConfig();
- }
-
- @Bean("dubbo-demo-protocol")
- public ProtocolConfig protocolConfig() {
- ProtocolConfig protocolConfig = new ProtocolConfig();
- protocolConfig.setName("dubbo");
- protocolConfig.setId("customConfigAlias");
- return protocolConfig;
- }
-
- @Bean
- public DubboConfigBindingBeanPostProcessor bindingBeanPostProcessor() {
- return new DubboConfigBindingBeanPostProcessor("dubbo.application", "dubbo-demo-application");
- }
-
- @Autowired
- private ApplicationContext applicationContext;
-
- @Test
- public void test() {
-
- ApplicationConfig applicationConfig = applicationContext.getBean(ApplicationConfig.class);
-
- String[] aliases = applicationContext.getAliases("dubbo-demo-protocol");
- ProtocolConfig protocolConfigByName = applicationContext.getBean("dubbo-demo-protocol", ProtocolConfig.class);
- ProtocolConfig protocolConfigById = applicationContext.getBean(protocolConfigByName.getId(), ProtocolConfig.class);
-
- Assert.assertEquals("dubbo-demo-application", applicationConfig.getName());
- Assert.assertEquals("mercyblitz", applicationConfig.getOwner());
- Assert.assertEquals("Apache", applicationConfig.getOrganization());
-
- Assert.assertArrayEquals(new String[]{"customConfigAlias"}, aliases);
- Assert.assertEquals(protocolConfigByName, protocolConfigById);
- }
-}
\ No newline at end of file
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrarTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrarTest.java
deleted file mode 100644
index 11c2ba4..0000000
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrarTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.context.annotation;
-
-import org.apache.dubbo.config.ApplicationConfig;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.springframework.context.annotation.PropertySource;
-
-/**
- * {@link DubboConfigBindingRegistrar}
- *
- * @since 2.5.8
- */
-public class DubboConfigBindingRegistrarTest {
-
- @Test
- public void testRegisterBeanDefinitionsForSingle() {
-
- AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
-
- context.register(TestApplicationConfig.class);
-
- context.refresh();
-
- ApplicationConfig applicationConfig = context.getBean("applicationBean", ApplicationConfig.class);
-
- Assertions.assertEquals("dubbo-demo-application", applicationConfig.getName());
-
-
- }
-
- @Test
- public void testRegisterBeanDefinitionsForMultiple() {
-
- AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
-
- context.register(TestMultipleApplicationConfig.class);
-
- context.refresh();
-
- ApplicationConfig applicationConfig = context.getBean("applicationBean", ApplicationConfig.class);
-
- Assertions.assertEquals("dubbo-demo-application", applicationConfig.getName());
-
- applicationConfig = context.getBean("applicationBean2", ApplicationConfig.class);
-
- Assertions.assertEquals("dubbo-demo-application2", applicationConfig.getName());
-
- applicationConfig = context.getBean("applicationBean3", ApplicationConfig.class);
-
- Assertions.assertEquals("dubbo-demo-application3", applicationConfig.getName());
-
-
- }
-
- @EnableDubboConfigBinding(prefix = "${application.prefixes}", type = ApplicationConfig.class, multiple = true)
- @PropertySource("META-INF/config.properties")
- private static class TestMultipleApplicationConfig {
-
- }
-
- @EnableDubboConfigBinding(prefix = "${application.prefix}", type = ApplicationConfig.class)
- @PropertySource("META-INF/config.properties")
- private static class TestApplicationConfig {
-
- }
-
-
-}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingsRegistrarTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingsRegistrarTest.java
deleted file mode 100644
index 498be8a..0000000
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigBindingsRegistrarTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.context.annotation;
-
-import org.apache.dubbo.config.ApplicationConfig;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.springframework.context.annotation.PropertySource;
-
-/**
- * {@link DubboConfigBindingsRegistrar} Test
- *
- * @since DubboConfigBindingsRegistrar
- */
-public class DubboConfigBindingsRegistrarTest {
-
- @Test
- public void test() {
-
- AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
-
- context.register(TestConfig.class);
-
- context.refresh();
-
- ApplicationConfig applicationConfig = context.getBean("applicationBean", ApplicationConfig.class);
-
- Assertions.assertEquals("dubbo-demo-application", applicationConfig.getName());
-
- Assertions.assertEquals(2, context.getBeansOfType(ApplicationConfig.class).size());
-
- }
-
-
- @EnableDubboConfigBindings({
- @EnableDubboConfigBinding(prefix = "${application.prefix}", type = ApplicationConfig.class),
- @EnableDubboConfigBinding(prefix = "dubbo.applications.applicationBean", type = ApplicationConfig.class)
- })
- @PropertySource("META-INF/config.properties")
- private static class TestConfig {
-
- }
-
-}
diff --git a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/RpcContextTest.java b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/RpcContextTest.java
index 3b6dd0e..594bc0f 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/RpcContextTest.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/RpcContextTest.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.rpc;
import org.apache.dubbo.common.URL;
+
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;