DUBBO 泛化调用
来源:互联网 发布:js 获取div value值 编辑:程序博客网 时间:2024/06/05 19:40
什么是泛化调用?
说白一点就是服务消费者并没有服务的接口。
先定义一个简单的接口
public interface EasyCommonService { public String helloService(String name); }
接口的具体实现
public class EasyCommonServiceImpl implements EasyCommonService { public String helloService(String name) { System.out.println("name is "+ name); return "hello " + name; } }
服务端的spring配置文件
<?xml version="1.1" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <dubbo:application owner="lyncc" name="bazinga-app" /> <!--zookeeper注册中心 --> <dubbo:registry protocol="zookeeper" address="127.0.0.1:2181"/> <dubbo:protocol name ="dubbo" port="20880" /> <bean id="easyCommonService" class="org.bazinga.service.impl.EasyCommonServiceImpl" /> <dubbo:service interface="org.bazinga.service.EasyCommonService" ref="easyCommonService" /> </beans>
<?xml version="1.1" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <dubbo:application owner="lyncc" name="bazinga-consumer" /> <!--zookeeper注册中心 --> <dubbo:registry protocol="zookeeper" address="127.0.0.1:2181"/> <dubbo:reference id="easyCommonService" interface="org.bazinga.service.EasyCommonService" generic="true"/> </beans>
有两点需要注意:第一个是interface,其实该接口在消费者并不存在,第二个地方需要注意的地方就是generic="true",表示该接口支持泛型调用。
public class DubboConsumerGenericService { public static void main(String[] args) { /////////////////Spring泛化调用///////// ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "spring-dubbo-consumer-generic.xml"); context.start(); GenericService easyCommonService = (GenericService) context.getBean("easyCommonService"); Object result = easyCommonService.$invoke("helloService", new String[] { "java.lang.String" }, new Object[] { "hello" }); System.out.println(result); } }
0 0
- DUBBO 泛化调用
- dubbo泛化调用
- dubbo泛化调用和泛化引用
- dubbo泛化调用 http接口 随意调用dubbo服务
- Dubbo-泛化引用
- Dubbo泛化实现
- Dubbo泛化引用
- hsf dubbo学习六--泛化,回声测试,上下文信息,隐式传参,异步调用,本地调用
- dubbo泛化处理(转)
- 11.dubbo结果缓存、泛化引用、泛化实现
- Dubbox 基本特性之泛化调用
- 远程调用框架dubbo
- 远程调用框架dubbo
- dubbo 同步调用
- dubbo容器-客户端调用
- Dubbo异步调用
- 远程调用框架dubbo
- 命令行调用dubbo服务
- Java注解之@Inherited
- 基于TensorFlow开发人脸识别
- Codeforces Round #180 (Div. 1) B
- 文件描述符 与 文件流 的关系
- 大数因数分解pollard rho
- DUBBO 泛化调用
- CDH大数据平台实施经验总结2016
- React Native 集成高德地图
- python学习之路七--函数
- html 强制不换行
- Sphinx参考手册(四)
- 全国市级城市拼音-中文对照表(json格式)
- greenplum启动报错gpstart error: Catalog Versions are incompatible
- TextView显示行数问题