diff options
| author | Mark Wielaard <mark@klomp.org> | 2002-11-07 10:19:13 +0000 |
|---|---|---|
| committer | Mark Wielaard <mark@klomp.org> | 2002-11-07 10:19:13 +0000 |
| commit | d57cec8e30ba0ee9ec1bedc9d1b87bd17e7bb53f (patch) | |
| tree | 36b8eb9e4a53549768e0abd9eb7e06a01c8f1223 /gnu/java/rmi/server/UnicastRemoteCall.java | |
| parent | 3c1a23e745501ccffb24a6e31299ce3a5d580206 (diff) | |
| download | classpath-d57cec8e30ba0ee9ec1bedc9d1b87bd17e7bb53f.tar.gz | |
* gnu/java/rmi/server/UnicastRemoteCall.java: Reindent.
Diffstat (limited to 'gnu/java/rmi/server/UnicastRemoteCall.java')
| -rw-r--r-- | gnu/java/rmi/server/UnicastRemoteCall.java | 388 |
1 files changed, 233 insertions, 155 deletions
diff --git a/gnu/java/rmi/server/UnicastRemoteCall.java b/gnu/java/rmi/server/UnicastRemoteCall.java index 14ff9650c..734002aaa 100644 --- a/gnu/java/rmi/server/UnicastRemoteCall.java +++ b/gnu/java/rmi/server/UnicastRemoteCall.java @@ -55,7 +55,8 @@ import java.rmi.server.RemoteObject; import java.util.Vector; public class UnicastRemoteCall - implements RemoteCall, ProtocolConstants { + implements RemoteCall, ProtocolConstants +{ private UnicastConnection conn; private Object result; @@ -65,152 +66,178 @@ public class UnicastRemoteCall private Vector vec; private int ptr; -private ObjectOutput oout; -private ObjectInput oin; + 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) { - this.object = obj; + 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); + } } -*/ - -UnicastRemoteCall(UnicastConnection conn, ObjID objid, int opnum, long hash) throws RemoteException + + UnicastConnection getConnection() { - 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()); - } + } + + 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()); + } } -public void releaseOutputStream() throws IOException { - if(oout != null) - oout.flush(); + public void releaseOutputStream() throws IOException + { + if(oout != null) + oout.flush(); } -public ObjectInput getInputStream() throws IOException { - if (conn != null) { - if(oin == null) - return (oin = conn.getObjectInputStream()); - else - return oin; - } - else { - ptr = 0; - return (new DummyObjectInputStream()); - } + public ObjectInput getInputStream() throws IOException + { + if (conn != null) + { + if(oin == null) + return (oin = conn.getObjectInputStream()); + else + return oin; + } + else + { + ptr = 0; + 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 + { + byte returncode; + ObjectInput oin; + try + { + releaseOutputStream(); + DataInputStream din = conn.getDataInputStream(); + if (din.readByte() != MESSAGE_CALL_ACK) + throw new RemoteException("Call not acked"); -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){ + } + 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"); - throw (Exception)returnobj; - } - default: - throw new UnmarshalException("Invalid 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 { + public void done() throws IOException + { // conn.disconnect(); } -Object returnValue() { - return (vec.elementAt(0)); + Object returnValue() + { + return vec.elementAt(0); } -Object[] getArguments() { - return (vec.toArray()); + Object[] getArguments() + { + return vec.toArray(); } -Object getObject() { - return (object); + Object getObject() + { + return object; } -int getOpnum() { - return (opnum); + int getOpnum() + { + return opnum; } -long getHash() { - return (hash); -} + long getHash() + { + return hash; + } -void setReturnValue(Object obj) { + void setReturnValue(Object obj) + { vec.removeAllElements(); vec.addElement(obj); } @@ -218,176 +245,227 @@ void setReturnValue(Object obj) { /** * Dummy object output class. */ -private class DummyObjectOutputStream implements ObjectOutput { + private class DummyObjectOutputStream implements ObjectOutput + { + /** + * Non-private constructor to reduce bytecode emitted. + */ + DummyObjectOutputStream() + { + } -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 close() throws IOException { + public void flush() throws IOException + { } + public void close() throws IOException + { } + } // class DummyObjectOutputStream /** * Dummy object input class. */ -private class DummyObjectInputStream implements ObjectInput { + private class DummyObjectInputStream implements ObjectInput + { + /** + * Non-private constructor to reduce bytecode emitted. + */ + DummyObjectInputStream() + { + } -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 } |
