home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / rmi / server / RemoteRef.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  4.3 KB  |  127 lines

  1. /*
  2.  * @(#)RemoteRef.java    1.11 98/03/18
  3.  *
  4.  * Copyright 1996-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.rmi.server;
  16.  
  17. import java.rmi.*;
  18.  
  19. /**
  20.  * RemoteRef represents the handle for a remote object.
  21.  */
  22. public interface RemoteRef extends java.io.Externalizable {
  23.  
  24.     /* indicate compatibility with JDK 1.1.x version of class */
  25.     static final long serialVersionUID = 3632638527362204081L;
  26.  
  27.     /**
  28.      * Initialize the server package prefix: assumes that the
  29.      * implementation of server ref classes (e.g., UnicastRef,
  30.      * UnicastServerRef) are located in the package defined by the
  31.      * prefix.
  32.      */
  33.     final static String packagePrefix = "sun.rmi.server";
  34.  
  35.     /**
  36.      * Invoke a method. This form of delegating method invocation
  37.      * to the reference allows the reference to take care of
  38.      * setting up the connection to the remote host, marshaling
  39.      * some representation for the method and parameters, then
  40.      * communicating the method invocation to the remote host.
  41.      * This method either returns the result of a method invocation
  42.      * on the remote object which resides on the remote host or
  43.      * throws a RemoteException if the call failed or an
  44.      * application-level exception if the remote invocation throws
  45.      * an exception.
  46.      *    
  47.      * @param obj the object that contains the RemoteRef (e.g., the
  48.      *            RemoteStub for the object.
  49.      * @param method the method to be invoked
  50.      * @param params the parameter list
  51.      * @param opnum  a hash that may be used to represent the method
  52.      * @since JDK1.2
  53.      */
  54.     Object invoke(Remote obj,
  55.           java.lang.reflect.Method method,
  56.           Object[] params,
  57.           long opnum)
  58.     throws Exception;
  59.     
  60.     /**
  61.      * Creates an appropriate call object for a new remote method
  62.      * invocation on this object.  Passing operation array and index,
  63.      * allows the stubs generator to assign the operation indexes and
  64.      * interpret them. The remote reference may need the operation to
  65.      * encode in the call.
  66.      *
  67.      * @exception RemoteException if registry could not be contacted.
  68.      */
  69.     RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum, long hash) 
  70.     throws RemoteException;
  71.     
  72.     /**
  73.      * Executes the remote call.
  74.      * 
  75.      * Invoke will raise any "user" exceptions which
  76.      * should pass through and not be caught by the stub.  If any
  77.      * exception is raised during the remote invocation, invoke should
  78.      * take care of cleaning up the connection before raising the
  79.      * "user" or remote exception.
  80.      *
  81.      * @exception java.lang.Exception if a general exception occurs.
  82.      */
  83.     void invoke(RemoteCall call) throws Exception;
  84.     
  85.     /**
  86.      * Allows the remote reference to clean up (or reuse) the connection.
  87.      * Done should only be called if the invoke returns successfully
  88.      * (non-exceptionally) to the stub.
  89.      *
  90.      * @exception RemoteException if registry could not be contacted.
  91.      */
  92.     void done(RemoteCall call) throws RemoteException;
  93.     
  94.     /**
  95.      * Returns the class name of the ref type to be serialized onto
  96.      * the stream 'out'.
  97.      */
  98.     String getRefClass(java.io.ObjectOutput out);
  99.     
  100.     /**
  101.      * Returns a hashcode for a remote object.  Two remote object stubs
  102.      * that refer to the same remote object will have the same hash code
  103.      * (in order to support remote objects as keys in hash tables).
  104.      *
  105.      * @see        java.util.Hashtable
  106.      */
  107.     int remoteHashCode();
  108.  
  109.     /**
  110.      * Compares two remote objects for equality.
  111.      * Returns a boolean that indicates whether this remote object is
  112.      * equivalent to the specified Object. This method is used when a
  113.      * remote object is stored in a hashtable.
  114.      * @param    obj    the Object to compare with
  115.      * @return    true if these Objects are equal; false otherwise.
  116.      * @see        java.util.Hashtable
  117.      */
  118.     boolean remoteEquals(RemoteRef obj);
  119.  
  120.     /**
  121.      * Returns a String that represents the reference of this remote
  122.      * object.
  123.      */
  124.     String remoteToString();
  125.     
  126. }
  127.