mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
rename fescar to seata
This commit is contained in:
parent
2a3ff1725a
commit
67bbfc1ed6
4
pom.xml
4
pom.xml
@ -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>
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
@ -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>
|
@ -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>
|
@ -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>
|
@ -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
|
||||
|
@ -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…
x
Reference in New Issue
Block a user