42 |
import java.rmi.server.RemoteRef; |
import java.rmi.server.RemoteRef; |
43 |
import java.rmi.NoSuchObjectException; |
import java.rmi.NoSuchObjectException; |
44 |
import gnu.java.rmi.server.UnicastServerRef; |
import gnu.java.rmi.server.UnicastServerRef; |
45 |
|
import gnu.java.rmi.server.UnicastServer; |
46 |
|
|
47 |
public class UnicastRemoteObject |
public class UnicastRemoteObject |
48 |
extends RemoteServer { |
extends RemoteServer { |
49 |
|
|
50 |
|
private static final long serialVersionUID = 4974527148936298033L; |
51 |
|
//The following serialized fields are from Java API Documentation "Serialized form" |
52 |
|
private int port = 0; |
53 |
|
private RMIClientSocketFactory csf = null; |
54 |
|
private RMIServerSocketFactory ssf = null; |
55 |
|
|
56 |
protected UnicastRemoteObject() throws RemoteException { |
protected UnicastRemoteObject() throws RemoteException { |
57 |
this(0); |
this(0); |
58 |
} |
} |
62 |
} |
} |
63 |
|
|
64 |
protected UnicastRemoteObject(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException { |
protected UnicastRemoteObject(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException { |
65 |
super(new UnicastServerRef(new ObjID(), port, ssf)); |
this.port = port; |
66 |
|
//Is RMIXXXSocketFactory serializable |
67 |
|
//this.csf = csf; |
68 |
|
//this.ssf = ssf; |
69 |
|
this.ref = new UnicastServerRef(new ObjID(), port, ssf); |
70 |
|
//Should we export it here? |
71 |
|
// if we export, we got infinite recursive call: |
72 |
|
// UnicastRemoteObject.<init>->...->UnicastServer.startDGC()->UnicastRemoteObject.<init>->... |
73 |
|
//exportObject(this); |
74 |
} |
} |
75 |
|
|
76 |
protected UnicastRemoteObject(RemoteRef ref) throws RemoteException { |
protected UnicastRemoteObject(RemoteRef ref) throws RemoteException { |
77 |
super((UnicastServerRef)ref); |
super((UnicastServerRef)ref); |
78 |
|
//Should we export it here? |
79 |
|
//exportObject(this); |
80 |
} |
} |
81 |
|
|
82 |
public Object clone() throws CloneNotSupportedException { |
public Object clone() throws CloneNotSupportedException { |
88 |
return (sref.exportObject(obj)); |
return (sref.exportObject(obj)); |
89 |
} |
} |
90 |
|
|
91 |
public static Remote exportObject(Remote obj, int port) throws RemoteException { |
public static Remote exportObject(Remote obj, int port) throws RemoteException |
92 |
return (exportObject(obj)); |
{ |
93 |
} |
return exportObject(obj, port, null); |
94 |
|
} |
95 |
public static Remote exportObject(Remote obj, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException { |
|
96 |
return (exportObject(obj)); |
protected static Remote exportObject(Remote obj, int port, RMIServerSocketFactory ssf) |
97 |
} |
throws RemoteException |
98 |
|
{ |
99 |
public static boolean unexportObject(Remote obj, boolean force) throws NoSuchObjectException { |
UnicastServerRef sref = null; |
100 |
throw new Error("Not implemented"); |
if (obj instanceof RemoteObject) |
101 |
} |
sref = (UnicastServerRef)((RemoteObject)obj).getRef (); |
102 |
|
if(sref == null) |
103 |
|
{ |
104 |
|
sref = new UnicastServerRef(new ObjID (), port, ssf); |
105 |
|
} |
106 |
|
return (sref.exportObject (obj)); |
107 |
|
} |
108 |
|
|
109 |
|
/** |
110 |
|
* FIX ME |
111 |
|
*/ |
112 |
|
public static Remote exportObject(Remote obj, int port, RMIClientSocketFactory csf, |
113 |
|
RMIServerSocketFactory ssf) |
114 |
|
throws RemoteException |
115 |
|
{ |
116 |
|
return (exportObject(obj, port, ssf)); |
117 |
|
} |
118 |
|
|
119 |
|
public static boolean unexportObject(Remote obj, boolean force) |
120 |
|
throws RemoteException, NoSuchObjectException |
121 |
|
{ |
122 |
|
if (obj instanceof RemoteObject) |
123 |
|
{ |
124 |
|
UnicastServerRef sref = (UnicastServerRef)((RemoteObject)obj).getRef(); |
125 |
|
return sref.unexportObject(obj, force); |
126 |
|
} |
127 |
|
else |
128 |
|
//FIX ME |
129 |
|
; |
130 |
|
return true; |
131 |
|
} |
132 |
|
|
133 |
} |
} |