public class RuntimeProcess extends PlatformObject implements IProcess
IProcess
that wrappers a system
process (java.lang.Process
).
Clients may subclass this class. Clients that need to replace the implementation
of a streams proxy associated with an IProcess
should subclass this
class. Generally clients should not instantiate this class directly, but should
instead call DebugPlugin.newProcess(...)
, which can delegate to an
IProcessFactory
if one is referenced by the associated launch configuration.
IProcess
,
IProcessFactory
ATTR_CMDLINE, ATTR_PROCESS_LABEL, ATTR_PROCESS_TYPE
Constructor and Description |
---|
RuntimeProcess(ILaunch launch,
Process process,
String name,
Map<String,String> attributes)
Constructs a RuntimeProcess on the given system process
with the given name, adding this process to the given
launch.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canTerminate()
Returns whether this element can be terminated.
|
protected IStreamsProxy |
createStreamsProxy()
Creates and returns the streams proxy associated with this process.
|
protected void |
fireChangeEvent()
Fires a change event.
|
protected void |
fireCreationEvent()
Fires a creation event.
|
protected void |
fireEvent(DebugEvent event)
Fires the given debug event.
|
protected void |
fireTerminateEvent()
Fires a terminate event.
|
<T> T |
getAdapter(Class<T> adapter)
Returns an object which is an instance of the given class
associated with this object.
|
String |
getAttribute(String key)
Returns the value of a client defined attribute.
|
int |
getExitValue()
Returns the exit value of this process.
|
String |
getLabel()
Returns a human-readable label for this process.
|
ILaunch |
getLaunch()
Returns the launch this element originated from.
|
IStreamsProxy |
getStreamsProxy()
Returns a proxy to the standard input, output, and error streams
for this process, or
null if not supported. |
protected Process |
getSystemProcess()
Returns the underlying system process associated with this process.
|
boolean |
isTerminated()
Returns whether this element is terminated.
|
void |
setAttribute(String key,
String value)
Sets the value of a client defined attribute.
|
protected void |
setLaunch(ILaunch launch)
Sets the launch this process is contained in
|
void |
terminate()
Causes this element to terminate, generating a
TERMINATE event. |
protected void |
terminated()
Notification that the system process associated with this process
has terminated.
|
public RuntimeProcess(ILaunch launch, Process process, String name, Map<String,String> attributes)
launch
- the parent launch of this processprocess
- underlying system processname
- the label used for this processattributes
- map of attributes used to initialize the attributes
of this process, or null
if nonepublic boolean canTerminate()
ITerminate
canTerminate
in interface ITerminate
ITerminate.canTerminate()
public String getLabel()
IProcess
getLabel
in interface IProcess
IProcess.getLabel()
protected void setLaunch(ILaunch launch)
launch
- the launch this process is contained inpublic ILaunch getLaunch()
IProcess
getLaunch
in interface IProcess
IProcess.getLaunch()
protected Process getSystemProcess()
public boolean isTerminated()
ITerminate
isTerminated
in interface ITerminate
ITerminate.isTerminated()
public void terminate() throws DebugException
ITerminate
TERMINATE
event.
Implementations may be blocking or non-blocking.terminate
in interface ITerminate
DebugException
- on failure. Reasons include:ITerminate.terminate()
protected void terminated()
public IStreamsProxy getStreamsProxy()
IProcess
null
if not supported.getStreamsProxy
in interface IProcess
null
if not supportedIProcess.getStreamsProxy()
protected IStreamsProxy createStreamsProxy()
protected void fireCreationEvent()
protected void fireEvent(DebugEvent event)
event
- debug event to fireprotected void fireTerminateEvent()
protected void fireChangeEvent()
public void setAttribute(String key, String value)
IProcess
setAttribute
in interface IProcess
key
- the attribute keyvalue
- the attribute valueIProcess.setAttribute(String, String)
public String getAttribute(String key)
IProcess
getAttribute
in interface IProcess
key
- the attribute keynull
if undefinedIProcess.getAttribute(String)
public <T> T getAdapter(Class<T> adapter)
PlatformObject
null
if
no such object can be found.
This implementation of the method declared by IAdaptable
passes the request along to the platform's adapter manager; roughly
Platform.getAdapterManager().getAdapter(this, adapter)
.
Subclasses may override this method (however, if they do so, they
should invoke the method on their superclass to ensure that the
Platform's adapter manager is consulted).
getAdapter
in interface IAdaptable
getAdapter
in class PlatformObject
adapter
- the class to adapt tonull
IAdaptable.getAdapter(Class)
public int getExitValue() throws DebugException
IProcess
getExitValue
in interface IProcess
DebugException
- if this process has not yet terminatedIProcess.getExitValue()
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.