如何使用java RMI 包实现一个RPC
1.需要使用到的两个类:
java.rmi.server.UnicastRemoteObject类和java.rmi.Remote接口
1.Remote接口
源代码:
/**
* The <code>Remote</code> interface serves to identify interfaces whose
* methods may be invoked from a non-local virtual machine.
* */
public interface Remote {
}
Remote 接口用来确定一些接口,这些接口的方法将被远端虚拟机调用。
在远端客户端和本地的服务之间需要定义一个接口,这个接口将被作为通用接口来提供客户端使用。而这个通用的接口需要继承于Remote接口。
public interface RMIQueryStatus