1 package hudson.remoting; 2 3 import java.io.IOException ; 4 import java.io.ObjectInputStream ; 5 import java.io.ObjectOutputStream ; 6 import java.io.OutputStream ; 7 import java.io.Serializable ; 8 9 42 public final class RemoteOutputStream extends OutputStream implements Serializable { 43 50 private transient OutputStream core; 51 52 public RemoteOutputStream(OutputStream core) { 53 this.core = core; 54 } 55 56 private void writeObject(ObjectOutputStream oos) throws IOException { 57 int id = Channel.current().export(core); 58 oos.writeInt(id); 59 } 60 61 private void readObject(ObjectInputStream ois) throws IOException , ClassNotFoundException { 62 final Channel channel = Channel.current(); 63 assert channel !=null; 64 65 this.core = new ProxyOutputStream(channel, ois.readInt()); 66 } 67 68 private static final long serialVersionUID = 1L; 69 70 71 public void write(int b) throws IOException { 77 core.write(b); 78 } 79 80 public void write(byte[] b) throws IOException { 81 core.write(b); 82 } 83 84 public void write(byte[] b, int off, int len) throws IOException { 85 core.write(b, off, len); 86 } 87 88 public void flush() throws IOException { 89 core.flush(); 90 } 91 92 public void close() throws IOException { 93 core.close(); 94 } 95 } 96 | Popular Tags |