public class ERXRuntimeUtilities extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ERXRuntimeUtilities.Result |
static class |
ERXRuntimeUtilities.StreamReader |
static class |
ERXRuntimeUtilities.TimeoutException |
static class |
ERXRuntimeUtilities.TimeoutTimerTask |
Constructor and Description |
---|
ERXRuntimeUtilities() |
Modifier and Type | Method and Description |
---|---|
static void |
addThreadInterrupt(Thread thread,
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 String |
clearThreadInterrupt(Thread thread)
Clear the interrupt flag for the thread.
|
static NSBundle |
createBundleIfNeeded(String name)
Hack to create a bundle after the app is loaded.
|
static ERXRuntimeUtilities.Result |
execute(String[] command,
String[] envp,
File dir,
long timeout)
Excecutes the specified command line commands.
|
static ERXRuntimeUtilities.Result[] |
executeCommandLineCommandsWithEnvVarsInWorkingDir(String[][] commands,
String[] envp,
File dir)
Excecutes the specified command line commands.
|
static ERXRuntimeUtilities.Result |
executeCommandLineCommandWithArgumentsWithEnvVarsInWorkingDir(String[] command,
String[] envp,
File dir)
Excecutes the specified command line commands.
|
static void |
freeProcessResources(Process p)
Frees all of a resources associated with a given process and then
destroys it.
|
static NSMutableDictionary<String,Object> |
informationForBundles() |
static NSMutableDictionary<String,Object> |
informationForContext(WOContext context) |
static NSMutableDictionary<String,Object> |
informationForException(Exception e)
Returns a dictionary with useful stuff.
|
static NSBundle |
loadBundleIfNeeded(File bundleFile)
Load an application, framework or jar bundle if not already loaded.
|
static Throwable |
originalThrowable(Throwable t)
Retrieves the actual cause of an error by unwrapping them as far as possible,
i.e.
|
public static NSBundle createBundleIfNeeded(String name)
name
- public static NSBundle loadBundleIfNeeded(File bundleFile)
bundleFile
- - the directory or archive (e.g., jar, war) of the bundle to loadNSForwardException
- if bundle loading failspublic static NSMutableDictionary<String,Object> informationForException(Exception e)
e
- public static NSMutableDictionary<String,Object> informationForBundles()
public static NSMutableDictionary<String,Object> informationForContext(WOContext context)
public static Throwable originalThrowable(Throwable t)
public static final ERXRuntimeUtilities.Result executeCommandLineCommandWithArgumentsWithEnvVarsInWorkingDir(String[] command, String[] envp, File dir) throws 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 nullIOException
- if something went wrongpublic static final ERXRuntimeUtilities.Result[] executeCommandLineCommandsWithEnvVarsInWorkingDir(String[][] commands, String[] envp, File dir) throws 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 nullIOException
- if something went wrongpublic static final ERXRuntimeUtilities.Result execute(String[] command, String[] envp, File dir, long timeout) throws 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
ERXTimeoutExceptionIOException
- if something went wrongERXRuntimeUtilities.TimeoutException
public static void freeProcessResources(Process p)
p
- process to destroypublic static void checkThreadInterrupt()
public static void addThreadInterrupt(Thread thread, String message)
thread
- message
- Copyright © 2002 – 2024 Project Wonder.