1 11 package org.eclipse.debug.internal.core; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 16 import org.eclipse.debug.core.IStreamListener; 17 import org.eclipse.debug.core.model.IStreamMonitor; 18 import org.eclipse.debug.core.model.IStreamsProxy2; 19 20 public class NullStreamsProxy implements IStreamsProxy2 { 21 private NullStreamMonitor outputStreamMonitor; 22 private NullStreamMonitor errorStreamMonitor; 23 24 public NullStreamsProxy(Process process) { 25 outputStreamMonitor = new NullStreamMonitor(process.getInputStream()); 26 errorStreamMonitor = new NullStreamMonitor(process.getErrorStream()); 27 } 28 29 32 public void closeInputStream() throws IOException { 33 } 34 35 38 public IStreamMonitor getErrorStreamMonitor() { 39 return errorStreamMonitor; 40 } 41 42 45 public IStreamMonitor getOutputStreamMonitor() { 46 return outputStreamMonitor; 47 } 48 49 52 public void write(String input) throws IOException { 53 } 54 55 private class NullStreamMonitor implements IStreamMonitor { 56 private InputStream fStream; 57 58 public NullStreamMonitor(InputStream stream) { 59 fStream = stream; 60 startReaderThread(); 61 } 62 63 private void startReaderThread() { 64 Thread thread = new Thread (new Runnable () { 65 public void run() { 66 byte[] bytes = new byte[1024]; 67 try { 68 while(fStream.read(bytes) >= 0) { 69 } 71 } catch (IOException e) { 72 } 73 } 74 }, DebugCoreMessages.NullStreamsProxy_0); 75 thread.setDaemon(true); 76 thread.start(); 77 78 } 79 80 83 public void addListener(IStreamListener listener) { 84 } 85 86 89 public String getContents() { 90 return ""; } 92 93 96 public void removeListener(IStreamListener listener) { 97 } 98 } 99 } 100 | Popular Tags |