java.rmi.Remote接口简介

首先,如下为该接口的注释及代码:html

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 <a
 href=../../../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接口,只是标明该接口是会被远程调用的,而不是本地。当你须要编写这样的接口的时候,能够继承这个接口,而后写本身独有的接口方法,例以下面这样:java

public interface HavanaInterface extends Remote{
	public final String SERVICENAME = "havana";
	//打印歌词
	public void printLyric(MySong song) throws RemoteException;
}
相关文章
相关标签/搜索