home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / sun / rmi / server / ActivatableRef.class (.txt) next >
Encoding:
Java Class File  |  1979-12-31  |  4.7 KB  |  199 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.lang.reflect.Method;
  7. import java.rmi.ConnectException;
  8. import java.rmi.ConnectIOException;
  9. import java.rmi.MarshalException;
  10. import java.rmi.NoSuchObjectException;
  11. import java.rmi.Remote;
  12. import java.rmi.RemoteException;
  13. import java.rmi.ServerError;
  14. import java.rmi.ServerException;
  15. import java.rmi.StubNotFoundException;
  16. import java.rmi.UnknownHostException;
  17. import java.rmi.UnmarshalException;
  18. import java.rmi.activation.ActivateFailedException;
  19. import java.rmi.activation.ActivationDesc;
  20. import java.rmi.activation.ActivationID;
  21. import java.rmi.activation.UnknownObjectException;
  22. import java.rmi.server.Operation;
  23. import java.rmi.server.RMIClassLoader;
  24. import java.rmi.server.RemoteCall;
  25. import java.rmi.server.RemoteObject;
  26. import java.rmi.server.RemoteRef;
  27. import java.rmi.server.RemoteStub;
  28.  
  29. public class ActivatableRef implements RemoteRef {
  30.    // $FF: renamed from: id java.rmi.activation.ActivationID
  31.    protected ActivationID field_0;
  32.    protected RemoteRef ref;
  33.    transient boolean force = false;
  34.    private static final int MAX_RETRIES = 3;
  35.    private static final String versionComplaint = "activation requires 1.2 stubs";
  36.  
  37.    public ActivatableRef() {
  38.    }
  39.  
  40.    public ActivatableRef(ActivationID var1, RemoteRef var2) {
  41.       this.field_0 = var1;
  42.       this.ref = var2;
  43.    }
  44.  
  45.    public static RemoteStub getStub(ActivationDesc var0, ActivationID var1) throws StubNotFoundException {
  46.       String var2 = var0.getClassName();
  47.  
  48.       try {
  49.          Class var3 = RMIClassLoader.loadClass(var0.getLocation(), var2);
  50.          Class var4 = RemoteProxy.getRemoteClass(var3);
  51.          return RemoteProxy.getStub(var4.getName(), var4, new ActivatableRef(var1, (RemoteRef)null));
  52.       } catch (Exception var5) {
  53.          throw new StubNotFoundException("unable to load class: " + var2, var5);
  54.       }
  55.    }
  56.  
  57.    public Object invoke(Remote var1, Method var2, Object[] var3, long var4) throws Exception {
  58.       boolean var6 = false;
  59.       Object var8 = null;
  60.       RemoteRef var7;
  61.       synchronized(this) {
  62.          if (this.ref == null) {
  63.             var7 = this.activate(var6);
  64.             var6 = true;
  65.          } else {
  66.             var7 = this.ref;
  67.          }
  68.       }
  69.  
  70.       for(int var10 = 3; var10 > 0; --var10) {
  71.          try {
  72.             return var7.invoke(var1, var2, var3, var4);
  73.          } catch (NoSuchObjectException var24) {
  74.             var8 = var24;
  75.          } catch (ConnectException var25) {
  76.             var8 = var25;
  77.          } catch (UnknownHostException var26) {
  78.             var8 = var26;
  79.          } catch (ConnectIOException var27) {
  80.             var8 = var27;
  81.          } catch (MarshalException var28) {
  82.             throw var28;
  83.          } catch (ServerError var29) {
  84.             throw var29;
  85.          } catch (ServerException var30) {
  86.             throw var30;
  87.          } catch (RemoteException var31) {
  88.             synchronized(this) {
  89.                if (var7 == this.ref) {
  90.                   this.ref = null;
  91.                }
  92.             }
  93.  
  94.             throw var31;
  95.          }
  96.  
  97.          if (var10 > 1) {
  98.             synchronized(this) {
  99.                if (!var7.equals(this.ref) && this.ref != null) {
  100.                   var7 = this.ref;
  101.                   var6 = false;
  102.                } else {
  103.                   RemoteRef var12 = this.activate(var6);
  104.                   if (var12.equals(var7) && var8 instanceof NoSuchObjectException && !var6) {
  105.                      var12 = this.activate(true);
  106.                   }
  107.  
  108.                   var7 = var12;
  109.                   var6 = true;
  110.                }
  111.             }
  112.          }
  113.       }
  114.  
  115.       throw (Exception)var8;
  116.    }
  117.  
  118.    private synchronized RemoteRef getRef() throws RemoteException {
  119.       if (this.ref == null) {
  120.          this.ref = this.activate(false);
  121.       }
  122.  
  123.       return this.ref;
  124.    }
  125.  
  126.    private RemoteRef activate(boolean var1) throws RemoteException {
  127.       this.ref = null;
  128.  
  129.       try {
  130.          ActivatableRef var2 = (ActivatableRef)((RemoteStub)this.field_0.activate(var1)).getRef();
  131.          this.ref = var2.ref;
  132.          return this.ref;
  133.       } catch (RemoteException var5) {
  134.          throw var5;
  135.       } catch (UnknownObjectException var6) {
  136.          throw new NoSuchObjectException("activatable object no longer registered");
  137.       } catch (Exception var7) {
  138.          throw new ActivateFailedException("failed to activate object", var7);
  139.       }
  140.    }
  141.  
  142.    public synchronized RemoteCall newCall(RemoteObject var1, Operation[] var2, int var3, long var4) throws RemoteException {
  143.       throw new UnsupportedOperationException("activation requires 1.2 stubs");
  144.    }
  145.  
  146.    public void invoke(RemoteCall var1) throws Exception {
  147.       throw new UnsupportedOperationException("activation requires 1.2 stubs");
  148.    }
  149.  
  150.    public void done(RemoteCall var1) throws RemoteException {
  151.       throw new UnsupportedOperationException("activation requires 1.2 stubs");
  152.    }
  153.  
  154.    public String getRefClass(ObjectOutput var1) {
  155.       return "ActivatableRef";
  156.    }
  157.  
  158.    public void writeExternal(ObjectOutput var1) throws IOException {
  159.       RemoteRef var2 = this.ref;
  160.       var1.writeObject(this.field_0);
  161.       if (var2 == null) {
  162.          var1.writeUTF("");
  163.       } else {
  164.          var1.writeUTF(var2.getRefClass(var1));
  165.          var2.writeExternal(var1);
  166.       }
  167.  
  168.    }
  169.  
  170.    public void readExternal(ObjectInput var1) throws IOException, ClassNotFoundException {
  171.       this.field_0 = (ActivationID)var1.readObject();
  172.       this.ref = null;
  173.       String var2 = var1.readUTF();
  174.       if (!var2.equals("")) {
  175.          try {
  176.             Class var3 = Class.forName("sun.rmi.server." + var2);
  177.             this.ref = (RemoteRef)var3.newInstance();
  178.             this.ref.readExternal(var1);
  179.          } catch (InstantiationException var5) {
  180.             throw new UnmarshalException("Unable to create remote reference", var5);
  181.          } catch (IllegalAccessException var6) {
  182.             throw new UnmarshalException("Illegal access creating remote reference");
  183.          }
  184.       }
  185.    }
  186.  
  187.    public String remoteToString() {
  188.       return "RemoteStub [ref: " + this.ref + "]";
  189.    }
  190.  
  191.    public int remoteHashCode() {
  192.       return this.field_0.hashCode();
  193.    }
  194.  
  195.    public boolean remoteEquals(RemoteRef var1) {
  196.       return var1 instanceof ActivatableRef ? this.field_0.equals(((ActivatableRef)var1).field_0) : false;
  197.    }
  198. }
  199.