home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / sun / rmi / transport / LiveRef.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-08  |  4.1 KB  |  163 lines

  1. package sun.rmi.transport;
  2.  
  3. import java.io.Externalizable;
  4. import java.io.IOException;
  5. import java.io.ObjectInput;
  6. import java.io.ObjectOutput;
  7. import java.rmi.RemoteException;
  8. import java.rmi.server.ObjID;
  9. import sun.rmi.transport.tcp.TCPEndpoint;
  10.  
  11. public class LiveRef implements Externalizable {
  12.    // $FF: renamed from: ep sun.rmi.transport.Endpoint
  13.    private transient Endpoint field_0;
  14.    // $FF: renamed from: id java.rmi.server.ObjID
  15.    private transient ObjID field_1;
  16.    // $FF: renamed from: ch sun.rmi.transport.Channel
  17.    private transient Channel field_2;
  18.    private transient boolean counted;
  19.    private transient boolean isLocal;
  20.  
  21.    private LiveRef(ObjID var1, Endpoint var2, Channel var3, boolean var4) {
  22.       this.counted = false;
  23.       this.isLocal = false;
  24.       this.field_0 = var2;
  25.       this.field_1 = var1;
  26.       this.field_2 = var3;
  27.       this.isLocal = var4;
  28.    }
  29.  
  30.    LiveRef copy() {
  31.       return new LiveRef(this.field_1, this.field_0, this.field_2, this.isLocal);
  32.    }
  33.  
  34.    public LiveRef(ObjID var1, Endpoint var2, boolean var3) {
  35.       this(var1, var2, (Channel)null, var3);
  36.    }
  37.  
  38.    public LiveRef() {
  39.       this.counted = false;
  40.       this.isLocal = false;
  41.    }
  42.  
  43.    public LiveRef(int var1) {
  44.       this(new ObjID(), var1);
  45.    }
  46.  
  47.    public int getPort() {
  48.       return ((TCPEndpoint)this.field_0).getPort();
  49.    }
  50.  
  51.    public LiveRef(ObjID var1, int var2) {
  52.       this(var1, TCPEndpoint.getLocalEndpoint(var2), true);
  53.    }
  54.  
  55.    public void exportObject(Target var1) throws RemoteException {
  56.       this.field_0.exportObject(this.field_1, var1);
  57.    }
  58.  
  59.    public Channel getChannel() throws RemoteException {
  60.       if (this.field_2 == null) {
  61.          this.field_2 = this.field_0.getChannel();
  62.       }
  63.  
  64.       return this.field_2;
  65.    }
  66.  
  67.    public ObjID getObjID() {
  68.       return this.field_1;
  69.    }
  70.  
  71.    Endpoint getEndpoint() {
  72.       return this.field_0;
  73.    }
  74.  
  75.    void counted() {
  76.       this.counted = true;
  77.    }
  78.  
  79.    public String toString() {
  80.       String var1;
  81.       if (this.isLocal) {
  82.          var1 = "local";
  83.       } else {
  84.          var1 = "remote";
  85.       }
  86.  
  87.       return "[endpoint:" + this.field_0 + "(" + var1 + ")," + "objID:" + this.field_1 + "]";
  88.    }
  89.  
  90.    public int hashCode() {
  91.       return this.field_1.hashCode();
  92.    }
  93.  
  94.    public boolean equals(Object var1) {
  95.       if (var1 instanceof LiveRef) {
  96.          LiveRef var2 = (LiveRef)var1;
  97.          return this.field_0.equals(var2.field_0) && this.field_1.equals(var2.field_1) && this.isLocal == var2.isLocal;
  98.       } else {
  99.          return false;
  100.       }
  101.    }
  102.  
  103.    public boolean remoteEquals(Object var1) {
  104.       if (var1 instanceof LiveRef) {
  105.          LiveRef var2 = (LiveRef)var1;
  106.          return this.field_0.equals(var2.field_0) && this.field_1.equals(var2.field_1);
  107.       } else {
  108.          return false;
  109.       }
  110.    }
  111.  
  112.    public void writeExternal(ObjectOutput var1) throws IOException {
  113.       boolean var2 = false;
  114.       if (var1 instanceof ConnectionOutputStream) {
  115.          ConnectionOutputStream var3 = (ConnectionOutputStream)var1;
  116.          if (this.isLocal) {
  117.             Target var4 = ObjectTable.getTarget(this.field_1);
  118.             if (var4 == null) {
  119.                throw new IOException("attempt to marshal unexported object reference: " + this);
  120.             }
  121.  
  122.             var4.pinImpl();
  123.          }
  124.  
  125.          var2 = var3.isResultStream();
  126.          if (var2) {
  127.             var3.saveRef(this);
  128.          }
  129.       }
  130.  
  131.       ((TCPEndpoint)this.field_0).write(var1);
  132.       this.field_1.write(var1);
  133.       var1.writeBoolean(var2);
  134.    }
  135.  
  136.    public void readExternal(ObjectInput var1) throws IOException, ClassNotFoundException {
  137.       this.field_0 = TCPEndpoint.read(var1);
  138.       this.field_1 = ObjID.read(var1);
  139.       boolean var2 = var1.readBoolean();
  140.       this.field_2 = null;
  141.       this.isLocal = false;
  142.       this.counted = false;
  143.       if (var1 instanceof ConnectionInputStream) {
  144.          ConnectionInputStream var3 = (ConnectionInputStream)var1;
  145.          var3.saveRef(this);
  146.          if (var2) {
  147.             var3.setAckNeeded();
  148.             return;
  149.          }
  150.       } else {
  151.          DGCClient.referenced(this);
  152.       }
  153.  
  154.    }
  155.  
  156.    public void finalize() throws Throwable {
  157.       if (!this.isLocal && !this.field_1.equals(DGCImpl.getID()) && this.counted) {
  158.          DGCClient.unreferenced(this);
  159.       }
  160.  
  161.    }
  162. }
  163.