mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
Polish spring-cloud-incubator/spring-cloud-alibaba#378 : Optimize The dependencies for Dubbo Spring Cloud
This commit is contained in:
parent
3f6904f5ff
commit
47733ea41f
@ -29,9 +29,6 @@
|
|||||||
<aliyun.sdk.edas.version>2.16.0</aliyun.sdk.edas.version>
|
<aliyun.sdk.edas.version>2.16.0</aliyun.sdk.edas.version>
|
||||||
<rocketmq.version>4.3.1</rocketmq.version>
|
<rocketmq.version>4.3.1</rocketmq.version>
|
||||||
<schedulerX.client.version>2.1.6</schedulerX.client.version>
|
<schedulerX.client.version>2.1.6</schedulerX.client.version>
|
||||||
<dubbo.version>2.6.5</dubbo.version>
|
|
||||||
<dubbo-spring-boot.version>0.2.1.RELEASE</dubbo-spring-boot.version>
|
|
||||||
<dubbo-registry-nacos.version>0.0.2</dubbo-registry-nacos.version>
|
|
||||||
<aliyun.java.sdk.dysmsapi>1.1.0</aliyun.java.sdk.dysmsapi>
|
<aliyun.java.sdk.dysmsapi>1.1.0</aliyun.java.sdk.dysmsapi>
|
||||||
<aliyun.sdk.mns>1.1.8</aliyun.sdk.mns>
|
<aliyun.sdk.mns>1.1.8</aliyun.sdk.mns>
|
||||||
<aliyun.java.sdk.dysmsapi>1.1.0</aliyun.java.sdk.dysmsapi>
|
<aliyun.java.sdk.dysmsapi>1.1.0</aliyun.java.sdk.dysmsapi>
|
||||||
@ -210,50 +207,6 @@
|
|||||||
<version>${oss.version}</version>
|
<version>${oss.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Apache Dubbo dependencies-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>dubbo-dependencies-bom</artifactId>
|
|
||||||
<version>${dubbo.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Dubbo -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>dubbo</artifactId>
|
|
||||||
<version>${dubbo.version}</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-context</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>servlet-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Dubbo Spring Boot Starter -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.boot</groupId>
|
|
||||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
|
||||||
<version>${dubbo-spring-boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Dubbo Nacos registry dependency -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>dubbo-registry-nacos</artifactId>
|
|
||||||
<version>${dubbo-registry-nacos.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Own dependencies -->
|
<!-- Own dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
@ -453,4 +406,4 @@
|
|||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
</project>
|
</project>
|
@ -13,6 +13,72 @@
|
|||||||
<artifactId>spring-cloud-alibaba-dubbo</artifactId>
|
<artifactId>spring-cloud-alibaba-dubbo</artifactId>
|
||||||
<name>Spring Cloud Alibaba Dubbo</name>
|
<name>Spring Cloud Alibaba Dubbo</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<dubbo.version>2.6.5</dubbo.version>
|
||||||
|
<dubbo-spring-boot.version>0.2.1.RELEASE</dubbo-spring-boot.version>
|
||||||
|
<dubbo-registry-nacos.version>0.0.2</dubbo-registry-nacos.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- Spring Boot dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Apache Dubbo dependencies-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>dubbo-dependencies-bom</artifactId>
|
||||||
|
<version>${dubbo.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Dubbo -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>dubbo</artifactId>
|
||||||
|
<version>${dubbo.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Dubbo Spring Boot Starter -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.boot</groupId>
|
||||||
|
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||||
|
<version>${dubbo-spring-boot.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Dubbo Nacos registry dependency -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>dubbo-registry-nacos</artifactId>
|
||||||
|
<version>${dubbo-registry-nacos.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- Spring Boot dependencies -->
|
<!-- Spring Boot dependencies -->
|
||||||
@ -170,9 +236,9 @@
|
|||||||
|
|
||||||
<!-- Eureka Service Discovery -->
|
<!-- Eureka Service Discovery -->
|
||||||
<!--<dependency>-->
|
<!--<dependency>-->
|
||||||
<!--<groupId>org.springframework.cloud</groupId>-->
|
<!--<groupId>org.springframework.cloud</groupId>-->
|
||||||
<!--<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>-->
|
<!--<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>-->
|
||||||
<!--<scope>test</scope>-->
|
<!--<scope>test</scope>-->
|
||||||
<!--</dependency>-->
|
<!--</dependency>-->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.cloud.alibaba.dubbo.http;
|
package org.springframework.cloud.alibaba.dubbo.http;
|
||||||
|
|
||||||
import org.springframework.http.HttpCookie;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpInputMessage;
|
import org.springframework.http.HttpInputMessage;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
@ -29,7 +28,6 @@ import java.net.URI;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.springframework.cloud.alibaba.dubbo.http.util.HttpUtils.getParameters;
|
import static org.springframework.cloud.alibaba.dubbo.http.util.HttpUtils.getParameters;
|
||||||
import static org.springframework.cloud.alibaba.dubbo.http.util.HttpUtils.parseCookies;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutable {@link HttpServerRequest} implementation
|
* Mutable {@link HttpServerRequest} implementation
|
||||||
@ -48,18 +46,15 @@ public class MutableHttpServerRequest implements HttpServerRequest {
|
|||||||
|
|
||||||
private final HttpHeaders httpHeaders;
|
private final HttpHeaders httpHeaders;
|
||||||
|
|
||||||
private final MultiValueMap<String, HttpCookie> cookies;
|
|
||||||
|
|
||||||
private final HttpInputMessage httpInputMessage;
|
private final HttpInputMessage httpInputMessage;
|
||||||
|
|
||||||
public MutableHttpServerRequest(HttpRequest httpRequest, byte[] body) {
|
public MutableHttpServerRequest(HttpRequest httpRequest, byte[] body) {
|
||||||
this.httpMethod = httpRequest.getMethod();
|
this.httpMethod = httpRequest.getMethod();
|
||||||
this.uri = httpRequest.getURI();
|
this.uri = httpRequest.getURI();
|
||||||
this.path = uri.getPath();
|
this.path = uri.getPath();
|
||||||
this.httpHeaders = new HttpHeaders(httpRequest.getHeaders());
|
this.httpHeaders = httpRequest.getHeaders();
|
||||||
this.queryParams = getParameters(httpRequest);
|
this.queryParams = getParameters(httpRequest);
|
||||||
this.httpInputMessage = new ByteArrayHttpInputMessage(body);
|
this.httpInputMessage = new ByteArrayHttpInputMessage(body);
|
||||||
this.cookies = parseCookies(httpHeaders);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableHttpServerRequest params(Map<String, String> params) {
|
public MutableHttpServerRequest params(Map<String, String> params) {
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.cloud.alibaba.dubbo.http.matcher;
|
package org.springframework.cloud.alibaba.dubbo.http.matcher;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@ -45,7 +43,7 @@ public abstract class AbstractHttpRequestMatcher implements HttpRequestMatcher {
|
|||||||
protected abstract String getToStringInfix();
|
protected abstract String getToStringInfix();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package org.springframework.cloud.alibaba.dubbo.http.matcher;
|
package org.springframework.cloud.alibaba.dubbo.http.matcher;
|
||||||
|
|
||||||
import org.springframework.http.HttpRequest;
|
import org.springframework.http.HttpRequest;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@ -75,7 +74,6 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
|
||||||
public T getValue() {
|
public T getValue() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.cloud.alibaba.dubbo.http.util;
|
package org.springframework.cloud.alibaba.dubbo.http.util;
|
||||||
|
|
||||||
import org.springframework.http.HttpCookie;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpRequest;
|
import org.springframework.http.HttpRequest;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
@ -33,11 +31,9 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.springframework.http.HttpHeaders.COOKIE;
|
|
||||||
import static org.springframework.util.StringUtils.delimitedListToStringArray;
|
import static org.springframework.util.StringUtils.delimitedListToStringArray;
|
||||||
import static org.springframework.util.StringUtils.hasText;
|
import static org.springframework.util.StringUtils.hasText;
|
||||||
import static org.springframework.util.StringUtils.trimAllWhitespace;
|
import static org.springframework.util.StringUtils.trimAllWhitespace;
|
||||||
import static org.springframework.util.StringUtils.trimWhitespace;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Http Utilities class
|
* Http Utilities class
|
||||||
@ -138,30 +134,30 @@ public abstract class HttpUtils {
|
|||||||
return getParameters(Arrays.asList(pairs));
|
return getParameters(Arrays.asList(pairs));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Parse a read-only {@link MultiValueMap} of {@link HttpCookie} from {@link HttpHeaders}
|
// * Parse a read-only {@link MultiValueMap} of {@link HttpCookie} from {@link HttpHeaders}
|
||||||
*
|
// *
|
||||||
* @param httpHeaders {@link HttpHeaders}
|
// * @param httpHeaders {@link HttpHeaders}
|
||||||
* @return non-null, the key is a cookie name , the value is {@link HttpCookie}
|
// * @return non-null, the key is a cookie name , the value is {@link HttpCookie}
|
||||||
*/
|
// */
|
||||||
public static MultiValueMap<String, HttpCookie> parseCookies(HttpHeaders httpHeaders) {
|
// public static MultiValueMap<String, HttpCookie> parseCookies(HttpHeaders httpHeaders) {
|
||||||
|
//
|
||||||
String cookie = httpHeaders.getFirst(COOKIE);
|
// String cookie = httpHeaders.getFirst(COOKIE);
|
||||||
|
//
|
||||||
String[] cookieNameAndValues = StringUtils.delimitedListToStringArray(cookie, SEMICOLON);
|
// String[] cookieNameAndValues = StringUtils.delimitedListToStringArray(cookie, SEMICOLON);
|
||||||
|
//
|
||||||
MultiValueMap<String, HttpCookie> cookies = new LinkedMultiValueMap<>(cookieNameAndValues.length);
|
// MultiValueMap<String, HttpCookie> cookies = new LinkedMultiValueMap<>(cookieNameAndValues.length);
|
||||||
|
//
|
||||||
for (String cookeNameAndValue : cookieNameAndValues) {
|
// for (String cookeNameAndValue : cookieNameAndValues) {
|
||||||
String[] nameAndValue = delimitedListToStringArray(trimWhitespace(cookeNameAndValue), EQUAL);
|
// String[] nameAndValue = delimitedListToStringArray(trimWhitespace(cookeNameAndValue), EQUAL);
|
||||||
String name = nameAndValue[0];
|
// String name = nameAndValue[0];
|
||||||
String value = nameAndValue.length < 2 ? null : nameAndValue[1];
|
// String value = nameAndValue.length < 2 ? null : nameAndValue[1];
|
||||||
HttpCookie httpCookie = new HttpCookie(name, value);
|
// HttpCookie httpCookie = new HttpCookie(name, value);
|
||||||
cookies.add(name, httpCookie);
|
// cookies.add(name, httpCookie);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return cookies;
|
// return cookies;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To the name and value line sets
|
* To the name and value line sets
|
||||||
|
@ -19,7 +19,6 @@ package org.springframework.cloud.alibaba.dubbo.metadata;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.apache.commons.lang3.ClassUtils;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Parameter;
|
import java.lang.reflect.Parameter;
|
||||||
@ -53,7 +52,7 @@ public class MethodMetadata {
|
|||||||
|
|
||||||
public MethodMetadata(Method method) {
|
public MethodMetadata(Method method) {
|
||||||
this.name = method.getName();
|
this.name = method.getName();
|
||||||
this.returnType = ClassUtils.getName(method.getReturnType());
|
this.returnType = method.getReturnType().getName();
|
||||||
this.params = initParameters(method);
|
this.params = initParameters(method);
|
||||||
this.method = method;
|
this.method = method;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class DubboServiceBeanMetadataResolver implements BeanClassLoaderAware, S
|
|||||||
"org.springframework.cloud.openfeign.support.SpringMvcContract",
|
"org.springframework.cloud.openfeign.support.SpringMvcContract",
|
||||||
};
|
};
|
||||||
|
|
||||||
private final ObjectProvider<Contract> contract;
|
private final ObjectProvider<Contract> contractObjectProvider;
|
||||||
|
|
||||||
private ClassLoader classLoader;
|
private ClassLoader classLoader;
|
||||||
|
|
||||||
@ -65,8 +65,8 @@ public class DubboServiceBeanMetadataResolver implements BeanClassLoaderAware, S
|
|||||||
*/
|
*/
|
||||||
private Collection<Contract> contracts;
|
private Collection<Contract> contracts;
|
||||||
|
|
||||||
public DubboServiceBeanMetadataResolver(ObjectProvider<Contract> contract) {
|
public DubboServiceBeanMetadataResolver(ObjectProvider<Contract> contractObjectProvider) {
|
||||||
this.contract = contract;
|
this.contractObjectProvider = contractObjectProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -75,7 +75,11 @@ public class DubboServiceBeanMetadataResolver implements BeanClassLoaderAware, S
|
|||||||
LinkedList<Contract> contracts = new LinkedList<>();
|
LinkedList<Contract> contracts = new LinkedList<>();
|
||||||
|
|
||||||
// Add injected Contract if available, for example SpringMvcContract Bean under Spring Cloud Open Feign
|
// Add injected Contract if available, for example SpringMvcContract Bean under Spring Cloud Open Feign
|
||||||
contract.ifAvailable(contracts::add);
|
Contract contract = contractObjectProvider.getIfAvailable();
|
||||||
|
|
||||||
|
if (contract != null) {
|
||||||
|
contracts.add(contract);
|
||||||
|
}
|
||||||
|
|
||||||
Stream.of(CONTRACT_CLASS_NAMES)
|
Stream.of(CONTRACT_CLASS_NAMES)
|
||||||
.filter(this::isClassPresent) // filter the existed classes
|
.filter(this::isClassPresent) // filter the existed classes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user