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 BaseShellDecorator


java.lang.Object
  extended by 

org.eclipse.core.runtime.PlatformObject
      extended by 
org.eclipse.rse.services.terminals.BaseShellDecorator
All Implemented Interfaces:
IAdaptable, IBaseShell
Direct Known Subclasses:
TerminalShellDecorator

public abstract class BaseShellDecorator
extends PlatformObject
implements IBaseShell

Abstract base class for clients to decorate an IBaseShell instance they have with additional functionality. Typically, such additional functionality can be provided either by additional knowledge about the underlying system or process, or by analyzing the input and output streams for some well-known data that gives such additional knowledge.

Since:
org.eclipse.rse.services 3.1

Field Summary
protected   IBaseShell fDelegate
           
 
Constructor Summary
BaseShellDecorator ( IBaseShell delegate)
           
 
Method Summary
 void exit ()
          Exit this shell.
 int exitValue ()
          Return the exit value of the Process connected by this shell.
  Object getAdapter ( Class adapterType)
           
  InputStream getErrorStream ()
          Get a remote-to-local InputStream connected to the standard error output of the underlying Process.
  InputStream getInputStream ()
          Get a remote-to-local InputStream connected to the standard output of the underlying Process.
  OutputStream getOutputStream ()
          Get a local-to-remote OutputStream connected to the standard input of the underlying Process.
 boolean isActive ()
          Test whether this connection is active.
 boolean waitFor (long timeout)
          Block the calling Thread until this shell is no longer active, or the specified timeout has elapsed.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fDelegate

protected final 
IBaseShell fDelegate
Constructor Detail

BaseShellDecorator

public BaseShellDecorator(
IBaseShell delegate)
Method Detail

exit

public void exit()
Description copied from interface: IBaseShell
Exit this shell. Implementations are encouraged to try terminating the underlying process in a clean way, if they can. Depending on the implementation, this may be possible or not. What's guaranteed to happen is that the Streams connected with the process are closed so the shell will not be active any more. Execution of this method may run asynchronously in the sense that the method performs everything to initiate terminating the shell but then returns immediately. Clients may use IBaseShell.waitFor(long) after calling this method to know when the shell is really terminated. At any rate, the exit() method returns quickly and guarantees that the shell will be terminated as soon as possible, after any required (and possible) cleanup is finished.

Specified by:
exit in interface IBaseShell
See Also:
Process.destroy()

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()

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.

getInputStream

public 
InputStream getInputStream()
Description copied from interface: IBaseShell
Get a remote-to-local InputStream connected to the standard output of the underlying Process. 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:
getInputStream in interface IBaseShell
Returns:
an InputStream for reading from the underlying process.

getOutputStream

public 
OutputStream getOutputStream()
Description copied from interface: IBaseShell
Get a local-to-remote OutputStream connected to the standard input of the underlying Process. Clients must not close the obtained OutputStream 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:
getOutputStream in interface IBaseShell
Returns:
an OutputStream for talking to the underlying process.

isActive

public boolean isActive()
Description copied from interface: IBaseShell
Test whether this connection is active.

Specified by:
isActive in interface IBaseShell
Returns:
true if the connection is active, i.e. the Process underlying this connection is running, and the Streams connected to it are not closed.
See Also:
IBaseShell.exitValue()

waitFor

public boolean waitFor(long timeout)
                throws 
InterruptedException
Description copied from interface: IBaseShell
Block the calling Thread until this shell is no longer active, or the specified timeout has elapsed. If the underlying shell has already terminated, this method returns immediately. When this method returns false, the shell is no longer active, so an IBaseShell.exitValue() may be obtained.

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.isActive()

getAdapter

public 
Object getAdapter(
Class adapterType)
Specified by:
getAdapter in interface IAdaptable
Overrides:
getAdapter in class PlatformObject

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