From 4006df1dcd12734cd228547777bf190cd5fe2659 Mon Sep 17 00:00:00 2001 From: jimin Date: Thu, 15 Feb 2024 13:05:53 +0800 Subject: [PATCH] optimize: compatible with integration.http and integration.http.Jakarta (#6327) --- changes/en-us/2.x.md | 1 + changes/zh-cn/2.x.md | 2 +- compatible/pom.xml | 21 ++++++ .../integration/http/DefaultHttpExecutor.java | 64 +++++++++++++++++++ .../http/JakartaSeataWebMvcConfigurer.java | 19 ++++++ ...artaTransactionPropagationInterceptor.java | 19 ++++++ .../http/SeataWebMvcConfigurer.java | 19 ++++++ .../TransactionPropagationInterceptor.java | 22 +++++++ 8 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 compatible/src/main/java/io/seata/integration/http/DefaultHttpExecutor.java create mode 100644 compatible/src/main/java/io/seata/integration/http/JakartaSeataWebMvcConfigurer.java create mode 100644 compatible/src/main/java/io/seata/integration/http/JakartaTransactionPropagationInterceptor.java create mode 100644 compatible/src/main/java/io/seata/integration/http/SeataWebMvcConfigurer.java create mode 100644 compatible/src/main/java/io/seata/integration/http/TransactionPropagationInterceptor.java diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index 84ac79f0039..33030d937d7 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -82,6 +82,7 @@ Add changes here for all PR submitted to the 2.x branch. - [[#6301](https://github.com/apache/incubator-seata/pull/6301)] upgrade console frontend dependencies and supported nodejs versions - [[#6301](https://github.com/apache/incubator-seata/pull/6312)] add saga related io.seata compatible api - [[#6313](https://github.com/apache/incubator-seata/pull/6313)] console display the version number +- [[#6327](https://github.com/apache/incubator-seata/pull/6327)] compatible with integration.http and integration.http.Jakarta - [[#6328](https://github.com/apache/incubator-seata/pull/6328)] compatible with integration.grpc - [[#6330](https://github.com/apache/incubator-seata/pull/6330)] remove mariadb API - [[#6329](https://github.com/apache/incubator-seata/pull/6312)] add saga subcomponent-level io.seata compatible api diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index a21c548ee22..bd974324e61 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -80,6 +80,7 @@ - [[#6301](https://github.com/apache/incubator-seata/pull/6301)] 升级console前端依赖及支持的nodejs版本 - [[#6301](https://github.com/apache/incubator-seata/pull/6312)] 添加saga相关的io.seata兼容性API - [[#6313](https://github.com/apache/incubator-seata/pull/6313)] console展示版本号 +- [[#6327](https://github.com/apache/incubator-seata/pull/6327)] 兼容 integration.http 和 integration.http.Jakarta API - [[#6328](https://github.com/apache/incubator-seata/pull/6328)] 兼容 integration.grpc API - [[#6330](https://github.com/apache/incubator-seata/pull/6330)] 去除 mariadb API - [[#6329](https://github.com/apache/incubator-seata/pull/6312)] 添加saga子组件的io.seata兼容性API @@ -87,7 +88,6 @@ - [[#6343](https://github.com/apache/incubator-seata/pull/6343)] 兼容tm 模块和rm-datasource模块 - ### security: - [[#6069](https://github.com/apache/incubator-seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞 - [[#6144](https://github.com/apache/incubator-seata/pull/6144)] 升级Nacos依赖版本至1.4.6 diff --git a/compatible/pom.xml b/compatible/pom.xml index 406d3e01d92..865aa264f84 100644 --- a/compatible/pom.xml +++ b/compatible/pom.xml @@ -49,6 +49,27 @@ 2.1.0-SNAPSHOT compile + + org.apache.seata + seata-http + ${project.version} + + + org.apache.seata + seata-http-jakarta + ${project.version} + + + org.apache.httpcomponents + httpclient + 4.5.13 + provided + + + org.springframework + spring-webmvc + 5.3.20 + org.apache.seata seata-grpc diff --git a/compatible/src/main/java/io/seata/integration/http/DefaultHttpExecutor.java b/compatible/src/main/java/io/seata/integration/http/DefaultHttpExecutor.java new file mode 100644 index 00000000000..c3fd8d7d587 --- /dev/null +++ b/compatible/src/main/java/io/seata/integration/http/DefaultHttpExecutor.java @@ -0,0 +1,64 @@ +/* + * 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 io.seata.integration.http; + +import java.util.Map; + +import org.apache.http.HttpResponse; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; + +public class DefaultHttpExecutor { + + private static final org.apache.seata.integration.http.DefaultHttpExecutor INSTANCE + = org.apache.seata.integration.http.DefaultHttpExecutor.getInstance(); + + private final org.apache.seata.integration.http.DefaultHttpExecutor targetDefaultHttpExecutor; + + private DefaultHttpExecutor(final org.apache.seata.integration.http.DefaultHttpExecutor innerInstance) { + this.targetDefaultHttpExecutor = innerInstance; + } + + public static DefaultHttpExecutor getInstance() { + return new DefaultHttpExecutor(INSTANCE); + } + + public void buildClientEntity(CloseableHttpClient httpClient, T paramObject) { + this.targetDefaultHttpExecutor.buildClientEntity(httpClient, paramObject); + } + + public void buildGetHeaders(Map headers, T paramObject) { + this.targetDefaultHttpExecutor.buildGetHeaders(headers, paramObject); + } + + public String initGetUrl(String host, String path, Map querys) { + return this.targetDefaultHttpExecutor.initGetUrl(host, path, querys); + } + + public void buildPostHeaders(Map headers, T t) { + this.targetDefaultHttpExecutor.buildPostHeaders(headers, t); + } + + public StringEntity buildEntity(StringEntity entity, T t) { + return this.targetDefaultHttpExecutor.buildEntity(entity, t); + } + + public K convertResult(HttpResponse response, Class clazz) { + return this.targetDefaultHttpExecutor.convertResult(response, clazz); + } + +} diff --git a/compatible/src/main/java/io/seata/integration/http/JakartaSeataWebMvcConfigurer.java b/compatible/src/main/java/io/seata/integration/http/JakartaSeataWebMvcConfigurer.java new file mode 100644 index 00000000000..888819cc63c --- /dev/null +++ b/compatible/src/main/java/io/seata/integration/http/JakartaSeataWebMvcConfigurer.java @@ -0,0 +1,19 @@ +/* + * 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 io.seata.integration.http; + +public class JakartaSeataWebMvcConfigurer extends org.apache.seata.integration.http.JakartaSeataWebMvcConfigurer{} \ No newline at end of file diff --git a/compatible/src/main/java/io/seata/integration/http/JakartaTransactionPropagationInterceptor.java b/compatible/src/main/java/io/seata/integration/http/JakartaTransactionPropagationInterceptor.java new file mode 100644 index 00000000000..468f4dd539c --- /dev/null +++ b/compatible/src/main/java/io/seata/integration/http/JakartaTransactionPropagationInterceptor.java @@ -0,0 +1,19 @@ +/* + * 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 io.seata.integration.http; + +public class JakartaTransactionPropagationInterceptor extends org.apache.seata.integration.http.JakartaTransactionPropagationInterceptor{} diff --git a/compatible/src/main/java/io/seata/integration/http/SeataWebMvcConfigurer.java b/compatible/src/main/java/io/seata/integration/http/SeataWebMvcConfigurer.java new file mode 100644 index 00000000000..160f1873fe6 --- /dev/null +++ b/compatible/src/main/java/io/seata/integration/http/SeataWebMvcConfigurer.java @@ -0,0 +1,19 @@ +/* + * 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 io.seata.integration.http; + +public class SeataWebMvcConfigurer extends org.apache.seata.integration.http.SeataWebMvcConfigurer {} diff --git a/compatible/src/main/java/io/seata/integration/http/TransactionPropagationInterceptor.java b/compatible/src/main/java/io/seata/integration/http/TransactionPropagationInterceptor.java new file mode 100644 index 00000000000..7fd5f6e84a0 --- /dev/null +++ b/compatible/src/main/java/io/seata/integration/http/TransactionPropagationInterceptor.java @@ -0,0 +1,22 @@ +/* + * 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 io.seata.integration.http; + +public class TransactionPropagationInterceptor + extends org.apache.seata.integration.http.TransactionPropagationInterceptor { + +}