[411343]Provide access to readers in host shell
RFC PATCH 1/1 [411343]Provide access to readers in host shell
From: Ioana Grigoropol <[email protected]>
- add a plain getter in the AbstractHostShell class:
- the compilation is not broken for subclasses of this class since it always returns null
- the targeted classes (local and remote) can implement the getter (local implementation is already there)
- the reader can be accessed and the output can be read in a synchronous way
- add implementation of getReader in TerminaServiceHostShell
- store the underlying reader as a field of this class & return it
Signed-off-by Ioana Grigoropol <[email protected]>
--- .../services/shells/TerminalServiceHostShell.java | 20 ++++++++++++-------- .../rse/services/shells/AbstractHostShell.java | 9 +++++++-- 2 files changed, 19 insertions(+), 10 deletions(-)
rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java +12 -8
@@ -22,6 +22,7 @@ * Anna Dushistova (MontaVista) - [258720] SshHostShell fails to run command if initialWorkingDirectory supplied * Rob Stryker (JBoss) - [335059] TerminalServiceShellOutputReader logs error when hostShell.exit() is called * Martin Oberhuber (Wind River) - [356132] wait for initial output + * Ioana Grigoropol (Intel) - [411343] Provide access to readers in host shell *******************************************************************************/ package org.eclipse.rse.internal.services.shells;
@@ -47,7 +48,7 @@ public class TerminalServiceHostShell extends AbstractHostShell { public static final String SHELL_INVOCATION = ">"; //$NON-NLS-1$ ITerminalShell fTerminalShell; - + BufferedReader fBufReader; private TerminalServiceShellOutputReader fStdoutHandler; private TerminalServiceShellOutputReader fStderrHandler;
@@ -60,21 +61,21 @@ public class TerminalServiceHostShell extends AbstractHostShell { try { fTerminalShell = terminalShell; String encoding = fTerminalShell.getDefaultEncoding(); - BufferedReader bufReader; + if (encoding != null) { - bufReader = new BufferedReader(new InputStreamReader(fTerminalShell + fBufReader = new BufferedReader(new InputStreamReader(fTerminalShell .getInputStream(), encoding)); } else { - bufReader = new BufferedReader(new InputStreamReader(fTerminalShell + fBufReader = new BufferedReader(new InputStreamReader(fTerminalShell .getInputStream())); } //bug 356132: wait for initial output before sending any command //FIXME this should likely move into the TerminalServiceShellWriterThread, so wait can be canceled - bufReader.mark(1); - bufReader.read(); - bufReader.reset(); + fBufReader.mark(1); + fBufReader.read(); + fBufReader.reset(); - fStdoutHandler = new TerminalServiceShellOutputReader(this, bufReader, false); + fStdoutHandler = new TerminalServiceShellOutputReader(this, fBufReader, false); fStderrHandler = new TerminalServiceShellOutputReader(this, null, true); OutputStream outputStream = fTerminalShell.getOutputStream(); if (encoding != null) {
@@ -170,4 +171,7 @@ public class TerminalServiceHostShell extends AbstractHostShell { return "echo $PWD'>'"; //$NON-NLS-1$ } + public BufferedReader getReader(boolean isErrorReader) { + return fBufReader; + } }
rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java +7 -2
@@ -11,11 +11,13 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Ioana Grigoropol (Intel) - [411343] Provide access to readers in host shell ********************************************************************************/ package org.eclipse.rse.services.shells; +import java.io.BufferedReader; + public abstract class AbstractHostShell implements IHostShell {
@@ -34,4 +36,7 @@ public abstract class AbstractHostShell implements IHostShell } } -} + public BufferedReader getReader(boolean isErrorReader){ + return null; + } +}
Signature · 1 line
1.7.10.4