[RFC PATCH v2 upstream org.eclipse.tm] [411343]Provide access to readers in host shell


Ioana Grigoropol <ioanax.grigoropol@...>
 

- 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 <ioanax.grigoropol@intel.com>
---
.../services/shells/TerminalServiceHostShell.java | 20 ++++++++++++--------
.../rse/services/shells/AbstractHostShell.java | 9 +++++++--
2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java
index 2a461ad..0775894 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java
@@ -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;
+ }
}
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java
index 0ac8e3f..4d189b6 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java
@@ -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
}
}

-}
\ No newline at end of file
+ public BufferedReader getReader(boolean isErrorReader){
+ return null;
+ }
+}
--
1.7.10.4


Zhang, Jessica
 

Hi Ioana,

Unfortunately we have to introduce the API getReader in IHostShell interface, otherwise, when I applied the patch to my clean upstream RSE master and open a project I'm getting:

An internal error occurred during "Open Project"
Unresolved compilation problems:
The method getReader(Boolean) is undefined for the type IHostShell....

Please do some local verification when sending patches upstream.

Thanks,
Jessica

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Friday, June 21, 2013 8:19 AM
To: yocto@yoctoproject.org
Subject: [yocto] [RFC PATCH v2 upstream org.eclipse.tm] [411343]Provide access to readers in host shell

- 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 <ioanax.grigoropol@intel.com>
---
.../services/shells/TerminalServiceHostShell.java | 20 ++++++++++++--------
.../rse/services/shells/AbstractHostShell.java | 9 +++++++--
2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java
index 2a461ad..0775894 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/
+++ services/shells/TerminalServiceHostShell.java
@@ -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;
+ }
}
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java
index 0ac8e3f..4d189b6 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/
+++ shells/AbstractHostShell.java
@@ -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
}
}

-}
\ No newline at end of file
+ public BufferedReader getReader(boolean isErrorReader){
+ return null;
+ }
+}
--
1.7.10.4

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


Grigoropol, IoanaX <ioanax.grigoropol@...>
 

Hi Jessica,

I have just tested with a clean master & my upstream patch. Everything compiles fine.
There are no changes made to IHostShell what so ever. In this patch, I only change AbstractHostShell and TerminalServiceHostShell.

Please make sure that your TM &Yocto plugin sources are up to date and refreshed in you workspace.

Thanks,
Ioana
________________________________________
From: Zhang, Jessica
Sent: Friday, June 21, 2013 8:42 PM
To: Grigoropol, IoanaX; yocto@yoctoproject.org
Subject: RE: [yocto] [RFC PATCH v2 upstream org.eclipse.tm] [411343]Provide access to readers in host shell

Hi Ioana,

Unfortunately we have to introduce the API getReader in IHostShell interface, otherwise, when I applied the patch to my clean upstream RSE master and open a project I'm getting:

An internal error occurred during "Open Project"
Unresolved compilation problems:
The method getReader(Boolean) is undefined for the type IHostShell....

Please do some local verification when sending patches upstream.

Thanks,
Jessica

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Friday, June 21, 2013 8:19 AM
To: yocto@yoctoproject.org
Subject: [yocto] [RFC PATCH v2 upstream org.eclipse.tm] [411343]Provide access to readers in host shell

- 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 <ioanax.grigoropol@intel.com>
---
.../services/shells/TerminalServiceHostShell.java | 20 ++++++++++++--------
.../rse/services/shells/AbstractHostShell.java | 9 +++++++--
2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java
index 2a461ad..0775894 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/
+++ services/shells/TerminalServiceHostShell.java
@@ -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;
+ }
}
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java
index 0ac8e3f..4d189b6 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/
+++ shells/AbstractHostShell.java
@@ -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
}
}

-}
\ No newline at end of file
+ public BufferedReader getReader(boolean isErrorReader){
+ return null;
+ }
+}
--
1.7.10.4

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto