You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2022/08/31 01:24:02 UTC
[dubbo-website] branch master updated: # 本地存根 (#1441)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-website.git
The following commit(s) were added to refs/heads/master by this push:
new 7a02a703a8f # 本地存根 (#1441)
7a02a703a8f is described below
commit 7a02a703a8f3a20859f7516349ebadaca229d3ac
Author: JIAN ZHONG <11...@qq.com>
AuthorDate: Wed Aug 31 09:23:58 2022 +0800
# 本地存根 (#1441)
---
.../advanced-features-and-usage/service/local-stub.md | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/content/zh/docs3-v2/java-sdk/advanced-features-and-usage/service/local-stub.md b/content/zh/docs3-v2/java-sdk/advanced-features-and-usage/service/local-stub.md
index 272014d54c6..89319386590 100644
--- a/content/zh/docs3-v2/java-sdk/advanced-features-and-usage/service/local-stub.md
+++ b/content/zh/docs3-v2/java-sdk/advanced-features-and-usage/service/local-stub.md
@@ -9,15 +9,13 @@ description: "了解 Dubbo3 中本地存根在客户端执行部分逻辑的使
远程服务后,客户端通常只剩下接口,而实现全在服务器端,但提供方有些时候想在客户端也执行部分逻辑。
-

-
## 使用场景
做 ThreadLocal 缓存,提前验证参数,调用失败后伪造容错数据等等,此时就需要在 API 中带上 Stub,客户端生成 Proxy 实例,会把 Proxy 通过构造函数传给 Stub [^1],然后把 Stub 暴露给用户,Stub 可以决定要不要去调 Proxy。
-## 使用方式:
-在 spring 配置文件中按以下方式配置:
+## 使用方式
+### spring 配置文件配置
```xml
<dubbo:consumer interface="com.foo.BarService" stub="true" />
@@ -29,7 +27,7 @@ description: "了解 Dubbo3 中本地存根在客户端执行部分逻辑的使
<dubbo:consumer interface="com.foo.BarService" stub="com.foo.BarServiceStub" />
```
-提供 Stub 的实现 [^2]:
+### 提供 Stub 的实现 [^2]
```java
package com.foo;
@@ -52,7 +50,6 @@ public class BarServiceStub implements BarService {
}
}
```
-#### 注意:
[^1]: Stub 必须有可传入 Proxy 的构造函数。
-[^2]: 在 interface 旁边放一个 Stub 实现,它实现 BarService 接口,并有一个传入远程 BarService 实例的构造函数
+[^2]: 在 interface 旁边放一个 Stub 实现,它实现 BarService 接口,并有一个传入远程 BarService 实例的构造函数。