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