没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
因为要给百技上实训课,让新同学们自行实现一个简易 RPC 框架,在准备 PPT 时,就想写
个示例,发现原来一个 RPC 框架只要一个类,10 来分钟就可以写完了,虽然简陋,也晒晒:
Java 代码
1. /*
2. * Copyright 2011 Alibaba.com All right reserved. This software is the
3. * confidential and proprietary information of Alibaba.com ("Confidential
4. * Information"). You shall not disclose such Confidential Information and s
hall
5. * use it only in accordance with the terms of the license agreement you ent
ered
6. * into with Alibaba.com.
7. */
8. package com.alibaba.study.rpc.framework;
9.
10. import java.io.ObjectInputStream;
11. import java.io.ObjectOutputStream;
12. import java.lang.reflect.InvocationHandler;
13. import java.lang.reflect.Method;
14. import java.lang.reflect.Proxy;
15. import java.net.ServerSocket;
16. import java.net.Socket;
17.
18. /**
19. * RpcFramework
20. *
21. *
22. */
23. public class RpcFramework {
24.
25. /**
26. * 暴露服务
27. *
28. * @param service 服务实现
29. * @param port 服务端口
30. * @throws Exception
31. */
32. public static void export(final Object service, int port) throws Excepti
on {
33. if (service == null)
资源评论
小小哭包
- 粉丝: 1899
- 资源: 3854
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功