zoukankan      html  css  js  c++  java
  • dubbo源码阅读-Filter默认实现(十一)之DeprecatedFilter

    /**
     * DeprecatedInvokerFilter
     * 服务于consumer 包含deprecated属性
     */
    @Activate(group = Constants.CONSUMER, value = Constants.DEPRECATED_KEY)
    public class DeprecatedFilter implements Filter {
    
        private static final Logger LOGGER = LoggerFactory.getLogger(DeprecatedFilter.class);
    
        private static final Set<String> logged = new ConcurrentHashSet<String>();
    
        @Override
        public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
            //获得key
            String key = invoker.getInterface().getName() + "." + invocation.getMethodName();
            //如果未打印
            if (!logged.contains(key)) {
                logged.add(key);
                //点调用废弃方法的时候 打印错误日志
                if (invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.DEPRECATED_KEY, false)) {
                    LOGGER.error("The service method " + invoker.getInterface().getName() + "." + getMethodSignature(invocation) + " is DEPRECATED! Declare from " + invoker.getUrl());
                }
            }
            return invoker.invoke(invocation);
        }
    
        private String getMethodSignature(Invocation invocation) {
            StringBuilder buf = new StringBuilder(invocation.getMethodName());
            buf.append("(");
            Class<?>[] types = invocation.getParameterTypes();
            if (types != null && types.length > 0) {
                boolean first = true;
                for (Class<?> type : types) {
                    if (first) {
                        first = false;
                    } else {
                        buf.append(", ");
                    }
                    buf.append(type.getSimpleName());
                }
            }
            buf.append(")");
            return buf.toString();
        }
    
    }
  • 相关阅读:
    sharepoint部署
    继承实体类出现传值时值不能保留
    面试经历
    sharepoint更换数据库链接
    asp.net c# 打开新页面或页面跳转
    sharepoint中配置工作流
    AD添加组织单位
    常用正则表达式
    删除多级非空目录
    C#实现对Word文件读写
  • 原文地址:https://www.cnblogs.com/LQBlog/p/12505246.html
Copyright © 2011-2022 走看看