1. /*
  2. * @(#)Registry.java 1.18 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.rmi.registry;
  8. import java.rmi.AccessException;
  9. import java.rmi.AlreadyBoundException;
  10. import java.rmi.NotBoundException;
  11. import java.rmi.Remote;
  12. import java.rmi.RemoteException;
  13. /**
  14. * <code>Registry</code> is a remote interface to a simple remote
  15. * object registry that provides methods for storing and retrieving
  16. * remote object references bound with arbitrary string names. The
  17. * <code>bind</code>, <code>unbind</code>, and <code>rebind</code>
  18. * methods are used to alter the name bindings in the registry, and
  19. * the <code>lookup</code> and <code>list</code> methods are used to
  20. * query the current name bindings.
  21. *
  22. * <p>In its typical usage, a <code>Registry</code> enables RMI client
  23. * bootstrapping: it provides a simple means for a client to obtain an
  24. * initial reference to a remote object. Therefore, a registry's
  25. * remote object implementation is typically exported with a
  26. * well-known address, such as with a well-known {@link
  27. * java.rmi.server.ObjID#REGISTRY_ID ObjID} and TCP port number
  28. * (default is {@link #REGISTRY_PORT 1099}).
  29. *
  30. * <p>The {@link LocateRegistry} class provides a programmatic API for
  31. * constructing a bootstrap reference to a <code>Registry</code> at a
  32. * remote address (see the static <code>getRegistry</code> methods)
  33. * and for creating and exporting a <code>Registry</code> in the
  34. * current VM on a particular local address (see the static
  35. * <code>createRegistry</code> methods).
  36. *
  37. * <p>A <code>Registry</code> implementation may choose to restrict
  38. * access to some or all of its methods (for example, methods that
  39. * mutate the registry's bindings may be restricted to calls
  40. * originating from the local host). If a <code>Registry</code>
  41. * method chooses to deny access for a given invocation, its
  42. * implementation may throw {@link java.rmi.AccessException}, which
  43. * (because it extends {@link java.rmi.RemoteException}) will be
  44. * wrapped in a {@link java.rmi.ServerException} when caught by a
  45. * remote client.
  46. *
  47. * <p>The names used for bindings in a <code>Registry</code> are pure
  48. * strings, not parsed. A service which stores its remote reference
  49. * in a <code>Registry</code> may wish to use a package name as a
  50. * prefix in the name binding to reduce the likelihood of name
  51. * collisions in the registry.
  52. *
  53. * @author Ann Wollrath
  54. * @author Peter Jones
  55. * @version 1.18, 03/12/19
  56. * @since JDK1.1
  57. * @see LocateRegistry
  58. */
  59. public interface Registry extends Remote {
  60. /** Well known port for registry. */
  61. public static final int REGISTRY_PORT = 1099;
  62. /**
  63. * Returns the remote reference bound to the specified
  64. * <code>name</code> in this registry.
  65. *
  66. * @param name the name for the remote reference to look up
  67. *
  68. * @return a reference to a remote object
  69. *
  70. * @throws NotBoundException if <code>name</code> is not currently bound
  71. *
  72. * @throws RemoteException if remote communication with the
  73. * registry failed; if exception is a <code>ServerException</code>
  74. * containing an <code>AccessException</code>, then the registry
  75. * denies the caller access to perform this operation
  76. *
  77. * @throws AccessException if this registry is local and it denies
  78. * the caller access to perform this operation
  79. *
  80. * @throws NullPointerException if <code>name</code> is <code>null</code>
  81. */
  82. public Remote lookup(String name)
  83. throws RemoteException, NotBoundException, AccessException;
  84. /**
  85. * Binds a remote reference to the specified <code>name</code> in
  86. * this registry.
  87. *
  88. * @param name the name to associate with the remote reference
  89. * @param obj a reference to a remote object (usually a stub)
  90. *
  91. * @throws AlreadyBoundException if <code>name</code> is already bound
  92. *
  93. * @throws RemoteException if remote communication with the
  94. * registry failed; if exception is a <code>ServerException</code>
  95. * containing an <code>AccessException</code>, then the registry
  96. * denies the caller access to perform this operation (if
  97. * originating from a non-local host, for example)
  98. *
  99. * @throws AccessException if this registry is local and it denies
  100. * the caller access to perform this operation
  101. *
  102. * @throws NullPointerException if <code>name</code> is
  103. * <code>null</code>, or if <code>obj</code> is <code>null</code>
  104. */
  105. public void bind(String name, Remote obj)
  106. throws RemoteException, AlreadyBoundException, AccessException;
  107. /**
  108. * Removes the binding for the specified <code>name</code> in
  109. * this registry.
  110. *
  111. * @param name the name of the binding to remove
  112. *
  113. * @throws NotBoundException if <code>name</code> is not currently bound
  114. *
  115. * @throws RemoteException if remote communication with the
  116. * registry failed; if exception is a <code>ServerException</code>
  117. * containing an <code>AccessException</code>, then the registry
  118. * denies the caller access to perform this operation (if
  119. * originating from a non-local host, for example)
  120. *
  121. * @throws AccessException if this registry is local and it denies
  122. * the caller access to perform this operation
  123. *
  124. * @throws NullPointerException if <code>name</code> is <code>null</code>
  125. */
  126. public void unbind(String name)
  127. throws RemoteException, NotBoundException, AccessException;
  128. /**
  129. * Replaces the binding for the specified <code>name</code> in
  130. * this registry with the supplied remote reference. If there is
  131. * an existing binding for the specified <code>name</code>, it is
  132. * discarded.
  133. *
  134. * @param name the name to associate with the remote reference
  135. * @param obj a reference to a remote object (usually a stub)
  136. *
  137. * @throws RemoteException if remote communication with the
  138. * registry failed; if exception is a <code>ServerException</code>
  139. * containing an <code>AccessException</code>, then the registry
  140. * denies the caller access to perform this operation (if
  141. * originating from a non-local host, for example)
  142. *
  143. * @throws AccessException if this registry is local and it denies
  144. * the caller access to perform this operation
  145. *
  146. * @throws NullPointerException if <code>name</code> is
  147. * <code>null</code>, or if <code>obj</code> is <code>null</code>
  148. */
  149. public void rebind(String name, Remote obj)
  150. throws RemoteException, AccessException;
  151. /**
  152. * Returns an array of the names bound in this registry. The
  153. * array will contain a snapshot of the names bound in this
  154. * registry at the time of the given invocation of this method.
  155. *
  156. * @return an array of the names bound in this registry
  157. *
  158. * @throws RemoteException if remote communication with the
  159. * registry failed; if exception is a <code>ServerException</code>
  160. * containing an <code>AccessException</code>, then the registry
  161. * denies the caller access to perform this operation
  162. *
  163. * @throws AccessException if this registry is local and it denies
  164. * the caller access to perform this operation
  165. */
  166. public String[] list() throws RemoteException, AccessException;
  167. }