ERXRuntimeUtilities Class Reference

Collaboration diagram for ERXRuntimeUtilities:

Collaboration graph
[legend]

List of all members.

Classes

class  Result
class  StreamReader
class  TimeoutException
class  TimeoutTimerTask

Static Public Member Functions

static synchronized void addThreadInterrupt (Thread thread, String message)
static void checkThreadInterrupt ()
static synchronized String clearThreadInterrupt (Thread thread)
static NSBundle createBundleIfNeeded (String name)
static final Result execute (String[] command, String[] envp, File dir, long timeout) throws IOException, TimeoutException
static final Result[] executeCommandLineCommandsWithEnvVarsInWorkingDir (String[][] commands, String[] envp, File dir) throws IOException
static final Result executeCommandLineCommandWithArgumentsWithEnvVarsInWorkingDir (String[] command, String[] envp, File dir) throws IOException
static void freeProcessResources (Process p)
static NSMutableDictionary
< String, Object > 
informationForBundles ()
static NSMutableDictionary
< String, Object > 
informationForContext (WOContext context)
static NSMutableDictionary
< String, Object > 
informationForException (Exception e)
static NSBundle loadBundleIfNeeded (File bundleFile)
static Throwable originalThrowable (Throwable t)

Static Public Attributes

static final Logger log

Static Private Attributes

static NSMutableDictionary
< Thread, String
flags


Detailed Description

Collection of utilities dealing with threads and processes.

Author:
ak

david


Member Function Documentation

static synchronized void addThreadInterrupt ( Thread  thread,
String  message 
) [static]

Call this to get the thread in question interrupted on the next call to checkThreadInterrupt().

Parameters:
thread 
message 

static void checkThreadInterrupt (  )  [static]

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 synchronized String clearThreadInterrupt ( Thread  thread  )  [static]

Clear the interrupt flag for the thread.

Parameters:
thread 

static NSBundle createBundleIfNeeded ( String  name  )  [static]

Hack to create a bundle after the app is loaded. Useful for the insistence of EOF on JavaXXXAdaptor bundles.

Parameters:
name 
Returns:
a new bundle under the system temp directory

static final Result execute ( String[]  command,
String[]  envp,
File  dir,
long  timeout 
) throws IOException, TimeoutException [static]

Excecutes the specified command line commands. If envp is not null the environment variables are set before executing the command. This method supports timeout's. This is quite important because its -always- possible that a UNIX or WINDOWS process does not return, even with simple shell scripts. This is due to whatever bugs and hence every invocation of Process.waitFor() should be observed and stopped if a certain amount of time is over.

Parameters:
command the commands to execute, this is an String array with two dimensions the following commands
"ls -la" or "cp /tmp/file1 /tmp/file2" or "open /Applications/*.app"
would be as String arrays
 new String[] { new String[] { "ls", "-la" },
      new String[] { "cp", "/tmp/file1", "/tmp/file2" },
      new String[] { "open", "/Applications/*.app" } }
 

Parameters:
envp a String array which represents the environment variables like String[] envp = new String[]{"PATH=/usr/bin:/bin", "CVS_RSH=ssh"}, can be null
dir a File object representing the working directory, can be null
timeout 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 ERXTimeoutException
Returns:
the results from the processes that were executed
Exceptions:
IOException if something went wrong

static final Result [] executeCommandLineCommandsWithEnvVarsInWorkingDir ( String  commands[][],
String[]  envp,
File  dir 
) throws IOException [static]

Excecutes the specified command line commands. If envp is not null the environment variables are set before executing the command.

Parameters:
commands the commands to execute, this is an String array with two dimensions the following commands
"ls -la" or "cp /tmp/file1 /tmp/file2" or "open /Applications/*.app"
would be as String arrays
     new String[] { 
      	new String[] { "ls", "-la" },
      	new String[] { "cp", "/tmp/file1", "/tmp/file2" },
      	new String[] { "open", "/Applications/*.app" } 
     }
 

Parameters:
envp a String array which represents the environment variables like String[] envp = new String[]{"PATH=/usr/bin:/bin", "CVS_RSH=ssh"}, can be null
dir a File object representing the working directory, can be null
Returns:
the results from the processes that were executed
Exceptions:
IOException if something went wrong

static final Result executeCommandLineCommandWithArgumentsWithEnvVarsInWorkingDir ( String[]  command,
String[]  envp,
File  dir 
) throws IOException [static]

Excecutes the specified command line commands. If envp is not null the environment variables are set before executing the command.

Parameters:
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 null
dir a File object representing the working directory, can be null
Returns:
the results from the processes that were executed
Exceptions:
IOException if something went wrong

static void freeProcessResources ( Process  p  )  [static]

Frees all of a resources associated with a given process and then destroys it.

Parameters:
p process to destroy

static NSMutableDictionary<String, Object> informationForBundles (  )  [static]

static NSMutableDictionary<String, Object> informationForContext ( WOContext  context  )  [static]

static NSMutableDictionary<String, Object> informationForException ( Exception  e  )  [static]

Returns a dictionary with useful stuff.

Parameters:
e 

static NSBundle loadBundleIfNeeded ( File  bundleFile  )  [static]

Load an application, framework or jar bundle if not already loaded.

Parameters:
bundleFile - the directory or archive (e.g., jar, war) of the bundle to load
Returns:
the bundle found at the given uri.
Exceptions:
NSForwardException if bundle loading fails

static Throwable originalThrowable ( Throwable  t  )  [static]

Retrieves the actual cause of an error by unwrapping them as far as possible, i.e. NSForwardException.originalThrowable(), InvocationTargetException.getTargetException() or Exception.getCause() are regarded as actual causes.


Member Data Documentation

NSMutableDictionary<Thread, String> flags [static, private]

final Logger log [static]

Initial value:

 Logger
            .getLogger(ERXRuntimeUtilities.class)
logging support


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:13 2012 for Project Wonder by  doxygen 1.5.8