home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / sun / rmi / server / UnicastRef.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  3.3 KB  |  115 lines

  1. package sun.rmi.server;
  2.  
  3. import java.io.IOException;
  4. import java.io.ObjectInput;
  5. import java.io.ObjectOutput;
  6. import java.io.Serializable;
  7. import java.rmi.RemoteException;
  8. import java.rmi.server.LogStream;
  9. import java.rmi.server.Operation;
  10. import java.rmi.server.RemoteCall;
  11. import java.rmi.server.RemoteObject;
  12. import java.rmi.server.RemoteRef;
  13. import sun.rmi.transport.Connection;
  14. import sun.rmi.transport.LiveRef;
  15. import sun.rmi.transport.StreamRemoteCall;
  16.  
  17. public class UnicastRef implements RemoteRef, Serializable {
  18.    protected LiveRef ref;
  19.  
  20.    public UnicastRef() {
  21.    }
  22.  
  23.    public UnicastRef(LiveRef var1) {
  24.       this.ref = var1;
  25.    }
  26.  
  27.    public RemoteCall newCall(RemoteObject var1, Operation[] var2, int var3, long var4) throws RemoteException {
  28.       if (RemoteProxy.logLevel >= 10) {
  29.          LogStream.log("transport").println("UnicastRef.newCall: get connection");
  30.       }
  31.  
  32.       Connection var6 = this.ref.getChannel().newConnection();
  33.  
  34.       try {
  35.          if (RemoteProxy.logLevel >= 20) {
  36.             LogStream.log("transport").println("UnicastRef.newCall: create call");
  37.          }
  38.  
  39.          StreamRemoteCall var7 = new StreamRemoteCall(var6, this.ref.getObjID(), var3, var4);
  40.          return var7;
  41.       } catch (RemoteException var8) {
  42.          this.ref.getChannel().free(var6, false);
  43.          throw var8;
  44.       }
  45.    }
  46.  
  47.    public void invoke(RemoteCall var1) throws Exception {
  48.       try {
  49.          if (RemoteProxy.logLevel >= 20) {
  50.             LogStream.log("transport").println("UnicastRef.invoke: execute call");
  51.          }
  52.  
  53.          var1.executeCall();
  54.       } catch (RemoteException var4) {
  55.          if (RemoteProxy.logLevel >= 10) {
  56.             LogStream.log("transport").println("UnicastRef.invoke: exception occurred " + var4.getMessage());
  57.          }
  58.  
  59.          Connection var6 = ((StreamRemoteCall)var1).getConnection();
  60.          this.ref.getChannel().free(var6, false);
  61.          throw var4;
  62.       } catch (Exception var5) {
  63.          if (RemoteProxy.logLevel >= 10) {
  64.             LogStream.log("transport").println("UnicastRef.invoke: exception occurred " + ((Throwable)var5).getMessage());
  65.          }
  66.  
  67.          Connection var3 = ((StreamRemoteCall)var1).getConnection();
  68.          this.ref.getChannel().free(var3, true);
  69.          throw var5;
  70.       }
  71.    }
  72.  
  73.    public void done(RemoteCall var1) throws RemoteException {
  74.       boolean var2 = true;
  75.  
  76.       try {
  77.          var1.done();
  78.       } catch (IOException var4) {
  79.          var2 = false;
  80.       }
  81.  
  82.       if (RemoteProxy.logLevel >= 10) {
  83.          LogStream.log("transport").println("UnicastRef.done: free connection (reuse = " + var2 + ")");
  84.       }
  85.  
  86.       Connection var3 = ((StreamRemoteCall)var1).getConnection();
  87.       this.ref.getChannel().free(var3, var2);
  88.    }
  89.  
  90.    public String getRefClass(ObjectOutput var1) {
  91.       return "UnicastRef";
  92.    }
  93.  
  94.    public void writeExternal(ObjectOutput var1) throws IOException {
  95.       this.ref.writeExternal(var1);
  96.    }
  97.  
  98.    public void readExternal(ObjectInput var1) throws IOException, ClassNotFoundException {
  99.       this.ref = new LiveRef();
  100.       this.ref.readExternal(var1);
  101.    }
  102.  
  103.    public String remoteToString() {
  104.       return "RemoteStub [ref: " + this.ref + "]";
  105.    }
  106.  
  107.    public int remoteHashCode() {
  108.       return this.ref.hashCode();
  109.    }
  110.  
  111.    public boolean remoteEquals(RemoteRef var1) {
  112.       return var1 instanceof UnicastRef ? this.ref.remoteEquals(((UnicastRef)var1).ref) : false;
  113.    }
  114. }
  115.