diff options
| author | Mark Wielaard <mark@klomp.org> | 2003-12-26 01:45:41 +0000 |
|---|---|---|
| committer | Mark Wielaard <mark@klomp.org> | 2003-12-26 01:45:41 +0000 |
| commit | dd596d85fce62c19c7f712e004c606a088db6b2b (patch) | |
| tree | 79428126c298660c586a1a6a5b0f80bc3e128f6e /gnu/java/rmi/server/UnicastRemoteCall.java | |
| parent | 36665224f971a2bc8acd8aefd4770eaa87e868fa (diff) | |
| download | classpath-dd596d85fce62c19c7f712e004c606a088db6b2b.tar.gz | |
2003-12-25 Guilhem Lavaux <guilhem@kaffe.org>
Mark Wielaard <mark@klomp.org>
* gnu/java/rmi/server/UnicastConnectionManager.java
(startScavenger): Set the client connection manager to daemon
state because it may block clients until TIMEOUT is reached
when they are exiting.
* gnu/java/rmi/RMIVoidValue.java: New file for a class representing
a void return.
* gnu/java/rmi/server/UnicastRemoteCall.java
(DummyOutputStream): Add a boolean before each written field to
know whether it is a primitive.
(releaseOutputStream): Flush parameters at write time.
* gnu/java/rmi/server/UnicastServerRef.java
(incomingMessageCall): Return a RMIVoidValue if no value is to be
returned.
* gnu/java/rmi/server/UnicastServer.java
(incomingMessageCall): Do not write a returned object if it is
a RMIVoidValue.
* gnu/java/rmi/server/Makefile.am (EXTRA_DIST): Add RMIVoidValue.java.
Diffstat (limited to 'gnu/java/rmi/server/UnicastRemoteCall.java')
| -rw-r--r-- | gnu/java/rmi/server/UnicastRemoteCall.java | 99 |
1 files changed, 69 insertions, 30 deletions
diff --git a/gnu/java/rmi/server/UnicastRemoteCall.java b/gnu/java/rmi/server/UnicastRemoteCall.java index 68d1bfe01..2d7d6d4a9 100644 --- a/gnu/java/rmi/server/UnicastRemoteCall.java +++ b/gnu/java/rmi/server/UnicastRemoteCall.java @@ -65,6 +65,7 @@ public class UnicastRemoteCall private long hash; private Vector vec; private int ptr; + private ObjID objid; private ObjectOutput oout; private ObjectInput oin; @@ -86,22 +87,7 @@ public class UnicastRemoteCall 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); - } + this.objid = objid; } UnicastConnection getConnection() @@ -111,22 +97,43 @@ public class UnicastRemoteCall 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()); - } + if (vec == null) + vec = new Vector(); + return (new DummyObjectOutputStream()); } public void releaseOutputStream() throws IOException { + if (vec != null) + { + oout = conn.getObjectOutputStream(); + + for (int i = 0; i < vec.size(); i += 2) + { + boolean primitive = ((Boolean)vec.elementAt(i)).booleanValue(); + Object data = vec.elementAt(i+1); + + // No type, this is + if (!primitive) + oout.writeObject(data); + else + { + if (data instanceof Boolean) + oout.writeBoolean(((Boolean)data).booleanValue()); + else if (data instanceof Character) + oout.writeChar(((Character)data).charValue()); + else if (data instanceof Byte) + oout.writeByte(((Byte)data).byteValue()); + else if (data instanceof Short) + oout.writeShort(((Short)data).shortValue()); + else if (data instanceof Integer) + oout.writeInt(((Integer)data).intValue()); + else if (data instanceof Long) + oout.writeLong(((Long)data).longValue()); + } + } + vec = null; + } if(oout != null) oout.flush(); } @@ -163,6 +170,23 @@ public class UnicastRemoteCall { byte returncode; ObjectInput oin; + + // 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); + } + try { releaseOutputStream(); @@ -211,9 +235,15 @@ public class UnicastRemoteCall // conn.disconnect(); } + boolean isReturnValue() + { + return vec.size() > 0; + } + Object returnValue() { - return (vec.size() > 0 ? vec.elementAt(0) : null); + // This is not the first one (Boolean) but the second. + return vec.elementAt(1); } Object[] getArguments() @@ -256,46 +286,55 @@ public class UnicastRemoteCall public void writeBoolean(boolean v) throws IOException { - vec.addElement(new Boolean(v)); + vec.addElement(Boolean.TRUE); + vec.addElement(Boolean.valueOf(v)); } public void writeByte(int v) throws IOException { + vec.addElement(Boolean.TRUE); vec.addElement(new Byte((byte) v)); } public void writeChar(int v) throws IOException { + vec.addElement(Boolean.TRUE); vec.addElement(new Character((char) v)); } public void writeDouble(double v) throws IOException { + vec.addElement(Boolean.TRUE); vec.addElement(new Double(v)); } public void writeFloat(float v) throws IOException { + vec.addElement(Boolean.TRUE); vec.addElement(new Float(v)); } public void writeInt(int v) throws IOException { + vec.addElement(Boolean.TRUE); vec.addElement(new Integer(v)); } public void writeLong(long v) throws IOException { + vec.addElement(Boolean.TRUE); vec.addElement(new Long(v)); } public void writeShort(int v) throws IOException { + vec.addElement(Boolean.TRUE); vec.addElement(new Short((short) v)); } public void writeObject(Object obj) throws IOException { + vec.addElement(Boolean.FALSE); vec.addElement(obj); } |
