1. /*
  2. * @(#)Registry.java 1.13 00/02/02
  3. *
  4. * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.rmi.registry;
  11. import java.rmi.*;
  12. /**
  13. * For obtaining references to remote objects, RMI provides a simple
  14. * remote object registry interface, implemented by RMI's
  15. * <code>rmiregistry</code>, that provides methods for storing and retrieving
  16. * remote object references. The <code>java.rmi.Naming</code> class
  17. * provides methods to access a remote object registry using URL-formatted
  18. * names to specify in a compact format both the remote registry along
  19. * with the name for the remote object.
  20. *
  21. * <p>Typically a "registry" exists on every node that allows RMI connections
  22. * to servers on that node. A registry on a particular node contains a
  23. * transient database that maps names to remote objects. When a registry
  24. * starts up, the registry database is empty. The names stored in the
  25. * registry are pure and are not parsed. A service storing itself in the
  26. * registry may want to prefix its name of the service by a package name
  27. * (although not required), to reduce name collisions in the registry.
  28. *
  29. * <p>To create a registry that runs in an application, use one of the
  30. * <code>LocateRegistry.createRegistry</code> methods. To obtain a reference
  31. * to a remote object registry, use one of the
  32. * <code>LocateRegistry.getRegistry</code> methods.
  33. *
  34. * @version 1.13, 02/02/00
  35. * @author Ann Wollrath
  36. * @since JDK1.1
  37. * @see java.rmi.Naming
  38. * @see java.rmi.registry.LocateRegistry
  39. */
  40. public interface Registry extends Remote {
  41. /** Well known port for registry. */
  42. public static final int REGISTRY_PORT = 1099;
  43. /**
  44. * Returns a reference, a stub, for the remote object associated
  45. * with the specified <code>name</code>.
  46. *
  47. * @param name a URL-formatted name for the remote object
  48. * @return a reference for a remote object
  49. * @exception NotBoundException if name is not currently bound
  50. * @exception RemoteException if registry could not be contacted
  51. * @exception AccessException if this operation is not permitted (if
  52. * originating from a non-local host, for example)
  53. * @since JDK1.1
  54. */
  55. public Remote lookup(String name)
  56. throws RemoteException, NotBoundException, AccessException;
  57. /**
  58. * Binds the specified <code>name</code> to a remote object.
  59. *
  60. * @param name a URL-formatted name for the remote object
  61. * @param obj a reference for the remote object (usually a stub)
  62. * @exception AlreadyBoundException if name is already bound
  63. * @exception MalformedURLException if the name is not an appropriately
  64. * formatted URL
  65. * @exception RemoteException if registry could not be contacted
  66. * @exception AccessException if this operation is not permitted (if
  67. * originating from a non-local host, for example)
  68. * @since JDK1.1
  69. */
  70. public void bind(String name, Remote obj)
  71. throws RemoteException, AlreadyBoundException, AccessException;
  72. /**
  73. * Destroys the binding for the specified name that is associated
  74. * with a remote object.
  75. *
  76. * @param name a URL-formatted name associated with a remote object
  77. * @exception NotBoundException if name is not currently bound
  78. * @exception MalformedURLException if the name is not an appropriately
  79. * formatted URL
  80. * @exception RemoteException if registry could not be contacted
  81. * @exception AccessException if this operation is not permitted (if
  82. * originating from a non-local host, for example)
  83. * @since JDK1.1
  84. */
  85. public void unbind(String name)
  86. throws RemoteException, NotBoundException, AccessException;
  87. /**
  88. * Rebinds the specified name to a new remote object. Any existing
  89. * binding for the name is replaced.
  90. *
  91. * @param name a URL-formatted name associated with the remote object
  92. * @param obj new remote object to associate with the name
  93. * @exception MalformedURLException if the name is not an appropriately
  94. * formatted URL
  95. * @exception RemoteException if registry could not be contacted
  96. * @exception AccessException if this operation is not permitted (if
  97. * originating from a non-local host, for example)
  98. * @since JDK1.1
  99. */
  100. public void rebind(String name, Remote obj)
  101. throws RemoteException, AccessException;
  102. /**
  103. * Returns an array of the names bound in the registry. The names are
  104. * URL-formatted strings. The array contains a snapshot of the names
  105. * present in the registry at the time of the call.
  106. *
  107. * @return an array of names (in the appropriate URL format) bound
  108. * in the registry
  109. * @exception RemoteException if registry could not be contacted
  110. * @exception AccessException if this operation is not permitted (if
  111. * originating from a non-local host, for example)
  112. * @since JDK1.1
  113. */
  114. public String[] list()
  115. throws RemoteException, AccessException;
  116. }