This is an automated email from the ASF dual-hosted git repository.
hefengen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new ae497d2898 [ISSUE #4612] init shenyu-plugin-wasm-base module (#5412)
ae497d2898 is described below
commit ae497d2898b4c6dca179a97f4f9ada4db9387bb0
Author: dragon-zhang <[email protected]>
AuthorDate: Fri Jan 26 09:52:08 2024 +0800
[ISSUE #4612] init shenyu-plugin-wasm-base module (#5412)
* [ISSUE #4612] init shenyu-plugin-wasm-base module
* fix rat
* close once
* add LICENSE
* add LICENSE
* add LICENSE
---
.gitignore | 2 +
pom.xml | 7 +
.../src/main/release-docs/LICENSE | 19 +-
.../main/release-docs/licenses/LICENSE-jni-rs.txt | 24 +++
.../licenses/LICENSE-wasi-cap-std-sync.txt | 221 +++++++++++++++++++++
.../release-docs/licenses/LICENSE-wasi-common.txt | 221 +++++++++++++++++++++
.../licenses/LICENSE-wasmtime-wasi.txt | 221 +++++++++++++++++++++
.../release-docs/licenses/LICENSE-wasmtime.txt | 221 +++++++++++++++++++++
shenyu-plugin/pom.xml | 1 +
.../shenyu/plugin/api/result/ShenyuResultEnum.java | 7 +-
.../shenyu/plugin/base/AbstractShenyuPlugin.java | 2 +-
.../{ => shenyu-plugin-wasm-base}/pom.xml | 49 ++---
.../plugin/wasm/base/AbstractShenyuWasmPlugin.java | 169 ++++++++++++++++
.../plugin/wasm/base/AbstractWasmPlugin.java | 127 ++++++++++++
.../apache/shenyu/plugin/wasm/base/WasmLoader.java | 183 +++++++++++++++++
.../wasm/base/exception/ShenyuWasmException.java | 56 ++++++
.../base/exception/ShenyuWasmInitException.java | 54 +++++
.../shenyu-plugin-wasm-base/src/test/README.md | 19 ++
.../plugin/wasm/base/AbstractWasmPluginTest.java | 132 ++++++++++++
...base.AbstractWasmPluginTest$RustWasmPlugin.wasm | Bin 0 -> 1984076 bytes
.../src/test/rust-wasm-plugin/Cargo.toml | 26 +++
.../src/test/rust-wasm-plugin/src/lib.rs | 38 ++++
22 files changed, 1761 insertions(+), 38 deletions(-)
diff --git a/.gitignore b/.gitignore
index 4c5abdb4b9..b9784dc9b2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,3 +43,5 @@ Thumbs.db
# agent build ignore
/agent/
+# rust ignore
+*.lock
diff --git a/pom.xml b/pom.xml
index a387ada743..a1f532dd4f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -182,6 +182,7 @@
<casdoor-java-sdk.version>1.9.0</casdoor-java-sdk.version>
<huawei-log-sdk.version>1.0.1</huawei-log-sdk.version>
<opengauss-jdbc.version>5.0.0-og</opengauss-jdbc.version>
+ <wasmtime-java.version>0.19.0</wasmtime-java.version>
<!-- dependency version end -->
</properties>
@@ -585,6 +586,12 @@
<artifactId>kafka-clients</artifactId>
<version>${kafka-clients.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>io.github.kawamuray.wasmtime</groupId>
+ <artifactId>wasmtime-java</artifactId>
+ <version>${wasmtime-java.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
diff --git a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
index 49a90d7560..30e3c069bf 100644
--- a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
+++ b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
@@ -218,6 +218,7 @@ The text of each license is the standard Apache 2.0 license.
accessors-smart 2.4.11: https://www.minidev.net, Apache 2.0
annotations 4.1.1.4: http://source.android.com, Apache 2.0
annotations 13.0: http://source.android.com, Apache 2.0
+ anyhow 1.0.70: https://github.com/dtolnay/anyhow, Apache 2.0
archaius-core 0.7.6: https://github.com/Netflix/archaius, Apache 2.0
assertj-core 3.22.0: http://assertj.org/assertj-core, Apache 2.0
brave 5.1.0: https://zipkin.io, Apache 2.0
@@ -232,7 +233,8 @@ The text of each license is the standard Apache 2.0 license.
btf 1.2: https://github.com/fge/btf, LGPL and Apache 2.0
byte-buddy 1.12.6: https://bytebuddy.net/byte-buddy, Apache 2.0
byte-buddy-agent 1.11.22: https://bytebuddy.net/byte-buddy, Apache 2.0
- caffeine 2.9.3 https://github.com/ben-manes/caffeine, Apache 2.0
+ caffeine 2.9.3: https://github.com/ben-manes/caffeine, Apache 2.0
+ cap-std 1.0.7: https://github.com/bytecodealliance/cap-std, Apache 2.0
classmate 1.5.1: https://github.com/FasterXML/java-classmate, Apache 2.0
clickhouse-client 0.3.2-patch11:
https://mvnrepository.com/artifact/com.clickhouse/clickhouse-client, Apache 2.0
clickhouse-http-client 0.3.2-patch11:
https://mvnrepository.com/artifact/com.clickhouse/clickhouse-http-client,
Apache 2.0
@@ -329,6 +331,7 @@ The text of each license is the standard Apache 2.0 license.
jsr305 3.0.2: http://findbugs.sourceforge.net/, Apache 2.0
kafka-clients 3.4.0: https://github.com/apache/kafka, Apache 2.0
lettuce-core 6.1.10.RELEASE: http://github.com/lettuce-io/lettuce-core,
Apache 2.0
+ wasmtime-java 0.19.0: https://github.com/kawamuray/wasmtime-java, Apache
2.0
listenablefuture 9999.0-empty-to-avoid-conflict-with-guava:
https://github.com/google/guava, Apache 2.0
log4j-api 2.17.2: https://logging.apache.org/log4j/2.x/log4j-api, Apache
2.0
log4j-1.2-api 2.17.2:
https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-1.2-api,
Apache 2.0
@@ -534,6 +537,7 @@ The text of each license is the standard Apache 2.0 license.
rxnetty-servo 0.4.9: https://github.com/ReactiveX/RxNetty, Apache 2.0
servo-core 0.12.21: https://github.com/Netflix/servo, Apache 2.0
stax-api 1.0.1: http://stax.codehaus.org/, Apache 2.0
+ thiserror 1.0.40: https://github.com/dtolnay/thiserror, Apache 2.0
woodstox-core 6.2.1: https://github.com/FasterXML/woodstox, Apache 2.0
libthrift 0.14.1: http://thrift.apache.org, Apache 2.0
tomcat-annotations-api 9.0.29: https://tomcat.apache.org/, Apache 2.0
@@ -563,6 +567,18 @@ The text of each license is the standard Apache 2.0
license.
amqp-client 5.14.3: https://www.rabbitmq.com/api-guide.html#license,
Apache 2.0
hessian-lite 3.2.13: https://github.com/apache/dubbo-hessian-lite, Apache
2.0
+========================================================================
+Apache 2.0 licenses
+========================================================================
+
+The following components are provided under the Apache license. See project
link for details.
+The text of each license is also included at licenses/LICENSE-[project].txt.
+
+ wasi-cap-std-sync 7.0.0: https://github.com/bytecodealliance/wasmtime,
Apache 2.0
+ wasi-common 7.0.0: https://github.com/bytecodealliance/wasmtime, Apache 2.0
+ wasmtime 7.0.0: https://github.com/bytecodealliance/wasmtime, Apache 2.0
+ wasmtime-wasi 7.0.0: https://github.com/bytecodealliance/wasmtime, Apache
2.0
+
========================================================================
BSD licenses
========================================================================
@@ -660,6 +676,7 @@ The text of each license is also included at
licenses/LICENSE-[project].txt.
checker-qual 3.12.0:
https://github.com/typetools/checker-framework/blob/master/checker-qual, MIT
Java-WebSocket 1.5.0: https://github.com/TooTallNate/Java-WebSocket, MIT
jcl-over-slf4j 1.7.36: https://www.slf4j.org, MIT
+ jni-rs 0.21.1: https://github.com/jni-rs/jni-rs, MIT
jul-to-slf4j 1.7.36: http://www.slf4j.org, MIT
mockito 3.5.15: https://github.com/mockito/mockito MIT
slf4j-api 1.7.36: https://www.slf4j.org, MIT
diff --git
a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-jni-rs.txt
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-jni-rs.txt
new file mode 100644
index 0000000000..bb65a171f6
--- /dev/null
+++
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-jni-rs.txt
@@ -0,0 +1,24 @@
+jni-rs License
+---------------
+
+The MIT License (MIT)
+
+Copyright (c) 2016 Prevoty, Inc. and jni-rs contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git
a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasi-cap-std-sync.txt
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasi-cap-std-sync.txt
new file mode 100644
index 0000000000..264466f63e
--- /dev/null
+++
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasi-cap-std-sync.txt
@@ -0,0 +1,221 @@
+wasi-common License
+---------------
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+
+--- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
diff --git
a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasi-common.txt
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasi-common.txt
new file mode 100644
index 0000000000..264466f63e
--- /dev/null
+++
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasi-common.txt
@@ -0,0 +1,221 @@
+wasi-common License
+---------------
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+
+--- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
diff --git
a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasmtime-wasi.txt
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasmtime-wasi.txt
new file mode 100644
index 0000000000..d8506353e7
--- /dev/null
+++
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasmtime-wasi.txt
@@ -0,0 +1,221 @@
+wasmtime-wasi License
+---------------
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+
+--- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
diff --git
a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasmtime.txt
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasmtime.txt
new file mode 100644
index 0000000000..299c81adaf
--- /dev/null
+++
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-wasmtime.txt
@@ -0,0 +1,221 @@
+wasmtime License
+---------------
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+
+--- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
diff --git a/shenyu-plugin/pom.xml b/shenyu-plugin/pom.xml
index 1c5fee0b12..17e406f8bb 100644
--- a/shenyu-plugin/pom.xml
+++ b/shenyu-plugin/pom.xml
@@ -29,6 +29,7 @@
<modules>
<module>shenyu-plugin-api</module>
<module>shenyu-plugin-base</module>
+ <module>shenyu-plugin-wasm-base</module>
<module>shenyu-plugin-httpclient</module>
<module>shenyu-plugin-rewrite</module>
<module>shenyu-plugin-waf</module>
diff --git
a/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/result/ShenyuResultEnum.java
b/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/result/ShenyuResultEnum.java
index 526763eefd..c7b6b02310 100644
---
a/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/result/ShenyuResultEnum.java
+++
b/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/result/ShenyuResultEnum.java
@@ -235,7 +235,12 @@ public enum ShenyuResultEnum {
/**
* Key is incorrect.
*/
- ERROR_KEY(401, "Key is incorrect");
+ ERROR_KEY(401, "Key is incorrect"),
+
+ /**
+ * WASM function not found.
+ */
+ WASM_FUNC_NOT_FOUND(533, "WASM function not found");
/**
* the code.
diff --git
a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java
b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java
index 67d91faae6..1d45050c93 100644
---
a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java
+++
b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java
@@ -70,7 +70,7 @@ public abstract class AbstractShenyuPlugin implements
ShenyuPlugin {
private ShenyuConfig.RuleMatchCache ruleMatchConfig;
/**
- * this is Template Method child has Implement your own logic.
+ * this is Template Method child has implements your own logic.
*
* @param exchange exchange the current server exchange {@linkplain
ServerWebExchange}
* @param chain chain the current chain {@linkplain ServerWebExchange}
diff --git a/shenyu-plugin/pom.xml
b/shenyu-plugin/shenyu-plugin-wasm-base/pom.xml
similarity index 50%
copy from shenyu-plugin/pom.xml
copy to shenyu-plugin/shenyu-plugin-wasm-base/pom.xml
index 1c5fee0b12..d64e2de340 100644
--- a/shenyu-plugin/pom.xml
+++ b/shenyu-plugin/shenyu-plugin-wasm-base/pom.xml
@@ -19,52 +19,31 @@
<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
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.shenyu</groupId>
- <artifactId>shenyu</artifactId>
+ <artifactId>shenyu-plugin</artifactId>
<version>2.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>shenyu-plugin</artifactId>
- <packaging>pom</packaging>
-
- <modules>
- <module>shenyu-plugin-api</module>
- <module>shenyu-plugin-base</module>
- <module>shenyu-plugin-httpclient</module>
- <module>shenyu-plugin-rewrite</module>
- <module>shenyu-plugin-waf</module>
- <module>shenyu-plugin-global</module>
- <module>shenyu-plugin-context-path</module>
- <module>shenyu-plugin-redirect</module>
- <module>shenyu-plugin-modify-response</module>
- <module>shenyu-plugin-request</module>
- <module>shenyu-plugin-response</module>
- <module>shenyu-plugin-param-mapping</module>
- <module>shenyu-plugin-uri</module>
- <module>shenyu-plugin-metrics</module>
- <module>shenyu-plugin-cache</module>
- <module>shenyu-plugin-logging</module>
- <module>shenyu-plugin-mock</module>
- <module>shenyu-plugin-proxy</module>
- <module>shenyu-plugin-security</module>
- <module>shenyu-plugin-fault-tolerance</module>
- </modules>
+ <artifactId>shenyu-plugin-wasm-base</artifactId>
<dependencies>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-plugin-base</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
- <groupId>io.projectreactor</groupId>
- <artifactId>reactor-test</artifactId>
+ <groupId>io.github.kawamuray.wasmtime</groupId>
+ <artifactId>wasmtime-java</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-kotlin</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
-
-</project>
+</project>
\ No newline at end of file
diff --git
a/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/AbstractShenyuWasmPlugin.java
b/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/AbstractShenyuWasmPlugin.java
new file mode 100644
index 0000000000..c44da42e74
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/AbstractShenyuWasmPlugin.java
@@ -0,0 +1,169 @@
+/*
+ * 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 org.apache.shenyu.plugin.wasm.base;
+
+import io.github.kawamuray.wasmtime.Extern;
+import io.github.kawamuray.wasmtime.Func;
+import io.github.kawamuray.wasmtime.Store;
+import io.github.kawamuray.wasmtime.WasmFunctions;
+import io.github.kawamuray.wasmtime.WasmValType;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
+import org.apache.shenyu.plugin.api.ShenyuPluginChain;
+import org.apache.shenyu.plugin.api.result.ShenyuResultEnum;
+import org.apache.shenyu.plugin.api.result.ShenyuResultWrap;
+import org.apache.shenyu.plugin.api.utils.WebFluxResultUtils;
+import org.apache.shenyu.plugin.base.AbstractShenyuPlugin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Complex plugins implemented in other languages should extend this class, we
still need to write Java subclasses,
+ * so we can reuse the convenient/powerful control of ShenYu, such as {@link
#getOrder}/{@link #skip}
+ * /{@link #skipExcept}/{@link #skipExceptHttpLike}.
+ *
+ * @see org.apache.shenyu.plugin.base.AbstractShenyuPlugin
+ * @see io.github.kawamuray.wasmtime.WasmValType
+ * @see org.apache.shenyu.plugin.wasm.base.WasmLoader
+ */
+public abstract class AbstractShenyuWasmPlugin extends AbstractShenyuPlugin {
+
+ protected static final Logger LOG =
LoggerFactory.getLogger(AbstractShenyuWasmPlugin.class);
+
+ protected static final Map<Long, Argument> ARGUMENTS = new
ConcurrentHashMap<>();
+
+ protected static final String DO_EXECUTE_METHOD_NAME = "doExecute";
+
+ protected static final String BEFORE_METHOD_NAME = "before";
+
+ protected static final String AFTER_METHOD_NAME = "after";
+
+ private final WasmLoader wasmLoader;
+
+ public AbstractShenyuWasmPlugin() {
+ this.wasmLoader = new WasmLoader(this.getClass(),
this::initWasmCallJavaFunc);
+ }
+
+ protected Map<String, Func> initWasmCallJavaFunc(final Store<Void> store) {
+ return null;
+ }
+
+ @Override
+ protected Mono<Void> doExecute(final ServerWebExchange exchange,
+ final ShenyuPluginChain chain,
+ final SelectorData selector,
+ final RuleData rule) {
+ return wasmLoader.getWasmExtern(DO_EXECUTE_METHOD_NAME).map(doExecute
-> {
+ final Long argumentId = callWASI(exchange, chain, selector, rule,
doExecute);
+ return doExecute(exchange, chain, selector, rule, argumentId);
+ }).orElseGet(() -> {
+ LOG.error("{} function not found in {}", DO_EXECUTE_METHOD_NAME,
wasmLoader.getWasmName());
+
exchange.getResponse().setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR);
+ Object error = ShenyuResultWrap.error(exchange,
ShenyuResultEnum.WASM_FUNC_NOT_FOUND);
+ return WebFluxResultUtils.result(exchange, error);
+ });
+ }
+
+ /**
+ * this is Template Method child has implements your own logic.
+ *
+ * @param exchange exchange the current server exchange {@linkplain
ServerWebExchange}
+ * @param chain chain the current chain {@linkplain
ServerWebExchange}
+ * @param selector selector {@linkplain SelectorData}
+ * @param rule rule {@linkplain RuleData}
+ * @param argumentId the argument id {@linkplain #getArgumentId}
+ * @return {@code Mono<Void>} to indicate when request handling is complete
+ */
+ protected abstract Mono<Void> doExecute(ServerWebExchange exchange,
ShenyuPluginChain chain, SelectorData selector, RuleData rule, Long argumentId);
+
+ private Long callWASI(final ServerWebExchange exchange,
+ final ShenyuPluginChain chain,
+ final SelectorData selector,
+ final RuleData rule,
+ final Extern doExecute) {
+ // WASI cannot easily pass Java objects like JNI, here we pass Long as
arg
+ // then we can get the argument by Long
+ final Long argumentId = getArgumentId(exchange, chain, selector, rule);
+ ARGUMENTS.put(argumentId, new Argument(exchange, chain, selector,
rule));
+ // call WASI function
+ WasmFunctions.consumer(wasmLoader.getStore(), doExecute.func(),
WasmValType.I64)
+ .accept(argumentId);
+ ARGUMENTS.remove(argumentId);
+ return argumentId;
+ }
+
+ protected abstract Long getArgumentId(ServerWebExchange exchange,
+ ShenyuPluginChain chain,
+ SelectorData selector,
+ RuleData rule);
+
+ @Override
+ public void before(final ServerWebExchange exchange) {
+ wasmLoader.getWasmExtern(BEFORE_METHOD_NAME)
+ .ifPresent(before -> callWASI(exchange, null, null, null,
before));
+ }
+
+ @Override
+ public void after(final ServerWebExchange exchange) {
+ wasmLoader.getWasmExtern(AFTER_METHOD_NAME)
+ .ifPresent(before -> callWASI(exchange, null, null, null,
before));
+ }
+
+ protected static final class Argument {
+
+ private final ServerWebExchange exchange;
+
+ private final ShenyuPluginChain chain;
+
+ private final SelectorData selector;
+
+ private final RuleData rule;
+
+ private Argument(final ServerWebExchange exchange,
+ final ShenyuPluginChain chain,
+ final SelectorData selector,
+ final RuleData rule) {
+ this.exchange = exchange;
+ this.chain = chain;
+ this.selector = selector;
+ this.rule = rule;
+ }
+
+ public ServerWebExchange getExchange() {
+ return exchange;
+ }
+
+ public ShenyuPluginChain getChain() {
+ return chain;
+ }
+
+ public SelectorData getSelector() {
+ return selector;
+ }
+
+ public RuleData getRule() {
+ return rule;
+ }
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/AbstractWasmPlugin.java
b/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/AbstractWasmPlugin.java
new file mode 100644
index 0000000000..ce3a58a059
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/AbstractWasmPlugin.java
@@ -0,0 +1,127 @@
+/*
+ * 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 org.apache.shenyu.plugin.wasm.base;
+
+import io.github.kawamuray.wasmtime.Extern;
+import io.github.kawamuray.wasmtime.WasmFunctions;
+import io.github.kawamuray.wasmtime.WasmValType;
+import org.apache.shenyu.plugin.api.ShenyuPlugin;
+import org.apache.shenyu.plugin.api.ShenyuPluginChain;
+import org.apache.shenyu.plugin.api.result.ShenyuResultEnum;
+import org.apache.shenyu.plugin.api.result.ShenyuResultWrap;
+import org.apache.shenyu.plugin.api.utils.WebFluxResultUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Simple plugins implemented in other languages should extend this class, we
still need to write Java subclasses,
+ * so we can reuse the convenient/powerful control of ShenYu, such as {@link
#getOrder}/{@link #skip}
+ * /{@link #skipExcept}/{@link #skipExceptHttpLike}.
+ *
+ * @see org.apache.shenyu.plugin.api.ShenyuPlugin
+ * @see io.github.kawamuray.wasmtime.WasmValType
+ * @see org.apache.shenyu.plugin.wasm.base.WasmLoader
+ */
+public abstract class AbstractWasmPlugin extends WasmLoader implements
ShenyuPlugin {
+
+ protected static final Logger LOG =
LoggerFactory.getLogger(AbstractWasmPlugin.class);
+
+ protected static final Map<Long, Argument> ARGUMENTS = new
ConcurrentHashMap<>();
+
+ protected static final String EXECUTE_METHOD_NAME = "execute";
+
+ protected static final String BEFORE_METHOD_NAME = "before";
+
+ protected static final String AFTER_METHOD_NAME = "after";
+
+ @Override
+ public Mono<Void> execute(final ServerWebExchange exchange, final
ShenyuPluginChain chain) {
+ return super.getWasmExtern(EXECUTE_METHOD_NAME).map(execute -> {
+ final Long argumentId = callWASI(exchange, chain, execute);
+ return doExecute(exchange, chain, argumentId);
+ }).orElseGet(() -> {
+ LOG.error("{} function not found in {}", EXECUTE_METHOD_NAME,
super.getWasmName());
+
exchange.getResponse().setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR);
+ Object error = ShenyuResultWrap.error(exchange,
ShenyuResultEnum.WASM_FUNC_NOT_FOUND);
+ return WebFluxResultUtils.result(exchange, error);
+ });
+ }
+
+ /**
+ * this is Template Method child has implements your own logic.
+ *
+ * @param exchange exchange the current server exchange {@linkplain
ServerWebExchange}
+ * @param chain chain the current chain {@linkplain ServerWebExchange}
+ * @param argumentId the argument id {@linkplain #getArgumentId}
+ * @return {@code Mono<Void>} to indicate when request handling is complete
+ */
+ protected abstract Mono<Void> doExecute(ServerWebExchange exchange,
ShenyuPluginChain chain, Long argumentId);
+
+ private Long callWASI(final ServerWebExchange exchange, final
ShenyuPluginChain chain, final Extern execute) {
+ // WASI cannot easily pass Java objects like JNI, here we pass Long as
arg
+ // then we can get the argument by Long
+ final Long argumentId = getArgumentId(exchange, chain);
+ ARGUMENTS.put(argumentId, new Argument(exchange, chain));
+ // call WASI function
+ WasmFunctions.consumer(super.getStore(), execute.func(),
WasmValType.I64)
+ .accept(argumentId);
+ ARGUMENTS.remove(argumentId);
+ return argumentId;
+ }
+
+ protected abstract Long getArgumentId(ServerWebExchange exchange,
ShenyuPluginChain chain);
+
+ @Override
+ public void before(final ServerWebExchange exchange) {
+ super.getWasmExtern(BEFORE_METHOD_NAME)
+ .ifPresent(before -> callWASI(exchange, null, before));
+ }
+
+ @Override
+ public void after(final ServerWebExchange exchange) {
+ super.getWasmExtern(AFTER_METHOD_NAME)
+ .ifPresent(before -> callWASI(exchange, null, before));
+ }
+
+ protected static final class Argument {
+
+ private final ServerWebExchange exchange;
+
+ private final ShenyuPluginChain chain;
+
+ private Argument(final ServerWebExchange exchange,
+ final ShenyuPluginChain chain) {
+ this.exchange = exchange;
+ this.chain = chain;
+ }
+
+ public ServerWebExchange getExchange() {
+ return exchange;
+ }
+
+ public ShenyuPluginChain getChain() {
+ return chain;
+ }
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/WasmLoader.java
b/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/WasmLoader.java
new file mode 100644
index 0000000000..706d55f503
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/WasmLoader.java
@@ -0,0 +1,183 @@
+/*
+ * 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 org.apache.shenyu.plugin.wasm.base;
+
+import io.github.kawamuray.wasmtime.Extern;
+import io.github.kawamuray.wasmtime.Func;
+import io.github.kawamuray.wasmtime.Linker;
+import io.github.kawamuray.wasmtime.Memory;
+import io.github.kawamuray.wasmtime.Module;
+import io.github.kawamuray.wasmtime.Store;
+import io.github.kawamuray.wasmtime.wasi.WasiCtx;
+import io.github.kawamuray.wasmtime.wasi.WasiCtxBuilder;
+import org.apache.shenyu.plugin.wasm.base.exception.ShenyuWasmInitException;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Function;
+
+/**
+ * The WasmLoader aims to load wasm file and provide the wasm function to java,
+ * also provide the java function to wasm if we need.
+ */
+public class WasmLoader implements AutoCloseable {
+
+ private static final String IMPORT_WASM_MODULE_NAME = "shenyu";
+
+ private static final String MEMORY_METHOD_NAME = "memory";
+
+ private final AtomicBoolean closed = new AtomicBoolean(false);
+
+ private final String wasmName;
+
+ private final WasiCtx wasiCtx = new
WasiCtxBuilder().inheritStdout().inheritStderr().build();
+
+ /**
+ * the WASM store.
+ *
+ * @see io.github.kawamuray.wasmtime.WasmFunctions#consumer
+ * @see io.github.kawamuray.wasmtime.WasmFunctions#func
+ */
+ private final Store<Void> store = Store.withoutData(wasiCtx);
+
+ private final Linker linker = new Linker(store.engine());
+
+ /**
+ * wasmCallJavaFuncName -> wasmCallJavaFunc.
+ */
+ private final Map<String, Func> wasmCallJavaFuncMap = new HashMap<>();
+
+ private final Module module;
+
+ private final Memory memRef;
+
+ public WasmLoader() {
+ this(null, null);
+ }
+
+ /**
+ * This constructor is designed for classes that cannot extend WasmLoader.
+ *
+ * @see io.github.kawamuray.wasmtime.WasmFunctions#wrap
+ */
+ public WasmLoader(final Class<?> wasmClass, final Function<Store<Void>,
Map<String, Func>> initializer) {
+ final Class<?> clazz = wasmClass != null ? wasmClass : this.getClass();
+ this.wasmName = clazz.getName() + ".wasm";
+ try {
+ // locate `.wasm` lib.
+ URL resource = clazz.getClassLoader().getResource(wasmName);
+ if (Objects.isNull(resource)) {
+ throw new ShenyuWasmInitException("Can't find wasm file: " +
wasmName);
+ }
+ // Reads the WebAssembly module as bytes.
+ byte[] wasmBytes = Files.readAllBytes(Paths.get(resource.toURI()));
+ // Instantiates the WebAssembly module.
+ if (Objects.nonNull(initializer)) {
+ Map<String, Func> wasmFunctionMap = initializer.apply(store);
+ if (Objects.nonNull(wasmFunctionMap) &&
!wasmFunctionMap.isEmpty()) {
+ wasmCallJavaFuncMap.putAll(wasmFunctionMap);
+ }
+ }
+ Map<String, Func> wasmFunctionMap = initWasmCallJavaFunc(store);
+ if (Objects.nonNull(wasmFunctionMap) &&
!wasmFunctionMap.isEmpty()) {
+ wasmCallJavaFuncMap.putAll(wasmFunctionMap);
+ }
+ this.module = Module.fromBinary(store.engine(), wasmBytes);
+ WasiCtx.addToLinker(linker);
+ // maybe need define many functions
+ if (!wasmCallJavaFuncMap.isEmpty()) {
+ wasmCallJavaFuncMap.forEach((funcName, wasmCallJavaFunc) ->
+ linker.define(store, IMPORT_WASM_MODULE_NAME,
funcName, Extern.fromFunc(wasmCallJavaFunc)));
+ }
+ linker.module(store, "", module);
+ // Let the `wasmCallJavaFunc` function to refer this as a
placeholder of Memory because
+ // we have to add the function as import before loading the module
exporting Memory.
+ Optional<Extern> extern = this.getWasmExtern(MEMORY_METHOD_NAME);
+ if (!extern.isPresent()) {
+ throw new ShenyuWasmInitException(MEMORY_METHOD_NAME + "
function not find in wasm file: " + wasmName);
+ }
+ this.memRef = extern.get().memory();
+ Runtime.getRuntime().addShutdownHook(new Thread(this::close));
+ } catch (URISyntaxException | IOException e) {
+ throw new ShenyuWasmInitException(e);
+ }
+ }
+
+ protected Map<String, Func> initWasmCallJavaFunc(final Store<Void> store) {
+ return null;
+ }
+
+ /**
+ * get the WASI function.
+ *
+ * @param wasiFuncName the WASI function name
+ * @return the WASI function
+ */
+ public Optional<Extern> getWasmExtern(final String wasiFuncName) {
+ return linker.get(store, "", wasiFuncName);
+ }
+
+ /**
+ * get the wasm file name.
+ *
+ * @return wasm file name
+ */
+ public String getWasmName() {
+ return wasmName;
+ }
+
+ /**
+ * use this when call WASI.
+ *
+ * @return the Store
+ */
+ public Store<Void> getStore() {
+ return store;
+ }
+
+ /**
+ * use this in wasmCallJavaFunc.
+ *
+ * @return the ByteBuffer
+ */
+ public ByteBuffer getBuffer() {
+ return memRef.buffer(store);
+ }
+
+ @Override
+ public void close() {
+ if (this.closed.compareAndSet(false, true)) {
+ this.wasiCtx.close();
+ this.store.close();
+ this.linker.close();
+ if (!wasmCallJavaFuncMap.isEmpty()) {
+ this.wasmCallJavaFuncMap.forEach((funcName, wasmCallJavaFunc)
-> wasmCallJavaFunc.close());
+ }
+ this.module.close();
+ }
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/exception/ShenyuWasmException.java
b/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/exception/ShenyuWasmException.java
new file mode 100644
index 0000000000..52b524bd71
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/exception/ShenyuWasmException.java
@@ -0,0 +1,56 @@
+/*
+ * 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 org.apache.shenyu.plugin.wasm.base.exception;
+
+import org.apache.shenyu.common.exception.ShenyuException;
+
+/**
+ * Shenyu WASM Exception.
+ */
+public class ShenyuWasmException extends ShenyuException {
+
+ private static final long serialVersionUID = -3927608941632834099L;
+
+ /**
+ * Instantiates a new Shenyu WASM exception.
+ *
+ * @param e the e
+ */
+ public ShenyuWasmException(final Throwable e) {
+ super(e);
+ }
+
+ /**
+ * Instantiates a new Shenyu WASM exception.
+ *
+ * @param message the message
+ */
+ public ShenyuWasmException(final String message) {
+ super(message);
+ }
+
+ /**
+ * Instantiates a new Shenyu WASM exception.
+ *
+ * @param message the message
+ * @param throwable the throwable
+ */
+ public ShenyuWasmException(final String message, final Throwable
throwable) {
+ super(message, throwable);
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/exception/ShenyuWasmInitException.java
b/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/exception/ShenyuWasmInitException.java
new file mode 100644
index 0000000000..230e93676a
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-wasm-base/src/main/java/org/apache/shenyu/plugin/wasm/base/exception/ShenyuWasmInitException.java
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.shenyu.plugin.wasm.base.exception;
+
+/**
+ * Shenyu WASM init Exception.
+ */
+public class ShenyuWasmInitException extends ShenyuWasmException {
+
+ private static final long serialVersionUID = -2152384472200663352L;
+
+ /**
+ * Instantiates a new Shenyu WASM exception.
+ *
+ * @param e the e
+ */
+ public ShenyuWasmInitException(final Throwable e) {
+ super(e);
+ }
+
+ /**
+ * Instantiates a new Shenyu WASM exception.
+ *
+ * @param message the message
+ */
+ public ShenyuWasmInitException(final String message) {
+ super(message);
+ }
+
+ /**
+ * Instantiates a new Shenyu WASM exception.
+ *
+ * @param message the message
+ * @param throwable the throwable
+ */
+ public ShenyuWasmInitException(final String message, final Throwable
throwable) {
+ super(message, throwable);
+ }
+}
diff --git a/shenyu-plugin/shenyu-plugin-wasm-base/src/test/README.md
b/shenyu-plugin/shenyu-plugin-wasm-base/src/test/README.md
new file mode 100644
index 0000000000..82bb92adb6
--- /dev/null
+++ b/shenyu-plugin/shenyu-plugin-wasm-base/src/test/README.md
@@ -0,0 +1,19 @@
+# How to build the wasm file
+
+1. install rustup
+
+2. install rust
+
+3. generate the wasm file
+
+```shell
+cd {shenyu}/shenyu-plugin/shenyu-plugin-wasm-base/src/test/rust-wasm-filter
+cargo build --target wasm32-wasi --release
+```
+
+then you will see the wasm file
+in
`{shenyu}/shenyu-plugin/shenyu-plugin-wasm-base/src/test/rust-wasm-filter/target/wasm32-wasi/release/rust_filter.wasm`
+
+4. rename the wasm file
+
+rename the file to
`org.apache.shenyu.plugin.wasm.base.AbstractWasmPluginTest$RustWasmPlugin.wasm`
diff --git
a/shenyu-plugin/shenyu-plugin-wasm-base/src/test/java/org/apache/shenyu/plugin/wasm/base/AbstractWasmPluginTest.java
b/shenyu-plugin/shenyu-plugin-wasm-base/src/test/java/org/apache/shenyu/plugin/wasm/base/AbstractWasmPluginTest.java
new file mode 100644
index 0000000000..e626c784ff
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-wasm-base/src/test/java/org/apache/shenyu/plugin/wasm/base/AbstractWasmPluginTest.java
@@ -0,0 +1,132 @@
+/*
+ * 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 org.apache.shenyu.plugin.wasm.base;
+
+import io.github.kawamuray.wasmtime.Func;
+import io.github.kawamuray.wasmtime.Store;
+import io.github.kawamuray.wasmtime.WasmFunctions;
+import io.github.kawamuray.wasmtime.WasmValType;
+import org.apache.shenyu.common.config.ShenyuConfig;
+import org.apache.shenyu.plugin.api.ShenyuPluginChain;
+import org.apache.shenyu.plugin.api.utils.SpringBeanUtils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
+import org.springframework.mock.web.server.MockServerWebExchange;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+import reactor.test.StepVerifier;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class AbstractWasmPluginTest {
+
+ private ServerWebExchange exchange;
+
+ private RustWasmPlugin rustWasmPlugin;
+
+ private ShenyuPluginChain shenyuPluginChain;
+
+ @BeforeEach
+ public void setUp() {
+ mockShenyuConfig();
+ this.shenyuPluginChain = mock(ShenyuPluginChain.class);
+ this.rustWasmPlugin = spy(new RustWasmPlugin());
+ this.exchange =
MockServerWebExchange.from(MockServerHttpRequest.get("/http/SHENYU/SHENYU")
+ .build());
+ when(shenyuPluginChain.execute(exchange)).thenReturn(Mono.empty());
+ }
+
+ /**
+ * The plugin is null test.
+ */
+ @Test
+ public void executePluginTest() {
+ StepVerifier.create(rustWasmPlugin.execute(exchange,
shenyuPluginChain)).expectSubscription().verifyComplete();
+ verify(shenyuPluginChain).execute(exchange);
+ }
+
+ private void mockShenyuConfig() {
+ ConfigurableApplicationContext context =
mock(ConfigurableApplicationContext.class);
+ when(context.getBean(ShenyuConfig.class)).thenReturn(new
ShenyuConfig());
+ SpringBeanUtils.getInstance().setApplicationContext(context);
+ }
+
+ static class RustWasmPlugin extends AbstractWasmPlugin {
+
+ private static final Map<Long, String> RESULTS = new
ConcurrentHashMap<>();
+
+ @Override
+ public int getOrder() {
+ return 0;
+ }
+
+ @Override
+ protected Mono<Void> doExecute(final ServerWebExchange exchange, final
ShenyuPluginChain chain, final Long argumentId) {
+ final String result = RESULTS.get(argumentId);
+ assertEquals("rust result", result);
+ return chain.execute(exchange);
+ }
+
+ @Override
+ protected Long getArgumentId(final ServerWebExchange exchange, final
ShenyuPluginChain chain) {
+ return 0L;
+ }
+
+ @Override
+ protected Map<String, Func> initWasmCallJavaFunc(final Store<Void>
store) {
+ Map<String, Func> funcMap = new HashMap<>();
+ funcMap.put("get_args", WasmFunctions.wrap(store, WasmValType.I64,
WasmValType.I64, WasmValType.I32, WasmValType.I32,
+ (argId, addr, len) -> {
+ String config = "hello from java " + argId;
+ LOG.info("java side->" + config);
+ assertEquals("hello from java 0", config);
+ ByteBuffer buf = super.getBuffer();
+ for (int i = 0; i < len && i < config.length(); i++) {
+ buf.put(addr.intValue() + i, (byte) config.charAt(i));
+ }
+ return Math.min(config.length(), len);
+ }));
+ funcMap.put("put_result", WasmFunctions.wrap(store,
WasmValType.I64, WasmValType.I64, WasmValType.I32, WasmValType.I32,
+ (argId, addr, len) -> {
+ ByteBuffer buf = super.getBuffer();
+ byte[] bytes = new byte[len];
+ for (int i = 0; i < len; i++) {
+ bytes[i] = buf.get(addr.intValue() + i);
+ }
+ String result = new String(bytes, StandardCharsets.UTF_8);
+ assertEquals("rust result", result);
+ RESULTS.put(argId, result);
+ LOG.info("java side->" + result);
+ return 0;
+ }));
+ return funcMap;
+ }
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-wasm-base/src/test/resources/org.apache.shenyu.plugin.wasm.base.AbstractWasmPluginTest$RustWasmPlugin.wasm
b/shenyu-plugin/shenyu-plugin-wasm-base/src/test/resources/org.apache.shenyu.plugin.wasm.base.AbstractWasmPluginTest$RustWasmPlugin.wasm
new file mode 100755
index 0000000000..e95a8d27bb
Binary files /dev/null and
b/shenyu-plugin/shenyu-plugin-wasm-base/src/test/resources/org.apache.shenyu.plugin.wasm.base.AbstractWasmPluginTest$RustWasmPlugin.wasm
differ
diff --git
a/shenyu-plugin/shenyu-plugin-wasm-base/src/test/rust-wasm-plugin/Cargo.toml
b/shenyu-plugin/shenyu-plugin-wasm-base/src/test/rust-wasm-plugin/Cargo.toml
new file mode 100644
index 0000000000..465d29ee59
--- /dev/null
+++ b/shenyu-plugin/shenyu-plugin-wasm-base/src/test/rust-wasm-plugin/Cargo.toml
@@ -0,0 +1,26 @@
+#
+# 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]
+name = "rust-wasm-plugin"
+version = "0.1.0"
+edition = "2021"
+
+[lib]
+crate-type = ["cdylib"]
diff --git
a/shenyu-plugin/shenyu-plugin-wasm-base/src/test/rust-wasm-plugin/src/lib.rs
b/shenyu-plugin/shenyu-plugin-wasm-base/src/test/rust-wasm-plugin/src/lib.rs
new file mode 100644
index 0000000000..b2ece8f3f1
--- /dev/null
+++ b/shenyu-plugin/shenyu-plugin-wasm-base/src/test/rust-wasm-plugin/src/lib.rs
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#[link(wasm_import_module = "shenyu")]
+extern "C" {
+ fn get_args(arg_id: i64, addr: i64, len: i32) -> i32;
+
+ fn put_result(arg_id: i64, addr: i64, len: i32) -> i32;
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn execute(arg_id: i64) {
+ let mut buf = [0u8; 32];
+ let buf_ptr = buf.as_mut_ptr() as i64;
+ eprintln!("rust side-> buffer base address: {}", buf_ptr);
+ // get arg from java
+ let len = get_args(arg_id, buf_ptr, buf.len() as i32);
+ let java_arg = std::str::from_utf8(&buf[..len as usize]).unwrap();
+ eprintln!("rust side-> recv:{}", java_arg);
+ // pass rust result to java
+ let rust_result = "rust result".as_bytes();
+ let result_ptr = rust_result.as_ptr() as i64;
+ _ = put_result(arg_id, result_ptr, rust_result.len() as i32);
+}