/** * Adds listener to monitor, and calls listener with any content monitor already has. * NOTE: This methods synchronises on monitor while listener is called. Listener may * not wait on any thread that waits for monitors monitor, what would result in dead-lock. */ public static void addAndNotifyStreamListener(IStreamMonitor monitor, IStreamListener listener) { // Synchronise on monitor to prevent writes to stream while we are adding listener. // It's weird to synchronise on monitor because that's a shared object, but that's // what ProcessConsole does. synchronized (monitor) { String contents = monitor.getContents(); if (!contents.isEmpty()) { // Call to unknown code while synchronising on monitor. This is dead-lock prone! // Listener must not wait for other threads that are waiting in line to // synchronise on monitor. listener.streamAppended(contents, monitor); } monitor.addListener(listener); } }
public synchronized void streamAppended(String text, IStreamMonitor monitor) { // broadcast the message for (int i = 0; i < listeners.length; i++) { if (listeners[i] != null) { try { listeners[i].appendText(text); } catch (Exception e) { TLCActivator.logError("Error broadcasting the message", e); } } } }
public synchronized void streamAppended(String text, IStreamMonitor monitor) { // broadcast the message for (int i = 0; i < listeners.length; i++) { if (listeners[i] != null) { try { listeners[i].appendText(text); } catch (Exception e) { ProverUIActivator.getDefault().logError("Error broadcasting the message", e); } } } }
private void onAfterCodeServerStarted(DebugEvent event) { if (!(event.getSource() instanceof IProcess)) { return; } IProcess runtimeProcess = (IProcess) event.getSource(); final ILaunch launch = runtimeProcess.getLaunch(); IProcess[] processes = launch.getProcesses(); final IProcess process = processes[0]; // Look for the links in the sdm console output consoleStreamListenerCodeServer = new IStreamListener() { @Override public void streamAppended(String text, IStreamMonitor monitor) { displayCodeServerUrlInDevMode(launch, text); } }; // Listen to Console output streamMonitorCodeServer = process.getStreamsProxy().getOutputStreamMonitor(); streamMonitorCodeServer.addListener(consoleStreamListenerCodeServer); }
@Override public IStreamsProxy getStreamsProxy() { return new IStreamsProxy() { @Override public void write(String input) throws IOException { } @Override public IStreamMonitor getErrorStreamMonitor() { return errorStream; } @Override public IStreamMonitor getOutputStreamMonitor() { return outputStream; } }; }
@Override public void streamAppended(String text, IStreamMonitor monitor) { HybridCore.trace(text); if(delegate != null){ delegate.streamAppended(text, monitor); } }
public void addMonListener(IConsole parserConsole, IStreamMonitor monitor, IStreamListener listener){ if (parserListeners==null){ MessageUI.error("BUG in addMonListener(): parserListeners=null - enable breakpoints"); System.out.println("BUG in addMonListener(): parserListeners=null"); return; } // synchronized (parserListeners){ parserListeners.put(parserConsole, new MonListener(monitor, listener)); // java.lang.NullPointerException // } }
@Override public void streamAppended(String text, IStreamMonitor monitor) { if (text.length() == 0 && !shell.isActive()) { getSystemRegistry().fireEvent( new SystemResourceChangeEvent(RemoteProcess.this, ISystemResourceChangeEvents.EVENT_COMMAND_SHELL_FINISHED, cmdSubSystem)); } }
@Override public void streamAppended(String text, IStreamMonitor monitor) { }
@Override public IStreamMonitor getErrorStreamMonitor() { return errorMonitor; }
@Override public IStreamMonitor getOutputStreamMonitor() { return outputMonitor; }
/** * This method sets up the mechanism for listening to the error and output streams * of the prover. It also sets the value of the field proverProcess. * * @param process * @param monitor */ private void setUpStreamListening(Process process, IProgressMonitor monitor) { /* * This code proceeds as follows. First, we wrap the java.lang.Process in an IProcess by calling * DebugPlugin.newProcess(). An IProcess is an eclipse object with some * convenience methods. Then we create a TLAPMBroadcastStreamListener and add it as * a listener to the output and error streams of the IProcess. * * The code is wrapped in two synchronized blocks to avoid a race condition on the * prover's output. The race condition can occur as follows. Calling DebugPlugin.newProcess() * creates instances of IStreamMonitor to monitor the output and error streams * of the prover. These monitors immediately start monitoring the streams and passing the * text from the streams to registered listeners. This means that they can potentially read * text from the prover's streams before the TLAPMBroadcastStreamListener is added as a listener. * This text would be lost. To solve this, this thread locks access to the prover's output and error * streams until after the TLAPMBroadcastStreamListener has been added as a listener. */ if (process != null) { synchronized (process.getInputStream()) { synchronized (process.getErrorStream()) { /* * Calling DebugPlugin.newProcess() * wraps the java.lang.Process in an IProcess with some * convenience methods. */ proverProcess = DebugPlugin.newProcess(launch, process, getName()); /* * Setup the broadcasting of the prover output stream. * We pass in the progress monitor to allow listeners * to report progress. */ listener = new TLAPMBroadcastStreamListener(module, this, monitor); /* * Send a string to the listener indicating * that a new prover job is starting. This makes * it easier to read the console. */ listener.streamAppended("---------------- New Prover Launch --------------\n", null); IStreamMonitor esMonitor = proverProcess.getStreamsProxy().getErrorStreamMonitor(); IStreamMonitor osMonitor = proverProcess.getStreamsProxy().getOutputStreamMonitor(); esMonitor.addListener(listener); osMonitor.addListener(listener); /* * The output from the prover can be long, so buffering it can lead to an * OutOfMemoryError. The following code turns off buffering. */ if (esMonitor instanceof IFlushableStreamMonitor && osMonitor instanceof IFlushableStreamMonitor) { ((IFlushableStreamMonitor) esMonitor).setBuffered(false); ((IFlushableStreamMonitor) osMonitor).setBuffered(false); } } } } }
@Override public void streamAppended(String text, IStreamMonitor monitor) { TypeScriptCompilerHelper.processMessage(text, this); }
@Override public IStreamMonitor getErrorStreamMonitor() { return this.error; }
@Override public IStreamMonitor getOutputStreamMonitor() { return this.output; }
BfOutputStream(IStreamMonitor monitor, String encoding) { this.monitor = monitor; this.encoding = encoding; }
public IStreamMonitor getErrorStreamMonitor() { return NullStreamMonitor.INSTANCE; }
public IStreamMonitor getOutputStreamMonitor() { return outputMonitor; }
@Override public void streamAppended(String text, IStreamMonitor monitor) { buffer.append(text); }
@Override public void streamAppended(String text, IStreamMonitor monitor) { if(text.contains(theText)){ detected = true; } }
@Override public void streamAppended(String text, IStreamMonitor monitor) { message.append(text); }
public IStreamMonitor getMonitor() { return monitor; }
public MonListener(IStreamMonitor monitor, IStreamListener listener) { super(); this.monitor = monitor; this.listener = listener; }
@Override public IStreamMonitor getErrorStreamMonitor() { return new TeaVMStreamMonitor(); }
@Override public IStreamMonitor getOutputStreamMonitor() { return new TeaVMStreamMonitor(); }
@Override public IStreamMonitor getErrorStreamMonitor() { return errorStreamMonitor; }
@Override public IStreamMonitor getOutputStreamMonitor() { return outputStreamMonitor; }
@Override public void streamAppended(String text, IStreamMonitor monitor) { if (!remoteVmReadyForDebug && text.startsWith(DEBUG_READY_MESSAGE)) { remoteVmReadyForDebug = true; } }