public interface HelloService {
String sayHello(String name);
}
public class HelloServiceImpl implements HelloService {
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
public class Server {
public static void main(String[] args) {
TeaRpcServer server = new TeaRpcServer();
server.register(HelloService.class, new HelloServiceImpl());
server.start();
}
}
public class Client {
public static void main(String[] args) {
TeaRpcClient client = new TeaRpcClient();
HelloService helloService = client.getProxy(HelloService.class, "127.0.0.1", 8888);
String result = helloService.sayHello("Alice");
System.out.println(result);
}
}