001 /*
002 * Copyright 1996-2001 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package java.rmi.registry;
026
027 import java.rmi.AccessException;
028 import java.rmi.AlreadyBoundException;
029 import java.rmi.NotBoundException;
030 import java.rmi.Remote;
031 import java.rmi.RemoteException;
032
033 /**
034 * <code>Registry</code> is a remote interface to a simple remote
035 * object registry that provides methods for storing and retrieving
036 * remote object references bound with arbitrary string names. The
037 * <code>bind</code>, <code>unbind</code>, and <code>rebind</code>
038 * methods are used to alter the name bindings in the registry, and
039 * the <code>lookup</code> and <code>list</code> methods are used to
040 * query the current name bindings.
041 *
042 * <p>In its typical usage, a <code>Registry</code> enables RMI client
043 * bootstrapping: it provides a simple means for a client to obtain an
044 * initial reference to a remote object. Therefore, a registry's
045 * remote object implementation is typically exported with a
046 * well-known address, such as with a well-known {@link
047 * java.rmi.server.ObjID#REGISTRY_ID ObjID} and TCP port number
048 * (default is {@link #REGISTRY_PORT 1099}).
049 *
050 * <p>The {@link LocateRegistry} class provides a programmatic API for
051 * constructing a bootstrap reference to a <code>Registry</code> at a
052 * remote address (see the static <code>getRegistry</code> methods)
053 * and for creating and exporting a <code>Registry</code> in the
054 * current VM on a particular local address (see the static
055 * <code>createRegistry</code> methods).
056 *
057 * <p>A <code>Registry</code> implementation may choose to restrict
058 * access to some or all of its methods (for example, methods that
059 * mutate the registry's bindings may be restricted to calls
060 * originating from the local host). If a <code>Registry</code>
061 * method chooses to deny access for a given invocation, its
062 * implementation may throw {@link java.rmi.AccessException}, which
063 * (because it extends {@link java.rmi.RemoteException}) will be
064 * wrapped in a {@link java.rmi.ServerException} when caught by a
065 * remote client.
066 *
067 * <p>The names used for bindings in a <code>Registry</code> are pure
068 * strings, not parsed. A service which stores its remote reference
069 * in a <code>Registry</code> may wish to use a package name as a
070 * prefix in the name binding to reduce the likelihood of name
071 * collisions in the registry.
072 *
073 * @author Ann Wollrath
074 * @author Peter Jones
075 * @version 1.25, 07/05/05
076 * @since JDK1.1
077 * @see LocateRegistry
078 */
079 public interface Registry extends Remote {
080
081 /** Well known port for registry. */
082 public static final int REGISTRY_PORT = 1099;
083
084 /**
085 * Returns the remote reference bound to the specified
086 * <code>name</code> in this registry.
087 *
088 * @param name the name for the remote reference to look up
089 *
090 * @return a reference to a remote object
091 *
092 * @throws NotBoundException if <code>name</code> is not currently bound
093 *
094 * @throws RemoteException if remote communication with the
095 * registry failed; if exception is a <code>ServerException</code>
096 * containing an <code>AccessException</code>, then the registry
097 * denies the caller access to perform this operation
098 *
099 * @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 <code>null</code>
103 */
104 public Remote lookup(String name) throws RemoteException,
105 NotBoundException, AccessException;
106
107 /**
108 * Binds a remote reference to the specified <code>name</code> in
109 * this registry.
110 *
111 * @param name the name to associate with the remote reference
112 * @param obj a reference to a remote object (usually a stub)
113 *
114 * @throws AlreadyBoundException if <code>name</code> is already bound
115 *
116 * @throws RemoteException if remote communication with the
117 * registry failed; if exception is a <code>ServerException</code>
118 * containing an <code>AccessException</code>, then the registry
119 * denies the caller access to perform this operation (if
120 * originating from a non-local host, for example)
121 *
122 * @throws AccessException if this registry is local and it denies
123 * the caller access to perform this operation
124 *
125 * @throws NullPointerException if <code>name</code> is
126 * <code>null</code>, or if <code>obj</code> is <code>null</code>
127 */
128 public void bind(String name, Remote obj) throws RemoteException,
129 AlreadyBoundException, AccessException;
130
131 /**
132 * Removes the binding for the specified <code>name</code> in
133 * this registry.
134 *
135 * @param name the name of the binding to remove
136 *
137 * @throws NotBoundException if <code>name</code> is not currently bound
138 *
139 * @throws RemoteException if remote communication with the
140 * registry failed; if exception is a <code>ServerException</code>
141 * containing an <code>AccessException</code>, then the registry
142 * denies the caller access to perform this operation (if
143 * originating from a non-local host, for example)
144 *
145 * @throws AccessException if this registry is local and it denies
146 * the caller access to perform this operation
147 *
148 * @throws NullPointerException if <code>name</code> is <code>null</code>
149 */
150 public void unbind(String name) throws RemoteException,
151 NotBoundException, AccessException;
152
153 /**
154 * Replaces the binding for the specified <code>name</code> in
155 * this registry with the supplied remote reference. If there is
156 * an existing binding for the specified <code>name</code>, it is
157 * discarded.
158 *
159 * @param name the name to associate with the remote reference
160 * @param obj a reference to a remote object (usually a stub)
161 *
162 * @throws RemoteException if remote communication with the
163 * registry failed; if exception is a <code>ServerException</code>
164 * containing an <code>AccessException</code>, then the registry
165 * denies the caller access to perform this operation (if
166 * originating from a non-local host, for example)
167 *
168 * @throws AccessException if this registry is local and it denies
169 * the caller access to perform this operation
170 *
171 * @throws NullPointerException if <code>name</code> is
172 * <code>null</code>, or if <code>obj</code> is <code>null</code>
173 */
174 public void rebind(String name, Remote obj) throws RemoteException,
175 AccessException;
176
177 /**
178 * Returns an array of the names bound in this registry. The
179 * array will contain a snapshot of the names bound in this
180 * registry at the time of the given invocation of this method.
181 *
182 * @return an array of the names bound in this registry
183 *
184 * @throws RemoteException if remote communication with the
185 * registry failed; if exception is a <code>ServerException</code>
186 * containing an <code>AccessException</code>, then the registry
187 * denies the caller access to perform this operation
188 *
189 * @throws AccessException if this registry is local and it denies
190 * the caller access to perform this operation
191 */
192 public String[] list() throws RemoteException, AccessException;
193 }
|