download:《極客時間》RPC實戰與核心原理php
package com.wgs.rpc.test;public interface HelloService {String hello(String name);}
package com.wgs.rpc.test;public class HelloServiceImpl implements HelloService {@Overridepublic String hello(String name) {return "name : " + name;}}
package com.wgs.rpc.test;import com.wgs.rpc.framework.RPCFramework;public class RPCProvider {public static void main(String[] args) throws Exception {HelloService service = new HelloServiceImpl();RPCFramework.export(service, 8989);}}
package com.wgs.rpc.test;import com.wgs.rpc.framework.RPCFramework;public class RPCProvider {public static void main(String[] args) throws Exception {HelloService service = new HelloServiceImpl();RPCFramework.export(service, 8989);}}
最後先運行服務端再運行客戶端,便可打印出」name : Hello First RPC!」.app