/[classpath]/classpath/java/rmi/server/RemoteObject.java
ViewVC logotype

Diff of /classpath/java/rmi/server/RemoteObject.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4.2.2 by gnu_andrew, Tue Jan 18 11:38:30 2005 UTC revision 1.4.2.3 by gnu_andrew, Sat Feb 19 10:50:38 2005 UTC
# Line 45  import java.lang.reflect.Constructor; Line 45  import java.lang.reflect.Constructor;
45  import java.rmi.NoSuchObjectException;  import java.rmi.NoSuchObjectException;
46  import java.rmi.Remote;  import java.rmi.Remote;
47  import java.rmi.UnmarshalException;  import java.rmi.UnmarshalException;
48    import java.util.WeakHashMap;
49    
50  public abstract class RemoteObject  public abstract class RemoteObject
51          implements Remote, Serializable {          implements Remote, Serializable {
# Line 53  private static final long serialVersionU Line 54  private static final long serialVersionU
54    
55  protected transient RemoteRef ref;  protected transient RemoteRef ref;
56    
57    private static final WeakHashMap stubs = new WeakHashMap();
58    
59  protected RemoteObject() {  protected RemoteObject() {
60          this(null);          this(null);
61  }  }
# Line 65  public RemoteRef getRef() { Line 68  public RemoteRef getRef() {
68          return (ref);          return (ref);
69  }  }
70    
71    synchronized static void addStub(Remote obj, Remote stub)
72    {
73      stubs.put(obj, stub);
74    }
75    
76    synchronized static void deleteStub(Remote obj)
77    {
78      stubs.remove(obj);
79    }
80    
81    public static Remote toStub(Remote obj) throws NoSuchObjectException    public static Remote toStub(Remote obj) throws NoSuchObjectException
82    {    {
83      Class cls = obj.getClass();      Remote stub = (Remote)stubs.get(obj);
84      String classname = cls.getName();  
85      ClassLoader cl = cls.getClassLoader();      if (stub == null)
86      try        throw new NoSuchObjectException(obj.getClass().getName());
87        {  
88          Class scls = cl.loadClass(classname + "_Stub");      return stub;
         // JDK 1.2 stubs  
         Class[] stubprototype = new Class[] { RemoteRef.class };  
         Constructor con = scls.getConstructor(stubprototype);  
         return (Remote)(con.newInstance(new Object[]{obj}));  
       }  
     catch (Exception e) {}  
     throw new NoSuchObjectException(obj.getClass().getName());  
89    }    }
90    
91  public int hashCode() {  public int hashCode() {

Legend:
Removed from v.1.4.2.2  
changed lines
  Added in v.1.4.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26