|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.nmu.os.shell.Command
Encapsulates the functionality of a single shell command
Constructor Summary | |
Command()
|
Method Summary | |
abstract boolean |
forceCurrentThread()
Determines whether the Command should be run in the same Thread as the executor |
abstract boolean |
fork()
Determines whether this Command should be joined with immediately after its execution |
abstract java.lang.String[] |
getArgs()
Gets the parameters that will be given to the program when this Command is executed |
protected abstract java.io.PrintStream |
getErr()
Gets the PrintStream that should be used as NewSystem.err during execution |
protected abstract java.io.InputStream |
getIn()
Gets the InputStream that should be used as NewSystem.in during execution |
protected abstract java.io.PrintStream |
getOut()
Gets the PrintStream that should be used as NewSystem.out during execution |
abstract java.lang.String |
getProgram()
Gets the name of the program that will be run when this Command is executed |
abstract boolean |
isExit()
Determines whether or not this Command is a command to exit the Shell |
boolean |
isResolved()
Determines whether or not this Command is able to resolve the program returned by getProgram() |
protected java.lang.Class |
resolveClass(java.lang.String program)
Resolves the given program as a Class |
protected java.io.File |
resolveExecutable(java.lang.String program)
Resolves the given program as a File |
void |
run()
Executes the Command |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Command()
Method Detail |
public abstract java.lang.String getProgram()
public abstract java.lang.String[] getArgs()
public abstract boolean fork()
protected abstract java.io.InputStream getIn()
protected abstract java.io.PrintStream getOut()
protected abstract java.io.PrintStream getErr()
public abstract boolean isExit()
public abstract boolean forceCurrentThread()
public boolean isResolved()
getProgram()
protected java.lang.Class resolveClass(java.lang.String program) throws java.lang.ClassNotFoundException
The default behavior of this method is to return:
this.getClass().getClassLoader().loadClass(program)
Implementations of this class should resolve Classes as is appropriate.
program
- the name of the program to be resolved
java.lang.ClassNotFoundException
- if resolution was unsuccessfulprotected java.io.File resolveExecutable(java.lang.String program) throws java.io.FileNotFoundException
The default behavior of this method is to return:
new File(program)
Implementations of this class should resolve Files as is appropriate.
program
- the name of the program to be resolved
java.io.FileNotFoundException
- if resolution was unsuccessfulpublic void run()
This method first sets the NewSystem.in,
NewSystem.out and NewSystem.err
streams as specified by getIn()
, getOut()
and getErr()
respectively.
Next, it will try to resolve the program as a Class.
If successful, it will invoke the classes main
method with the arguments given by getArgs()
.
If Class resolution was unsuccessful, an attempt to
resolve a File will be made. If a file is found,
the method will then call
OldRuntime.exec(String[],String[],File)
with a
null environment and with the current ShellImpl's
present working directory.
If all attempts at program resolution are unsuccessful, the method gives up and exits.
run
in interface java.lang.Runnable
OldRuntime.exec(String[],String[],File)
,
ShellImpl
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |