Java Code Examples for com.alibaba.dubbo.rpc.Exporter#getInvoker()

The following examples show how to use com.alibaba.dubbo.rpc.Exporter#getInvoker() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InvokeTelnetHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) {
    Invoker<?> invoker = exporter.getInvoker();
    Method[] methods = invoker.getInterface().getMethods();
    Method invokeMethod = null;
    for (Method m : methods) {
        if (m.getName().equals(method) && m.getParameterTypes().length == args.size()) {
            if (invokeMethod != null) { // 重载
                if (isMatch(invokeMethod.getParameterTypes(), args)) {
                    invokeMethod = m;
                    break;
                }
            } else {
                invokeMethod = m;
            }
            invoker = exporter.getInvoker();
        }
    }
    return invokeMethod;
}
 
Example 2
Source File: InvokeTelnetHandler.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) {
    Invoker<?> invoker = exporter.getInvoker();
    Method[] methods = invoker.getInterface().getMethods();
    Method invokeMethod = null;
    for (Method m : methods) {
        if (m.getName().equals(method) && m.getParameterTypes().length == args.size()) {
            if (invokeMethod != null) { // 重载
                if (isMatch(invokeMethod.getParameterTypes(), args)) {
                    invokeMethod = m;
                    break;
                }
            } else {
                invokeMethod = m;
            }
            invoker = exporter.getInvoker();
        }
    }
    return invokeMethod;
}
 
Example 3
Source File: InvokeTelnetHandler.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) {
    Invoker<?> invoker = exporter.getInvoker();
    Method[] methods = invoker.getInterface().getMethods();
    Method invokeMethod = null;
    for (Method m : methods) {
        if (m.getName().equals(method) && m.getParameterTypes().length == args.size()) {
            if (invokeMethod != null) { // 重载
                if (isMatch(invokeMethod.getParameterTypes(), args)) {
                    invokeMethod = m;
                    break;
                }
            } else {
                invokeMethod = m;
            }
            invoker = exporter.getInvoker();
        }
    }
    return invokeMethod;
}
 
Example 4
Source File: InvokeTelnetHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) {
    Invoker<?> invoker = exporter.getInvoker();
    Method[] methods = invoker.getInterface().getMethods();
    Method invokeMethod = null;
    for (Method m : methods) {
        if (m.getName().equals(method) && m.getParameterTypes().length == args.size()) {
            if (invokeMethod != null) { // 重载
                if (isMatch(invokeMethod.getParameterTypes(), args)) {
                    invokeMethod = m;
                    break;
                }
            } else {
                invokeMethod = m;
            }
            invoker = exporter.getInvoker();
        }
    }
    return invokeMethod;
}
 
Example 5
Source File: InvokeTelnetHandler.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) {
    Invoker<?> invoker = exporter.getInvoker();
    Method[] methods = invoker.getInterface().getMethods();
    for (Method m : methods) {
        if (m.getName().equals(method) && isMatch(m.getParameterTypes(), args)) {
            return m;
        }
    }
    return null;
}
 
Example 6
Source File: InvokeTelnetHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) {
    Invoker<?> invoker = exporter.getInvoker();
    Method[] methods = invoker.getInterface().getMethods();
    for (Method m : methods) {
        if (m.getName().equals(method) && isMatch(m.getParameterTypes(), args)) {
            return m;
        }
    }
    return null;
}
 
Example 7
Source File: TraceTelnetHandler.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
@Override
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;
}
 
Example 8
Source File: TraceTelnetHandler.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 9
Source File: TraceTelnetHandler.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 10
Source File: TraceTelnetHandler.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 11
Source File: TraceTelnetHandler.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 12
Source File: TraceTelnetHandler.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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;
}