1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

Merge branch 'master' into issues765

# Conflicts:
#	spring-cloud-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/registry/NacosRegistration.java
This commit is contained in:
ly 2019-07-23 23:11:23 +08:00
commit 7301700a90
608 changed files with 3482 additions and 3316 deletions

View File

@ -109,7 +109,7 @@ Example 列表:
[RocketMQ Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/rocketmq-example/readme-zh.md)
[Seata Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/seata-example/readme-zh.md)
[Fescar Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/fescar-example/readme-zh.md)
[Alibaba Cloud OSS Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/oss-example/readme-zh.md)
@ -139,4 +139,4 @@ spring-cloud-alibaba@googlegroups.com欢迎通过此邮件列表讨论与 spr
### 钉钉群
![DingQR](https://cdn.nlark.com/lark/0/2018/png/54319/1544667717958-b3022f21-3357-4270-836d-4064e7ac728c.png)
![DingQR](https://img.alicdn.com/tfs/TB1fr81ba61gK0jSZFlXXXDKFXa-892-1213.jpg)

View File

@ -25,7 +25,7 @@ Apache RocketMQ™ 基于 Java 的高性能、高吞吐量的分布式消息和
Apache Dubbo™ 是一款高性能 Java RPC 框架。
**Seata**
**Fescar**
阿里巴巴开源产品,一个易于使用的高性能微服务分布式事务解决方案。

View File

@ -28,7 +28,7 @@ Apache RocketMQ™ is an open source distributed messaging and streaming data pl
Apache Dubbo™ is a high-performance, Java based open source RPC framework.
**Seata**
**Fescar**
A distributed transaction solution with high performance and ease of use for microservices architecture.

View File

@ -1,74 +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 com.alibaba.cloud.dubbo.http.matcher;
import java.util.Collection;
import java.util.Iterator;
/**
* Abstract {@link HttpRequestMatcher} implementation
*
* @author Rossen Stoyanchev
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
public abstract class AbstractHttpRequestMatcher implements HttpRequestMatcher {
/**
* Return the discrete items a request condition is composed of.
* <p>For example URL patterns, HTTP request methods, param expressions, etc.
*
* @return a collection of objects, never {@code null}
*/
protected abstract Collection<?> getContent();
/**
* The notation to use when printing discrete items of content.
* <p>For example {@code " || "} for URL patterns or {@code " && "}
* for param expressions.
*/
protected abstract String getToStringInfix();
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (other == null || getClass() != other.getClass()) {
return false;
}
return getContent().equals(((AbstractHttpRequestMatcher)other).getContent());
}
@Override
public int hashCode() {
return getContent().hashCode();
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder("[");
for (Iterator<?> iterator = getContent().iterator(); iterator.hasNext(); ) {
Object expression = iterator.next();
builder.append(expression.toString());
if (iterator.hasNext()) {
builder.append(getToStringInfix());
}
}
builder.append("]");
return builder.toString();
}
}

View File

@ -1,21 +0,0 @@
package com.alibaba.cloud.nacos.ribbon;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.client.naming.core.Balancer;
import java.util.List;
/**
* @author itmuch.com
*/
public class ExtendBalancer extends Balancer {
/**
* 根据权重随机选择实例
*
* @param instances 实例列表
* @return 选择的实例
*/
public static Instance getHostByRandomWeight2(List<Instance> instances) {
return getHostByRandomWeight(instances);
}
}

View File

@ -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 com.alibaba.cloud.sentinel.datasource.config;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.springframework.core.env.Environment;
import com.alibaba.cloud.sentinel.datasource.RuleType;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.GatewayApiDefinitionManager;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;
import com.alibaba.csp.sentinel.datasource.AbstractDataSource;
import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRuleManager;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRuleManager;
import com.alibaba.csp.sentinel.slots.system.SystemRuleManager;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* Abstract class Using by {@link DataSourcePropertiesConfiguration}
*
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
*/
public class AbstractDataSourceProperties {
@NotEmpty
private String dataType = "json";
@NotNull
private RuleType ruleType;
private String converterClass;
@JsonIgnore
private final String factoryBeanName;
@JsonIgnore
private Environment env;
public AbstractDataSourceProperties(String factoryBeanName) {
this.factoryBeanName = factoryBeanName;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public RuleType getRuleType() {
return ruleType;
}
public void setRuleType(RuleType ruleType) {
this.ruleType = ruleType;
}
public String getConverterClass() {
return converterClass;
}
public void setConverterClass(String converterClass) {
this.converterClass = converterClass;
}
public String getFactoryBeanName() {
return factoryBeanName;
}
protected Environment getEnv() {
return env;
}
public void setEnv(Environment env) {
this.env = env;
}
public void preCheck(String dataSourceName) {
}
public void postRegister(AbstractDataSource dataSource) {
switch (this.getRuleType()) {
case FLOW:
FlowRuleManager.register2Property(dataSource.getProperty());
break;
case DEGRADE:
DegradeRuleManager.register2Property(dataSource.getProperty());
break;
case PARAM_FLOW:
ParamFlowRuleManager.register2Property(dataSource.getProperty());
break;
case SYSTEM:
SystemRuleManager.register2Property(dataSource.getProperty());
break;
case AUTHORITY:
AuthorityRuleManager.register2Property(dataSource.getProperty());
break;
case GW_FLOW:
GatewayRuleManager.register2Property(dataSource.getProperty());
break;
case GW_API_GROUP:
GatewayApiDefinitionManager.register2Property(dataSource.getProperty());
break;
default:
break;
}
}
}

View File

@ -1,93 +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 com.alibaba.cloud.sentinel.datasource.factorybean;
import java.io.File;
import java.nio.charset.Charset;
import org.springframework.beans.factory.FactoryBean;
import com.alibaba.csp.sentinel.datasource.Converter;
import com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource;
/**
* A {@link FactoryBean} for creating {@link FileRefreshableDataSource} instance.
*
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
* @see FileRefreshableDataSource
*/
public class FileRefreshableDataSourceFactoryBean
implements FactoryBean<FileRefreshableDataSource> {
private String file;
private String charset;
private long recommendRefreshMs;
private int bufSize;
private Converter converter;
@Override
public FileRefreshableDataSource getObject() throws Exception {
return new FileRefreshableDataSource(new File(file), converter,
recommendRefreshMs, bufSize, Charset.forName(charset));
}
@Override
public Class<?> getObjectType() {
return FileRefreshableDataSource.class;
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
public String getCharset() {
return charset;
}
public void setCharset(String charset) {
this.charset = charset;
}
public long getRecommendRefreshMs() {
return recommendRefreshMs;
}
public void setRecommendRefreshMs(long recommendRefreshMs) {
this.recommendRefreshMs = recommendRefreshMs;
}
public int getBufSize() {
return bufSize;
}
public void setBufSize(int bufSize) {
this.bufSize = bufSize;
}
public Converter getConverter() {
return converter;
}
public void setConverter(Converter converter) {
this.converter = converter;
}
}

View File

@ -1,231 +0,0 @@
///*
// * Copyright (C) 2018 the original author or authors.
// *
// * Licensed 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 com.alibaba.cloud.sentinel.datasource;
//
//import com.alibaba.cloud.sentinel.datasource.config.ApolloDataSourceProperties;
//import com.alibaba.cloud.sentinel.datasource.config.DataSourcePropertiesConfiguration;
//import com.alibaba.cloud.sentinel.datasource.config.FileDataSourceProperties;
//import com.alibaba.cloud.sentinel.datasource.config.NacosDataSourceProperties;
//import com.alibaba.cloud.sentinel.datasource.config.ZookeeperDataSourceProperties;
//
//import static org.junit.Assert.assertEquals;
//import static org.junit.Assert.assertNotNull;
//import static org.junit.Assert.assertNull;
//
//import org.junit.Test;
//
///**
// * @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
// */
//public class DataSourcePropertiesConfigurationTests {
//
// @Test
// public void testFileAttr() {
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration();
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
// dataSourcePropertiesConfiguration.getValidField().size());
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
//
// FileDataSourceProperties fileDataSourceProperties = buildFileProperties();
//
// dataSourcePropertiesConfiguration.setFile(fileDataSourceProperties);
//
// assertEquals(
// "DataSourcePropertiesConfiguration valid field size was wrong after set file attribute",
// 1, dataSourcePropertiesConfiguration.getValidField().size());
// assertNotNull(
// "DataSourcePropertiesConfiguration file properties was null after set file attribute",
// dataSourcePropertiesConfiguration.getFile());
// assertNotNull(
// "DataSourcePropertiesConfiguration valid properties was null after set file attribute",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
// }
//
// @Test
// public void testNacosAttr() {
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration();
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
// dataSourcePropertiesConfiguration.getValidField().size());
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
//
// NacosDataSourceProperties nacosDataSourceProperties = buildNacosProperties();
//
// dataSourcePropertiesConfiguration.setNacos(nacosDataSourceProperties);
//
// assertEquals(
// "DataSourcePropertiesConfiguration valid field size was wrong after set nacos attribute",
// 1, dataSourcePropertiesConfiguration.getValidField().size());
// assertNotNull(
// "DataSourcePropertiesConfiguration nacos properties was null after set nacos attribute",
// dataSourcePropertiesConfiguration.getNacos());
// assertNotNull(
// "DataSourcePropertiesConfiguration valid properties was null after set nacos attribute",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
// }
//
// @Test
// public void testZKAttr() {
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration();
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
// dataSourcePropertiesConfiguration.getValidField().size());
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
//
// ZookeeperDataSourceProperties zookeeperDataSourceProperties = buildZKProperties();
//
// dataSourcePropertiesConfiguration.setZk(zookeeperDataSourceProperties);
//
// assertEquals(
// "DataSourcePropertiesConfiguration valid field size was wrong after set zk attribute",
// 1, dataSourcePropertiesConfiguration.getValidField().size());
// assertNotNull(
// "DataSourcePropertiesConfiguration zk properties was null after set zk attribute",
// dataSourcePropertiesConfiguration.getZk());
// assertNotNull(
// "DataSourcePropertiesConfiguration valid properties was null after set zk attribute",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
// }
//
// @Test
// public void testApolloAttr() {
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration();
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
// dataSourcePropertiesConfiguration.getValidField().size());
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
//
// ApolloDataSourceProperties apolloDataSourceProperties = buildApolloProperties();
//
// dataSourcePropertiesConfiguration.setApollo(apolloDataSourceProperties);
//
// assertEquals(
// "DataSourcePropertiesConfiguration valid field size was wrong after set apollo attribute",
// 1, dataSourcePropertiesConfiguration.getValidField().size());
// assertNotNull(
// "DataSourcePropertiesConfiguration apollo properties was null after set apollo attribute",
// dataSourcePropertiesConfiguration.getApollo());
// assertNotNull(
// "DataSourcePropertiesConfiguration valid properties was null after set apollo attribute",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
// }
//
// @Test
// public void testMultiAttr() {
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration();
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
// dataSourcePropertiesConfiguration.getValidField().size());
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
//
// FileDataSourceProperties fileDataSourceProperties = buildFileProperties();
// NacosDataSourceProperties nacosDataSourceProperties = buildNacosProperties();
//
// dataSourcePropertiesConfiguration.setFile(fileDataSourceProperties);
// dataSourcePropertiesConfiguration.setNacos(nacosDataSourceProperties);
//
// assertEquals(
// "DataSourcePropertiesConfiguration valid field size was wrong after set file and nacos attribute",
// 2, dataSourcePropertiesConfiguration.getValidField().size());
// assertNull(
// "DataSourcePropertiesConfiguration valid properties was not null after set file and nacos attribute",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
// }
//
// @Test
// public void testFileConstructor() {
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration(
// buildFileProperties());
// assertEquals(
// "DataSourcePropertiesConfiguration file constructor valid field size was wrong",
// 1, dataSourcePropertiesConfiguration.getValidField().size());
// assertNotNull(
// "DataSourcePropertiesConfiguration file constructor valid properties was null",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
// }
//
// @Test
// public void testNacosConstructor() {
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration(
// buildNacosProperties());
// assertEquals(
// "DataSourcePropertiesConfiguration nacos constructor valid field size was wrong",
// 1, dataSourcePropertiesConfiguration.getValidField().size());
// assertNotNull(
// "DataSourcePropertiesConfiguration nacos constructor valid properties was null",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
// }
//
// @Test
// public void testApolloConstructor() {
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration(
// buildApolloProperties());
// assertEquals(
// "DataSourcePropertiesConfiguration apollo constructor valid field size was wrong",
// 1, dataSourcePropertiesConfiguration.getValidField().size());
// assertNotNull(
// "DataSourcePropertiesConfiguration apollo constructor valid properties was null",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
// }
//
// @Test
// public void testZKConstructor() {
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration(
// buildZKProperties());
// assertEquals(
// "DataSourcePropertiesConfiguration zk constructor valid field size was wrong",
// 1, dataSourcePropertiesConfiguration.getValidField().size());
// assertNotNull(
// "DataSourcePropertiesConfiguration zk constructor valid properties was null",
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
// }
//
// private FileDataSourceProperties buildFileProperties() {
// FileDataSourceProperties fileDataSourceProperties = new FileDataSourceProperties();
//
// fileDataSourceProperties.setFile("/tmp/test.json");
// fileDataSourceProperties.setBufSize(1024);
// fileDataSourceProperties.setRecommendRefreshMs(2000);
// return fileDataSourceProperties;
// }
//
// private NacosDataSourceProperties buildNacosProperties() {
// NacosDataSourceProperties nacosDataSourceProperties = new NacosDataSourceProperties();
// nacosDataSourceProperties.setServerAddr("127.0.0.1:8848");
// nacosDataSourceProperties.setDataId("sentinel");
// nacosDataSourceProperties.setGroupId("custom-group");
// return nacosDataSourceProperties;
// }
//
// private ApolloDataSourceProperties buildApolloProperties() {
// ApolloDataSourceProperties apolloDataSourceProperties = new ApolloDataSourceProperties();
// apolloDataSourceProperties.setFlowRulesKey("test-key");
// apolloDataSourceProperties.setDefaultFlowRuleValue("dft-val");
// apolloDataSourceProperties.setNamespaceName("namespace");
// return apolloDataSourceProperties;
// }
//
// private ZookeeperDataSourceProperties buildZKProperties() {
// ZookeeperDataSourceProperties zookeeperDataSourceProperties = new ZookeeperDataSourceProperties();
//
// zookeeperDataSourceProperties.setServerAddr("localhost:2181");
// zookeeperDataSourceProperties.setPath("/path");
// return zookeeperDataSourceProperties;
// }
//
//}

View File

@ -1,132 +0,0 @@
/*
* Copyright (C) 2018 the original author or authors.
*
* Licensed 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 com.alibaba.cloud.sentinel.endpoint;
import com.alibaba.csp.sentinel.datasource.AbstractDataSource;
import com.alibaba.csp.sentinel.heartbeat.HeartbeatSenderProvider;
import com.alibaba.csp.sentinel.transport.HeartbeatSender;
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.Status;
import com.alibaba.cloud.sentinel.SentinelProperties;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* A {@link HealthIndicator} for Sentinel, which checks the status of
* Sentinel Dashboard and DataSource.
*
* <p>
* Check the status of Sentinel Dashboard by sending a heartbeat message to it.
* If return true, it's OK.
*
* Check the status of Sentinel DataSource by calling loadConfig method of {@link AbstractDataSource}.
* If no Exception thrown, it's OK.
*
* If Dashboard and DataSource are both OK, the health status is UP.
*</p>
*
* <p>
* Note:
* If Sentinel isn't enabled, the health status is up.
* If Sentinel Dashboard isn't configured, it's OK and mark the status of Dashboard with UNKNOWN.
* More informations are provided in details.
* </p>
*
* @author cdfive
*/
public class SentinelHealthIndicator extends AbstractHealthIndicator {
private DefaultListableBeanFactory beanFactory;
private SentinelProperties sentinelProperties;
public SentinelHealthIndicator(DefaultListableBeanFactory beanFactory, SentinelProperties sentinelProperties) {
this.beanFactory = beanFactory;
this.sentinelProperties = sentinelProperties;
}
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
Map<String, Object> detailMap = new HashMap<>();
// If sentinel isn't enabled, set the status up and set the enabled to false in detail
if (!sentinelProperties.isEnabled()) {
detailMap.put("enabled", false);
builder.up().withDetails(detailMap);
return;
}
detailMap.put("enabled", true);
// Check health of Dashboard
boolean dashboardUp = true;
String consoleServer = TransportConfig.getConsoleServer();
if (StringUtils.isEmpty(consoleServer)) {
// If Dashboard isn't configured, it's OK and mark the status of Dashboard with UNKNOWN.
detailMap.put("dashboard", new Status(Status.UNKNOWN.getCode(), "dashboard isn't configured"));
} else {
// If Dashboard is configured, send a heartbeat message to it and check the result
HeartbeatSender heartbeatSender = HeartbeatSenderProvider.getHeartbeatSender();
boolean result = heartbeatSender.sendHeartbeat();
if (result) {
detailMap.put("dashboard", Status.UP);
} else {
// If failed to send heartbeat message, means that the Dashboard is DOWN
dashboardUp = false;
detailMap.put("dashboard", new Status(Status.DOWN.getCode(), consoleServer + " can't be connected"));
}
}
// Check health of DataSource
boolean dataSourceUp = true;
Map<String, Object> dataSourceDetailMap = new HashMap<>();
detailMap.put("dataSource", dataSourceDetailMap);
// Get all DataSources and each call loadConfig to check if it's OK
// If no Exception thrown, it's OK
// Note:
// Even if the dynamic config center is down, the loadConfig() might return successfully
// e.g. for Nacos client, it might retrieve from the local cache)
// But in most circumstances it's okay
Map<String, AbstractDataSource> dataSourceMap = beanFactory.getBeansOfType(AbstractDataSource.class);
for (Map.Entry<String, AbstractDataSource> dataSourceMapEntry : dataSourceMap.entrySet()) {
String dataSourceBeanName = dataSourceMapEntry.getKey();
AbstractDataSource dataSource = dataSourceMapEntry.getValue();
try {
dataSource.loadConfig();
dataSourceDetailMap.put(dataSourceBeanName, Status.UP);
} catch (Exception e) {
// If one DataSource failed to loadConfig, means that the DataSource is DOWN
dataSourceUp = false;
dataSourceDetailMap.put(dataSourceBeanName, new Status(Status.DOWN.getCode(), e.getMessage()));
}
}
// If Dashboard and DataSource are both OK, the health status is UP
if (dashboardUp && dataSourceUp) {
builder.up().withDetails(detailMap);
} else {
builder.down().withDetails(detailMap);
}
}
}

View File

@ -1,162 +0,0 @@
/*
* Copyright (C) 2018 the original author or authors.
*
* Licensed 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 com.alibaba.cloud.sentinel.endpoint;
import com.alibaba.csp.sentinel.config.SentinelConfig;
import com.alibaba.csp.sentinel.datasource.AbstractDataSource;
import com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource;
import com.alibaba.csp.sentinel.heartbeat.HeartbeatSenderProvider;
import com.alibaba.csp.sentinel.transport.HeartbeatSender;
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
import com.alibaba.cloud.sentinel.SentinelProperties;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* Test cases for {@link SentinelHealthIndicator}.
*
* @author cdfive
*/
public class SentinelHealthIndicatorTests {
private SentinelHealthIndicator sentinelHealthIndicator;
private DefaultListableBeanFactory beanFactory;
private SentinelProperties sentinelProperties;
private HeartbeatSender heartbeatSender;
@Before
public void setUp() {
beanFactory = mock(DefaultListableBeanFactory.class);
sentinelProperties = mock(SentinelProperties.class);
sentinelHealthIndicator = new SentinelHealthIndicator(beanFactory, sentinelProperties);
SentinelConfig.setConfig(TransportConfig.CONSOLE_SERVER, "");
heartbeatSender = mock(HeartbeatSender.class);
Field heartbeatSenderField = ReflectionUtils.findField(HeartbeatSenderProvider.class, "heartbeatSender");
heartbeatSenderField.setAccessible(true);
ReflectionUtils.setField(heartbeatSenderField, null, heartbeatSender);
}
@Test
public void testSentinelNotEnabled() {
when(sentinelProperties.isEnabled()).thenReturn(false);
Health health = sentinelHealthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("enabled")).isEqualTo(false);
}
@Test
public void testSentinelDashboardNotConfigured() {
when(sentinelProperties.isEnabled()).thenReturn(true);
Health health = sentinelHealthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("dashboard")).isEqualTo(Status.UNKNOWN);
}
@Test
public void testSentinelDashboardConfiguredSuccess() throws Exception {
when(sentinelProperties.isEnabled()).thenReturn(true);
SentinelConfig.setConfig(TransportConfig.CONSOLE_SERVER, "localhost:8080");
when(heartbeatSender.sendHeartbeat()).thenReturn(true);
Health health = sentinelHealthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
}
@Test
public void testSentinelDashboardConfiguredFailed() throws Exception {
when(sentinelProperties.isEnabled()).thenReturn(true);
SentinelConfig.setConfig(TransportConfig.CONSOLE_SERVER, "localhost:8080");
when(heartbeatSender.sendHeartbeat()).thenReturn(false);
Health health = sentinelHealthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("dashboard")).isEqualTo(new Status(Status.DOWN.getCode(), "localhost:8080 can't be connected"));
}
@Test
public void testSentinelDataSourceSuccess() throws Exception {
when(sentinelProperties.isEnabled()).thenReturn(true);
SentinelConfig.setConfig(TransportConfig.CONSOLE_SERVER, "localhost:8080");
when(heartbeatSender.sendHeartbeat()).thenReturn(true);
Map<String, AbstractDataSource> dataSourceMap = new HashMap<>();
FileRefreshableDataSource fileDataSource1 = mock(FileRefreshableDataSource.class);
dataSourceMap.put("ds1-sentinel-file-datasource", fileDataSource1);
FileRefreshableDataSource fileDataSource2 = mock(FileRefreshableDataSource.class);
dataSourceMap.put("ds2-sentinel-file-datasource", fileDataSource2);
when(beanFactory.getBeansOfType(AbstractDataSource.class)).thenReturn(dataSourceMap);
Health health = sentinelHealthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
Map<String, Status> dataSourceDetailMap = (Map<String, Status>) health.getDetails().get("dataSource");
assertThat(dataSourceDetailMap.get("ds1-sentinel-file-datasource")).isEqualTo(Status.UP);
assertThat(dataSourceDetailMap.get("ds2-sentinel-file-datasource")).isEqualTo(Status.UP);
}
@Test
public void testSentinelDataSourceFailed() throws Exception {
when(sentinelProperties.isEnabled()).thenReturn(true);
SentinelConfig.setConfig(TransportConfig.CONSOLE_SERVER, "localhost:8080");
when(heartbeatSender.sendHeartbeat()).thenReturn(true);
Map<String, AbstractDataSource> dataSourceMap = new HashMap<>();
FileRefreshableDataSource fileDataSource1 = mock(FileRefreshableDataSource.class);
dataSourceMap.put("ds1-sentinel-file-datasource", fileDataSource1);
FileRefreshableDataSource fileDataSource2 = mock(FileRefreshableDataSource.class);
when(fileDataSource2.loadConfig()).thenThrow(new RuntimeException("fileDataSource2 error"));
dataSourceMap.put("ds2-sentinel-file-datasource", fileDataSource2);
when(beanFactory.getBeansOfType(AbstractDataSource.class)).thenReturn(dataSourceMap);
Health health = sentinelHealthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
Map<String, Status> dataSourceDetailMap = (Map<String, Status>) health.getDetails().get("dataSource");
assertThat(dataSourceDetailMap.get("ds1-sentinel-file-datasource")).isEqualTo(Status.UP);
assertThat(dataSourceDetailMap.get("ds2-sentinel-file-datasource")).isEqualTo(new Status(Status.DOWN.getCode(), "fileDataSource2 error"));
}
}

View File

@ -1,24 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba</artifactId>
<version>0.9.1.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>alibaba-spring-cloud-starter</artifactId>
<packaging>pom</packaging>
<name>Alibaba Spring Cloud Starters</name>
<description>Alibaba Spring Cloud Starters</description>
<modules>
<module>alibaba-nacos-config-spring-cloud-starter</module>
<module>alibaba-nacos-config-server-spring-cloud-starter</module>
<module>alibaba-nacos-discovery-spring-cloud-starter</module>
<module>alibaba-sentinel-spring-cloud-starter</module>
<module>alibaba-seata-spring-cloud-starter</module>
<module>rocketmq-spring-cloud-starter-stream</module>
<module>rocketmq-spring-cloud-starter-bus</module>
<module>dubbo-spring-cloud-starter</module>
</modules>
</project>

41
pom.xml
View File

@ -44,11 +44,8 @@
<email>flystar32@163.com</email>
</developer>
<developer>
<id>fangjian0423</id>
<name>fangjian</name>
<email>fangjian0423@gmail.com</email>
<organization>Alibaba</organization>
<url>https://github.com/fangjian0423</url>
</developer>
<developer>
<name>xiaolongzuo</name>
@ -93,26 +90,26 @@
</properties>
<modules>
<module>alibaba-spring-cloud-dependencies</module>
<module>alibaba-sentinel-spring-cloud</module>
<module>alibaba-sentinel-datasource-spring-cloud</module>
<module>alibaba-sentinel-gateway-spring-cloud</module>
<module>alibaba-nacos-config-spring-cloud</module>
<module>alibaba-nacos-discovery-spring-cloud</module>
<module>alibaba-seata-spring-cloud</module>
<module>rocketmq-spring-cloud-stream-binder</module>
<module>alibaba-nacos-config-server-spring-cloud</module>
<module>alibaba-dubbo-spring-cloud</module>
<module>alicloud-context-spring-cloud</module>
<module>spring-cloud-alibaba-dependencies</module>
<module>spring-cloud-alibaba-sentinel</module>
<module>spring-cloud-alibaba-sentinel-datasource</module>
<module>spring-cloud-alibaba-sentinel-gateway</module>
<module>spring-cloud-alibaba-nacos-config</module>
<module>spring-cloud-alibaba-nacos-discovery</module>
<module>spring-cloud-alibaba-seata</module>
<module>spring-cloud-stream-binder-rocketmq</module>
<module>spring-cloud-alibaba-nacos-config-server</module>
<module>spring-cloud-alibaba-dubbo</module>
<module>spring-cloud-alicloud-context</module>
<module>spring-cloud-alibaba-examples</module>
<module>spring-cloud-alibaba-docs</module>
<module>alibaba-spring-cloud-starter</module>
<module>alicloud-spring-cloud-starter</module>
<module>alicloud-oss-spring-cloud</module>
<module>alicloud-acm-spring-cloud</module>
<module>alicloud-ans-spring-cloud</module>
<module>alicloud-schedulerx-spring-cloud</module>
<module>alicloud-sms-spring-cloud</module>
<module>spring-cloud-starter-alibaba</module>
<module>spring-cloud-starter-alicloud</module>
<module>spring-cloud-alicloud-oss</module>
<module>spring-cloud-alicloud-acm</module>
<module>spring-cloud-alicloud-ans</module>
<module>spring-cloud-alicloud-schedulerx</module>
<module>spring-cloud-alicloud-sms</module>
<module>spring-cloud-alibaba-coverage</module>
</modules>
@ -130,7 +127,7 @@
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-spring-cloud-dependencies</artifactId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>

View File

@ -18,52 +18,52 @@
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-dubbo-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-dubbo</artifactId>
<version>${spring.cloud.alibaba.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-nacos-config-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-nacos-config</artifactId>
<version>${spring.cloud.alibaba.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-nacos-discovery-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
<version>${spring.cloud.alibaba.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-sentinel-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-sentinel</artifactId>
<version>${spring.cloud.alibaba.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-sentinel-datasource-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-sentinel-datasource</artifactId>
<version>${spring.cloud.alibaba.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-acm-spring-cloud</artifactId>
<artifactId>spring-cloud-alicloud-acm</artifactId>
<version>${spring.cloud.alibaba.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-ans-spring-cloud</artifactId>
<artifactId>spring-cloud-alicloud-ans</artifactId>
<version>${spring.cloud.alibaba.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-context-spring-cloud</artifactId>
<artifactId>spring-cloud-alicloud-context</artifactId>
<version>${spring.cloud.alibaba.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>rocketmq-spring-cloud-stream-binder</artifactId>
<artifactId>spring-cloud-stream-binder-rocketmq</artifactId>
<version>${spring.cloud.alibaba.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-seata-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
<version>${spring.cloud.alibaba.version}</version>
</dependency>
</dependencies>

View File

@ -11,16 +11,16 @@
</parent>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-spring-cloud-dependencies</artifactId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>0.9.1.BUILD-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Alibaba Spring Cloud Dependencies</name>
<description>BOM for Spring Cloud Alibaba Dependencies</description>
<name>Spring Cloud Alibaba Dependencies</name>
<description>Spring Cloud Alibaba Dependencies</description>
<properties>
<sentinel.version>1.6.2</sentinel.version>
<oss.version>3.1.0</oss.version>
<seata.version>0.5.2</seata.version>
<seata.version>0.7.1</seata.version>
<nacos.client.version>1.1.1</nacos.client.version>
<nacos.config.version>0.8.0</nacos.config.version>
<acm.version>1.0.9</acm.version>
@ -210,7 +210,7 @@
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring</artifactId>
<artifactId>seata-all</artifactId>
<version>${seata.version}</version>
</dependency>
@ -259,156 +259,156 @@
<!-- Own dependencies -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-sentinel-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-sentinel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-sentinel-datasource-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-sentinel-datasource</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-sentinel-gateway-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-oss-spring-cloud</artifactId>
<artifactId>spring-cloud-alicloud-oss</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-nacos-discovery-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-nacos-config-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-nacos-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-nacos-config-server-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-nacos-config-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-seata-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-acm-spring-cloud</artifactId>
<artifactId>spring-cloud-alicloud-acm</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-ans-spring-cloud</artifactId>
<artifactId>spring-cloud-alicloud-ans</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-schedulerx-spring-cloud</artifactId>
<artifactId>spring-cloud-alicloud-schedulerx</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-sms-spring-cloud</artifactId>
<artifactId>spring-cloud-alicloud-sms</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-context-spring-cloud</artifactId>
<artifactId>spring-cloud-alicloud-context</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>rocketmq-spring-cloud-stream-binder</artifactId>
<artifactId>spring-cloud-stream-binder-rocketmq</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-dubbo-spring-cloud</artifactId>
<artifactId>spring-cloud-alibaba-dubbo</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Own dependencies - Starters -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-sentinel-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-oss-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-alicloud-oss</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-seata-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-nacos-discovery-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-nacos-config-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-nacos-config-server-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-alibaba-nacos-config-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-ans-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-alicloud-ans</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-acm-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-alicloud-acm</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-schedulerx-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-alicloud-schedulerx</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>rocketmq-spring-cloud-starter-stream</artifactId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>rocketmq-spring-cloud-starter-bus</artifactId>
<artifactId>spring-cloud-starter-bus-rocketmq</artifactId>
<version>${project.version}</version>
</dependency>
<!-- SMS -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alicloud-sms-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-alicloud-sms</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Dubbo -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>dubbo-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-dubbo</artifactId>
<version>${project.version}</version>
</dependency>

View File

@ -9,7 +9,6 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-docs</artifactId>
<name>Spring Cloud Alibaba Documentation</name>
<packaging>pom</packaging>

View File

@ -6,12 +6,12 @@ Spring Cloud AliCloud ACM 是 Config Server 和 Client 的替代方案,客户
=== 如何引入 Spring Cloud AliCloud ACM
如果要在您的项目中引入 ACM使用 group ID 为 `org.springframework.cloud` 和 artifact ID 为 `spring-cloud-starter-alicloud-acm` 的 starter。
如果要在您的项目中引入 ACM使用 group ID 为 `com.alibaba.cloud` 和 artifact ID 为 `spring-cloud-starter-alicloud-acm` 的 starter。
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alicloud-acm</artifactId>
</dependency>
----

View File

@ -4,12 +4,12 @@ ANSApplication Naming Service 是隶属于阿里云 EDAS 产品的组件
=== 如何引入 Spring Cloud AliCloud ANS
如果要在您的项目中引入 ANS使用 group ID 为 `org.springframework.cloud` 和 artifact ID 为 `spring-cloud-starter-alicloud-ans` 的 starter。
如果要在您的项目中引入 ANS使用 group ID 为 `com.alibaba.cloud` 和 artifact ID 为 `spring-cloud-starter-alicloud-ans` 的 starter。
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alicloud-ans</artifactId>
</dependency>
----

View File

@ -28,12 +28,12 @@ NOTE: 注意dataid是以 properties(默认的文件扩展名方式)为扩展名
===== 客户端使用方式
如果要在您的项目中使用 Nacos 来实现应用的外部化配置,使用 group ID 为 `org.springframework.cloud` 和 artifact ID 为 `spring-cloud-starter-alibaba-nacos-config` 的 starter。
如果要在您的项目中使用 Nacos 来实现应用的外部化配置,使用 group ID 为 `com.alibaba.cloud` 和 artifact ID 为 `spring-cloud-starter-alibaba-nacos-config` 的 starter。
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
----

View File

@ -11,12 +11,12 @@ Discovery Starter 也将服务实例自身的一些元数据信息-例如 host
==== 如何引入 Nacos Discovery Starter
如果要在您的项目中使用 Nacos 来实现服务发现,使用 group ID 为 `org.springframework.cloud` 和 artifact ID 为 `spring-cloud-starter-alibaba-nacos-discovery` 的 starter。
如果要在您的项目中使用 Nacos 来实现服务发现,使用 group ID 为 `com.alibaba.cloud` 和 artifact ID 为 `spring-cloud-starter-alibaba-nacos-discovery` 的 starter。
[source,xml,indent=0]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
----
@ -82,7 +82,7 @@ Discovery Starter 也将服务实例自身的一些元数据信息-例如 host
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependencies>

View File

@ -9,7 +9,7 @@ OSSObject Storage Service是阿里云的一款对象存储服务产品
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alicloud-oss</artifactId>
</dependency>
----

View File

@ -121,7 +121,7 @@ messageChannel.send(MessageBuilder.withPayload("simple msg").build());
```xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rocketmq</artifactId>
</dependency>
```
@ -130,7 +130,7 @@ messageChannel.send(MessageBuilder.withPayload("simple msg").build());
```xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
</dependency>
```

View File

@ -4,12 +4,12 @@ SchedulerX分布式任务调度 是隶属于阿里云EDAS产品的组件
=== 如何引入 Spring Cloud AliCloud SchedulerX
如果要在您的项目中引入 SchedulerX使用 group ID 为 `org.springframework.cloud` 和 artifact ID 为 `spring-cloud-starter-alicloud-schedulerX` 的 starter。
如果要在您的项目中引入 SchedulerX使用 group ID 为 `com.alibaba.cloud` 和 artifact ID 为 `spring-cloud-starter-alicloud-schedulerX` 的 starter。
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alicloud-schedulerX</artifactId>
</dependency>
----
@ -75,7 +75,7 @@ public class SimpleTask implements ScxSimpleJobProcessor {
[source,text]
----
Job分组测试——***-*-*-****
Job处理接口com.alibaba.cloud.examples.SimpleTask
Job处理接口SimpleTask
类型简单Job单机版
定时表达式默认选项——0 * * * * ?
Job描述

View File

@ -18,7 +18,7 @@ https://github.com/alibaba/Sentinel[Sentinel] 具有以下特征:
```xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
```
@ -193,7 +193,7 @@ spring.cloud.sentinel.datasource.ds1.file.rule-type=flow
#spring.cloud.sentinel.datasource.ds1.file.file=classpath: flowrule.json
#spring.cloud.sentinel.datasource.ds1.file.data-type=custom
#spring.cloud.sentinel.datasource.ds1.file.converter-class=com.alibaba.cloud.examples.JsonFlowRuleListConverter
#spring.cloud.sentinel.datasource.ds1.file.converter-class=JsonFlowRuleListConverter
#spring.cloud.sentinel.datasource.ds1.file.rule-type=flow
spring.cloud.sentinel.datasource.ds2.nacos.server-addr=localhost:8848
@ -219,7 +219,7 @@ NOTE: d1, ds2, ds3, ds4 是 `ReadableDataSource` 的名字,可随意编写。
每种数据源都有两个共同的配置项: `data-type`、 `converter-class` 以及 `rule-type`。
`data-type` 配置项表示 `Converter` 类型Spring Cloud Alibaba Sentinel 默认提供两种内置的值,分别是 `json` 和 `xml` (不填默认是json)。 如果不想使用内置的 `json` 或 `xml` 这两种 `Converter`,可以填写 `custom` 表示自定义 `Converter`,然后再配置 `converter-class` 配置项,该配置项需要写类的全路径名(比如 `spring.cloud.sentinel.datasource.ds1.file.converter-class=com.alibaba.cloud.examples.JsonFlowRuleListConverter`)。
`data-type` 配置项表示 `Converter` 类型Spring Cloud Alibaba Sentinel 默认提供两种内置的值,分别是 `json` 和 `xml` (不填默认是json)。 如果不想使用内置的 `json` 或 `xml` 这两种 `Converter`,可以填写 `custom` 表示自定义 `Converter`,然后再配置 `converter-class` 配置项,该配置项需要写类的全路径名(比如 `spring.cloud.sentinel.datasource.ds1.file.converter-class=JsonFlowRuleListConverter`)。
`rule-type` 配置表示该数据源中的规则属于哪种类型的规则(`flow``degrade``authority``system`, `param-flow`)。

View File

@ -4,12 +4,12 @@
=== 如何引入 Spring Cloud AliCloud SMS
如果要在您的项目中引入 SMS使用 group ID 为 `org.springframework.cloud` 和 artifact ID 为 `spring-cloud-starter-alicloud-sms` 的 starter。
如果要在您的项目中引入 SMS使用 group ID 为 `com.alibaba.cloud` 和 artifact ID 为 `spring-cloud-starter-alicloud-sms` 的 starter。
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alicloud-sms</artifactId>
</dependency>
----
@ -181,7 +181,7 @@ spring.cloud.alicloud.sms.report-queue-name=Alicom-Queue-********-SmsReport
*/
@Component
public class SmsReportMessageListener
implements org.springframework.cloud.alicloud.sms.SmsReportMessageListener {
implements SmsReportMessageListener {
@Override
public boolean dealMessage(Message message) {
@ -217,7 +217,7 @@ spring.cloud.alicloud.sms.up-queue-name=Alicom-Queue-********-SmsUp
*/
@Component
public class SmsUpMessageListener
implements org.springframework.cloud.alicloud.sms.SmsUpMessageListener {
implements SmsUpMessageListener {
@Override
public boolean dealMessage(Message message) {

View File

@ -6,12 +6,12 @@ Spring Cloud Alibaba Cloud ACM is an alternative solution for Config Server and
=== How to Introduce Spring Cloud Alibaba Cloud ACM
If you want to use ACM in your project, please use the starter with the group ID as `org.springframework.cloud` and the artifact ID as `spring-cloud-starter-alicloud-acm`.
If you want to use ACM in your project, please use the starter with the group ID as `com.alibaba.cloud` and the artifact ID as `spring-cloud-starter-alicloud-acm`.
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alicloud-acm</artifactId>
</dependency>
----

View File

@ -4,12 +4,12 @@ ANS(Application Naming Service) is a component of EDAS. Spring Cloud Alibaba Cl
=== How to Introduce Spring Cloud Alibaba Cloud ANS
If you want to use ANS in your project, please use the starter with the group ID as `org.springframework.cloud` and the artifact ID as `spring-cloud-starter-alicloud-ans`.
If you want to use ANS in your project, please use the starter with the group ID as `com.alibaba.cloud` and the artifact ID as `spring-cloud-starter-alicloud-ans`.
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alicloud-ans</artifactId>
</dependency>
----

View File

@ -28,12 +28,12 @@ NOTE: The default file extension of dataid is properties.
===== Usage on the Client
If you want to use Nacos to manage externalized configurations for your applications, please use the starter with the group ID as `org.springframework.cloud` and the artifact ID as `spring-cloud-starter-alibaba-nacos-config`.
If you want to use Nacos to manage externalized configurations for your applications, please use the starter with the group ID as `com.alibaba.cloud` and the artifact ID as `spring-cloud-starter-alibaba-nacos-config`.
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
----

View File

@ -11,12 +11,12 @@ Discovery Starter registers some of the metadata of the service instance, such a
==== How to Introduce Nacos Discovery Starter
please use the starter with the group ID as `org.springframework.cloud` and the artifact ID as `spring-cloud-starter-alibaba-nacos-discovery`.
please use the starter with the group ID as `com.alibaba.cloud` and the artifact ID as `spring-cloud-starter-alibaba-nacos-discovery`.
[source,xml,indent=0]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
----
@ -82,7 +82,7 @@ The following sample illustrates how to register a service to Nacos.
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependencies>

View File

@ -26,7 +26,7 @@ Next we need to introduce Spring Cloud Alibaba Cloud OSS Starter.
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alicloud-oss</artifactId>
</dependency>
----

View File

@ -120,7 +120,7 @@ For using the Spring Cloud Alibaba RocketMQ Binder, you just need to add it to y
```xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rocketmq</artifactId>
</dependency>
```
@ -129,7 +129,7 @@ Alternatively, you can also use the Spring Cloud Stream RocketMQ Starter:
```xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
</dependency>
```

View File

@ -4,12 +4,12 @@ SchedulerXDistributed job scheduling is a component of EDAS, an Alibaba Cl
=== How to Introduce Spring Cloud Alibaba Cloud SchedulerX
If you want to use SchedulerX in your project, please use the starter with the group ID as `org.springframework.cloud` and the artifact ID as `spring-cloud-starter-alicloud-schedulerX`.
If you want to use SchedulerX in your project, please use the starter with the group ID as `com.alibaba.cloud` and the artifact ID as `spring-cloud-starter-alicloud-schedulerX`.
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alicloud-schedulerX</artifactId>
</dependency>
----
@ -75,7 +75,7 @@ Go to the https://edas.console.aliyun.com/#/edasSchedulerXJob?regionNo=cn-test[S
[source,text]
----
Job Group Test——***-*-*-****
Job process interfacecom.alibaba.cloud.examples.SimpleTask
Job process interfaceSimpleTask
Type Simple Single-Server Job
Quartz Cron Expression Default Option——0 * * * * ?
Job Description Empty

View File

@ -14,7 +14,7 @@ https://github.com/alibaba/Sentinel[Sentinel] has the following features:
### How to Use Sentinel
If you want to use Sentinel in your project, please use the starter with the group ID as `org.springframework.cloud` and the artifact ID as `spring-cloud-starter-alibaba-sentinel`.
If you want to use Sentinel in your project, please use the starter with the group ID as `com.alibaba.cloud` and the artifact ID as `spring-cloud-starter-alibaba-sentinel`.
```xml
<dependency>
@ -195,7 +195,7 @@ spring.cloud.sentinel.datasource.ds1.file.rule-type=flow
#spring.cloud.sentinel.datasource.ds1.file.file=classpath: flowrule.json
#spring.cloud.sentinel.datasource.ds1.file.data-type=custom
#spring.cloud.sentinel.datasource.ds1.file.converter-class=com.alibaba.cloud.examples.JsonFlowRuleListConverter
#spring.cloud.sentinel.datasource.ds1.file.converter-class=JsonFlowRuleListConverter
#spring.cloud.sentinel.datasource.ds1.file.rule-type=flow
spring.cloud.sentinel.datasource.ds2.nacos.server-addr=localhost:8848

View File

@ -6,12 +6,12 @@ Spring Cloud AliCloud SMS provide an easier-to-use API for quick access to Aliba
=== 如何引入 Spring Cloud AliCloud SMS
If you want to use SMS in your project, please use the starter with the group ID as `org.springframework.cloud` and the artifact ID as `spring-cloud-starter-alicloud-sms`.
If you want to use SMS in your project, please use the starter with the group ID as `com.alibaba.cloud` and the artifact ID as `spring-cloud-starter-alicloud-sms`.
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alicloud-sms</artifactId>
</dependency>
----
@ -165,7 +165,7 @@ spring.cloud.alicloud.sms.report-queue-name=Alicom-Queue-********-SmsReport
----
@Component
public class SmsReportMessageListener
implements org.springframework.cloud.alicloud.sms.SmsReportMessageListener {
implements SmsReportMessageListener {
@Override
public boolean dealMessage(Message message) {
@ -195,7 +195,7 @@ spring.cloud.alicloud.sms.up-queue-name=Alicom-Queue-********-SmsUp
----
@Component
public class SmsUpMessageListener
implements org.springframework.cloud.alicloud.sms.SmsUpMessageListener {
implements SmsUpMessageListener {
@Override
public boolean dealMessage(Message message) {

View File

@ -10,8 +10,8 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>alibaba-dubbo-spring-cloud</artifactId>
<name>Alibaba Dubbo Spring Cloud</name>
<artifactId>spring-cloud-alibaba-dubbo</artifactId>
<name>Spring Cloud Alibaba Dubbo</name>
<properties>
<dubbo.version>2.7.1</dubbo.version>
@ -143,7 +143,7 @@
<!-- Nacos Service Discovery -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>alibaba-nacos-discovery-spring-cloud-starter</artifactId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<optional>true</optional>
</dependency>

View File

@ -26,8 +26,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import com.alibaba.cloud.dubbo.annotation.DubboTransported;
import com.alibaba.cloud.dubbo.loadbalancer.DubboMetadataInitializerInterceptor;
import com.alibaba.cloud.dubbo.loadbalancer.DubboTransporterInterceptor;
import com.alibaba.cloud.dubbo.client.loadbalancer.DubboMetadataInitializerInterceptor;
import com.alibaba.cloud.dubbo.client.loadbalancer.DubboTransporterInterceptor;
import com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository;
import com.alibaba.cloud.dubbo.metadata.resolver.DubboTransportedAttributesResolver;
import com.alibaba.cloud.dubbo.service.DubboGenericServiceExecutionContextFactory;

View File

@ -16,18 +16,21 @@
*/
package com.alibaba.cloud.dubbo.autoconfigure;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository;
import com.alibaba.cloud.dubbo.openfeign.TargeterBeanPostProcessor;
import com.alibaba.cloud.dubbo.service.DubboGenericServiceExecutionContextFactory;
import com.alibaba.cloud.dubbo.service.DubboGenericServiceFactory;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import static com.alibaba.cloud.dubbo.autoconfigure.DubboOpenFeignAutoConfiguration.TARGETER_CLASS_NAME;
/**
* Dubbo Feign Auto-{@link Configuration Configuration}
*

View File

@ -16,16 +16,18 @@
*/
package com.alibaba.cloud.dubbo.autoconfigure;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import com.alibaba.cloud.dubbo.env.DubboCloudProperties;
import com.alibaba.cloud.dubbo.service.DubboGenericServiceExecutionContextFactory;
import com.alibaba.cloud.dubbo.service.DubboGenericServiceFactory;
import com.alibaba.cloud.dubbo.service.parameter.PathVariableServiceParameterResolver;
import com.alibaba.cloud.dubbo.service.parameter.RequestBodyServiceParameterResolver;
import com.alibaba.cloud.dubbo.service.parameter.RequestHeaderServiceParameterResolver;
import com.alibaba.cloud.dubbo.service.parameter.RequestParamServiceParameterResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import com.alibaba.cloud.dubbo.env.DubboCloudProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

View File

@ -27,8 +27,8 @@ import org.springframework.util.StringUtils;
import java.util.Map;
import static com.alibaba.cloud.dubbo.registry.SpringCloudRegistryFactory.PROTOCOL;
import static org.apache.dubbo.config.spring.util.PropertySourcesUtils.getSubProperties;
import static com.alibaba.cloud.dubbo.registry.SpringCloudRegistryFactory.PROTOCOL;
/**
* Missing {@link SpringCloudRegistry} Property {@link Condition}

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.loadbalancer;
package com.alibaba.cloud.dubbo.client.loadbalancer;
import org.apache.dubbo.rpc.service.GenericException;
import org.springframework.http.HttpHeaders;

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.loadbalancer;
package com.alibaba.cloud.dubbo.client.loadbalancer;
import org.apache.dubbo.rpc.service.GenericException;
import com.alibaba.cloud.dubbo.http.converter.HttpMessageConverterHolder;

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.loadbalancer;
package com.alibaba.cloud.dubbo.client.loadbalancer;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpOutputMessage;

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.loadbalancer;
package com.alibaba.cloud.dubbo.client.loadbalancer;
import com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository;
import org.springframework.http.HttpRequest;

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.dubbo.loadbalancer;
package com.alibaba.cloud.dubbo.client.loadbalancer;
import org.apache.dubbo.rpc.service.GenericException;
import org.apache.dubbo.rpc.service.GenericService;

View File

@ -0,0 +1,76 @@
/*
* 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 com.alibaba.cloud.dubbo.http.matcher;
import java.util.Collection;
import java.util.Iterator;
/**
* Abstract {@link HttpRequestMatcher} implementation
*
* @author Rossen Stoyanchev
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
public abstract class AbstractHttpRequestMatcher implements HttpRequestMatcher {
/**
* Return the discrete items a request condition is composed of.
* <p>
* For example URL patterns, HTTP request methods, param expressions, etc.
*
* @return a collection of objects, never {@code null}
*/
protected abstract Collection<?> getContent();
/**
* The notation to use when printing discrete items of content.
* <p>
* For example {@code " || "} for URL patterns or {@code " && "} for param
* expressions.
*/
protected abstract String getToStringInfix();
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (other == null || getClass() != other.getClass()) {
return false;
}
return getContent().equals(((AbstractHttpRequestMatcher) other).getContent());
}
@Override
public int hashCode() {
return getContent().hashCode();
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder("[");
for (Iterator<?> iterator = getContent().iterator(); iterator.hasNext();) {
Object expression = iterator.next();
builder.append(expression.toString());
if (iterator.hasNext()) {
builder.append(getToStringInfix());
}
}
builder.append("]");
return builder.toString();
}
}

View File

@ -18,7 +18,6 @@ package com.alibaba.cloud.dubbo.http.matcher;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
import org.springframework.util.CollectionUtils;
import java.util.Collection;
import java.util.LinkedHashSet;

View File

@ -54,8 +54,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import static com.alibaba.cloud.dubbo.env.DubboCloudProperties.ALL_DUBBO_SERVICES;
import static com.alibaba.cloud.dubbo.http.DefaultHttpRequest.builder;
import static java.lang.String.format;
import static java.lang.String.valueOf;
import static java.util.Collections.emptyList;
@ -65,6 +63,8 @@ import static java.util.Collections.unmodifiableMap;
import static java.util.Collections.unmodifiableSet;
import static org.apache.dubbo.common.Constants.APPLICATION_KEY;
import static org.apache.dubbo.common.Constants.VERSION_KEY;
import static com.alibaba.cloud.dubbo.env.DubboCloudProperties.ALL_DUBBO_SERVICES;
import static com.alibaba.cloud.dubbo.http.DefaultHttpRequest.builder;
import static org.springframework.util.CollectionUtils.isEmpty;
import static org.springframework.util.StringUtils.hasText;

View File

@ -171,7 +171,7 @@ public class DubboServiceBeanMetadataResolver implements BeanClassLoaderAware, S
String configKey = methodMetadata.configKey();
Method feignContractMethod = getMatchedFeignContractMethod(targetType, feignContractMethods, configKey);
RestMethodMetadata metadata = new RestMethodMetadata(methodMetadata);
metadata.setMethod(new com.alibaba.cloud.dubbo.metadata.MethodMetadata (feignContractMethod));
metadata.setMethod(new com.alibaba.cloud.dubbo.metadata.MethodMetadata(feignContractMethod));
return metadata;
}

View File

@ -16,16 +16,18 @@
*/
package com.alibaba.cloud.dubbo.openfeign;
import com.alibaba.cloud.dubbo.service.DubboGenericServiceExecutionContextFactory;
import com.alibaba.cloud.dubbo.service.DubboGenericServiceFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.config.BeanPostProcessor;
import com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository;
import com.alibaba.cloud.dubbo.service.DubboGenericServiceExecutionContextFactory;
import com.alibaba.cloud.dubbo.service.DubboGenericServiceFactory;
import org.springframework.core.env.Environment;
import static com.alibaba.cloud.dubbo.autoconfigure.DubboOpenFeignAutoConfiguration.TARGETER_CLASS_NAME;
import static java.lang.reflect.Proxy.newProxyInstance;
import static com.alibaba.cloud.dubbo.autoconfigure.DubboOpenFeignAutoConfiguration.TARGETER_CLASS_NAME;
import static org.springframework.util.ClassUtils.getUserClass;
import static org.springframework.util.ClassUtils.isPresent;
import static org.springframework.util.ClassUtils.resolveClassName;

Some files were not shown because too many files have changed in this diff Show More