1. /*
  2. * @(#)RemoteRef.java 1.23 04/05/18
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.rmi.server;
  8. import java.rmi.*;
  9. /**
  10. * <code>RemoteRef</code> represents the handle for a remote object. A
  11. * <code>RemoteStub</code> uses a remote reference to carry out a
  12. * remote method invocation to a remote object.
  13. *
  14. * @version 1.23, 05/18/04
  15. * @author Ann Wollrath
  16. * @since JDK1.1
  17. * @see java.rmi.server.RemoteStub
  18. */
  19. public interface RemoteRef extends java.io.Externalizable {
  20. /** indicate compatibility with JDK 1.1.x version of class. */
  21. static final long serialVersionUID = 3632638527362204081L;
  22. /**
  23. * Initialize the server package prefix: assumes that the
  24. * implementation of server ref classes (e.g., UnicastRef,
  25. * UnicastServerRef) are located in the package defined by the
  26. * prefix.
  27. */
  28. final static String packagePrefix = "sun.rmi.server";
  29. /**
  30. * Invoke a method. This form of delegating method invocation
  31. * to the reference allows the reference to take care of
  32. * setting up the connection to the remote host, marshaling
  33. * some representation for the method and parameters, then
  34. * communicating the method invocation to the remote host.
  35. * This method either returns the result of a method invocation
  36. * on the remote object which resides on the remote host or
  37. * throws a RemoteException if the call failed or an
  38. * application-level exception if the remote invocation throws
  39. * an exception.
  40. *
  41. * @param obj the object that contains the RemoteRef (e.g., the
  42. * RemoteStub for the object.
  43. * @param method the method to be invoked
  44. * @param params the parameter list
  45. * @param opnum a hash that may be used to represent the method
  46. * @return result of remote method invocation
  47. * @exception Exception if any exception occurs during remote method
  48. * invocation
  49. * @since 1.2
  50. */
  51. Object invoke(Remote obj,
  52. java.lang.reflect.Method method,
  53. Object[] params,
  54. long opnum)
  55. throws Exception;
  56. /**
  57. * Creates an appropriate call object for a new remote method
  58. * invocation on this object. Passing operation array and index,
  59. * allows the stubs generator to assign the operation indexes and
  60. * interpret them. The remote reference may need the operation to
  61. * encode in the call.
  62. *
  63. * @since JDK1.1
  64. * @deprecated 1.2 style stubs no longer use this method. Instead of
  65. * using a sequence of method calls on the stub's the remote reference
  66. * (<code>newCall</code>, <code>invoke</code>, and <code>done</code>), a
  67. * stub uses a single method, <code>invoke(Remote, Method, Object[],
  68. * int)</code>, on the remote reference to carry out parameter
  69. * marshalling, remote method executing and unmarshalling of the return
  70. * value.
  71. *
  72. * @param obj remote stub through which to make call
  73. * @param op array of stub operations
  74. * @param opnum operation number
  75. * @param hash stub/skeleton interface hash
  76. * @return call object representing remote call
  77. * @throws RemoteException if failed to initiate new remote call
  78. * @see #invoke(Remote,java.lang.reflect.Method,Object[],long)
  79. */
  80. @Deprecated
  81. RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum, long hash)
  82. throws RemoteException;
  83. /**
  84. * Executes the remote call.
  85. *
  86. * Invoke will raise any "user" exceptions which
  87. * should pass through and not be caught by the stub. If any
  88. * exception is raised during the remote invocation, invoke should
  89. * take care of cleaning up the connection before raising the
  90. * "user" or remote exception.
  91. *
  92. * @since JDK1.1
  93. * @deprecated 1.2 style stubs no longer use this method. Instead of
  94. * using a sequence of method calls to the remote reference
  95. * (<code>newCall</code>, <code>invoke</code>, and <code>done</code>), a
  96. * stub uses a single method, <code>invoke(Remote, Method, Object[],
  97. * int)</code>, on the remote reference to carry out parameter
  98. * marshalling, remote method executing and unmarshalling of the return
  99. * value.
  100. *
  101. * @param call object representing remote call
  102. * @throws Exception if any exception occurs during remote method
  103. * @see #invoke(Remote,java.lang.reflect.Method,Object[],long)
  104. */
  105. @Deprecated
  106. void invoke(RemoteCall call) throws Exception;
  107. /**
  108. * Allows the remote reference to clean up (or reuse) the connection.
  109. * Done should only be called if the invoke returns successfully
  110. * (non-exceptionally) to the stub.
  111. *
  112. * @since JDK1.1
  113. * @deprecated 1.2 style stubs no longer use this method. Instead of
  114. * using a sequence of method calls to the remote reference
  115. * (<code>newCall</code>, <code>invoke</code>, and <code>done</code>), a
  116. * stub uses a single method, <code>invoke(Remote, Method, Object[],
  117. * int)</code>, on the remote reference to carry out parameter
  118. * marshalling, remote method executing and unmarshalling of the return
  119. * value.
  120. *
  121. * @param call object representing remote call
  122. * @throws RemoteException if remote error occurs during call cleanup
  123. * @see #invoke(Remote,java.lang.reflect.Method,Object[],long)
  124. */
  125. @Deprecated
  126. void done(RemoteCall call) throws RemoteException;
  127. /**
  128. * Returns the class name of the ref type to be serialized onto
  129. * the stream 'out'.
  130. * @param out the output stream to which the reference will be serialized
  131. * @return the class name (without package qualification) of the reference
  132. * type
  133. * @since JDK1.1
  134. */
  135. String getRefClass(java.io.ObjectOutput out);
  136. /**
  137. * Returns a hashcode for a remote object. Two remote object stubs
  138. * that refer to the same remote object will have the same hash code
  139. * (in order to support remote objects as keys in hash tables).
  140. *
  141. * @return remote object hashcode
  142. * @see java.util.Hashtable
  143. * @since JDK1.1
  144. */
  145. int remoteHashCode();
  146. /**
  147. * Compares two remote objects for equality.
  148. * Returns a boolean that indicates whether this remote object is
  149. * equivalent to the specified Object. This method is used when a
  150. * remote object is stored in a hashtable.
  151. * @param obj the Object to compare with
  152. * @return true if these Objects are equal; false otherwise.
  153. * @see java.util.Hashtable
  154. * @since JDK1.1
  155. */
  156. boolean remoteEquals(RemoteRef obj);
  157. /**
  158. * Returns a String that represents the reference of this remote
  159. * object.
  160. * @return string representing remote object reference
  161. * @since JDK1.1
  162. */
  163. String remoteToString();
  164. }