public class ERXRuntimeUtilities
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ERXRuntimeUtilities.Result |
static class |
ERXRuntimeUtilities.StreamReader |
static class |
ERXRuntimeUtilities.TimeoutException |
static class |
ERXRuntimeUtilities.TimeoutTimerTask |
| Modifier and Type | Field and Description |
|---|---|
static org.apache.log4j.Logger |
log
logging support
|
| Constructor and Description |
|---|
ERXRuntimeUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addThreadInterrupt(java.lang.Thread thread,
java.lang.String message)
Call this to get the thread in question interrupted on the next call to checkThreadInterrupt().
|
static void |
checkThreadInterrupt()
When you have an inner loop and you want to be able to bail out on a stop
request, call this method and you will get interrupted when another thread wants you to.
|
static java.lang.String |
clearThreadInterrupt(java.lang.Thread thread)
Clear the interrupt flag for the thread.
|
static NSBundle |
createBundleIfNeeded(java.lang.String name)
Hack to create a bundle after the app is loaded.
|
static ERXRuntimeUtilities.Result |
execute(java.lang.String[] command,
java.lang.String[] envp,
java.io.File dir,
long timeout)
Excecutes the specified command line commands.
|
static ERXRuntimeUtilities.Result[] |
executeCommandLineCommandsWithEnvVarsInWorkingDir(java.lang.String[][] commands,
java.lang.String[] envp,
java.io.File dir)
Excecutes the specified command line commands.
|
static ERXRuntimeUtilities.Result |
executeCommandLineCommandWithArgumentsWithEnvVarsInWorkingDir(java.lang.String[] command,
java.lang.String[] envp,
java.io.File dir)
Excecutes the specified command line commands.
|
static void |
freeProcessResources(java.lang.Process p)
Frees all of a resources associated with a given process and then
destroys it.
|
static NSMutableDictionary<java.lang.String,java.lang.Object> |
informationForBundles() |
static NSMutableDictionary<java.lang.String,java.lang.Object> |
informationForContext(WOContext context) |
static NSMutableDictionary<java.lang.String,java.lang.Object> |
informationForException(java.lang.Exception e)
Returns a dictionary with useful stuff.
|
static NSBundle |
loadBundleIfNeeded(java.io.File bundleFile)
Load an application, framework or jar bundle if not already loaded.
|
static java.lang.Throwable |
originalThrowable(java.lang.Throwable t)
Retrieves the actual cause of an error by unwrapping them as far as possible,
i.e.
|
public static NSBundle createBundleIfNeeded(java.lang.String name)
name - public static NSBundle loadBundleIfNeeded(java.io.File bundleFile)
bundleFile - - the directory or archive (e.g., jar, war) of the bundle to loadNSForwardException - if bundle loading failspublic static NSMutableDictionary<java.lang.String,java.lang.Object> informationForException(java.lang.Exception e)
e - public static NSMutableDictionary<java.lang.String,java.lang.Object> informationForBundles()
public static NSMutableDictionary<java.lang.String,java.lang.Object> informationForContext(WOContext context)
public static java.lang.Throwable originalThrowable(java.lang.Throwable t)
public static final ERXRuntimeUtilities.Result executeCommandLineCommandWithArgumentsWithEnvVarsInWorkingDir(java.lang.String[] command, java.lang.String[] envp, java.io.File dir) throws java.io.IOException
command - the commands to execute like "ls -la" or "cp /tmp/file1
/tmp/file2" or "open /Applications/*.app" new String[]{"ls",
"-la"} new String[]{"cp", "/tmp/file1", "/tmp/file2"} new
String[]{"open", "/Applications/*.app"}envp - a String array which represents the environment
variables like
String[] envp = new String[]{"PATH=/usr/bin:/bin", "CVS_RSH=ssh"},
can be nulldir - a File object representing the working
directory, can be nulljava.io.IOException - if something went wrongpublic static final ERXRuntimeUtilities.Result[] executeCommandLineCommandsWithEnvVarsInWorkingDir(java.lang.String[][] commands, java.lang.String[] envp, java.io.File dir) throws java.io.IOException
commands - the commands to execute, this is an String array with two
dimensions the following commands
new String[] {
new String[] { "ls", "-la" },
new String[] { "cp", "/tmp/file1", "/tmp/file2" },
new String[] { "open", "/Applications/*.app" }
}
envp - a String array which represents the environment
variables like
String[] envp = new String[]{"PATH=/usr/bin:/bin", "CVS_RSH=ssh"},
can be nulldir - a File object representing the working
directory, can be nulljava.io.IOException - if something went wrongpublic static final ERXRuntimeUtilities.Result execute(java.lang.String[] command, java.lang.String[] envp, java.io.File dir, long timeout) throws java.io.IOException, ERXRuntimeUtilities.TimeoutException
Process.waitFor() should be observed and stopped if a
certain amount of time is over.command - the commands to execute, this is an String array with two
dimensions the following commands
new String[] { new String[] { "ls", "-la" },
new String[] { "cp", "/tmp/file1", "/tmp/file2" },
new String[] { "open", "/Applications/*.app" } }
envp - a String array which represents the environment
variables like
String[] envp = new String[]{"PATH=/usr/bin:/bin", "CVS_RSH=ssh"},
can be nulldir - a File object representing the working
directory, can be nulltimeout - a long which can be either 0
indicating this method call waits until the process exits or
any long number larger than 0
which means if the process does not exit after
timeout milliseconds then this method throws an
ERXTimeoutExceptionjava.io.IOException - if something went wrongERXRuntimeUtilities.TimeoutExceptionpublic static void freeProcessResources(java.lang.Process p)
p - process to destroypublic static void checkThreadInterrupt()
public static void addThreadInterrupt(java.lang.Thread thread,
java.lang.String message)
thread - message - public static java.lang.String clearThreadInterrupt(java.lang.Thread thread)
thread - Copyright © 2002 – 2022 Project Wonder.