Merge remote-tracking branch 'upstream/master'

pull/562/head
mercyblitz 6 years ago
commit 7af5e12003

@ -62,7 +62,7 @@
<organization>Alibaba</organization>
<url>https://github.com/mercyblitz</url>
</developer>
<developer>
<developer>
<name>yunzheng</name>
<email>yunzheng1228@gmail.com</email>
</developer>
@ -96,7 +96,7 @@
<module>spring-cloud-alibaba-sentinel-zuul</module>
<module>spring-cloud-alibaba-nacos-config</module>
<module>spring-cloud-alibaba-nacos-discovery</module>
<module>spring-cloud-alibaba-fescar</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>

@ -63,7 +63,7 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alibaba-fescar</artifactId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
<version>${spring.cloud.alibaba.version}</version>
</dependency>
</dependencies>

@ -17,10 +17,10 @@
<description>Spring Cloud Alibaba Dependencies</description>
<properties>
<sentinel.version>1.4.2</sentinel.version>
<sentinel.version>1.5.1</sentinel.version>
<oss.version>3.1.0</oss.version>
<fescar.version>0.4.0</fescar.version>
<nacos.client.version>1.0.0-RC3</nacos.client.version>
<fescar.version>0.4.2</fescar.version>
<nacos.client.version>1.0.0</nacos.client.version>
<nacos.config.version>0.8.0</nacos.config.version>
<acm.version>1.0.8</acm.version>
<ans.version>1.0.1</ans.version>
@ -272,7 +272,7 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alibaba-fescar</artifactId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@ -325,7 +325,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-fescar</artifactId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
<version>${project.version}</version>
</dependency>

@ -1,35 +0,0 @@
registry {
# file 、nacos 、redis
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
file {
name = "file.conf"
}
}
config {
# file nacos apollo
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
apollo {
app.id = "fescar-server"
apollo.meta = "http://192.168.1.204:8801"
}
file {
name = "file.conf"
}
}

@ -1,35 +0,0 @@
registry {
# file 、nacos 、redis
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
file {
name = "file.conf"
}
}
config {
# file nacos apollo
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
apollo {
app.id = "fescar-server"
apollo.meta = "http://192.168.1.204:8801"
}
file {
name = "file.conf"
}
}

@ -1,35 +0,0 @@
registry {
# file 、nacos 、redis
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
file {
name = "file.conf"
}
}
config {
# file nacos apollo
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
apollo {
app.id = "fescar-server"
apollo.meta = "http://192.168.1.204:8801"
}
file {
name = "file.conf"
}
}

@ -1,35 +0,0 @@
registry {
# file 、nacos 、redis
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
file {
name = "file.conf"
}
}
config {
# file nacos apollo
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
apollo {
app.id = "fescar-server"
apollo.meta = "http://192.168.1.204:8801"
}
file {
name = "file.conf"
}
}

@ -28,10 +28,10 @@
<module>ans-example/ans-consumer-feign-example</module>
<module>ans-example/ans-consumer-ribbon-example</module>
<module>ans-example/ans-provider-example</module>
<module>fescar-example/business-service</module>
<module>fescar-example/order-service</module>
<module>fescar-example/storage-service</module>
<module>fescar-example/account-service</module>
<module>seata-example/business-service</module>
<module>seata-example/order-service</module>
<module>seata-example/storage-service</module>
<module>seata-example/account-service</module>
<module>acm-example/acm-local-example</module>
<module>rocketmq-example/rocketmq-consume-example</module>
<module>rocketmq-example/rocketmq-produce-example</module>

@ -14,7 +14,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-fescar</artifactId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

@ -20,17 +20,26 @@ transport {
worker-thread-size = 8
}
}
store {
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
max-branch-session-size = 16384
# globe session size , if exceeded throws exceptions
max-global-session-size = 512
# file buffer size , if exceeded allocate new buffer
file-write-buffer-cache-size = 16384
# when recover batch read size
session.reload.read_size = 100
}
service {
#vgroup->rgroup
vgroup_mapping.account-service-fescar-service-group = "localRgroup"
vgroup_mapping.account-service-fescar-service-group = "default"
#only support single node
localRgroup.grouplist = "127.0.0.1:8091"
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
}
client {
async.commit.buffer.limit = 10000
lock {

@ -0,0 +1,55 @@
registry {
# file 、nacos 、eureka、redis、zk、consul
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:1001/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
apollo {
app.id = "fescar-server"
apollo.meta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
file {
name = "file.conf"
}
}

@ -14,7 +14,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-fescar</artifactId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>

@ -20,17 +20,26 @@ transport {
worker-thread-size = 8
}
}
store {
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
max-branch-session-size = 16384
# globe session size , if exceeded throws exceptions
max-global-session-size = 512
# file buffer size , if exceeded allocate new buffer
file-write-buffer-cache-size = 16384
# when recover batch read size
session.reload.read_size = 100
}
service {
#vgroup->rgroup
vgroup_mapping.storage-service-fescar-service-group = "localRgroup"
vgroup_mapping.business-service-fescar-service-group = "default"
#only support single node
localRgroup.grouplist = "127.0.0.1:8091"
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
}
client {
async.commit.buffer.limit = 10000
lock {

@ -0,0 +1,55 @@
registry {
# file 、nacos 、eureka、redis、zk、consul
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:1001/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
apollo {
app.id = "fescar-server"
apollo.meta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
file {
name = "file.conf"
}
}

@ -14,7 +14,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-fescar</artifactId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

@ -20,17 +20,26 @@ transport {
worker-thread-size = 8
}
}
store {
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
max-branch-session-size = 16384
# globe session size , if exceeded throws exceptions
max-global-session-size = 512
# file buffer size , if exceeded allocate new buffer
file-write-buffer-cache-size = 16384
# when recover batch read size
session.reload.read_size = 100
}
service {
#vgroup->rgroup
vgroup_mapping.business-service-fescar-service-group = "localRgroup"
vgroup_mapping.order-service-fescar-service-group = "default"
#only support single node
localRgroup.grouplist = "127.0.0.1:8091"
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
}
client {
async.commit.buffer.limit = 10000
lock {

@ -0,0 +1,55 @@
registry {
# file 、nacos 、eureka、redis、zk、consul
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:1001/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
apollo {
app.id = "fescar-server"
apollo.meta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
file {
name = "file.conf"
}
}

@ -1,11 +1,11 @@
# Fescar Example
# Seata Example
## 项目说明
本项目演示如何使用 Fescar Starter 完成 Spring Cloud 应用的分布式事务接入。
本项目演示如何使用 Seata Starter 完成 Spring Cloud 应用的分布式事务接入。
[Fescar](https://github.com/alibaba/fescar) 是 阿里巴巴 开源的 分布式事务中间件,以 高效 并且对业务 0 侵入 的方式,解决 微服务 场景下面临的分布式事务问题。
[Seata](https://github.com/seata/seata) 是 阿里巴巴 开源的 分布式事务中间件,以 高效 并且对业务 0 侵入 的方式,解决 微服务 场景下面临的分布式事务问题。

@ -14,7 +14,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-fescar</artifactId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

@ -20,17 +20,26 @@ transport {
worker-thread-size = 8
}
}
store {
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
max-branch-session-size = 16384
# globe session size , if exceeded throws exceptions
max-global-session-size = 512
# file buffer size , if exceeded allocate new buffer
file-write-buffer-cache-size = 16384
# when recover batch read size
session.reload.read_size = 100
}
service {
#vgroup->rgroup
vgroup_mapping.order-service-fescar-service-group = "localRgroup"
vgroup_mapping.storage-service-fescar-service-group = "default"
#only support single node
localRgroup.grouplist = "127.0.0.1:8091"
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
}
client {
async.commit.buffer.limit = 10000
lock {

@ -0,0 +1,55 @@
registry {
# file 、nacos 、eureka、redis、zk、consul
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:1001/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk
type = "file"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
apollo {
app.id = "fescar-server"
apollo.meta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
file {
name = "file.conf"
}
}

@ -1,7 +0,0 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.alibaba.fescar.rest.FescarRestTemplateAutoConfiguration,\
org.springframework.cloud.alibaba.fescar.web.FescarHandlerInterceptorConfiguration,\
org.springframework.cloud.alibaba.fescar.GlobalTransactionAutoConfiguration,\
org.springframework.cloud.alibaba.fescar.feign.FescarFeignClientAutoConfiguration,\
org.springframework.cloud.alibaba.fescar.feign.hystrix.FescarHystrixAutoConfiguration

@ -57,14 +57,10 @@ import org.springframework.test.context.junit4.SpringRunner;
"spring.cloud.nacos.config.encode=utf-8",
"spring.cloud.nacos.config.timeout=1000",
"spring.cloud.nacos.config.file-extension=properties",
"spring.cloud.nacos.config.ext-config[0].data-id=ext-config-common01.properties",
"spring.cloud.nacos.config.ext-config[1].data-id=ext-config-common02.properties",
"spring.cloud.nacos.config.ext-config[1].group=GLOBAL_GROUP",
"spring.cloud.nacos.config.shared-dataids=common1.properties,common2.properties",
"spring.cloud.nacos.config.accessKey=test-accessKey",
"spring.cloud.nacos.config.secretKey=test-secretKey" }, webEnvironment = NONE)
public class NacosConfigurationExtConfigTests {

@ -22,11 +22,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
import com.alibaba.nacos.client.config.NacosConfigService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -48,6 +45,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.test.context.junit4.SpringRunner;
import com.alibaba.nacos.client.config.NacosConfigService;
/**
* @author xiaojing
*/
@ -59,7 +58,6 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest(classes = NacosConfigurationTests.TestConfig.class, properties = {
"spring.application.name=myTestService1", "spring.profiles.active=dev,test",
"spring.cloud.nacos.config.server-addr=127.0.0.1:8848",
"spring.cloud.nacos.config.endpoint=test-endpoint",
"spring.cloud.nacos.config.namespace=test-namespace",
"spring.cloud.nacos.config.encode=utf-8",
"spring.cloud.nacos.config.timeout=1000",
@ -68,14 +66,10 @@ import org.springframework.test.context.junit4.SpringRunner;
"spring.cloud.nacos.config.cluster-name=test-cluster",
"spring.cloud.nacos.config.file-extension=properties",
"spring.cloud.nacos.config.contextPath=test-contextpath",
"spring.cloud.nacos.config.ext-config[0].data-id=ext-config-common01.properties",
"spring.cloud.nacos.config.ext-config[1].data-id=ext-config-common02.properties",
"spring.cloud.nacos.config.ext-config[1].group=GLOBAL_GROUP",
"spring.cloud.nacos.config.shared-dataids=common1.properties,common2.properties",
"spring.cloud.nacos.config.accessKey=test-accessKey",
"spring.cloud.nacos.config.secretKey=test-secretKey" }, webEnvironment = NONE)
public class NacosConfigurationTests {
@ -83,8 +77,6 @@ public class NacosConfigurationTests {
static {
try {
// when(any(ConfigService.class).getConfig(eq("test-name.properties"),
// eq("test-group"), any())).thenReturn("user.name=hello");
Method method = PowerMockito.method(NacosConfigService.class, "getConfig",
String.class, String.class, long.class);
@ -152,7 +144,6 @@ public class NacosConfigurationTests {
assertNotNull("NacosConfigProperties was not created", properties);
checkoutNacosConfigServerAddr();
checkoutNacosConfigEndpoint();
checkoutNacosConfigNamespace();
checkoutNacosConfigClusterName();
checkoutNacosConfigAccessKey();
@ -172,19 +163,12 @@ public class NacosConfigurationTests {
private void checkoutNacosConfigServerAddr() {
assertEquals("NacosConfigProperties server address is wrong", "127.0.0.1:8848",
properties.getServerAddr());
}
private void checkoutNacosConfigEndpoint() {
assertEquals("NacosConfigProperties endpoint is wrong", "test-endpoint",
properties.getEndpoint());
}
private void checkoutNacosConfigNamespace() {
assertEquals("NacosConfigProperties namespace is wrong", "test-namespace",
properties.getNamespace());
}
private void checkoutNacosConfigClusterName() {
@ -234,8 +218,8 @@ public class NacosConfigurationTests {
private void checkoutDataLoad() {
Assert.assertEquals(environment.getProperty("user.name"), "dev");
Assert.assertEquals(environment.getProperty("user.age"), "12");
Assert.assertEquals("dev", environment.getProperty("user.name"));
Assert.assertEquals("12", environment.getProperty("user.age"));
}
private void checkoutEndpoint() throws Exception {

@ -10,8 +10,8 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alibaba-fescar</artifactId>
<name>Spring Cloud Alibaba Fescar</name>
<artifactId>spring-cloud-alibaba-seata</artifactId>
<name>Spring Cloud Alibaba Seata</name>
<dependencies>

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar;
package org.springframework.cloud.alibaba.seata;
import com.alibaba.fescar.spring.annotation.GlobalTransactionScanner;
@ -29,17 +29,17 @@ import org.springframework.util.StringUtils;
*/
@Configuration
@EnableConfigurationProperties(FescarProperties.class)
@EnableConfigurationProperties(SeataProperties.class)
public class GlobalTransactionAutoConfiguration {
private final ApplicationContext applicationContext;
private final FescarProperties fescarProperties;
private final SeataProperties seataProperties;
public GlobalTransactionAutoConfiguration(ApplicationContext applicationContext,
FescarProperties fescarProperties) {
SeataProperties seataProperties) {
this.applicationContext = applicationContext;
this.fescarProperties = fescarProperties;
this.seataProperties = seataProperties;
}
@Bean
@ -48,11 +48,11 @@ public class GlobalTransactionAutoConfiguration {
String applicationName = applicationContext.getEnvironment()
.getProperty("spring.application.name");
String txServiceGroup = fescarProperties.getTxServiceGroup();
String txServiceGroup = seataProperties.getTxServiceGroup();
if (StringUtils.isEmpty(txServiceGroup)) {
txServiceGroup = applicationName + "-fescar-service-group";
fescarProperties.setTxServiceGroup(txServiceGroup);
seataProperties.setTxServiceGroup(txServiceGroup);
}
return new GlobalTransactionScanner(applicationName, txServiceGroup);

@ -14,20 +14,20 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar;
package org.springframework.cloud.alibaba.seata;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* @author xiaojing
*/
@ConfigurationProperties("spring.cloud.alibaba.fescar")
public class FescarProperties {
@ConfigurationProperties("spring.cloud.alibaba.seata")
public class SeataProperties {
// todo support config Fescar server information
/**
* Fescar tx service group.default is ${spring.application.name}-fescar-service-group.
* Seata tx service group.default is ${spring.application.name}-fescar-service-group.
*/
private String txServiceGroup;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign;
package org.springframework.cloud.alibaba.seata.feign;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
@ -22,18 +22,18 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
/**
* @author xiaojing
*/
final class FescarBeanPostProcessor implements BeanPostProcessor {
final class SeataBeanPostProcessor implements BeanPostProcessor {
private final FescarFeignObjectWrapper fescarFeignObjectWrapper;
private final SeataFeignObjectWrapper seataFeignObjectWrapper;
FescarBeanPostProcessor(FescarFeignObjectWrapper fescarFeignObjectWrapper) {
this.fescarFeignObjectWrapper = fescarFeignObjectWrapper;
SeataBeanPostProcessor(SeataFeignObjectWrapper seataFeignObjectWrapper) {
this.seataFeignObjectWrapper = seataFeignObjectWrapper;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
return this.fescarFeignObjectWrapper.wrap(bean);
return this.seataFeignObjectWrapper.wrap(bean);
}
@Override

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign;
package org.springframework.cloud.alibaba.seata.feign;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
@ -24,20 +24,20 @@ import org.springframework.cloud.openfeign.FeignContext;
/**
* @author xiaojing
*/
public class FescarContextBeanPostProcessor implements BeanPostProcessor {
public class SeataContextBeanPostProcessor implements BeanPostProcessor {
private final BeanFactory beanFactory;
private FescarFeignObjectWrapper fescarFeignObjectWrapper;
private SeataFeignObjectWrapper seataFeignObjectWrapper;
FescarContextBeanPostProcessor(BeanFactory beanFactory) {
SeataContextBeanPostProcessor(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
if (bean instanceof FeignContext && !(bean instanceof FescarFeignContext)) {
return new FescarFeignContext(getFescarFeignObjectWrapper(),
if (bean instanceof FeignContext && !(bean instanceof SeataFeignContext)) {
return new SeataFeignContext(getSeataFeignObjectWrapper(),
(FeignContext) bean);
}
return bean;
@ -49,11 +49,11 @@ public class FescarContextBeanPostProcessor implements BeanPostProcessor {
return bean;
}
private FescarFeignObjectWrapper getFescarFeignObjectWrapper() {
if (this.fescarFeignObjectWrapper == null) {
this.fescarFeignObjectWrapper = this.beanFactory
.getBean(FescarFeignObjectWrapper.class);
private SeataFeignObjectWrapper getSeataFeignObjectWrapper() {
if (this.seataFeignObjectWrapper == null) {
this.seataFeignObjectWrapper = this.beanFactory
.getBean(SeataFeignObjectWrapper.class);
}
return this.fescarFeignObjectWrapper;
return this.seataFeignObjectWrapper;
}
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign;
package org.springframework.cloud.alibaba.seata.feign;
import org.springframework.beans.factory.BeanFactory;
@ -23,12 +23,12 @@ import feign.Feign;
/**
* @author xiaojing
*/
final class FescarFeignBuilder {
final class SeataFeignBuilder {
private FescarFeignBuilder() {
private SeataFeignBuilder() {
}
static Feign.Builder builder(BeanFactory beanFactory) {
return Feign.builder().client(new FescarFeignClient(beanFactory));
return Feign.builder().client(new SeataFeignClient(beanFactory));
}
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign;
package org.springframework.cloud.alibaba.seata.feign;
import java.io.IOException;
import java.util.ArrayList;
@ -35,17 +35,17 @@ import org.springframework.util.StringUtils;
/**
* @author xiaojing
*/
public class FescarFeignClient implements Client {
public class SeataFeignClient implements Client {
private final Client delegate;
private final BeanFactory beanFactory;
FescarFeignClient(BeanFactory beanFactory) {
SeataFeignClient(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
this.delegate = new Client.Default(null, null);
}
FescarFeignClient(BeanFactory beanFactory, Client delegate) {
SeataFeignClient(BeanFactory beanFactory, Client delegate) {
this.delegate = delegate;
this.beanFactory = beanFactory;
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign;
package org.springframework.cloud.alibaba.seata.feign;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
@ -36,14 +36,14 @@ import feign.Feign;
@Configuration
@ConditionalOnClass(Client.class)
@AutoConfigureBefore(FeignAutoConfiguration.class)
public class FescarFeignClientAutoConfiguration {
public class SeataFeignClientAutoConfiguration {
@Bean
@Scope("prototype")
@ConditionalOnClass(name = "com.netflix.hystrix.HystrixCommand")
@ConditionalOnProperty(name = "feign.hystrix.enabled", havingValue = "true")
Feign.Builder feignHystrixBuilder(BeanFactory beanFactory) {
return FescarHystrixFeignBuilder.builder(beanFactory);
return SeataHystrixFeignBuilder.builder(beanFactory);
}
@Bean
@ -51,34 +51,34 @@ public class FescarFeignClientAutoConfiguration {
@ConditionalOnClass(name = "com.alibaba.csp.sentinel.SphU")
@ConditionalOnProperty(name = "feign.sentinel.enabled", havingValue = "true")
Feign.Builder feignSentinelBuilder(BeanFactory beanFactory) {
return FescarSentinelFeignBuilder.builder(beanFactory);
return SeataSentinelFeignBuilder.builder(beanFactory);
}
@Bean
@ConditionalOnMissingBean
@Scope("prototype")
Feign.Builder feignBuilder(BeanFactory beanFactory) {
return FescarFeignBuilder.builder(beanFactory);
return SeataFeignBuilder.builder(beanFactory);
}
@Configuration
protected static class FeignBeanPostProcessorConfiguration {
@Bean
FescarBeanPostProcessor fescarBeanPostProcessor(
FescarFeignObjectWrapper fescarFeignObjectWrapper) {
return new FescarBeanPostProcessor(fescarFeignObjectWrapper);
SeataBeanPostProcessor fescarBeanPostProcessor(
SeataFeignObjectWrapper seataFeignObjectWrapper) {
return new SeataBeanPostProcessor(seataFeignObjectWrapper);
}
@Bean
FescarContextBeanPostProcessor fescarContextBeanPostProcessor(
SeataContextBeanPostProcessor fescarContextBeanPostProcessor(
BeanFactory beanFactory) {
return new FescarContextBeanPostProcessor(beanFactory);
return new SeataContextBeanPostProcessor(beanFactory);
}
@Bean
FescarFeignObjectWrapper fescarFeignObjectWrapper(BeanFactory beanFactory) {
return new FescarFeignObjectWrapper(beanFactory);
SeataFeignObjectWrapper fescarFeignObjectWrapper(BeanFactory beanFactory) {
return new SeataFeignObjectWrapper(beanFactory);
}
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign;
package org.springframework.cloud.alibaba.seata.feign;
import java.util.HashMap;
import java.util.Map;
@ -26,14 +26,14 @@ import org.springframework.cloud.openfeign.FeignContext;
*
* @author xiaojing
*/
public class FescarFeignContext extends FeignContext {
public class SeataFeignContext extends FeignContext {
private final FescarFeignObjectWrapper fescarFeignObjectWrapper;
private final SeataFeignObjectWrapper seataFeignObjectWrapper;
private final FeignContext delegate;
FescarFeignContext(FescarFeignObjectWrapper fescarFeignObjectWrapper,
FeignContext delegate) {
this.fescarFeignObjectWrapper = fescarFeignObjectWrapper;
SeataFeignContext(SeataFeignObjectWrapper seataFeignObjectWrapper,
FeignContext delegate) {
this.seataFeignObjectWrapper = seataFeignObjectWrapper;
this.delegate = delegate;
}
@ -43,7 +43,7 @@ public class FescarFeignContext extends FeignContext {
if (object instanceof Client) {
return object;
}
return (T) this.fescarFeignObjectWrapper.wrap(object);
return (T) this.seataFeignObjectWrapper.wrap(object);
}
@Override
@ -59,7 +59,7 @@ public class FescarFeignContext extends FeignContext {
}
else {
convertedInstances.put(entry.getKey(),
(T) this.fescarFeignObjectWrapper.wrap(entry.getValue()));
(T) this.seataFeignObjectWrapper.wrap(entry.getValue()));
}
}
return convertedInstances;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign;
package org.springframework.cloud.alibaba.seata.feign;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
@ -26,25 +26,25 @@ import org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient;
/**
* @author xiaojing
*/
public class FescarFeignObjectWrapper {
public class SeataFeignObjectWrapper {
private final BeanFactory beanFactory;
private CachingSpringLoadBalancerFactory cachingSpringLoadBalancerFactory;
private SpringClientFactory springClientFactory;
FescarFeignObjectWrapper(BeanFactory beanFactory) {
SeataFeignObjectWrapper(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}
Object wrap(Object bean) {
if (bean instanceof Client && !(bean instanceof FescarFeignClient)) {
if (bean instanceof Client && !(bean instanceof SeataFeignClient)) {
if (bean instanceof LoadBalancerFeignClient) {
LoadBalancerFeignClient client = ((LoadBalancerFeignClient) bean);
return new FescarLoadBalancerFeignClient(client.getDelegate(), factory(),
return new SeataLoadBalancerFeignClient(client.getDelegate(), factory(),
clientFactory(), this.beanFactory);
}
return new FescarFeignClient(this.beanFactory, (Client) bean);
return new SeataFeignClient(this.beanFactory, (Client) bean);
}
return bean;
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign;
package org.springframework.cloud.alibaba.seata.feign;
import feign.Retryer;
import feign.hystrix.HystrixFeign;
@ -25,13 +25,13 @@ import feign.Feign;
/**
* @author xiaojing
*/
final class FescarHystrixFeignBuilder {
final class SeataHystrixFeignBuilder {
private FescarHystrixFeignBuilder() {
private SeataHystrixFeignBuilder() {
}
static Feign.Builder builder(BeanFactory beanFactory) {
return HystrixFeign.builder().retryer(Retryer.NEVER_RETRY)
.client(new FescarFeignClient(beanFactory));
.client(new SeataFeignClient(beanFactory));
}
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign;
package org.springframework.cloud.alibaba.seata.feign;
import java.io.IOException;
@ -30,13 +30,13 @@ import org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient;
/**
* @author xiaojing
*/
public class FescarLoadBalancerFeignClient extends LoadBalancerFeignClient {
public class SeataLoadBalancerFeignClient extends LoadBalancerFeignClient {
private final BeanFactory beanFactory;
FescarLoadBalancerFeignClient(Client delegate,
CachingSpringLoadBalancerFactory lbClientFactory,
SpringClientFactory clientFactory, BeanFactory beanFactory) {
SeataLoadBalancerFeignClient(Client delegate,
CachingSpringLoadBalancerFactory lbClientFactory,
SpringClientFactory clientFactory, BeanFactory beanFactory) {
super(wrap(delegate, beanFactory), lbClientFactory, clientFactory);
this.beanFactory = beanFactory;
}
@ -47,7 +47,7 @@ public class FescarLoadBalancerFeignClient extends LoadBalancerFeignClient {
}
private static Client wrap(Client delegate, BeanFactory beanFactory) {
return (Client) new FescarFeignObjectWrapper(beanFactory).wrap(delegate);
return (Client) new SeataFeignObjectWrapper(beanFactory).wrap(delegate);
}
}

@ -14,26 +14,24 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign;
package org.springframework.cloud.alibaba.seata.feign;
import org.springframework.beans.factory.BeanFactory;
import feign.Feign;
import feign.Retryer;
import feign.hystrix.HystrixFeign;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties.Sentinel;
import org.springframework.cloud.alibaba.sentinel.feign.SentinelFeign;
/**
* @author xiaojing
*/
final class FescarSentinelFeignBuilder {
final class SeataSentinelFeignBuilder {
private FescarSentinelFeignBuilder() {
private SeataSentinelFeignBuilder() {
}
static Feign.Builder builder(BeanFactory beanFactory) {
return SentinelFeign.builder().retryer(Retryer.NEVER_RETRY)
.client(new FescarFeignClient(beanFactory));
.client(new SeataFeignClient(beanFactory));
}
}

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign.hystrix;
package org.springframework.cloud.alibaba.seata.feign.hystrix;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
@ -27,11 +27,11 @@ import com.netflix.hystrix.HystrixCommand;
@Configuration
@ConditionalOnClass(HystrixCommand.class)
public class FescarHystrixAutoConfiguration {
public class SeataHystrixAutoConfiguration {
@Bean
FescarHystrixConcurrencyStrategy fescarHystrixConcurrencyStrategy() {
return new FescarHystrixConcurrencyStrategy();
SeataHystrixConcurrencyStrategy fescarHystrixConcurrencyStrategy() {
return new SeataHystrixConcurrencyStrategy();
}
}

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.feign.hystrix;
package org.springframework.cloud.alibaba.seata.feign.hystrix;
import java.util.concurrent.Callable;
@ -25,11 +25,11 @@ import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy;
/**
* @author xiaojing
*/
public class FescarHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy {
public class SeataHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy {
private HystrixConcurrencyStrategy delegate;
public FescarHystrixConcurrencyStrategy() {
public SeataHystrixConcurrencyStrategy() {
this.delegate = HystrixPlugins.getInstance().getConcurrencyStrategy();
HystrixPlugins.reset();
HystrixPlugins.getInstance().registerConcurrencyStrategy(this);

@ -29,7 +29,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.rest;
package org.springframework.cloud.alibaba.seata.rest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
@ -47,18 +47,18 @@ import java.util.List;
*/
@Configuration
public class FescarRestTemplateAutoConfiguration {
public class SeataRestTemplateAutoConfiguration {
@Bean
public FescarRestTemplateInterceptor fescarRestTemplateInterceptor() {
return new FescarRestTemplateInterceptor();
public SeataRestTemplateInterceptor fescarRestTemplateInterceptor() {
return new SeataRestTemplateInterceptor();
}
@Autowired(required = false)
private Collection<RestTemplate> restTemplates;
@Autowired
private FescarRestTemplateInterceptor fescarRestTemplateInterceptor;
private SeataRestTemplateInterceptor seataRestTemplateInterceptor;
@PostConstruct
public void init() {
@ -66,7 +66,7 @@ public class FescarRestTemplateAutoConfiguration {
for (RestTemplate restTemplate : restTemplates) {
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>(
restTemplate.getInterceptors());
interceptors.add(this.fescarRestTemplateInterceptor);
interceptors.add(this.seataRestTemplateInterceptor);
restTemplate.setInterceptors(interceptors);
}
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.rest;
package org.springframework.cloud.alibaba.seata.rest;
import java.io.IOException;
@ -30,7 +30,7 @@ import org.springframework.util.StringUtils;
/**
* @author xiaojing
*/
public class FescarRestTemplateInterceptor implements ClientHttpRequestInterceptor {
public class SeataRestTemplateInterceptor implements ClientHttpRequestInterceptor {
@Override
public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes,
ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.web;
package org.springframework.cloud.alibaba.seata.web;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -35,10 +35,10 @@ import org.springframework.web.servlet.HandlerInterceptor;
* And clean up Fescar information after servlet method invocation in
* {@link org.springframework.web.servlet.HandlerInterceptor#afterCompletion(HttpServletRequest, HttpServletResponse, Object, Exception)}
*/
public class FescarHandlerInterceptor implements HandlerInterceptor {
public class SeataHandlerInterceptor implements HandlerInterceptor {
private static final Logger log = LoggerFactory
.getLogger(FescarHandlerInterceptor.class);
.getLogger(SeataHandlerInterceptor.class);
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.cloud.alibaba.fescar.web;
package org.springframework.cloud.alibaba.seata.web;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@ -22,10 +22,10 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author xiaojing
*/
public class FescarHandlerInterceptorConfiguration implements WebMvcConfigurer {
public class SeataHandlerInterceptorConfiguration implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new FescarHandlerInterceptor()).addPathPatterns("/**");
registry.addInterceptor(new SeataHandlerInterceptor()).addPathPatterns("/**");
}
}

@ -0,0 +1,7 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.alibaba.seata.rest.SeataRestTemplateAutoConfiguration,\
org.springframework.cloud.alibaba.seata.web.SeataHandlerInterceptorConfiguration,\
org.springframework.cloud.alibaba.seata.GlobalTransactionAutoConfiguration,\
org.springframework.cloud.alibaba.seata.feign.SeataFeignClientAutoConfiguration,\
org.springframework.cloud.alibaba.seata.feign.hystrix.SeataHystrixAutoConfiguration

@ -16,7 +16,7 @@
<module>spring-cloud-starter-alibaba-nacos-config-server</module>
<module>spring-cloud-starter-alibaba-nacos-discovery</module>
<module>spring-cloud-starter-alibaba-sentinel</module>
<module>spring-cloud-starter-alibaba-fescar</module>
<module>spring-cloud-starter-alibaba-seata</module>
<module>spring-cloud-starter-stream-rocketmq</module>
<module>spring-cloud-starter-bus-rocketmq</module>
<module>spring-cloud-starter-dubbo</module>

@ -7,13 +7,13 @@
<artifactId>spring-cloud-starter-alibaba</artifactId>
<version>2.1.0.BUILD-SNAPSHOT</version>
</parent>
<artifactId>spring-cloud-starter-alibaba-fescar</artifactId>
<name>Spring Cloud Starter Alibaba Fescar</name>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
<name>Spring Cloud Starter Alibaba Seata</name>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alibaba-fescar</artifactId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
</dependency>
</dependencies>
Loading…
Cancel
Save