[关闭]
@hengbao 2018-06-04T03:31:44.000000Z 字数 1197 阅读 1802

java.rmi.Remote接口简介

Java


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

  1. package java.rmi;
  2. /**
  3. * The <code>Remote</code> interface serves to identify interfaces whose
  4. * methods may be invoked from a non-local virtual machine. Any object that
  5. * is a remote object must directly or indirectly implement this interface.
  6. * Only those methods specified in a "remote interface", an interface that
  7. * extends <code>java.rmi.Remote</code> are available remotely.
  8. *
  9. * <p>Implementation classes can implement any number of remote interfaces and
  10. * can extend other remote implementation classes. RMI provides some
  11. * convenience classes that remote object implementations can extend which
  12. * facilitate remote object creation. These classes are
  13. * <code>java.rmi.server.UnicastRemoteObject</code> and
  14. * <code>java.rmi.activation.Activatable</code>.
  15. *
  16. * <p>For complete details on RMI, see the <a
  17. href=../../../platform/rmi/spec/rmiTOC.html>RMI Specification</a> which describes the RMI API and system.
  18. *
  19. * @since JDK1.1
  20. * @author Ann Wollrath
  21. * @see java.rmi.server.UnicastRemoteObject
  22. * @see java.rmi.activation.Activatable
  23. */
  24. public interface Remote {}

从英文中我们可以得知,Remote接口,只是标明该接口是会被远程调用的,而不是本地。当你需要编写这样的接口的时候,可以继承这个接口,然后写自己独有的接口方法,例如下面这样:

  1. public interface HavanaInterface extends Remote{
  2. public final String SERVICENAME = "havana";
  3. //打印歌词
  4. public void printLyric(MySong song) throws RemoteException;
  5. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注