Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » how to get an IProcess view of a Process value?
how to get an IProcess view of a Process value? [message #168199] Tue, 09 December 2003 17:29 Go to next message
Eclipse UserFriend
Originally posted by: progers.classwide.com

I have a Process value returned from

Runtime.getRuntime().exec()

that I must treat as an IProcess value.

Is there a way to do that (other than casting it, which will fail)?
Re: how to get an IProcess view of a Process value? [message #168206 is a reply to message #168199] Tue, 09 December 2003 17:39 Go to previous messageGo to next message
Darin Swanson is currently offline Darin SwansonFriend
Messages: 2386
Registered: July 2009
Senior Member
Without any more context on what you are trying to do, I would propose that
you should take a look at the convenience methods on DebugPlugin.
Have a look at:

exec(String[], File)
exec(String[], File, String[])
newProcess(ILaunch, Process, String)
newProcess(ILaunch, Process, String, Map)

HTH
Darins

"Pat Rogers" <progers@classwide.com> wrote in message
news:br50jh$fef$1@eclipse.org...
> I have a Process value returned from
>
> Runtime.getRuntime().exec()
>
> that I must treat as an IProcess value.
>
> Is there a way to do that (other than casting it, which will fail)?
>
>
Re: how to get an IProcess view of a Process value? [message #168327 is a reply to message #168206] Tue, 09 December 2003 20:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: progers.classwide.com

Darin Swanson wrote:
> Without any more context on what you are trying to do, I would
> propose that you should take a look at the convenience methods on
> DebugPlugin.
> Have a look at:
>
> exec(String[], File)
> exec(String[], File, String[])

These return a Process rather than an IProcess, right?

> newProcess(ILaunch, Process, String)
> newProcess(ILaunch, Process, String, Map)

These do return an IProcess but require the launch value, which I
don't have. (Do I need to have it otherwise?)

My event listener is modelled after BackgroundResourceRefresher
in package
org.eclipse.ui.externaltools.internal.program.launchConfigur ations,
but without all the launch stuff, and it includes this code:

public void startBackgroundRefresh() {
synchronized (watchedProcess) {
if (watchedProcess.isTerminated()) {
refresh();
} else {
DebugPlugin.getDefault().addDebugEventListener(this);
}
}
}

But a Process does not provide the isTerminated function.



The process creation code in the action class (that executes the
external command) is the following:

try {
P = Runtime.getRuntime().exec(Command.toString());
} catch (IOException e) {
...
} // try
IProcess process = DebugPlugin.newProcess(P, null);
ProjectRefresher refresher = new ProjectRefresher(process);
refresher.startBackgroundRefresh();
}

but unfortunately that specific newProcess function is no longer
provided by DebugPlugin.
Re: how to get an IProcess view of a Process value? [message #168694 is a reply to message #168327] Wed, 10 December 2003 14:57 Go to previous messageGo to next message
Darin Wright is currently offline Darin WrightFriend
Messages: 454
Registered: July 2009
Senior Member
The process support provided by the debugger requires a launch object. An
IProcess is an abstraction of a system process, and the debug plugin simply
provides an implementation of an IProcess that is a proxy to a
java.lang.Process.

Darin

"Pat Rogers" <progers@classwide.com> wrote in message
news:br5chk$u8t$1@eclipse.org...
> Darin Swanson wrote:
> > Without any more context on what you are trying to do, I would
> > propose that you should take a look at the convenience methods on
> > DebugPlugin.
> > Have a look at:
> >
> > exec(String[], File)
> > exec(String[], File, String[])
>
> These return a Process rather than an IProcess, right?
>
> > newProcess(ILaunch, Process, String)
> > newProcess(ILaunch, Process, String, Map)
>
> These do return an IProcess but require the launch value, which I
> don't have. (Do I need to have it otherwise?)
>
> My event listener is modelled after BackgroundResourceRefresher
> in package
> org.eclipse.ui.externaltools.internal.program.launchConfigur ations,
> but without all the launch stuff, and it includes this code:
>
> public void startBackgroundRefresh() {
> synchronized (watchedProcess) {
> if (watchedProcess.isTerminated()) {
> refresh();
> } else {
> DebugPlugin.getDefault().addDebugEventListener(this);
> }
> }
> }
>
> But a Process does not provide the isTerminated function.
>
>
>
> The process creation code in the action class (that executes the
> external command) is the following:
>
> try {
> P = Runtime.getRuntime().exec(Command.toString());
> } catch (IOException e) {
> ...
> } // try
> IProcess process = DebugPlugin.newProcess(P, null);
> ProjectRefresher refresher = new ProjectRefresher(process);
> refresher.startBackgroundRefresh();
> }
>
> but unfortunately that specific newProcess function is no longer
> provided by DebugPlugin.
>
>
Re: how to get an IProcess view of a Process value? [message #168750 is a reply to message #168694] Wed, 10 December 2003 16:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: progers.classwide.com

Darin Wright wrote:
> The process support provided by the debugger requires a launch
> object. An IProcess is an abstraction of a system process, and the
> debug plugin simply provides an implementation of an IProcess that
is
> a proxy to a java.lang.Process.

Right, but I don't know how to use that knowledge. Let me restate my
situation.

I'm writing a listener to call localRefresh() in response to an
external tool completing. Currently, I need an IProcess view of a
process (only) because I use function isTerminated in my listener:

>> public void startBackgroundRefresh() {
>> synchronized (watchedProcess) {
>> if (watchedProcess.isTerminated()) {
>> refresh();
>> } else {
>> DebugPlugin.getDefault().addDebugEventListener(this);
>> }
>> }
>> }


But instead of an IProcess I have a Process (named P) because I am
doing the following:

>> try {
>> P = Runtime.getRuntime().exec(Command.toString());
>> } catch (IOException e) {
>> ...
>> } // try

I tried to get an IProcess wrapper via this call to DebugPlugin:

>> IProcess process = DebugPlugin.newProcess(P, null);

but that function no longer exists with that signature. This won't
compile in Eclipse 2.1.

The remaining newProcess functions require a launch configuration and
clearly I'll need that if I am to call them. But are there other
functions elsewhere that give me an IProcess, such that I can avoid
the launch stuff altogether? I know nothing about using launches and
this seems to be the only reason I need them so I'd like to avoid them
if possible.

Thanks!
Re: how to get an IProcess view of a Process value? [message #168934 is a reply to message #168750] Wed, 10 December 2003 21:50 Go to previous messageGo to next message
Darin Wright is currently offline Darin WrightFriend
Messages: 454
Registered: July 2009
Senior Member
You cannot avoid the launch stuff.

If all you want to know, is when a java.lang.Process is terminated, you need
to write your own code to do it (why use an IProcess just for that?). For
example, you can start a thread that joins on the process and sends a
notification when it is complete, as is done by the "ProcessMonitorJob" in
the debug platform. See Process.waitFor() and Process.exitValue().

Darin

"Pat Rogers" <progers@classwide.com> wrote in message
news:br7icl$h9u$1@eclipse.org...
> Darin Wright wrote:
> > The process support provided by the debugger requires a launch
> > object. An IProcess is an abstraction of a system process, and the
> > debug plugin simply provides an implementation of an IProcess that
> is
> > a proxy to a java.lang.Process.
>
> Right, but I don't know how to use that knowledge. Let me restate my
> situation.
>
> I'm writing a listener to call localRefresh() in response to an
> external tool completing. Currently, I need an IProcess view of a
> process (only) because I use function isTerminated in my listener:
>
> >> public void startBackgroundRefresh() {
> >> synchronized (watchedProcess) {
> >> if (watchedProcess.isTerminated()) {
> >> refresh();
> >> } else {
> >> DebugPlugin.getDefault().addDebugEventListener(this);
> >> }
> >> }
> >> }
>
>
> But instead of an IProcess I have a Process (named P) because I am
> doing the following:
>
> >> try {
> >> P = Runtime.getRuntime().exec(Command.toString());
> >> } catch (IOException e) {
> >> ...
> >> } // try
>
> I tried to get an IProcess wrapper via this call to DebugPlugin:
>
> >> IProcess process = DebugPlugin.newProcess(P, null);
>
> but that function no longer exists with that signature. This won't
> compile in Eclipse 2.1.
>
> The remaining newProcess functions require a launch configuration and
> clearly I'll need that if I am to call them. But are there other
> functions elsewhere that give me an IProcess, such that I can avoid
> the launch stuff altogether? I know nothing about using launches and
> this seems to be the only reason I need them so I'd like to avoid them
> if possible.
>
> Thanks!
>
>
Re: how to get an IProcess view of a Process value? [message #169423 is a reply to message #168934] Thu, 11 December 2003 21:37 Go to previous message
Eclipse UserFriend
Originally posted by: progers.classwide.com

Darin Wright wrote:
> You cannot avoid the launch stuff.

OK.

Say I have a launch configuration XML file named "GPS.launch". How do
I access it? I can see how to get the launch manager but don't see
how to go from there. I assume eventually I will call the launch
function but the intermediate steps are unclear to me.

PS: I've read your "Launching Java Applications Programmatically" web
article.

Thanks!
Previous Topic:'Navigate' menu
Next Topic:Different attribute name for 'definitionID' ?
Goto Forum:
  


Current Time: Sat Apr 20 04:11:39 GMT 2024

Powered by FUDForum. Page generated in 0.07730 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top