forked from JeffLi1993/java-core-learning-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRpcTest.java
More file actions
31 lines (27 loc) · 894 Bytes
/
RpcTest.java
File metadata and controls
31 lines (27 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package org.jee.rpc;
import java.io.IOException;
import java.net.InetSocketAddress;
/**
* 描述:RPC测试代码类
* Created by bysocket on 16/2/29.
*/
public class RpcTest {
public static void main(String[] args) {
// 启动服务提供者
new Thread(new Runnable() {
@Override
public void run() {
try {
RpcExporter.exporter("localhost",8088);
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
// 创建服务本地代理
RpcImporter<EchoService> importer = new RpcImporter<>();
// 从服务本地代理获取服务对象类
EchoService echo = importer.importer(EchoServiceImpl.class,new InetSocketAddress("localhost",8088));
System.out.println(echo.echo("Are you OK?"));
}
}