1 |
/* |
/* |
2 |
Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. |
Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
63 |
import java.io.DataOutputStream; |
import java.io.DataOutputStream; |
64 |
import java.io.ObjectInputStream; |
import java.io.ObjectInputStream; |
65 |
import java.io.ObjectOutputStream; |
import java.io.ObjectOutputStream; |
66 |
|
import java.io.ObjectInput; |
67 |
|
import java.io.ObjectOutput; |
68 |
import java.util.Hashtable; |
import java.util.Hashtable; |
69 |
|
|
70 |
public class UnicastServerRef |
public class UnicastServerRef |
73 |
|
|
74 |
final static private Class[] stubprototype = new Class[] { RemoteRef.class }; |
final static private Class[] stubprototype = new Class[] { RemoteRef.class }; |
75 |
|
|
76 |
Remote myself; |
Remote myself; //save the remote object itself |
77 |
private Skeleton skel; |
private Skeleton skel; |
78 |
private RemoteStub stub; |
private RemoteStub stub; |
79 |
private Hashtable methods = new Hashtable(); |
private Hashtable methods = new Hashtable(); |
80 |
|
|
81 |
|
/** |
82 |
|
* Used by serialization. |
83 |
|
*/ |
84 |
|
UnicastServerRef() |
85 |
|
{ |
86 |
|
} |
87 |
|
|
88 |
public UnicastServerRef(ObjID id, int port, RMIServerSocketFactory ssf) { |
public UnicastServerRef(ObjID id, int port, RMIServerSocketFactory ssf) { |
89 |
super(id); |
super(id); |
90 |
manager = UnicastConnectionManager.getInstance(port, ssf); |
manager = UnicastConnectionManager.getInstance(port, ssf); |
93 |
public RemoteStub exportObject(Remote obj) throws RemoteException { |
public RemoteStub exportObject(Remote obj) throws RemoteException { |
94 |
if (myself == null) { |
if (myself == null) { |
95 |
myself = obj; |
myself = obj; |
96 |
|
// Save it to server manager, to let client calls in the same VM to issue |
97 |
|
// local call |
98 |
|
manager.serverobj = obj; |
99 |
|
|
100 |
// Find and install the stub |
// Find and install the stub |
101 |
Class cls = obj.getClass(); |
Class cls = obj.getClass(); |
124 |
return exportObject(remote); |
return exportObject(remote); |
125 |
} |
} |
126 |
|
|
127 |
|
public RemoteStub getStub(){ |
128 |
|
return stub; |
129 |
|
} |
130 |
|
|
131 |
|
|
132 |
public boolean unexportObject(Remote obj, boolean force) throws RemoteException { |
public boolean unexportObject(Remote obj, boolean force) throws RemoteException { |
133 |
// Remove all hashes of methods which may be called. |
// Remove all hashes of methods which may be called. |