上一篇《Android Retrofit2.0 实现原理分析》我们分析了Retrofit2.0的实现原理,用到了AOP的方式,实现了注解的动态解析。
下面我们利用AOP的原理实现多模块的RPC通信。
工程目录
app module是client角色,rpc功能的调用者
apis 定义了rpc提供的所有接口,包含ITest1 、ITest2接口
rpc rpcservice模块,rpc功能的提供者,
module1实现了ITest1接口
module2实现了ITest2接口
public interface ITest1 {
void test1();
}
public interface ITest2 {
String test2();
}
ITest1和ITest2接口
public class MainAct