com.mucommander.process
Class AbstractProcess

java.lang.Object
  extended by com.mucommander.process.AbstractProcess

public abstract class AbstractProcess
extends java.lang.Object

muCommander specific version of a process.

Implementations of this class are used to execute various types of processes. It can be a LocalProcess, but some types of abstract files, such as SFTP files, allow for commands to be executed.

Unlike normal instances of java.lang.Process, abstract processes will empty their own streams, preventing deadlocks from occuring on some systems.

Note that abstract processes should not be created directly. They should be instanciated through ProcessRunner.execute(String[],com.mucommander.file.AbstractFile,ProcessListener).

Author:
Nicolas Rinaudo

Constructor Summary
AbstractProcess()
           
 
Method Summary
 void destroy()
          Kills the process.
protected abstract  void destroyProcess()
          Destroys the process.
abstract  int exitValue()
          Returns this process' exit value.
abstract  java.io.InputStream getErrorStream()
          Returns the process' standard error stream.
abstract  java.io.InputStream getInputStream()
          Returns the process' standard output stream.
abstract  java.io.OutputStream getOutputStream()
          Returns the stream used to send data to the process.
abstract  boolean usesMergedStreams()
          Returns true if this process only uses one output stream.
abstract  int waitFor()
          Makes the current thread wait for the process to die.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractProcess

public AbstractProcess()
Method Detail

destroy

public final void destroy()
Kills the process.


usesMergedStreams

public abstract boolean usesMergedStreams()
Returns true if this process only uses one output stream.

Some processes will use a single stream for their standard error and standard output streams. Such processes should return true here to prevent both streams from being monitored.
Note that if a process uses merged streams, getInputStream() will be monitored.

Returns:
true if this process merges his output streams, false otherwise.

waitFor

public abstract int waitFor()
                     throws java.lang.InterruptedException,
                            java.io.IOException
Makes the current thread wait for the process to die.

Returns:
the process' exit code.
Throws:
java.lang.InterruptedException - thrown if the current thread is interrupted while wainting on the process to die.
java.io.IOException - thrown if an error occurs while waiting for the process to die.

destroyProcess

protected abstract void destroyProcess()
                                throws java.io.IOException
Destroys the process.

Throws:
java.io.IOException - thrown if an error occurs while destroying the process.

exitValue

public abstract int exitValue()
Returns this process' exit value.

Returns:
this process' exit value.

getOutputStream

public abstract java.io.OutputStream getOutputStream()
                                              throws java.io.IOException
Returns the stream used to send data to the process.

Returns:
the stream used to send data to the process.
Throws:
java.io.IOException - thrown if an error occurs while retrieving the process' output stream.

getInputStream

public abstract java.io.InputStream getInputStream()
                                            throws java.io.IOException
Returns the process' standard output stream.

Returns:
the process' standard output stream.
Throws:
java.io.IOException - thrown if an error occurs while retrieving the process' input stream.

getErrorStream

public abstract java.io.InputStream getErrorStream()
                                            throws java.io.IOException
Returns the process' standard error stream.

Returns:
the process' standard error stream.
Throws:
java.io.IOException - thrown if an error occurs while retrieving the process' error stream.


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard