1 package hudson.remoting; 2 3 import java.io.InputStream ; 4 import java.io.Serializable ; 5 import java.io.ObjectOutputStream ; 6 import java.io.IOException ; 7 import java.io.ObjectInputStream ; 8 9 12 public class RemoteInputStream extends InputStream implements Serializable { 13 private transient InputStream core; 14 15 public RemoteInputStream(InputStream core) { 16 this.core = core; 17 } 18 19 private void writeObject(ObjectOutputStream oos) throws IOException { 20 int id = Channel.current().export(core); 21 oos.writeInt(id); 22 } 23 24 private void readObject(ObjectInputStream ois) throws IOException , ClassNotFoundException { 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 39 public int read() throws IOException { 40 return core.read(); 41 } 42 43 public int read(byte[] b) throws IOException { 44 return core.read(b); 45 } 46 47 public int read(byte[] b, int off, int len) throws IOException { 48 return core.read(b, off, len); 49 } 50 51 public long skip(long n) throws IOException { 52 return core.skip(n); 53 } 54 55 public int available() throws IOException { 56 return core.available(); 57 } 58 59 public void close() throws IOException { 60 core.close(); 61 } 62 63 public void mark(int readlimit) { 64 core.mark(readlimit); 65 } 66 67 public void reset() throws IOException { 68 core.reset(); 69 } 70 71 public boolean markSupported() { 72 return core.markSupported(); 73 } 74 } 75 | Popular Tags |