Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

RSE
Release 3.0

org.eclipse.rse.services.terminals
Class AbstractTerminalShell


java.lang.Object
  extended by 

org.eclipse.core.runtime.PlatformObject
      extended by 
org.eclipse.rse.services.terminals.AbstractTerminalShell
All Implemented Interfaces:
IAdaptable, IBaseShell, ITerminalShell

public abstract class AbstractTerminalShell
extends PlatformObject
implements ITerminalShell

Abstract base class for clients to create an ITerminalShell instance. This abstract base class provides valid default implementations for all ITerminalShell methods where possible. Clients should extend this base class rather than implementing ITerminalShell directly, in order to remain compatible when the ITerminalShell interface is evolved in the future.

Since:
org.eclipse.rse.services 3.1

Constructor Summary
AbstractTerminalShell ()
           
 
Method Summary
 int exitValue ()
          Return the exit value of the Process connected by this shell.
  String getDefaultEncoding ()
          Return the default encoding that the terminal service had specified when creating this terminal connection, or that's known from the remote side to be expected.
  InputStream getErrorStream ()
          Get a remote-to-local InputStream connected to the standard error output of the underlying Process.
  String getPtyType ()
          Get the Terminal Type that's expected on this connection.
protected  long getWaitForPollInterval ()
          Return the interval (in milliseconds) for polling the method during the waitFor(long) method.
 boolean isLocalEcho ()
          Test if local echo is needed on this terminal connection.
 void setTerminalSize (int newWidth, int newHeight)
          Notify the remote site that the size of the terminal has changed.
 boolean waitFor (long timeout)
          Wait for the shell to terminate.
 
Methods inherited from class org.eclipse.core.runtime. PlatformObject
getAdapter
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.rse.services.terminals. IBaseShell
exit, getInputStream, getOutputStream, isActive
 
Methods inherited from interface org.eclipse.core.runtime. IAdaptable
getAdapter
 

Constructor Detail

AbstractTerminalShell

public AbstractTerminalShell()
Method Detail

getDefaultEncoding

public 
String getDefaultEncoding()
Description copied from interface: ITerminalShell
Return the default encoding that the terminal service had specified when creating this terminal connection, or that's known from the remote side to be expected. This is not necessarily known or accurate, and may be null. TODO I'm not actually sure if this method is a good idea. Perhaps we should use the IAdaptable mechanism for dealing with encodings, since our shells basically deal with binary data only.

Specified by:
getDefaultEncoding in interface ITerminalShell
Returns:
the specified default encoding, or null if unknown.

getPtyType

public 
String getPtyType()
Description copied from interface: ITerminalShell
Get the Terminal Type that's expected on this connection. The terminal type may be specified by the client when constructing a concrete instance of an ITerminalShell, or a remote side may actually expect a particular terminal type to be present.

Specified by:
getPtyType in interface ITerminalShell
Returns:
the terminal type expected by the remote side to properly render the Streams associated with this Terminal, or null if the ITerminalShell does not know what kind of Terminal Type is expected.

isLocalEcho

public boolean isLocalEcho()
Description copied from interface: ITerminalShell
Test if local echo is needed on this terminal connection. Clients are expected to return false if in doubt.

Specified by:
isLocalEcho in interface ITerminalShell
Returns:
true if a local echo is needed.

setTerminalSize

public void setTerminalSize(int newWidth,
                            int newHeight)
Description copied from interface: ITerminalShell
Notify the remote site that the size of the terminal has changed. There is no guarantee that the remote side is actually capable of changing the Terminal size.

Specified by:
setTerminalSize in interface ITerminalShell

getErrorStream

public 
InputStream getErrorStream()
Description copied from interface: IBaseShell
Get a remote-to-local InputStream connected to the standard error output of the underlying Process. Implementations may return null if they do not support separate Streams for output and error. Clients must not close the obtained InputStream themselves, since the behavior that this may have on the underlying shell or process is undefined. Use {#exit()} instead to terminate the shell if that is desired, it will close all relevant Streams.

Specified by:
getErrorStream in interface IBaseShell
Returns:
an InputStream for reading error output from the underlying process, or null if separate output and error streams are not supported. Error output will be merged with the Stream obtained from IBaseShell.getInputStream() in that case.

exitValue

public int exitValue()
Description copied from interface: IBaseShell
Return the exit value of the Process connected by this shell. Depending on the underlying implementation, this call may not be supported. Implementations which do not support this must throw an IllegalThreadStateException when the shell is still active, or return 0 the shell has terminated.

Specified by:
exitValue in interface IBaseShell
Returns:
the exit value of the Process connected by this shell, provided that it has already terminated. By convention, the exit value 0 indicates successful completion or the fact that transmission of exit values is not supported by an implementation.
See Also:
Process.exitValue()

getWaitForPollInterval

protected long getWaitForPollInterval()
Return the interval (in milliseconds) for polling the method during the waitFor(long) method. Subclasses may override to return different poll intervals. The interval may be changed dynamically as appropriate for the current state of this shell. That way, wait polling mechanisms such as exponential backoff can be implemented. Or, a concrete implementation that supports a notification mechanism for knowing when the shell terminates, can use this to tweak the waitFor() method by returning Long.MAX_VALUE here (wait forever), but calling Object.notifyAll() when the shell is dead.

Returns:
interval (in milliseconds) for polling active state

waitFor

public boolean waitFor(long timeout)
                throws 
InterruptedException
Wait for the shell to terminate. This uses a polling mechanism by default, which can be tweaked by overriding getWaitForPollInterval().

Specified by:
waitFor in interface IBaseShell
Parameters:
timeout - the maximum time (in milliseconds) to wait. Implementations may return sooner even if the underlying Process has not yet terminated, so clients always need to keep track of time themselves and need to check the return value. A timeout value of zero causes this method to not limit the wait time. Negative wait time has undefined behavior.
Returns:
true if the Shell is still active after waiting (e.g. because the timeout has elapsed); false if the shell is no longer active.
Throws:
InterruptedException - if the waiting Thread has been interrupted, e.g. because the main application is shutting down.
See Also:
IBaseShell.waitFor(long)

RSE
Release 3.0

Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire