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