From 9cc52706f5f9ad239f6d054ef4a256b1824d0c72 Mon Sep 17 00:00:00 2001 From: echooymxq Date: Mon, 13 Jan 2020 09:39:06 +0800 Subject: [PATCH] Polish code in Dubbo adapter and use Dubbo common constants (#1245) --- .../csp/sentinel/adapter/dubbo/DubboAppContextFilter.java | 4 +++- .../sentinel/adapter/dubbo/SentinelDubboConsumerFilter.java | 4 +++- .../sentinel/adapter/dubbo/SentinelDubboProviderFilter.java | 4 +++- .../csp/sentinel/adapter/dubbo/DubboAppContextFilter.java | 4 +++- .../sentinel/adapter/dubbo/SentinelDubboConsumerFilter.java | 4 +++- .../sentinel/adapter/dubbo/SentinelDubboProviderFilter.java | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilter.java b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilter.java index 789bb96e..b7354293 100644 --- a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilter.java +++ b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilter.java @@ -24,12 +24,14 @@ import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.RpcException; +import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER; + /** * Puts current consumer's application name in the attachment of each invocation. * * @author Eric Zhao */ -@Activate(group = "consumer") +@Activate(group = CONSUMER) public class DubboAppContextFilter implements Filter { @Override diff --git a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilter.java b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilter.java index 8b317e90..ffa9fba9 100644 --- a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilter.java +++ b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilter.java @@ -32,6 +32,8 @@ import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.support.RpcUtils; +import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER; + /** *

Dubbo service consumer filter for Sentinel. Auto activated by default.

*

@@ -43,7 +45,7 @@ import org.apache.dubbo.rpc.support.RpcUtils; * @author Carpenter Lee * @author Eric Zhao */ -@Activate(group = "consumer") +@Activate(group = CONSUMER) public class SentinelDubboConsumerFilter extends BaseSentinelDubboFilter { public SentinelDubboConsumerFilter() { diff --git a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilter.java b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilter.java index 479b0954..c9199786 100644 --- a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilter.java +++ b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilter.java @@ -31,6 +31,8 @@ import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.RpcException; +import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER; + /** *

Apache Dubbo service provider filter that enables integration with Sentinel. Auto activated by default.

*

Note: this only works for Apache Dubbo 2.7.x or above version.

@@ -43,7 +45,7 @@ import org.apache.dubbo.rpc.RpcException; * @author Carpenter Lee * @author Eric Zhao */ -@Activate(group = "provider") +@Activate(group = PROVIDER) public class SentinelDubboProviderFilter extends BaseSentinelDubboFilter { public SentinelDubboProviderFilter() { diff --git a/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilter.java b/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilter.java index ceae979d..e76f2db4 100644 --- a/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilter.java +++ b/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilter.java @@ -24,12 +24,14 @@ import com.alibaba.dubbo.rpc.Result; import com.alibaba.dubbo.rpc.RpcContext; import com.alibaba.dubbo.rpc.RpcException; +import static com.alibaba.dubbo.common.Constants.CONSUMER; + /** * Puts current consumer's application name in the attachment of each invocation. * * @author Eric Zhao */ -@Activate(group = "consumer") +@Activate(group = CONSUMER) public class DubboAppContextFilter implements Filter { @Override diff --git a/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilter.java b/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilter.java index e4d822f0..e7c36af9 100755 --- a/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilter.java +++ b/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilter.java @@ -31,6 +31,8 @@ import com.alibaba.dubbo.rpc.Invoker; import com.alibaba.dubbo.rpc.Result; import com.alibaba.dubbo.rpc.RpcException; +import static com.alibaba.dubbo.common.Constants.CONSUMER; + /** *

Dubbo service consumer filter for Sentinel. Auto activated by default.

* @@ -42,7 +44,7 @@ import com.alibaba.dubbo.rpc.RpcException; * @author leyou * @author Eric Zhao */ -@Activate(group = "consumer") +@Activate(group = CONSUMER) public class SentinelDubboConsumerFilter extends AbstractDubboFilter implements Filter { public SentinelDubboConsumerFilter() { diff --git a/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilter.java b/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilter.java index 1d78ab8a..85d566ad 100755 --- a/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilter.java +++ b/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilter.java @@ -32,6 +32,8 @@ import com.alibaba.dubbo.rpc.Invoker; import com.alibaba.dubbo.rpc.Result; import com.alibaba.dubbo.rpc.RpcException; +import static com.alibaba.dubbo.common.Constants.PROVIDER; + /** *

Dubbo service provider filter for Sentinel. Auto activated by default.

* @@ -43,7 +45,7 @@ import com.alibaba.dubbo.rpc.RpcException; * @author leyou * @author Eric Zhao */ -@Activate(group = "provider") +@Activate(group = PROVIDER) public class SentinelDubboProviderFilter extends AbstractDubboFilter implements Filter { public SentinelDubboProviderFilter() {