jdk/src/share/classes/java/rmi/server/RemoteRef.java
author smarks
Thu, 24 Oct 2013 10:13:39 -0700
changeset 21359 2d32ce9ea2b4
parent 5506 202f599c92aa
child 24865 09b1d992ca72
permissions -rw-r--r--
8023862: deprecate HTTP proxying from RMI Reviewed-by: mchung
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, 2004, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.rmi.server;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.rmi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * <code>RemoteRef</code> represents the handle for a remote object. A
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * <code>RemoteStub</code> uses a remote reference to carry out a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * remote method invocation to a remote object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @author  Ann Wollrath
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @since   JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @see     java.rmi.server.RemoteStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
public interface RemoteRef extends java.io.Externalizable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    /** indicate compatibility with JDK 1.1.x version of class. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    static final long serialVersionUID = 3632638527362204081L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * Initialize the server package prefix: assumes that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * implementation of server ref classes (e.g., UnicastRef,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * UnicastServerRef) are located in the package defined by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * prefix.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    final static String packagePrefix = "sun.rmi.server";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * Invoke a method. This form of delegating method invocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * to the reference allows the reference to take care of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * setting up the connection to the remote host, marshaling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * some representation for the method and parameters, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * communicating the method invocation to the remote host.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * This method either returns the result of a method invocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * on the remote object which resides on the remote host or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * throws a RemoteException if the call failed or an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * application-level exception if the remote invocation throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param obj the object that contains the RemoteRef (e.g., the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     *            RemoteStub for the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @param method the method to be invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @param params the parameter list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @param opnum  a hash that may be used to represent the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @return result of remote method invocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @exception Exception if any exception occurs during remote method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * invocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    Object invoke(Remote obj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                  java.lang.reflect.Method method,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                  Object[] params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                  long opnum)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        throws Exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Creates an appropriate call object for a new remote method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * invocation on this object.  Passing operation array and index,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * allows the stubs generator to assign the operation indexes and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * interpret them. The remote reference may need the operation to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * encode in the call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @since JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @deprecated 1.2 style stubs no longer use this method. Instead of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * using a sequence of method calls on the stub's the remote reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * (<code>newCall</code>, <code>invoke</code>, and <code>done</code>), a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * stub uses a single method, <code>invoke(Remote, Method, Object[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * int)</code>, on the remote reference to carry out parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * marshalling, remote method executing and unmarshalling of the return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @param obj remote stub through which to make call
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param op array of stub operations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param opnum operation number
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @param hash stub/skeleton interface hash
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @return call object representing remote call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @throws RemoteException if failed to initiate new remote call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @see #invoke(Remote,java.lang.reflect.Method,Object[],long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum, long hash)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        throws RemoteException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * Executes the remote call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Invoke will raise any "user" exceptions which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * should pass through and not be caught by the stub.  If any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * exception is raised during the remote invocation, invoke should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * take care of cleaning up the connection before raising the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * "user" or remote exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @since JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @deprecated 1.2 style stubs no longer use this method. Instead of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * using a sequence of method calls to the remote reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * (<code>newCall</code>, <code>invoke</code>, and <code>done</code>), a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * stub uses a single method, <code>invoke(Remote, Method, Object[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * int)</code>, on the remote reference to carry out parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * marshalling, remote method executing and unmarshalling of the return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param call object representing remote call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @throws Exception if any exception occurs during remote method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @see #invoke(Remote,java.lang.reflect.Method,Object[],long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    void invoke(RemoteCall call) throws Exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Allows the remote reference to clean up (or reuse) the connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Done should only be called if the invoke returns successfully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * (non-exceptionally) to the stub.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @since JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @deprecated 1.2 style stubs no longer use this method. Instead of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * using a sequence of method calls to the remote reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * (<code>newCall</code>, <code>invoke</code>, and <code>done</code>), a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * stub uses a single method, <code>invoke(Remote, Method, Object[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * int)</code>, on the remote reference to carry out parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * marshalling, remote method executing and unmarshalling of the return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @param call object representing remote call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @throws RemoteException if remote error occurs during call cleanup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @see #invoke(Remote,java.lang.reflect.Method,Object[],long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    void done(RemoteCall call) throws RemoteException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * Returns the class name of the ref type to be serialized onto
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * the stream 'out'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @param out the output stream to which the reference will be serialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @return the class name (without package qualification) of the reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @since JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    String getRefClass(java.io.ObjectOutput out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * Returns a hashcode for a remote object.  Two remote object stubs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * that refer to the same remote object will have the same hash code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * (in order to support remote objects as keys in hash tables).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @return remote object hashcode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @see             java.util.Hashtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @since JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    int remoteHashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * Compares two remote objects for equality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * Returns a boolean that indicates whether this remote object is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * equivalent to the specified Object. This method is used when a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * remote object is stored in a hashtable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @param   obj     the Object to compare with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @return  true if these Objects are equal; false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @see             java.util.Hashtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @since JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    boolean remoteEquals(RemoteRef obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * Returns a String that represents the reference of this remote
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @return string representing remote object reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @since JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    String remoteToString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
}