@hengbao
2018-06-04T03:31:44.000000Z
字数 1197
阅读 1870
Java
首先,以下为该接口的注释及代码:
package java.rmi;/*** The <code>Remote</code> interface serves to identify interfaces whose* methods may be invoked from a non-local virtual machine. Any object that* is a remote object must directly or indirectly implement this interface.* Only those methods specified in a "remote interface", an interface that* extends <code>java.rmi.Remote</code> are available remotely.** <p>Implementation classes can implement any number of remote interfaces and* can extend other remote implementation classes. RMI provides some* convenience classes that remote object implementations can extend which* facilitate remote object creation. These classes are* <code>java.rmi.server.UnicastRemoteObject</code> and* <code>java.rmi.activation.Activatable</code>.** <p>For complete details on RMI, see the <ahref=../../../platform/rmi/spec/rmiTOC.html>RMI Specification</a> which describes the RMI API and system.** @since JDK1.1* @author Ann Wollrath* @see java.rmi.server.UnicastRemoteObject* @see java.rmi.activation.Activatable*/public interface Remote {}
从英文中我们可以得知,Remote接口,只是标明该接口是会被远程调用的,而不是本地。当你需要编写这样的接口的时候,可以继承这个接口,然后写自己独有的接口方法,例如下面这样:
public interface HavanaInterface extends Remote{public final String SERVICENAME = "havana";//打印歌词public void printLyric(MySong song) throws RemoteException;}