KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > remoting > RemoteInputStream


1 package hudson.remoting;
2
3 import java.io.InputStream JavaDoc;
4 import java.io.Serializable JavaDoc;
5 import java.io.ObjectOutputStream JavaDoc;
6 import java.io.IOException JavaDoc;
7 import java.io.ObjectInputStream JavaDoc;
8
9 /**
10  * @author Kohsuke Kawaguchi
11  */

12 public class RemoteInputStream extends InputStream JavaDoc implements Serializable JavaDoc {
13     private transient InputStream JavaDoc core;
14
15     public RemoteInputStream(InputStream JavaDoc core) {
16         this.core = core;
17     }
18
19     private void writeObject(ObjectOutputStream JavaDoc oos) throws IOException JavaDoc {
20         int id = Channel.current().export(core);
21         oos.writeInt(id);
22     }
23
24     private void readObject(ObjectInputStream JavaDoc ois) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
25         final Channel channel = Channel.current();
26         assert channel !=null;
27
28         this.core = new ProxyInputStream(channel, ois.readInt());
29     }
30
31     private static final long serialVersionUID = 1L;
32
33 //
34
//
35
// delegation to core
36
//
37
//
38

39     public int read() throws IOException JavaDoc {
40         return core.read();
41     }
42
43     public int read(byte[] b) throws IOException JavaDoc {
44         return core.read(b);
45     }
46
47     public int read(byte[] b, int off, int len) throws IOException JavaDoc {
48         return core.read(b, off, len);
49     }
50
51     public long skip(long n) throws IOException JavaDoc {
52         return core.skip(n);
53     }
54
55     public int available() throws IOException JavaDoc {
56         return core.available();
57     }
58
59     public void close() throws IOException JavaDoc {
60         core.close();
61     }
62
63     public void mark(int readlimit) {
64         core.mark(readlimit);
65     }
66
67     public void reset() throws IOException JavaDoc {
68         core.reset();
69     }
70
71     public boolean markSupported() {
72         return core.markSupported();
73     }
74 }
75
Popular Tags