diff options
author | Mark Wielaard <mark@klomp.org> | 2002-11-07 18:01:05 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2002-11-07 18:01:05 +0000 |
commit | f150fe3fa7cc90fa7abd9bd64e4b5ccd6646d5a7 (patch) | |
tree | dfca54cc19c9efec9125010fd9fcb7030f24bea4 /libjava/gnu/java/rmi/server/UnicastRemoteCall.java | |
parent | 396a80436c733527118877c95bfec72e38401eeb (diff) | |
download | gcc-f150fe3fa7cc90fa7abd9bd64e4b5ccd6646d5a7.zip gcc-f150fe3fa7cc90fa7abd9bd64e4b5ccd6646d5a7.tar.gz gcc-f150fe3fa7cc90fa7abd9bd64e4b5ccd6646d5a7.tar.bz2 |
backport: MarshalledObject.java (equals): Check hashcode first.
Merge Orp RMI patches from Wu Gansha <gansha.wu@intel.com>
* java/rmi/MarshalledObject.java (equals): Check hashcode first.
* java/rmi/server/RMIClassLoader.java (MyClassLoader): Create/Use
annotation.
(loadClass): Take String as codebases.
(getClassAnnotation): Use MyClassLoader annotations.
* java/rmi/server/UnicastRemoteObject.java (UnicastRemoteObject):
call exportObject(this).
* gnu/java/rmi/RMIMarshalledObjectOutputStream.java
(RMIMarshalledObjectOutputStream): set locBytesStream and locStream.
(setAnnotation): Don't set locBytesStream and locStream.
(replaceObject): Removed.
(flush): Don't test locStream.
(getLocBytes): LikeWise.
* gnu/java/rmi/dgc/DGCImpl.java: extends UnicastServerRef.
(leaseCache): New field.
(dirty): Use leaseCache.
(LeaseRecord): New inner class.
* gnu/java/rmi/registry/RegistryImpl.java (RegistryImpl): Don't
explicitly call exportObject().
* gnu/java/rmi/registry/RegistryImpl_Stub.java: set useNewInvoke to
false to communicate with Sun JDK130.
* gnu/java/rmi/server/ConnectionRunnerPool.java: Add CPU comment.
* gnu/java/rmi/server/RMIObjectInputStream.java
(UnicastConnectionManager): Removed field.
* gnu/java/rmi/server/RMIObjectOutputStream.java (replaceObject):
Use UnicastServer.getExportedRef().
* gnu/java/rmi/server/UnicastConnection.java (reviveTime): New field.
(expireTime): Likewise.
(CONNECTION_TIMEOUT): Likewise.
(disconnect): Call sock.close().
(isExpired): New method.
(resetTime): Likewise.
(run): Use do while loop and catch Exception for discardConnection().
* gnu/java/rmi/server/UnicastConnectionManager.java: Pool connections.
* gnu/java/rmi/server/UnicastRef.java: Lots of changes.
* gnu/java/rmi/server/UnicastRemoteCall.java: Lots of changes.
* gnu/java/rmi/server/UnicastServer.java (refcache): New field.
(exportObject): Use refcache.
(unexportObject): Likewise.
(getExportedRef): New method.
* gnu/java/rmi/server/UnicastServerRef.java (UnicastServerRef): New
constructor.
(exportObject): Save manager.serverobj.
(getStub): New method.
From-SVN: r58900
Diffstat (limited to 'libjava/gnu/java/rmi/server/UnicastRemoteCall.java')
-rw-r--r-- | libjava/gnu/java/rmi/server/UnicastRemoteCall.java | 122 |
1 files changed, 109 insertions, 13 deletions
diff --git a/libjava/gnu/java/rmi/server/UnicastRemoteCall.java b/libjava/gnu/java/rmi/server/UnicastRemoteCall.java index 200538d..734002a 100644 --- a/libjava/gnu/java/rmi/server/UnicastRemoteCall.java +++ b/libjava/gnu/java/rmi/server/UnicastRemoteCall.java @@ -38,14 +38,24 @@ exception statement from your version. */ package gnu.java.rmi.server; import java.lang.Exception; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectOutput; import java.io.ObjectInput; import java.io.StreamCorruptedException; import java.rmi.server.RemoteCall; +import java.rmi.RemoteException; +import java.rmi.MarshalException; +import java.rmi.UnmarshalException; +import java.rmi.server.UID; +import java.rmi.server.ObjID; +import java.rmi.server.RemoteObject; + import java.util.Vector; -public class UnicastRemoteCall implements RemoteCall +public class UnicastRemoteCall + implements RemoteCall, ProtocolConstants { private UnicastConnection conn; @@ -56,6 +66,9 @@ public class UnicastRemoteCall implements RemoteCall private Vector vec; private int ptr; + private ObjectOutput oout; + private ObjectInput oin; + /** * Incoming call. */ @@ -67,30 +80,71 @@ public class UnicastRemoteCall implements RemoteCall /** * Outgoing call. */ - UnicastRemoteCall(Object obj, int opnum, long hash) + UnicastRemoteCall(UnicastConnection conn, ObjID objid, int opnum, long hash) + throws RemoteException { - this.object = obj; + this.conn = conn; this.opnum = opnum; this.hash = hash; + + // signal the call when constructing + try + { + DataOutputStream dout = conn.getDataOutputStream(); + dout.write(MESSAGE_CALL); + + oout = conn.getObjectOutputStream(); + objid.write(oout); + oout.writeInt(opnum); + oout.writeLong(hash); + } + catch(IOException ex) + { + throw new MarshalException("Try to write header but failed.", ex); + } } - + + UnicastConnection getConnection() + { + return conn; + } + public ObjectOutput getOutputStream() throws IOException { - vec = new Vector(); - return new DummyObjectOutputStream(); + if (conn != null) + { + if(oout == null) + return (oout = conn.getObjectOutputStream()); + else + return oout; + } + else + { + vec = new Vector(); + return (new DummyObjectOutputStream()); + } } public void releaseOutputStream() throws IOException { - // Does nothing. + if(oout != null) + oout.flush(); } public ObjectInput getInputStream() throws IOException { if (conn != null) - return conn.getObjectInputStream(); - ptr = 0; - return new DummyObjectInputStream(); + { + if(oin == null) + return (oin = conn.getObjectInputStream()); + else + return oin; + } + else + { + ptr = 0; + return (new DummyObjectInputStream()); + } } public void releaseInputStream() throws IOException @@ -104,15 +158,57 @@ public class UnicastRemoteCall implements RemoteCall vec = new Vector(); return new DummyObjectOutputStream(); } - + public void executeCall() throws Exception { - throw new Error("Not implemented"); + byte returncode; + ObjectInput oin; + try + { + releaseOutputStream(); + DataInputStream din = conn.getDataInputStream(); + if (din.readByte() != MESSAGE_CALL_ACK) + throw new RemoteException("Call not acked"); + + oin = getInputStream(); + returncode = oin.readByte(); + UID.read(oin); + } + catch(IOException ex) + { + throw new UnmarshalException("Try to read header but failed:", ex); + } + + //check return code + switch(returncode) + { + case RETURN_ACK: //it's ok + return; + case RETURN_NACK: + Object returnobj; + try + { + returnobj = oin.readObject(); + } + catch(Exception ex2) + { + throw new UnmarshalException + ("Try to read exception object but failed", ex2); + } + + if(!(returnobj instanceof Exception)) + throw new UnmarshalException("Should be Exception type here: " + + returnobj); + throw (Exception)returnobj; + + default: + throw new UnmarshalException("Invalid return code"); + } } public void done() throws IOException { - /* Does nothing */ + // conn.disconnect(); } Object returnValue() |