本文整理汇总了Java中com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter类的典型用法代码示例。如果您正苦于以下问题:Java TraceFilter类的具体用法?Java TraceFilter怎么用?Java TraceFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TraceFilter类属于com.alibaba.dubbo.rpc.protocol.dubbo.filter包,在下文中一共展示了TraceFilter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: telnet
import com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter; //导入依赖的package包/类
public String telnet(Channel channel, String message) {
String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
if ((service == null || service.length() == 0)
&& (message == null || message.length() == 0)) {
return "Please input service name, eg: \r\ntrace XxxService\r\ntrace XxxService xxxMethod\r\ntrace XxxService xxxMethod 10\r\nor \"cd XxxService\" firstly.";
}
String[] parts = message.split("\\s+");
String method;
String times;
if (service == null || service.length() == 0) {
service = parts.length > 0 ? parts[0] : null;
method = parts.length > 1 ? parts[1] : null;
} else {
method = parts.length > 0 ? parts[0] : null;
}
if (StringUtils.isInteger(method)) {
times = method;
method = null;
} else {
times = parts.length > 2 ? parts[2] : "1";
}
if (! StringUtils.isInteger(times)) {
return "Illegal times " + times + ", must be integer.";
}
Invoker<?> invoker = null;
for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
if (service.equals(exporter.getInvoker().getInterface().getSimpleName())
|| service.equals(exporter.getInvoker().getInterface().getName())
|| service.equals(exporter.getInvoker().getUrl().getPath())) {
invoker = exporter.getInvoker();
break;
}
}
if (invoker != null) {
if (method != null && method.length() > 0) {
boolean found = false;
for (Method m : invoker.getInterface().getMethods()) {
if (m.getName().equals(method)) {
found = true;
break;
}
}
if (! found) {
return "No such method " + method + " in class " + invoker.getInterface().getName();
}
}
TraceFilter.addTracer(invoker.getInterface(), method, channel, Integer.parseInt(times));
} else {
return "No such service " + service;
}
return null;
}
示例2: telnet
import com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter; //导入依赖的package包/类
public String telnet(Channel channel, String message) {
String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
if ((service == null || service.length() == 0)
&& (message == null || message.length() == 0)) {
return "Please input service name, eg: \r\ntrace XxxService\r\ntrace XxxService xxxMethod\r\ntrace XxxService xxxMethod 10\r\nor \"cd XxxService\" firstly.";
}
String[] parts = message.split("\\s+");
String method;
String times;
if (service == null || service.length() == 0) {
service = parts.length > 0 ? parts[0] : null;
method = parts.length > 1 ? parts[1] : null;
} else {
method = parts.length > 0 ? parts[0] : null;
}
if (StringUtils.isInteger(method)) {
times = method;
method = null;
} else {
times = parts.length > 2 ? parts[2] : "1";
}
if (!StringUtils.isInteger(times)) {
return "Illegal times " + times + ", must be integer.";
}
Invoker<?> invoker = null;
for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
if (service.equals(exporter.getInvoker().getInterface().getSimpleName())
|| service.equals(exporter.getInvoker().getInterface().getName())
|| service.equals(exporter.getInvoker().getUrl().getPath())) {
invoker = exporter.getInvoker();
break;
}
}
if (invoker != null) {
if (method != null && method.length() > 0) {
boolean found = false;
for (Method m : invoker.getInterface().getMethods()) {
if (m.getName().equals(method)) {
found = true;
break;
}
}
if (!found) {
return "No such method " + method + " in class " + invoker.getInterface().getName();
}
}
TraceFilter.addTracer(invoker.getInterface(), method, channel, Integer.parseInt(times));
} else {
return "No such service " + service;
}
return null;
}