This is an automated email from the ASF dual-hosted git repository.

lixiaojie pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 3a22a50  Fix and improve  [first-dubbo-filter.md] (#288)
3a22a50 is described below

commit 3a22a509094c0d4c34adc344de2208b5ec8e32c2
Author: web <[email protected]>
AuthorDate: Sun Feb 17 14:04:28 2019 +0800

    Fix and improve  [first-dubbo-filter.md] (#288)
---
 blog/zh-cn/first-dubbo-filter.md | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/blog/zh-cn/first-dubbo-filter.md b/blog/zh-cn/first-dubbo-filter.md
index b0fd455..9f0830f 100644
--- a/blog/zh-cn/first-dubbo-filter.md
+++ b/blog/zh-cn/first-dubbo-filter.md
@@ -152,7 +152,7 @@ src
 
 XxxFilter.java:
 
-```
+```java
 public class XxxFilter implements Filter {
     public Result invoke(Invoker<?> invoker, Invocation invocation) throws 
RpcException {
         // before filter ...
@@ -167,4 +167,29 @@ META-INF/dubbo/com.alibaba.dubbo.rpc.Filter:
 ```
 xxx=com.xxx.XxxFilter
 ```
+
+在 xml 中配置:
+
+```xml
+<!-- 消费方调用过程拦截 -->
+<dubbo:reference filter="xxx" />
+<!-- 消费方调用过程缺省拦截器,将拦截所有reference -->
+<dubbo:consumer filter="xxx"/>
+<!-- 提供方调用过程拦截 -->
+<dubbo:service filter="xxx" />
+<!-- 提供方调用过程缺省拦截器,将拦截所有service -->
+<dubbo:provider filter="xxx"/>
+```
+
+或者使用注解:
+
+```java
+@Activate(group = "consumer")
+public class XxxFilter implements Filter {
+    // ...
+}
+```
+
+使用 xml 的配置方式会更加灵活,粒度更细。
+
 
在before和after中,可以实现自己的业务逻辑来赋予改filter一定的功能。编写和配置完成后,该filter就会被Dubbo框架激活并且在调用链中执行。

Reply via email to