blob: bbfe08bc36dcf72d42e0e392aeab0c6625e2f7bd [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1996-2001 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25package java.rmi.registry;
26
27import java.rmi.AccessException;
28import java.rmi.AlreadyBoundException;
29import java.rmi.NotBoundException;
30import java.rmi.Remote;
31import java.rmi.RemoteException;
32
33/**
34 * <code>Registry</code> is a remote interface to a simple remote
35 * object registry that provides methods for storing and retrieving
36 * remote object references bound with arbitrary string names. The
37 * <code>bind</code>, <code>unbind</code>, and <code>rebind</code>
38 * methods are used to alter the name bindings in the registry, and
39 * the <code>lookup</code> and <code>list</code> methods are used to
40 * query the current name bindings.
41 *
42 * <p>In its typical usage, a <code>Registry</code> enables RMI client
43 * bootstrapping: it provides a simple means for a client to obtain an
44 * initial reference to a remote object. Therefore, a registry's
45 * remote object implementation is typically exported with a
46 * well-known address, such as with a well-known {@link
47 * java.rmi.server.ObjID#REGISTRY_ID ObjID} and TCP port number
48 * (default is {@link #REGISTRY_PORT 1099}).
49 *
50 * <p>The {@link LocateRegistry} class provides a programmatic API for
51 * constructing a bootstrap reference to a <code>Registry</code> at a
52 * remote address (see the static <code>getRegistry</code> methods)
53 * and for creating and exporting a <code>Registry</code> in the
54 * current VM on a particular local address (see the static
55 * <code>createRegistry</code> methods).
56 *
57 * <p>A <code>Registry</code> implementation may choose to restrict
58 * access to some or all of its methods (for example, methods that
59 * mutate the registry's bindings may be restricted to calls
60 * originating from the local host). If a <code>Registry</code>
61 * method chooses to deny access for a given invocation, its
62 * implementation may throw {@link java.rmi.AccessException}, which
63 * (because it extends {@link java.rmi.RemoteException}) will be
64 * wrapped in a {@link java.rmi.ServerException} when caught by a
65 * remote client.
66 *
67 * <p>The names used for bindings in a <code>Registry</code> are pure
68 * strings, not parsed. A service which stores its remote reference
69 * in a <code>Registry</code> may wish to use a package name as a
70 * prefix in the name binding to reduce the likelihood of name
71 * collisions in the registry.
72 *
73 * @author Ann Wollrath
74 * @author Peter Jones
75 * @since JDK1.1
76 * @see LocateRegistry
77 */
78public interface Registry extends Remote {
79
80 /** Well known port for registry. */
81 public static final int REGISTRY_PORT = 1099;
82
83 /**
84 * Returns the remote reference bound to the specified
85 * <code>name</code> in this registry.
86 *
87 * @param name the name for the remote reference to look up
88 *
89 * @return a reference to a remote object
90 *
91 * @throws NotBoundException if <code>name</code> is not currently 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
97 *
98 * @throws AccessException if this registry is local and it denies
99 * the caller access to perform this operation
100 *
101 * @throws NullPointerException if <code>name</code> is <code>null</code>
102 */
103 public Remote lookup(String name)
104 throws RemoteException, NotBoundException, AccessException;
105
106 /**
107 * Binds a remote reference to the specified <code>name</code> in
108 * this registry.
109 *
110 * @param name the name to associate with the remote reference
111 * @param obj a reference to a remote object (usually a stub)
112 *
113 * @throws AlreadyBoundException if <code>name</code> is already 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
125 * <code>null</code>, or if <code>obj</code> is <code>null</code>
126 */
127 public void bind(String name, Remote obj)
128 throws RemoteException, AlreadyBoundException, AccessException;
129
130 /**
131 * Removes the binding for the specified <code>name</code> in
132 * this registry.
133 *
134 * @param name the name of the binding to remove
135 *
136 * @throws NotBoundException if <code>name</code> is not currently bound
137 *
138 * @throws RemoteException if remote communication with the
139 * registry failed; if exception is a <code>ServerException</code>
140 * containing an <code>AccessException</code>, then the registry
141 * denies the caller access to perform this operation (if
142 * originating from a non-local host, for example)
143 *
144 * @throws AccessException if this registry is local and it denies
145 * the caller access to perform this operation
146 *
147 * @throws NullPointerException if <code>name</code> is <code>null</code>
148 */
149 public void unbind(String name)
150 throws RemoteException, NotBoundException, AccessException;
151
152 /**
153 * Replaces the binding for the specified <code>name</code> in
154 * this registry with the supplied remote reference. If there is
155 * an existing binding for the specified <code>name</code>, it is
156 * discarded.
157 *
158 * @param name the name to associate with the remote reference
159 * @param obj a reference to a remote object (usually a stub)
160 *
161 * @throws RemoteException if remote communication with the
162 * registry failed; if exception is a <code>ServerException</code>
163 * containing an <code>AccessException</code>, then the registry
164 * denies the caller access to perform this operation (if
165 * originating from a non-local host, for example)
166 *
167 * @throws AccessException if this registry is local and it denies
168 * the caller access to perform this operation
169 *
170 * @throws NullPointerException if <code>name</code> is
171 * <code>null</code>, or if <code>obj</code> is <code>null</code>
172 */
173 public void rebind(String name, Remote obj)
174 throws RemoteException, AccessException;
175
176 /**
177 * Returns an array of the names bound in this registry. The
178 * array will contain a snapshot of the names bound in this
179 * registry at the time of the given invocation of this method.
180 *
181 * @return an array of the names bound in this registry
182 *
183 * @throws RemoteException if remote communication with the
184 * registry failed; if exception is a <code>ServerException</code>
185 * containing an <code>AccessException</code>, then the registry
186 * denies the caller access to perform this operation
187 *
188 * @throws AccessException if this registry is local and it denies
189 * the caller access to perform this operation
190 */
191 public String[] list() throws RemoteException, AccessException;
192}