You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "gudegg (GitHub)" <gi...@apache.org> on 2019/01/07 13:30:52 UTC

[GitHub] [incubator-dubbo] gudegg commented on issue #3161: Telnet 提供命令能否通过代码或泛化调用直接调用而不必通过 Telnet 协议

> > > 不知道我是否理解你的意思了。
> > > 因为你说你有 ReferenceConfig ,所以我觉得可以通过反射来获取到你想调用方法的参数类型。
> > > ```
> > >  Method[] methods = ReferenceConfig.getInterfaceClass().getMethods();
> > >         for (Method method : methods) {
> > >             Class<?>[] parameter = method.getParameterTypes();
> > >         }
> > > ```
> > 
> > 
> > 没有,这个是通过泛型引用创建的,里面只有 `$invoke` 这个方法
> > <img alt="2019-01-07 7 40 37" width="987" src="https://user-images.githubusercontent.com/4575409/50766444-325ed600-12b4-11e9-98db-623d1d8bd429.png">
> 
> 没使用过泛化调用,但是我看了一下文档
> 
> ```
> ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>(); 
> // 弱类型接口名
> reference.setInterface("com.xxx.XxxService");  
> reference.setVersion("1.0.0");
> // 声明为泛化接口 
> reference.setGeneric(true);  
> ```
> 你已经获取到了需要调用的接口类型 也就是 "com.xxx.XxxService”, 反射它就好了。

泛化调用端不一定`com.xxx.XxxService`接口,反射是不可靠的。像一般dubbo泛化用于网关建设,是不存在当前接口架包的

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3161 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org