com.partnersoft.system
Class RuntimeLib

java.lang.Object
  extended by com.partnersoft.system.RuntimeLib

public class RuntimeLib
extends java.lang.Object

A library with handy routines for handling external execution etc.

Copyright 2001-2008 Partner Software, Inc.

Version:
$Id: RuntimeLib.java 2328 2010-01-06 15:38:22Z paul $
Author:
Paul Reavis

Constructor Summary
RuntimeLib()
           
 
Method Summary
static void cleanupMemory()
          Does it's damnedest to clear out memory, both used and available heap.
static void execAndHalt(java.lang.String command)
          Executes the given OS-specific command; then halts the current Java session.
static void execAndHalt(java.lang.String[] commands, java.io.File currentDir)
          Executes the given OS-specific command; then halts the current Java session.
static void execAndHalt(java.lang.String command, java.io.File currentDir)
          Executes the given OS-specific command; then halts the current Java session.
static void execAndHalt(VfsFile executable)
          Executes the given program file (e.g.
static void execAndWait(java.lang.String command)
          Same as execAndWait(command, currentDir) but defaulted to the install dir.
static void execAndWait(java.lang.String[] commandArray)
          Same as execAndWait(commandArray, currentDir) but defaulted to the install dir.
static int execAndWait(java.lang.String[] commandArray, java.io.File currentDir)
          A wrapper for Runtime.exec() that handles the problems of grabbing the input streams and reading from them, and waits for completion.
static void execAndWait(java.lang.String command, java.io.File currentDir)
          A wrapper for Runtime.exec() that handles the problems of grabbing the input streams and reading from them, and waits for completion.
static void execAndWait(VfsFile executable)
          Executes the given program file (e.g.
static java.lang.Process execNoWait(java.lang.String command)
          Same as execNoWait(command, currentDir) but defaulted to the install directory.
static java.lang.Process execNoWait(java.lang.String[] commands, java.io.File currentDir)
          Same as execAndWait(commands, currentDir) but does not wait - the process continues in a separate thread.
static java.lang.Process execNoWait(java.lang.String command, java.io.File currentDir)
          Same as execAndWait(command, currentDir) but does not wait - the process continues in a separate thread.
static void execNoWait(VfsFile executable)
          Executes the given program file (e.g.
static void halt()
          Shuts down the system.
static void launchAppAndHalt(java.lang.String appName)
          Restart the Java session, calling the given application.
static void launchAppAndHalt(java.lang.String appName, java.io.File currentDir)
          Restart the Java session, calling the given application.
static void logMemoryUsage()
          Logs Java's current heap usage and total heap size.
static void logOutput(java.lang.Process proc)
          Logs all output from a process; waits for result.
static void restart(java.lang.String appName)
          Attempts to restart the given app.
static void restart(java.lang.String installPath, java.lang.String appName)
          Attempts to restart the given app in the given installation.
static void restartPartner()
          Restarts the main Partner app.
static void tossOutput(java.lang.Process proc)
          Tosses all output from a process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuntimeLib

public RuntimeLib()
Method Detail

cleanupMemory

public static void cleanupMemory()
Does it's damnedest to clear out memory, both used and available heap.


logMemoryUsage

public static void logMemoryUsage()
Logs Java's current heap usage and total heap size.


execAndWait

public static void execAndWait(java.lang.String command)
                        throws java.io.IOException
Same as execAndWait(command, currentDir) but defaulted to the install dir.

Throws:
java.io.IOException

execAndWait

public static void execAndWait(java.lang.String[] commandArray)
                        throws java.io.IOException
Same as execAndWait(commandArray, currentDir) but defaulted to the install dir.

Throws:
java.io.IOException

execAndWait

public static void execAndWait(java.lang.String command,
                               java.io.File currentDir)
                        throws java.io.IOException
A wrapper for Runtime.exec() that handles the problems of grabbing the input streams and reading from them, and waits for completion. Note that with Windows you need to use backslashes (doubled inside strings) to separate directories; these functions do not fix the path separators like com.partnersoft.io.FileLib does. As much as possible, the command is run just as if you typed it in a command shell. Note that some commands (e.g. start in Windows) are built-in to the shell rather than being independent executable.

Throws:
java.io.IOException

execAndWait

public static int execAndWait(java.lang.String[] commandArray,
                              java.io.File currentDir)
                       throws java.io.IOException
A wrapper for Runtime.exec() that handles the problems of grabbing the input streams and reading from them, and waits for completion. Note that with Windows you need to use backslashes (doubled inside strings) to separate directories; these functions do not fix the path separators like com.partnersoft.io.FileLib does. As much as possible, the command is run just as if you typed it in a command shell. Note that some commands (e.g. start in Windows) are built-in to the shell rather than being independent executable.

Throws:
java.io.IOException

execNoWait

public static java.lang.Process execNoWait(java.lang.String command)
                                    throws java.io.IOException
Same as execNoWait(command, currentDir) but defaulted to the install directory.

Throws:
java.io.IOException

execNoWait

public static java.lang.Process execNoWait(java.lang.String command,
                                           java.io.File currentDir)
                                    throws java.io.IOException
Same as execAndWait(command, currentDir) but does not wait - the process continues in a separate thread.

Throws:
java.io.IOException

execNoWait

public static java.lang.Process execNoWait(java.lang.String[] commands,
                                           java.io.File currentDir)
                                    throws java.io.IOException
Same as execAndWait(commands, currentDir) but does not wait - the process continues in a separate thread.

Throws:
java.io.IOException

execAndHalt

public static void execAndHalt(java.lang.String command)
                        throws java.io.IOException
Executes the given OS-specific command; then halts the current Java session.

Throws:
java.io.IOException

execAndHalt

public static void execAndHalt(java.lang.String command,
                               java.io.File currentDir)
                        throws java.io.IOException
Executes the given OS-specific command; then halts the current Java session.

Throws:
java.io.IOException

execAndHalt

public static void execAndHalt(java.lang.String[] commands,
                               java.io.File currentDir)
                        throws java.io.IOException
Executes the given OS-specific command; then halts the current Java session.

Throws:
java.io.IOException

execAndHalt

public static void execAndHalt(VfsFile executable)
Executes the given program file (e.g. an .exe or .bat file in Windows) in its own directory. Then exits.

Parameters:
executable -

execNoWait

public static void execNoWait(VfsFile executable)
Executes the given program file (e.g. an .exe or .bat file in Windows) in its own directory. Runs it in a separate thread and returns immediately.

Parameters:
executable -

execAndWait

public static void execAndWait(VfsFile executable)
Executes the given program file (e.g. an .exe or .bat file in Windows) in its own directory. Blocks until the program finishes.

Parameters:
executable -

launchAppAndHalt

public static void launchAppAndHalt(java.lang.String appName)
                             throws java.io.IOException
Restart the Java session, calling the given application.

Throws:
java.io.IOException

launchAppAndHalt

public static void launchAppAndHalt(java.lang.String appName,
                                    java.io.File currentDir)
                             throws java.io.IOException
Restart the Java session, calling the given application.

Throws:
java.io.IOException

tossOutput

public static void tossOutput(java.lang.Process proc)
Tosses all output from a process.


logOutput

public static void logOutput(java.lang.Process proc)
Logs all output from a process; waits for result.


restartPartner

public static void restartPartner()
Restarts the main Partner app.


restart

public static void restart(java.lang.String appName)
Attempts to restart the given app.


restart

public static void restart(java.lang.String installPath,
                           java.lang.String appName)
Attempts to restart the given app in the given installation.


halt

public static void halt()
Shuts down the system.