Skip to content

Commit

Permalink
2.7.6 REST Metadata (#5738)
Browse files Browse the repository at this point in the history
* Polish /#4687 : Remove the duplicated test code in dubbo-config-spring

* Polish /#4674 & /#4470

* Polish /#5093 : Revert the previous commit

* Polish #5093 : [Feature] Dubbo Services generate the metadata of REST services

* Polish #5306 : [Migration] Upgrade the @SInCE tags in Javadoc migration cloud native to master

* Polish #5306 : [Migration] Upgrade the @SInCE tags in Javadoc migration cloud native to master

* Polish #5309 : [ISSURE] The beans of Dubbo's Config can't be found on the ReferenceBean's initialization

* Polish #5312 : Resolve the demos' issues of zookeeper and nacos

* Polish #5313 : [Migration] migrate the code in common module from cloud-native branch to master

* Polish #5316 : [Refactor] Replace @EnableDubboConfigBinding Using spring-context-support

* Polish #5317 : [Refactor] Refactor ReferenceAnnotationBeanPostProcessor using Alibaba spring-context-suuport API

* Polish #5321 : Remove BeanFactoryUtils

* Polish #5321 : Remove AnnotatedBeanDefinitionRegistryUtils

* Polish #5321 : Remove AnnotationUtils

* Polish #5321 : Remove ClassUtils

* Polish #5321 : Remove BeanRegistrar

* Polish #5321 : Remove ObjectUtils

* Polish #5321 : Remove PropertySourcesUtils

* Polish #5325 : [Migration] To migrate dubbo-metadata-api from cloud-native branch

* Polish #5326 : [Migration] To migrate dubbo-metadata-processor from cloud-native branch

* Polish #5329 : [Feature] To add the default metadata into ServiceInstance

* Polish #5339 : [Refactor] Refactor the DynamicConfiguration interface

* Polish bugfix

* Fixes test cases

* Merge remote-tracking branch 'upstream/master' into cloud-native-2.7.5

# Conflicts:
#	dubbo-configcenter/dubbo-configcenter-zookeeper/src/test/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationTest.java
#	dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/DynamicConfigurationServiceNameMappingTest.java

* Merge remote-tracking branch 'upstream/master' into cloud-native-2.7.5

# Conflicts:
#	dubbo-configcenter/dubbo-configcenter-zookeeper/src/test/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationTest.java
#	dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/DynamicConfigurationServiceNameMappingTest.java

* Polish /#5721 : [Enhancement] Setting the default IDs for Dubbo's Config Beans

* Polish /#5729 : [Optimization] To remove EnableDubboConfigBinding and EnableDubboConfigBindings

* Polish /#5594 : [Feature] Add the resolver of ServiceRestMetadata based on Java Reflection

* Polish /#5736 : [Feature] Introducing Conversion features

* Polish /#5737 : [Feature] Introducing "dubbo-metadata-processor" module

* Polish /#5594 : Change the Metadata implementation

* Polish /#5594 : Fixed test cases

* Polish /#5594 : Fixed test cases

* Polish /#5594 : Fixed test cases

* Polish /#5594 : Fixed test cases

* Polish /#5594 : Fixed test cases

* Polish /#5594 : Fixed test cases

* Polish /#5594 : Fixed test cases

* Polish /#5594 : Fixed test cases
  • Loading branch information
mercyblitz committed Feb 17, 2020
1 parent d30ca86 commit 7b0ae12
Show file tree
Hide file tree
Showing 192 changed files with 16,107 additions and 85 deletions.
191 changes: 144 additions & 47 deletions dubbo-all/pom.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* 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.common.convert;

import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.extension.SPI;
import org.apache.dubbo.common.lang.Prioritized;

import static org.apache.dubbo.common.extension.ExtensionLoader.getExtensionLoader;
import static org.apache.dubbo.common.utils.ClassUtils.isAssignableFrom;
import static org.apache.dubbo.common.utils.TypeUtils.findActualTypeArgument;

/**
* A class to convert the source-typed value to the target-typed value
*
* @param <S> The source type
* @param <T> The target type
* @since 2.7.6
*/
@SPI
@FunctionalInterface
public interface Converter<S, T> extends Prioritized {

/**
* Accept the source type and target type or not
*
* @param sourceType the source type
* @param targetType the target type
* @return if accepted, return <code>true</code>, or <code>false</code>
*/
default boolean accept(Class<?> sourceType, Class<?> targetType) {
return isAssignableFrom(sourceType, getSourceType()) && isAssignableFrom(targetType, getTargetType());
}

/**
* Convert the source-typed value to the target-typed value
*
* @param source the source-typed value
* @return the target-typed value
*/
T convert(S source);

/**
* Get the source type
*
* @return non-null
*/
default Class<S> getSourceType() {
return findActualTypeArgument(getClass(), Converter.class, 0);
}

/**
* Get the target type
*
* @return non-null
*/
default Class<T> getTargetType() {
return findActualTypeArgument(getClass(), Converter.class, 1);
}

/**
* Get the Converter instance from {@link ExtensionLoader} with the specified source and target type
*
* @param sourceType the source type
* @param targetType the target type
* @return
* @see ExtensionLoader#getSupportedExtensionInstances()
*/
static Converter<?, ?> getConverter(Class<?> sourceType, Class<?> targetType) {
return getExtensionLoader(Converter.class)
.getSupportedExtensionInstances()
.stream()
.filter(converter -> converter.accept(sourceType, targetType))
.findFirst()
.orElse(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.common.convert;

/**
* A class to covert {@link String} to the target-typed value
*
* @see Converter
* @since 2.7.6
*/
@FunctionalInterface
public interface StringConverter<T> extends Converter<String, T> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.common.convert;

import static java.lang.Boolean.valueOf;
import static org.apache.dubbo.common.utils.StringUtils.isNotEmpty;

/**
* The class to convert {@link String} to {@link Boolean}
*
* @since 2.7.6
*/
public class StringToBooleanConverter implements StringConverter<Boolean> {

@Override
public Boolean convert(String source) {
return isNotEmpty(source) ? valueOf(source) : null;
}

@Override
public int getPriority() {
return NORMAL_PRIORITY + 5;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.common.convert;


import static org.apache.dubbo.common.utils.StringUtils.isNotEmpty;

/**
* The class to convert {@link String} to <code>char[]</code>
*
* @since 2.7.6
*/
public class StringToCharArrayConverter implements StringConverter<char[]> {

@Override
public char[] convert(String source) {
return isNotEmpty(source) ? source.toCharArray() : null;
}


@Override
public int getPriority() {
return NORMAL_PRIORITY + 7;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.common.convert;

import static org.apache.dubbo.common.utils.StringUtils.length;

/**
* The class to convert {@link String} to {@link Character}
*
* @since 2.7.6
*/
public class StringToCharacterConverter implements StringConverter<Character> {

@Override
public Character convert(String source) {
int length = length(source);
if (length == 0) {
return null;
}
if (length > 1) {
throw new IllegalArgumentException("The source String is more than one character!");
}
return source.charAt(0);
}

@Override
public int getPriority() {
return NORMAL_PRIORITY + 8;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.common.convert;

import static java.lang.Double.valueOf;
import static org.apache.dubbo.common.utils.StringUtils.isNotEmpty;

/**
* The class to convert {@link String} to {@link Double}
*
* @since 2.7.6
*/
public class StringToDoubleConverter implements StringConverter<Double> {

@Override
public Double convert(String source) {
return isNotEmpty(source) ? valueOf(source) : null;
}


@Override
public int getPriority() {
return NORMAL_PRIORITY + 3;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.common.convert;

import static java.lang.Float.valueOf;
import static org.apache.dubbo.common.utils.StringUtils.isNotEmpty;

/**
* The class to convert {@link String} to {@link Float}
*
* @since 2.7.6
*/
public class StringToFloatConverter implements StringConverter<Float> {

@Override
public Float convert(String source) {
return isNotEmpty(source) ? valueOf(source) : null;
}

@Override
public int getPriority() {
return NORMAL_PRIORITY + 4;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.common.convert;

import static java.lang.Integer.valueOf;
import static org.apache.dubbo.common.utils.StringUtils.isNotEmpty;

/**
* The class to convert {@link String} to {@link Integer}
*
* @since 2.7.6
*/
public class StringToIntegerConverter implements StringConverter<Integer> {

@Override
public Integer convert(String source) {
return isNotEmpty(source) ? valueOf(source) : null;
}

@Override
public int getPriority() {
return NORMAL_PRIORITY;
}
}
Loading

0 comments on commit 7b0ae12

Please sign in to comment.