diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-10-01 03:46:43 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-10-01 03:46:43 +0000 |
commit | 1834f2d6e707af5e33654167ac0b3844210764c3 (patch) | |
tree | bf757dbbf21b52fd568fba72014b0347b815ecdb /libjava/gnu/java/rmi/server/UnicastServerRef.java | |
parent | 52d972392150fc1a07734a90ba55586e7cee710b (diff) | |
download | ppe42-gcc-1834f2d6e707af5e33654167ac0b3844210764c3.tar.gz ppe42-gcc-1834f2d6e707af5e33654167ac0b3844210764c3.zip |
* java/io/ObjectInputStream.java (resolveProxyClass): New method
from Classpath.
* Makefile.in: Rebuilt.
* Makefile.am (rmi_java_source_files): Added new files.
* gnu/java/rmi/RMIMarshalledObjectInputStream.java,
gnu/java/rmi/RMIMarshalledObjectOutputStream.java,
gnu/java/rmi/server/ConnectionRunnerPool.java: New files from
Classpath.
* gnu/java/rmi/dgc/DGCImpl.java,
gnu/java/rmi/dgc/DGCImpl_Skel.java,
gnu/java/rmi/dgc/DGCImpl_Stub.java,
gnu/java/rmi/registry/RegistryImpl_Skel.java,
gnu/java/rmi/registry/RegistryImpl_Stub.java,
gnu/java/rmi/server/RMIHashes.java,
gnu/java/rmi/server/RMIObjectInputStream.java,
gnu/java/rmi/server/RMIObjectOutputStream.java,
gnu/java/rmi/server/UnicastConnection.java,
gnu/java/rmi/server/UnicastConnectionManager.java,
gnu/java/rmi/server/UnicastRef.java,
gnu/java/rmi/server/UnicastServer.java,
gnu/java/rmi/server/UnicastServerRef.java,
java/rmi/MarshalledObject.java,
java/rmi/server/RMIClassLoader.java,
java/rmi/server/RemoteObject.java,
java/rmi/server/UnicastRemoteObject.java,
java/security/SecureClassLoader.java: Merged from Classpath.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@57675 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/gnu/java/rmi/server/UnicastServerRef.java')
-rw-r--r-- | libjava/gnu/java/rmi/server/UnicastServerRef.java | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/libjava/gnu/java/rmi/server/UnicastServerRef.java b/libjava/gnu/java/rmi/server/UnicastServerRef.java index b145089e600..196f969d292 100644 --- a/libjava/gnu/java/rmi/server/UnicastServerRef.java +++ b/libjava/gnu/java/rmi/server/UnicastServerRef.java @@ -66,14 +66,15 @@ import java.io.ObjectOutputStream; import java.util.Hashtable; public class UnicastServerRef - extends UnicastRef { + extends UnicastRef + implements ServerRef{ //SHOULD implement ServerRef final static private Class[] stubprototype = new Class[] { RemoteRef.class }; Remote myself; private Skeleton skel; private RemoteStub stub; -private Hashtable methods; +private Hashtable methods = new Hashtable(); public UnicastServerRef(ObjID id, int port, RMIServerSocketFactory ssf) { super(id); @@ -95,7 +96,7 @@ public RemoteStub exportObject(Remote obj) throws RemoteException { skel = (Skeleton)getHelperClass(cls, "_Skel"); // Build hash of methods which may be called. - buildMethodHash(obj.getClass()); + buildMethodHash(obj.getClass(), true); // Export it. UnicastServer.exportObject(this); @@ -104,10 +105,25 @@ public RemoteStub exportObject(Remote obj) throws RemoteException { return (stub); } +public RemoteStub exportObject(Remote remote, Object obj) + throws RemoteException +{ + //FIX ME + return exportObject(remote); +} + + +public boolean unexportObject(Remote obj, boolean force) throws RemoteException { + // Remove all hashes of methods which may be called. + buildMethodHash(obj.getClass(), false); + return UnicastServer.unexportObject(this, force); +} + private Object getHelperClass(Class cls, String type) { try { - String classname = cls.getName(); - Class scls = Class.forName(classname + type); + String classname = cls.getName(); + ClassLoader cl = cls.getClassLoader(); //DONT use "Class scls = Class.forName(classname + type);" + Class scls = cl.loadClass(classname + type); if (type.equals("_Stub")) { try { // JDK 1.2 stubs @@ -147,8 +163,7 @@ public String getClientHost() throws ServerNotActiveException { throw new Error("Not implemented"); } -private void buildMethodHash(Class cls) { - methods = new Hashtable(); +private void buildMethodHash(Class cls, boolean build) { Method[] meths = cls.getMethods(); for (int i = 0; i < meths.length; i++) { /* Don't need to include any java.xxx related stuff */ @@ -156,11 +171,23 @@ private void buildMethodHash(Class cls) { continue; } long hash = RMIHashes.getMethodHash(meths[i]); - methods.put(new Long (hash), meths[i]); + if(build) + methods.put(new Long (hash), meths[i]); + else + methods.remove(new Long (hash)); //System.out.println("meth = " + meths[i] + ", hash = " + hash); } } +Class getMethodReturnType(int method, long hash) throws Exception +{ + if (method == -1) { + Method meth = (Method)methods.get(new Long (hash)); + return meth.getReturnType(); + }else + return null; +} + public Object incomingMessageCall(UnicastConnection conn, int method, long hash) throws Exception { //System.out.println("method = " + method + ", hash = " + hash); // If method is -1 then this is JDK 1.2 RMI - so use the hash @@ -189,7 +216,15 @@ public Object incomingMessageCall(UnicastConnection conn, int method, long hash) throw t; } } - return (meth.invoke(myself, args)); + //We must reinterpret the exception thrown by meth.invoke() + //return (meth.invoke(myself, args)); + Object ret = null; + try{ + ret = meth.invoke(myself, args); + }catch(InvocationTargetException e){ + throw (Exception)(e.getTargetException()); + } + return ret; } // Otherwise this is JDK 1.1 style RMI - we find the skeleton // and invoke it using the method number. We wrap up our |