/[classpath]/classpath/gnu/java/rmi/server/UnicastRemoteCall.java
ViewVC logotype

Diff of /classpath/gnu/java/rmi/server/UnicastRemoteCall.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mark, Tue Jan 22 22:26:57 2002 UTC revision 1.3 by ericb, Sat Feb 9 23:22:05 2002 UTC
# Line 1  Line 1 
1  /*  /* UnicastRemoteCall.java
2    Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.    Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 7  GNU Classpath is free software; you can Line 7  GNU Classpath is free software; you can
7  it under the terms of the GNU General Public License as published by  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)  the Free Software Foundation; either version 2, or (at your option)
9  any later version.  any later version.
10    
11  GNU Classpath is distributed in the hope that it will be useful, but  GNU Classpath is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Line 45  import java.io.StreamCorruptedException; Line 45  import java.io.StreamCorruptedException;
45  import java.rmi.server.RemoteCall;  import java.rmi.server.RemoteCall;
46  import java.util.Vector;  import java.util.Vector;
47    
48  public class UnicastRemoteCall  public class UnicastRemoteCall implements RemoteCall
49          implements RemoteCall {  {
   
 private UnicastConnection conn;  
 private Object result;  
 private Object object;  
 private int opnum;  
 private long hash;  
 private Vector vec;  
 private int ptr;  
   
 /**  
  * Incoming call.  
  */  
 UnicastRemoteCall(UnicastConnection conn) {  
         this.conn = conn;  
 }  
   
 /**  
  * Outgoing call.  
  */  
 UnicastRemoteCall(Object obj, int opnum, long hash) {  
         this.object = obj;  
         this.opnum = opnum;  
         this.hash = hash;  
 }  
   
 public ObjectOutput getOutputStream() throws IOException {  
         vec = new Vector();  
         return (new DummyObjectOutputStream());  
 }  
   
 public void releaseOutputStream() throws IOException {  
         // Does nothing.  
 }  
   
 public ObjectInput getInputStream() throws IOException {  
         if (conn != null) {  
                 return (conn.getObjectInputStream());  
         }  
         else {  
                 ptr = 0;  
                 return (new DummyObjectInputStream());  
         }  
 }  
   
 public void releaseInputStream() throws IOException {  
         // Does nothing.  
 }  
   
 public ObjectOutput getResultStream(boolean success) throws IOException, StreamCorruptedException {  
         vec = new Vector();  
         return (new DummyObjectOutputStream());  
 }  
   
 public void executeCall() throws Exception {  
         throw new Error("Not implemented");  
 }  
   
 public void done() throws IOException {  
         /* Does nothing */  
 }  
   
 Object returnValue() {  
         return (vec.elementAt(0));  
 }  
   
 Object[] getArguments() {  
         return (vec.toArray());  
 }  
   
 Object getObject() {  
         return (object);  
 }  
   
 int getOpnum() {  
         return (opnum);  
 }  
   
 long getHash() {  
         return (hash);  
 }  
50    
51  void setReturnValue(Object obj) {    private UnicastConnection conn;
52          vec.removeAllElements();    private Object result;
53          vec.addElement(obj);    private Object object;
54  }    private int opnum;
55      private long hash;
56  /**    private Vector vec;
57   * Dummy object output class.    private int ptr;
58   */  
59  private class DummyObjectOutputStream implements ObjectOutput {    /**
60       * Incoming call.
61  public void writeBoolean(boolean v) throws IOException {     */
62          vec.addElement(new Boolean(v));    UnicastRemoteCall(UnicastConnection conn)
63  }    {
64        this.conn = conn;
65  public void writeByte(int v) throws IOException {    }
66          vec.addElement(new Byte((byte)v));  
67  }    /**
68       * Outgoing call.
69  public void writeChar(int v) throws IOException {     */
70          vec.addElement(new Character((char)v));    UnicastRemoteCall(Object obj, int opnum, long hash)
71  }    {
72        this.object = obj;
73  public void writeDouble(double v) throws IOException {      this.opnum = opnum;
74          vec.addElement(new Double(v));      this.hash = hash;
75  }    }
76    
77  public void writeFloat(float v) throws IOException {    public ObjectOutput getOutputStream() throws IOException
78          vec.addElement(new Float(v));    {
79  }      vec = new Vector();
80        return new DummyObjectOutputStream();
81  public void writeInt(int v) throws IOException {    }
82          vec.addElement(new Integer(v));  
83  }    public void releaseOutputStream() throws IOException
84      {
85  public void writeLong(long v) throws IOException {      // Does nothing.
86          vec.addElement(new Long(v));    }
87  }  
88      public ObjectInput getInputStream() throws IOException
89  public void writeShort(int v) throws IOException {    {
90          vec.addElement(new Short((short)v));      if (conn != null)
91  }        return conn.getObjectInputStream();
92        ptr = 0;
93  public void writeObject(Object obj) throws IOException {      return new DummyObjectInputStream();
94          vec.addElement(obj);    }
95  }  
96      public void releaseInputStream() throws IOException
97  public void write(byte b[]) throws IOException {    {
98          throw new IOException("not required");      // Does nothing.
99  }    }
100    
101  public void write(byte b[], int off, int len) throws IOException {    public ObjectOutput getResultStream(boolean success)
102          throw new IOException("not required");      throws IOException, StreamCorruptedException
103  }    {
104        vec = new Vector();
105  public void write(int b) throws IOException {      return new DummyObjectOutputStream();
106          throw new IOException("not required");    }
107  }  
108      public void executeCall() throws Exception
109  public void writeBytes(String s) throws IOException {    {
110          throw new IOException("not required");      throw new Error("Not implemented");
111  }    }
112    
113  public void writeChars(String s) throws IOException {    public void done() throws IOException
114          throw new IOException("not required");    {
115  }      /* Does nothing */
116      }
117  public void writeUTF(String str) throws IOException {  
118          throw new IOException("not required");    Object returnValue()
119  }    {
120        return vec.elementAt(0);
121  public void flush() throws IOException {    }
122  }  
123      Object[] getArguments()
124  public void close() throws IOException {    {
125  }      return vec.toArray();
126      }
127  }  
128      Object getObject()
129  /**    {
130   * Dummy object input class.      return object;
131   */    }
132  private class DummyObjectInputStream implements ObjectInput {  
133      int getOpnum()
134  public boolean readBoolean() throws IOException {    {
135          Object obj = vec.elementAt(ptr++);      return opnum;
136          return (((Boolean)obj).booleanValue());    }
137  }  
138      long getHash()
139  public byte readByte() throws IOException {    {
140          Object obj = vec.elementAt(ptr++);      return hash;
141          return (((Byte)obj).byteValue());    }
142  }  
143      void setReturnValue(Object obj)
144  public char readChar() throws IOException {    {
145          Object obj = vec.elementAt(ptr++);      vec.removeAllElements();
146          return (((Character)obj).charValue());      vec.addElement(obj);
147  }    }
148    
149  public double readDouble() throws IOException {    /**
150          Object obj = vec.elementAt(ptr++);     * Dummy object output class.
151          return (((Double)obj).doubleValue());     */
152  }    private class DummyObjectOutputStream implements ObjectOutput
153      {
154  public float readFloat() throws IOException {      public void writeBoolean(boolean v) throws IOException
155          Object obj = vec.elementAt(ptr++);      {
156          return (((Float)obj).floatValue());        vec.addElement(new Boolean(v));
157  }      }
158    
159  public int readInt() throws IOException {      public void writeByte(int v) throws IOException
160          Object obj = vec.elementAt(ptr++);      {
161          return (((Integer)obj).intValue());        vec.addElement(new Byte((byte) v));
162  }      }
163    
164  public long readLong() throws IOException {      public void writeChar(int v) throws IOException
165          Object obj = vec.elementAt(ptr++);      {
166          return (((Long)obj).longValue());        vec.addElement(new Character((char) v));
167  }      }
168    
169  public short readShort() throws IOException {      public void writeDouble(double v) throws IOException
170          Object obj = vec.elementAt(ptr++);      {
171          return (((Short)obj).shortValue());        vec.addElement(new Double(v));
172  }      }
173    
174  public Object readObject() throws IOException {      public void writeFloat(float v) throws IOException
175          return (vec.elementAt(ptr++));      {
176  }        vec.addElement(new Float(v));
177        }
178  public int read(byte b[]) throws IOException {  
179          throw new IOException("not required");      public void writeInt(int v) throws IOException
180  }      {
181          vec.addElement(new Integer(v));
182  public int read(byte b[], int off, int len) throws IOException {      }
183          throw new IOException("not required");  
184  }      public void writeLong(long v) throws IOException
185        {
186  public int read() throws IOException {        vec.addElement(new Long(v));
187          throw new IOException("not required");      }
188  }  
189        public void writeShort(int v) throws IOException
190  public long skip(long n) throws IOException {      {
191          throw new IOException("not required");        vec.addElement(new Short((short) v));
192  }      }
193    
194  public int available() throws IOException {      public void writeObject(Object obj) throws IOException
195          throw new IOException("not required");      {
196  }        vec.addElement(obj);
197        }
198  public void readFully(byte b[]) throws IOException {  
199          throw new IOException("not required");      public void write(byte b[]) throws IOException
200  }      {
201          throw new IOException("not required");
202  public void readFully(byte b[], int off, int len) throws IOException {      }
203          throw new IOException("not required");  
204  }      public void write(byte b[], int off, int len) throws IOException
205        {
206  public String readLine() throws IOException {        throw new IOException("not required");
207          throw new IOException("not required");      }
208  }  
209        public void write(int b) throws IOException
210  public String readUTF() throws IOException {      {
211          throw new IOException("not required");        throw new IOException("not required");
212  }      }
213    
214  public int readUnsignedByte() throws IOException {      public void writeBytes(String s) throws IOException
215          throw new IOException("not required");      {
216  }        throw new IOException("not required");
217        }
218  public int readUnsignedShort() throws IOException {  
219          throw new IOException("not required");      public void writeChars(String s) throws IOException
220  }      {
221          throw new IOException("not required");
222  public int skipBytes(int n) throws IOException {      }
223          throw new IOException("not required");  
224  }      public void writeUTF(String str) throws IOException
225        {
226  public void close() throws IOException {        throw new IOException("not required");
227  }      }
228    
229  }      public void flush() throws IOException
230        {
231        }
232    
233        public void close() throws IOException
234        {
235        }
236      } // class DummyObjectOutputStream
237    
238      /**
239       * Dummy object input class.
240       */
241      private class DummyObjectInputStream implements ObjectInput
242      {
243        public boolean readBoolean() throws IOException
244        {
245          Object obj = vec.elementAt(ptr++);
246          return ((Boolean) obj).booleanValue();
247        }
248    
249        public byte readByte() throws IOException
250        {
251          Object obj = vec.elementAt(ptr++);
252          return ((Byte) obj).byteValue();
253        }
254    
255        public char readChar() throws IOException
256        {
257          Object obj = vec.elementAt(ptr++);
258          return ((Character) obj).charValue();
259        }
260    
261        public double readDouble() throws IOException
262        {
263          Object obj = vec.elementAt(ptr++);
264          return ((Double) obj).doubleValue();
265        }
266    
267        public float readFloat() throws IOException
268        {
269          Object obj = vec.elementAt(ptr++);
270          return ((Float) obj).floatValue();
271        }
272    
273        public int readInt() throws IOException
274        {
275          Object obj = vec.elementAt(ptr++);
276          return ((Integer) obj).intValue();
277        }
278    
279        public long readLong() throws IOException
280        {
281          Object obj = vec.elementAt(ptr++);
282          return ((Long) obj).longValue();
283        }
284    
285        public short readShort() throws IOException
286        {
287          Object obj = vec.elementAt(ptr++);
288          return ((Short) obj).shortValue();
289        }
290    
291        public Object readObject() throws IOException
292        {
293          return vec.elementAt(ptr++);
294        }
295    
296        public int read(byte b[]) throws IOException
297        {
298          throw new IOException("not required");
299        }
300    
301        public int read(byte b[], int off, int len) throws IOException
302        {
303          throw new IOException("not required");
304        }
305    
306        public int read() throws IOException
307        {
308          throw new IOException("not required");
309        }
310    
311        public long skip(long n) throws IOException
312        {
313          throw new IOException("not required");
314        }
315    
316        public int available() throws IOException
317        {
318          throw new IOException("not required");
319        }
320    
321        public void readFully(byte b[]) throws IOException
322        {
323          throw new IOException("not required");
324        }
325    
326        public void readFully(byte b[], int off, int len) throws IOException
327        {
328          throw new IOException("not required");
329        }
330    
331        public String readLine() throws IOException
332        {
333          throw new IOException("not required");
334        }
335    
336        public String readUTF() throws IOException
337        {
338          throw new IOException("not required");
339        }
340    
341        public int readUnsignedByte() throws IOException
342        {
343          throw new IOException("not required");
344        }
345    
346        public int readUnsignedShort() throws IOException
347        {
348          throw new IOException("not required");
349        }
350    
351        public int skipBytes(int n) throws IOException
352        {
353          throw new IOException("not required");
354        }
355    
356        public void close() throws IOException
357        {
358        }
359      } // class DummyObjectInputStream
360    
361  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26