37 |
|
|
38 |
package gnu.java.rmi.server; |
package gnu.java.rmi.server; |
39 |
|
|
40 |
|
import java.io.DataInputStream; |
41 |
|
import java.io.DataOutputStream; |
42 |
|
import java.io.IOException; |
43 |
|
import java.io.ObjectInput; |
44 |
|
import java.io.ObjectInputStream; |
45 |
|
import java.io.ObjectOutput; |
46 |
|
import java.io.ObjectOutputStream; |
47 |
|
import java.lang.reflect.InvocationTargetException; |
48 |
|
import java.lang.reflect.Method; |
49 |
import java.rmi.Remote; |
import java.rmi.Remote; |
50 |
import java.rmi.RemoteException; |
import java.rmi.RemoteException; |
51 |
import java.rmi.server.RemoteRef; |
import java.rmi.server.ObjID; |
52 |
import java.rmi.server.RMISocketFactory; |
import java.rmi.server.Operation; |
53 |
import java.rmi.server.RMIClientSocketFactory; |
import java.rmi.server.RMIClientSocketFactory; |
|
import java.rmi.server.RMIServerSocketFactory; |
|
|
import java.rmi.server.RemoteObject; |
|
54 |
import java.rmi.server.RemoteCall; |
import java.rmi.server.RemoteCall; |
55 |
import java.rmi.server.UnicastRemoteObject; |
import java.rmi.server.RemoteObject; |
56 |
import java.rmi.server.Operation; |
import java.rmi.server.RemoteRef; |
|
import java.rmi.server.ObjID; |
|
57 |
import java.rmi.server.UID; |
import java.rmi.server.UID; |
|
import java.lang.reflect.Method; |
|
|
import java.io.ObjectOutput; |
|
|
import java.io.ObjectInput; |
|
|
import java.io.IOException; |
|
|
import java.net.Socket; |
|
|
import java.net.InetAddress; |
|
|
import java.io.BufferedInputStream; |
|
|
import java.io.BufferedOutputStream; |
|
|
import java.io.ObjectInputStream; |
|
|
import java.io.ObjectOutputStream; |
|
|
import java.io.DataInputStream; |
|
|
import java.io.DataOutputStream; |
|
|
|
|
|
import java.lang.reflect.InvocationTargetException; |
|
58 |
|
|
59 |
public class UnicastRef |
public class UnicastRef |
60 |
implements RemoteRef, ProtocolConstants { |
implements RemoteRef, ProtocolConstants { |
65 |
/** |
/** |
66 |
* Used by serialization, and let subclass capable of having default constructor |
* Used by serialization, and let subclass capable of having default constructor |
67 |
*/ |
*/ |
68 |
//private |
// must be public otherwise java.rmi.RemoteObject cannot instantiate this class |
69 |
UnicastRef() { |
// -- iP |
70 |
|
public UnicastRef() { |
71 |
} |
} |
72 |
|
|
73 |
public UnicastRef(ObjID objid, String host, int port, RMIClientSocketFactory csf) { |
public UnicastRef(ObjID objid, String host, int port, RMIClientSocketFactory csf) { |
83 |
// Check if client and server are in the same VM, then local call can be used to |
// Check if client and server are in the same VM, then local call can be used to |
84 |
// replace remote call, but it's somewhat violating remote semantic. |
// replace remote call, but it's somewhat violating remote semantic. |
85 |
Object svrobj = manager.serverobj; |
Object svrobj = manager.serverobj; |
86 |
if(svrobj != null){ |
|
87 |
|
// Make sure that the server object is compatible. It could be loaded from a different |
88 |
|
// classloader --iP |
89 |
|
if(svrobj != null && method.getDeclaringClass().isInstance(svrobj)){ |
90 |
//local call |
//local call |
91 |
Object ret = null; |
Object ret = null; |
92 |
try{ |
try{ |