diff options
| author | Mark Wielaard <mark@klomp.org> | 2002-10-31 18:35:20 +0000 |
|---|---|---|
| committer | Mark Wielaard <mark@klomp.org> | 2002-10-31 18:35:20 +0000 |
| commit | cd7775b47a1f77eb774ff6ecfc6518a4231b636e (patch) | |
| tree | f12da6efc0976abdd9afcb1a48191c87f7cbd603 /gnu/java/rmi/server/UnicastRemoteCall.java | |
| parent | 16932d0c5c2cccf533af93f66464b7836b3bb269 (diff) | |
| download | classpath-cd7775b47a1f77eb774ff6ecfc6518a4231b636e.tar.gz | |
Merge Orp RMI patches from Wu Gansha <gansha.wu@intel.com>
* configure.in (AC_OUTPUT): Add javax/rmi/Makefile,
* gnu/javax/Makefile, gnu/javax/rmi/Makefile,
javax/rmi/CORBA/Makefile and gnu/javax/rmi/CORBA/Makefile.
* javax/.cvsignore: New File.
* javax/Makefile.am (SUBDIRS): Add rmi.
* javax/rmi/.cvsignore: New File.
* javax/rmi/Makefile.am: New file.
* javax/rmi/CORBA/.cvsignore: New file.
* javax/rmi/CORBA/Makefile.am: New file.
* gnu/Makefile.am (SUBDIRS): Add javax.
* gnu/javax/.cvsignore: New file.
* gnu/javax/Makefile.am: New file.
* gnu/javax/rmi/.cvsignore: New file.
* gnu/javax/rmi/Makefile.am: New file.
* gnu/javax/rmi/CORBA/.cvsignore: New file.
* gnu/javax/rmi/CORBA/Makefile.am: New file.
* 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.
(getLocButes): 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.
* javax/rmi/PortableRemoteObject.java: New file.
* gnu/javax/rmi/PortableServer.java: Likewise.
* javax/rmi/CORBA/ClassDesc.java: New file.
* javax/rmi/CORBA/PortableRemoteObjectDelegate.java: Likewise.
* javax/rmi/CORBA/Stub.java: Likewise.
* javax/rmi/CORBA/StubDelegate.java: Likewise.
* javax/rmi/CORBA/Tie.java: Likewise.
* javax/rmi/CORBA/Util.java: Likewise.
* javax/rmi/CORBA/UtilDelegate.java: Likewise.
* javax/rmi/CORBA/ValueHandler.java: Likewise.
* gnu/javax/rmi/CORBA/DelegateFactory.java: Likewise.
* gnu/javax/rmi/CORBA/GetDelegateInstanceException.java: Likewise.
* gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java: Likewise.
* gnu/javax/rmi/CORBA/StubDelegateImpl.java: Likewise.
* gnu/javax/rmi/CORBA/UtilDelegateImpl.java: Likewise.
* gnu/javax/rmi/CORBA/ValueHandlerImpl.java: Likewise.
* javax/rmi/BAD_OPERATION.java: Stub class.
* javax/rmi/ORB.java: Likewise
* javax/rmi/CORBA/ObjectImpl.java: Likewise
* javax/rmi/CORBA/SystemException.java: Likewise.
Diffstat (limited to 'gnu/java/rmi/server/UnicastRemoteCall.java')
| -rw-r--r-- | gnu/java/rmi/server/UnicastRemoteCall.java | 318 |
1 files changed, 168 insertions, 150 deletions
diff --git a/gnu/java/rmi/server/UnicastRemoteCall.java b/gnu/java/rmi/server/UnicastRemoteCall.java index 200538d4a..14ff9650c 100644 --- a/gnu/java/rmi/server/UnicastRemoteCall.java +++ b/gnu/java/rmi/server/UnicastRemoteCall.java @@ -38,15 +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; private Object result; @@ -56,92 +65,152 @@ public class UnicastRemoteCall implements RemoteCall private Vector vec; private int ptr; +private ObjectOutput oout; +private ObjectInput oin; + /** * Incoming call. */ - UnicastRemoteCall(UnicastConnection conn) - { +UnicastRemoteCall(UnicastConnection conn) { this.conn = conn; } /** * Outgoing call. */ - UnicastRemoteCall(Object obj, int opnum, long hash) - { +/* +UnicastRemoteCall(Object obj, int opnum, long hash) { this.object = obj; this.opnum = opnum; this.hash = hash; } +*/ - public ObjectOutput getOutputStream() throws IOException +UnicastRemoteCall(UnicastConnection conn, ObjID objid, int opnum, long hash) throws RemoteException { + 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 { + if (conn != null) { + if(oout == null) + return (oout = conn.getObjectOutputStream()); + else + return oout; + }else{ vec = new Vector(); - return new DummyObjectOutputStream(); + return (new DummyObjectOutputStream()); + } } - public void releaseOutputStream() throws IOException - { - // Does nothing. +public void releaseOutputStream() throws IOException { + if(oout != null) + oout.flush(); } - public ObjectInput getInputStream() throws IOException - { - if (conn != null) - return conn.getObjectInputStream(); +public ObjectInput getInputStream() throws IOException { + if (conn != null) { + if(oin == null) + return (oin = conn.getObjectInputStream()); + else + return oin; + } + else { ptr = 0; - return new DummyObjectInputStream(); + return (new DummyObjectInputStream()); + } } - public void releaseInputStream() throws IOException - { +public void releaseInputStream() throws IOException { // Does nothing. } - public ObjectOutput getResultStream(boolean success) - throws IOException, StreamCorruptedException - { +public ObjectOutput getResultStream(boolean success) throws IOException, StreamCorruptedException { vec = new Vector(); - return new DummyObjectOutputStream(); + return (new DummyObjectOutputStream()); } - public void executeCall() throws Exception - { - throw new Error("Not implemented"); +public void executeCall() throws Exception { + 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); } - public void done() throws IOException - { - /* Does nothing */ + //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"); + throw (Exception)returnobj; + } + default: + throw new UnmarshalException("Invalid return code"); + } } - Object returnValue() - { - return vec.elementAt(0); +public void done() throws IOException { + // conn.disconnect(); } - Object[] getArguments() - { - return vec.toArray(); +Object returnValue() { + return (vec.elementAt(0)); } - Object getObject() - { - return object; +Object[] getArguments() { + return (vec.toArray()); } - int getOpnum() - { - return opnum; +Object getObject() { + return (object); } - long getHash() - { - return hash; +int getOpnum() { + return (opnum); } - void setReturnValue(Object obj) - { +long getHash() { + return (hash); +} + +void setReturnValue(Object obj) { vec.removeAllElements(); vec.addElement(obj); } @@ -149,227 +218,176 @@ public class UnicastRemoteCall implements RemoteCall /** * Dummy object output class. */ - private class DummyObjectOutputStream implements ObjectOutput - { - /** - * Non-private constructor to reduce bytecode emitted. - */ - DummyObjectOutputStream() - { - } +private class DummyObjectOutputStream implements ObjectOutput { - public void writeBoolean(boolean v) throws IOException - { +public void writeBoolean(boolean v) throws IOException { vec.addElement(new Boolean(v)); } - public void writeByte(int v) throws IOException - { +public void writeByte(int v) throws IOException { vec.addElement(new Byte((byte) v)); } - public void writeChar(int v) throws IOException - { +public void writeChar(int v) throws IOException { vec.addElement(new Character((char) v)); } - public void writeDouble(double v) throws IOException - { +public void writeDouble(double v) throws IOException { vec.addElement(new Double(v)); } - public void writeFloat(float v) throws IOException - { +public void writeFloat(float v) throws IOException { vec.addElement(new Float(v)); } - public void writeInt(int v) throws IOException - { +public void writeInt(int v) throws IOException { vec.addElement(new Integer(v)); } - public void writeLong(long v) throws IOException - { +public void writeLong(long v) throws IOException { vec.addElement(new Long(v)); } - public void writeShort(int v) throws IOException - { +public void writeShort(int v) throws IOException { vec.addElement(new Short((short) v)); } - public void writeObject(Object obj) throws IOException - { +public void writeObject(Object obj) throws IOException { vec.addElement(obj); } - public void write(byte b[]) throws IOException - { +public void write(byte b[]) throws IOException { throw new IOException("not required"); } - public void write(byte b[], int off, int len) throws IOException - { +public void write(byte b[], int off, int len) throws IOException { throw new IOException("not required"); } - public void write(int b) throws IOException - { +public void write(int b) throws IOException { throw new IOException("not required"); } - public void writeBytes(String s) throws IOException - { +public void writeBytes(String s) throws IOException { throw new IOException("not required"); } - public void writeChars(String s) throws IOException - { +public void writeChars(String s) throws IOException { throw new IOException("not required"); } - public void writeUTF(String str) throws IOException - { +public void writeUTF(String str) throws IOException { throw new IOException("not required"); } - public void flush() throws IOException - { +public void flush() throws IOException { +} + +public void close() throws IOException { } - public void close() throws IOException - { } - } // class DummyObjectOutputStream /** * Dummy object input class. */ - private class DummyObjectInputStream implements ObjectInput - { - /** - * Non-private constructor to reduce bytecode emitted. - */ - DummyObjectInputStream() - { - } +private class DummyObjectInputStream implements ObjectInput { - public boolean readBoolean() throws IOException - { +public boolean readBoolean() throws IOException { Object obj = vec.elementAt(ptr++); - return ((Boolean) obj).booleanValue(); + return (((Boolean)obj).booleanValue()); } - public byte readByte() throws IOException - { +public byte readByte() throws IOException { Object obj = vec.elementAt(ptr++); - return ((Byte) obj).byteValue(); + return (((Byte)obj).byteValue()); } - public char readChar() throws IOException - { +public char readChar() throws IOException { Object obj = vec.elementAt(ptr++); - return ((Character) obj).charValue(); + return (((Character)obj).charValue()); } - public double readDouble() throws IOException - { +public double readDouble() throws IOException { Object obj = vec.elementAt(ptr++); - return ((Double) obj).doubleValue(); + return (((Double)obj).doubleValue()); } - public float readFloat() throws IOException - { +public float readFloat() throws IOException { Object obj = vec.elementAt(ptr++); - return ((Float) obj).floatValue(); + return (((Float)obj).floatValue()); } - public int readInt() throws IOException - { +public int readInt() throws IOException { Object obj = vec.elementAt(ptr++); - return ((Integer) obj).intValue(); + return (((Integer)obj).intValue()); } - public long readLong() throws IOException - { +public long readLong() throws IOException { Object obj = vec.elementAt(ptr++); - return ((Long) obj).longValue(); + return (((Long)obj).longValue()); } - public short readShort() throws IOException - { +public short readShort() throws IOException { Object obj = vec.elementAt(ptr++); - return ((Short) obj).shortValue(); + return (((Short)obj).shortValue()); } - public Object readObject() throws IOException - { - return vec.elementAt(ptr++); +public Object readObject() throws IOException { + return (vec.elementAt(ptr++)); } - public int read(byte b[]) throws IOException - { +public int read(byte b[]) throws IOException { throw new IOException("not required"); } - public int read(byte b[], int off, int len) throws IOException - { +public int read(byte b[], int off, int len) throws IOException { throw new IOException("not required"); } - public int read() throws IOException - { +public int read() throws IOException { throw new IOException("not required"); } - public long skip(long n) throws IOException - { +public long skip(long n) throws IOException { throw new IOException("not required"); } - public int available() throws IOException - { +public int available() throws IOException { throw new IOException("not required"); } - public void readFully(byte b[]) throws IOException - { +public void readFully(byte b[]) throws IOException { throw new IOException("not required"); } - public void readFully(byte b[], int off, int len) throws IOException - { +public void readFully(byte b[], int off, int len) throws IOException { throw new IOException("not required"); } - public String readLine() throws IOException - { +public String readLine() throws IOException { throw new IOException("not required"); } - public String readUTF() throws IOException - { +public String readUTF() throws IOException { throw new IOException("not required"); } - public int readUnsignedByte() throws IOException - { +public int readUnsignedByte() throws IOException { throw new IOException("not required"); } - public int readUnsignedShort() throws IOException - { +public int readUnsignedShort() throws IOException { throw new IOException("not required"); } - public int skipBytes(int n) throws IOException - { +public int skipBytes(int n) throws IOException { throw new IOException("not required"); } - public void close() throws IOException - { +public void close() throws IOException { +} + } - } // class DummyObjectInputStream } |
