|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.gridsystems.utils.NativeShell
public final class NativeShell
Cross-Platform command execution manager.
This class provides a configurable mechanism to invoke native commands in a cross-platform way.
| Constructor Summary | |
|---|---|
NativeShell()
Creates an instance. |
|
| Method Summary | |
|---|---|
static java.lang.String |
alias(java.lang.String cmd,
java.lang.Object... args)
Gets a platform dependent alias for the specified command. |
protected static java.lang.String |
doAlias(java.lang.String osName,
java.lang.String cmd,
java.lang.Object... args)
Gets a platform dependent alias for the specified command. |
protected java.lang.Integer |
doExec(java.lang.String osName,
java.lang.String cmd,
java.lang.Object... args)
Executes a native application. |
protected static java.lang.String[] |
doShell(java.lang.String osName,
java.lang.String cmd,
java.lang.Object... args)
Gets an array to be used for executing the given command in a platform dependent shell. |
java.lang.Integer |
exec(java.lang.String cmd,
java.lang.Object... args)
Executes a native application. |
static java.lang.String[] |
getAllCommands()
Gets a list of all commands this instance is aware of. |
static java.lang.String[] |
getAvailableCommands()
Gets a list of all commands available in this platform. |
java.io.File |
getDirectory()
Gets the working directory. |
java.util.Map<java.lang.String,java.lang.String> |
getEnv()
Gets the shell environment. |
static void |
setConfigFile(java.io.File f)
Sets the command alias configuration file. |
void |
setDirectory(java.io.File dir)
Sets the working directory. |
void |
setStdErr(java.io.File f)
Redirects the standard error to a file. |
void |
setStdErr(java.io.OutputStream os)
Redirects the standard error to a stream. |
void |
setStdOut(java.io.File f)
Redirects the standard output to a file. |
void |
setStdOut(java.io.OutputStream os)
Redirects the standard output to a stream. |
static java.lang.String[] |
shell(java.lang.String cmd,
java.lang.Object... args)
Gets an array to be used for executing the given command in a platform dependent shell. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NativeShell()
| Method Detail |
|---|
public static void setConfigFile(java.io.File f)
f - The file
public static java.lang.String alias(java.lang.String cmd,
java.lang.Object... args)
cmd - The command to search forargs - Command parameters
protected static java.lang.String doAlias(java.lang.String osName,
java.lang.String cmd,
java.lang.Object... args)
cmd - The command to search forosName - The platform for which the command is expectedargs - Command parameters
public static java.lang.String[] getAllCommands()
getAvailableCommands() instead.
public static java.lang.String[] getAvailableCommands()
public static java.lang.String[] shell(java.lang.String cmd,
java.lang.Object... args)
The command is converted in a platform dependent command by calling
alias(String, Object...).
cmd - The command to executeargs - The command arguments
protected static java.lang.String[] doShell(java.lang.String osName,
java.lang.String cmd,
java.lang.Object... args)
The command is converted in a platform dependent command by calling
alias(String, Object...).
osName - The OS namecmd - The command to executeargs - The command arguments
public java.util.Map<java.lang.String,java.lang.String> getEnv()
public void setDirectory(java.io.File dir)
dir - The directorypublic java.io.File getDirectory()
public void setStdOut(java.io.File f)
throws java.io.IOException
f - The file to redirect to
java.io.IOException - If the file cannot be createdpublic void setStdOut(java.io.OutputStream os)
os - The stream to redirect to
public void setStdErr(java.io.File f)
throws java.io.IOException
f - The file to redirect to
java.io.IOException - If the file cannot be createdpublic void setStdErr(java.io.OutputStream os)
os - The stream to redirect to
public java.lang.Integer exec(java.lang.String cmd,
java.lang.Object... args)
throws java.io.IOException,
java.lang.InterruptedException
cmd - The command to executeargs - The command arguments
java.io.IOException - If an error occurs during the execution
java.lang.InterruptedException - If the thread is interrupted
protected java.lang.Integer doExec(java.lang.String osName,
java.lang.String cmd,
java.lang.Object... args)
throws java.io.IOException,
java.lang.InterruptedException
osName - The OS namecmd - The command to executeargs - The command arguments
java.io.IOException - If an error occurs during the execution
java.lang.InterruptedException - If the thread is interrupted
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||