diff options
| author | Michael Koch <konqueror@gmx.de> | 2004-03-21 10:10:14 +0000 |
|---|---|---|
| committer | Michael Koch <konqueror@gmx.de> | 2004-03-21 10:10:14 +0000 |
| commit | 1ea4bde3447a9c4e437be979b5dc8860d89031cd (patch) | |
| tree | b8743b4206429436c98f9e24b4101497e131d09b /gnu/java/rmi/server/UnicastServerRef.java | |
| parent | 9e70865e826bf2816d7343924e003fe24d42b07f (diff) | |
| download | classpath-1ea4bde3447a9c4e437be979b5dc8860d89031cd.tar.gz | |
2004-03-21 Norbert Frese <postfach@nfrese.net>
* gnu/java/rmi/server/RMIIncomingThread.java: New file.
* gnu/java/rmi/server/UnicastConnection.java:
Create a new RMIObjectOuputStream/RMIObjectInputStream for every
rmi-message.
(getObjectInputStream): Return object reference, throw IOException if null.
(startObjectInputStream): Create new RMIObjectInputStream on top of 'din'.
(getObjectOutputStream): Return object reference, throw IOException if null.
(startObjectOutputStream): Create new RMIObjectOutputStream on top of 'dout'.
* gnu/java/rmi/server/UnicastConnectionManager.java:
(UnicastConnectionManager): Throw RemoteException if port is not available.
(getInstance): Throw RemoteException.
(run): Lookup client host and attach it to new RMIIncomingThread for later retrieval.
* gnu/java/rmi/server/UnicastRef.java:
Start a new RMIObjectInputStream/RMIObjectOutputStream for every rmi-message.
Collect Exceptions which are returned by a rmi-call and fix void returns.
* gnu/java/rmi/server/UnicastRemoteCall.java:
Start a new RMIObjectInputStream/RMIObjectOutputStream for every rmi-message.
* gnu/java/rmi/server/UnicastServer.java:
(dispatch): Answer ping messages which are sent by other java implementions.
(incomingMessageCall): Start a new RMIObjectInputStream/RMIObjectOutputStream
for every rmi-message and fix void return problems.
* gnu/java/rmi/server/UnicastServerRef.java
(UnicastServerRef): Throw RemoteException.
(exportObject): Find the class up the class hierarchy which has a _Stub generated by rmic.
In some situations it is necessary to export a subclass of the class which has the _Stub.
For instance when the class with has the _Stub is abstract.
(findStubSkelClass): New method which looks for the class which has the _Stub.
(getClientHost): Implementated.
* java/rmi/server/RemoteServer.java
(getClientHost): Implemented.
* gnu/java/rmi/server/Makefile.am
(EXTRA_DIST): RMIIncomingThread.java.
Diffstat (limited to 'gnu/java/rmi/server/UnicastServerRef.java')
| -rw-r--r-- | gnu/java/rmi/server/UnicastServerRef.java | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/gnu/java/rmi/server/UnicastServerRef.java b/gnu/java/rmi/server/UnicastServerRef.java index b00492750..3e9529c59 100644 --- a/gnu/java/rmi/server/UnicastServerRef.java +++ b/gnu/java/rmi/server/UnicastServerRef.java @@ -46,6 +46,7 @@ import java.rmi.RemoteException; import java.rmi.server.RemoteStub; import java.rmi.server.ObjID; import java.rmi.server.ServerRef; +import java.rmi.server.RemoteServer; import java.rmi.server.RemoteRef; import java.rmi.server.ServerNotActiveException; import java.rmi.server.RMIClientSocketFactory; @@ -85,7 +86,7 @@ UnicastServerRef() { } -public UnicastServerRef(ObjID id, int port, RMIServerSocketFactory ssf) { +public UnicastServerRef(ObjID id, int port, RMIServerSocketFactory ssf) throws RemoteException { super(id); manager = UnicastConnectionManager.getInstance(port, ssf); } @@ -99,13 +100,21 @@ public RemoteStub exportObject(Remote obj) throws RemoteException { // Find and install the stub Class cls = obj.getClass(); - stub = (RemoteStub)getHelperClass(cls, "_Stub"); + Class expCls; + try { + // where ist the _Stub? (check superclasses also) + expCls = findStubSkelClass(cls); + } catch (Exception ex) { + throw new RemoteException("can not find stubs for class: " + cls, ex); + } + + stub = (RemoteStub)getHelperClass(expCls, "_Stub"); if (stub == null) { throw new RemoteException("failed to export: " + cls); } // Find and install the skeleton (if there is one) - skel = (Skeleton)getHelperClass(cls, "_Skel"); + skel = (Skeleton)getHelperClass(expCls, "_Skel"); // Build hash of methods which may be called. buildMethodHash(obj.getClass(), true); @@ -135,6 +144,38 @@ public boolean unexportObject(Remote obj, boolean force) { return UnicastServer.unexportObject(this, force); } +/** +* +* The Subs/Skels might not there for the actual class, but maybe +* for one of the superclasses. +* +*/ +private Class findStubSkelClass(Class startCls) throws Exception { + Class cls = startCls; + + while (true) { + try { + String stubClassname = cls.getName() + "_Stub"; + ClassLoader cl = cls.getClassLoader(); + Class scls = cl == null ? Class.forName(stubClassname) + : cl.loadClass(stubClassname); + return cls; // found it + } catch (ClassNotFoundException e) { + Class superCls = cls.getSuperclass(); + if (superCls == null + || superCls == java.rmi.server.UnicastRemoteObject.class) + { + throw new Exception("Neither " + startCls + + " nor one of their superclasses (like" + cls + ")" + + " has a _Stub"); + } + cls = superCls; + } + } +} + + + private Object getHelperClass(Class cls, String type) { try { String classname = cls.getName(); @@ -176,8 +217,10 @@ private Object getHelperClass(Class cls, String type) { return (null); } + + public String getClientHost() throws ServerNotActiveException { - throw new Error("Not implemented"); + return RemoteServer.getClientHost(); } private void buildMethodHash(Class cls, boolean build) { |
